Java Code Examples for com.intellij.ide.util.PropertiesComponent#setValue()

The following examples show how to use com.intellij.ide.util.PropertiesComponent#setValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TogglePresentationModeAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static ActionCallback tweakFrameFullScreen(Project project, boolean inPresentation) {
  IdeFrameEx frame = (IdeFrameEx)IdeFrameUtil.findActiveRootIdeFrame();
  if (frame != null) {
    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
    if (inPresentation) {
      propertiesComponent.setValue("full.screen.before.presentation.mode", String.valueOf(frame.isInFullScreen()));
      return frame.toggleFullScreen(true);
    }
    else {
      if (frame.isInFullScreen()) {
        final String value = propertiesComponent.getValue("full.screen.before.presentation.mode");
        return frame.toggleFullScreen("true".equalsIgnoreCase(value));
      }
    }
  }
  return ActionCallback.DONE;
}
 
Example 2
Source File: FileColorsModel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void setConfigurations(@Nonnull List<? extends FileColorConfiguration> configurations, boolean isProjectLevel) {
  if (isProjectLevel) {
    myProjectLevelConfigurations.clear();
    myProjectLevelConfigurations.addAll(configurations);
  }
  else {
    myApplicationLevelConfigurations.clear();
    Map<String, String> predefinedScopeNameToPropertyKey = new THashMap<>(myPredefinedScopeNameToPropertyKey);
    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    for (FileColorConfiguration configuration : configurations) {
      myApplicationLevelConfigurations.add(configuration);
      String propertyKey = predefinedScopeNameToPropertyKey.remove(configuration.getScopeName());
      if (propertyKey != null) {
        propertiesComponent.setValue(propertyKey, configuration.getColorName());
      }
    }
    for (String scopeName : predefinedScopeNameToPropertyKey.keySet()) {
      // empty string means that value deleted
      propertiesComponent.setValue(predefinedScopeNameToPropertyKey.get(scopeName), "");
      // previously it was saved incorrectly as scope name instead of specified property key
      propertiesComponent.setValue(scopeName, null);
    }
  }
}
 
Example 3
Source File: ChooseRunConfigurationPopup.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void removeSelected() {
  final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
  if (!propertiesComponent.isTrueValue("run.configuration.delete.ad")) {
    propertiesComponent.setValue("run.configuration.delete.ad", Boolean.toString(true));
  }

  final int index = getSelectedIndex();
  if (index == -1) {
    return;
  }

  final Object o = getListModel().get(index);
  if (o != null && o instanceof ItemWrapper && ((ItemWrapper)o).canBeDeleted()) {
    deleteConfiguration(myProject, (RunnerAndConfigurationSettings)((ItemWrapper)o).getValue());
    getListModel().deleteItem(o);
    final List<Object> values = getListStep().getValues();
    values.remove(o);

    if (index < values.size()) {
      onChildSelectedFor(values.get(index));
    }
    else if (index - 1 >= 0) {
      onChildSelectedFor(values.get(index - 1));
    }
  }
}
 
Example 4
Source File: FlutterRunNotifications.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void checkForDisplayFirstReload() {
  final PropertiesComponent properties = PropertiesComponent.getInstance(myProject);

  final boolean alreadyRun = properties.getBoolean(RELOAD_ALREADY_RUN);
  if (!alreadyRun) {
    properties.setValue(RELOAD_ALREADY_RUN, true);

    final Notification notification = new Notification(
      FlutterMessages.FLUTTER_NOTIFICATION_GROUP_ID,
      FlutterBundle.message("flutter.reload.firstRun.title"),
      FlutterBundle.message("flutter.reload.firstRun.content"),
      NotificationType.INFORMATION);
    notification.setIcon(FlutterIcons.HotReload);
    notification.addAction(new AnAction("Learn more") {
      @Override
      public void actionPerformed(@NotNull AnActionEvent event) {
        BrowserUtil.browse(FlutterBundle.message("flutter.reload.firstRun.url"));
        notification.expire();
      }
    });
    Notifications.Bus.notify(notification);
  }
}
 
Example 5
Source File: FlutterUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void disableGradleProjectMigrationNotification(@NotNull Project project) {
  final String showMigrateToGradlePopup = "show.migrate.to.gradle.popup";
  final PropertiesComponent properties = PropertiesComponent.getInstance(project);

  if (properties.getValue(showMigrateToGradlePopup) == null) {
    properties.setValue(showMigrateToGradlePopup, "false");
  }
}
 
Example 6
Source File: CreateIpaDialog.java    From robovm-idea with GNU General Public License v2.0 5 votes vote down vote up
private void saveProperties() {
    PropertiesComponent properties = PropertiesComponent.getInstance(project);
    properties.setValue(MODULE_NAME, module.getSelectedItem().toString());
    properties.setValue(SIGNING_IDENTITY, signingIdentity.getSelectedItem().toString());
    properties.setValue(PROVISIONING_PROFILE, provisioningProfile.getSelectedItem().toString());
    properties.setValue(ARCHS, archs.getSelectedItem().toString());
    properties.setValue(DESTINATION_DIR, destinationDir.getText());
}
 
Example 7
Source File: ClearBackground.java    From backgroundImagePlus with MIT License 5 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
    PropertiesComponent prop = PropertiesComponent.getInstance();
    prop.setValue(IdeBackgroundUtil.EDITOR_PROP, null);
    prop.setValue(IdeBackgroundUtil.FRAME_PROP, null);
    prop.setValue(Settings.AUTO_CHANGE, false);
    BackgroundService.stop();
    IdeBackgroundUtil.repaintAllWindows();
}
 
Example 8
Source File: AllFileTemplatesConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void disposeUIResources() {
  if (myCurrentTab != null) {
    final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    propertiesComponent.setValue(CURRENT_TAB, myCurrentTab.getTitle(), TEMPLATES_TITLE);
    final FileTemplate template = myCurrentTab.getSelectedTemplate();
    if (template != null) {
      propertiesComponent.setValue(SELECTED_TEMPLATE, template.getName());
    }
  }

  if (myEditor != null) {
    myEditor.disposeUIResources();
    myEditor = null;
    myEditorComponent = null;
  }
  myMainPanel = null;
  if (myUIDisposable != null) {
    Disposer.dispose(myUIDisposable);
    myUIDisposable = null;
  }
  myTabbedPane = null;
  myToolBar = null;
  myTabs = null;
  myCurrentTab = null;
  myTemplatesList = null;
  myCodeTemplatesList = null;
  myIncludesList = null;
  myOtherTemplatesList = null;
}
 
Example 9
Source File: DesktopSettingsDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void saveCurrentConfigurable() {
  final Configurable current = myEditor.getContext().getCurrentConfigurable();
  if (current == null) return;

  final PropertiesComponent props = PropertiesComponent.getInstance(myProject);

  if (current instanceof SearchableConfigurable) {
    props.setValue(LAST_SELECTED_CONFIGURABLE, ((SearchableConfigurable)current).getId());
  }
  else {
    props.setValue(LAST_SELECTED_CONFIGURABLE, current.getClass().getName());
  }
}
 
Example 10
Source File: FlutterInitializer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void setCanReportAnalytics(boolean canReportAnalytics) {
  if (getCanReportAnalytics() != canReportAnalytics) {
    final boolean wasReporting = getCanReportAnalytics();

    final PropertiesComponent properties = PropertiesComponent.getInstance();
    properties.setValue(analyticsOptOutKey, !canReportAnalytics);
    if (analytics != null) {
      analytics.setCanSend(getCanReportAnalytics());
    }

    if (!wasReporting && canReportAnalytics) {
      getAnalytics().sendScreenView("main");
    }
  }
}
 
Example 11
Source File: HookConfigurable.java    From trains-pycharm-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void apply() throws ConfigurationException {
    storedKey = userKey.getText().trim();
    storedSecret = userSecret.getText().trim();
    storedAPI = fixHost(userAPI.getText().trim());
    storedWEB = fixHost(userWEB.getText().trim());
    storedFILES = fixHost(userFILES.getText().trim());

    PropertiesComponent properties = PropertiesComponent.getInstance(project);
    properties.setValue(PATH_API, storedAPI);
    properties.setValue(PATH_WEB, storedWEB);
    properties.setValue(PATH_FILES, storedFILES);
    properties.setValue(PATH_KEY, storedKey);
    properties.setValue(PATH_SECRET, storedSecret);
}
 
Example 12
Source File: FlutterInitializer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void setCanReportAnalytics(boolean canReportAnalytics) {
  if (getCanReportAnalytics() != canReportAnalytics) {
    final boolean wasReporting = getCanReportAnalytics();

    final PropertiesComponent properties = PropertiesComponent.getInstance();
    properties.setValue(analyticsOptOutKey, !canReportAnalytics);
    if (analytics != null) {
      analytics.setCanSend(getCanReportAnalytics());
    }

    if (!wasReporting && canReportAnalytics) {
      getAnalytics().sendScreenView("main");
    }
  }
}
 
Example 13
Source File: FlutterConsoleLogManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Set our preferred settings for the run console.
 */
public static void initConsolePreferences() {
  final PropertiesComponent properties = PropertiesComponent.getInstance();
  if (!properties.getBoolean(consolePreferencesSetKey)) {
    properties.setValue(consolePreferencesSetKey, true);

    // Set our preferred default settings for console text wrapping.
    final EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
    editorSettings.setUseSoftWraps(true, SoftWrapAppliancePlaces.CONSOLE);
  }
}
 
Example 14
Source File: ProjectStructureConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void disposeUIResources() {
  final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject);
  propertiesComponent.setValue("project.structure.last.edited", myUiState.lastEditedConfigurable);

  myContext.getDaemonAnalyzer().stop();
  for (Configurable each : myName2Config) {
    each.disposeUIResources();
  }
  myProjectStructureDialog = null;
  myContext.clear();
  myName2Config.clear();
}
 
Example 15
Source File: SetAsDefaultDirectoryAction.java    From IDEA-Native-Terminal-Plugin with MIT License 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
    Project project = getEventProject(e);
    VirtualFile directory = getSelectedDirectory(e);
    if (project == null || directory == null) return;

    PropertiesComponent properties = PropertiesComponent.getInstance(project);
    properties.setValue(DEFAULT_DIRECTORY_PROPERTY_KEY, directory.getPath());

    log.info("'" + properties.getValue(DEFAULT_DIRECTORY_PROPERTY_KEY) +
            "' is set as default directory for project: " + project.getName());
}
 
Example 16
Source File: ImageMoveIntentionAction.java    From markdown-image-kit with MIT License 5 votes vote down vote up
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element)
    throws IncorrectOperationException {
    MarkdownImage markdownImage = getMarkdownImage(editor);
    if (markdownImage == null) {
        return;
    }

    OssClient client = getClient();
    if (markdownImage.getLocation().name().equals(ImageLocationEnum.LOCAL.name())
        // 如果当前标签所在的图床与设置的图床一样则不处理
        || markdownImage.getPath().contains(client.getCloudType().feature)) {
        return;
    }

    Map<Document, List<MarkdownImage>> waitingForMoveMap = new HashMap<Document, List<MarkdownImage>>(1) {
        {
            put(editor.getDocument(), new ArrayList<MarkdownImage>(1) {
                {
                    add(markdownImage);
                }
            });
        }
    };

    EventData data = new EventData()
        .setProject(project)
        .setClient(client)
        .setClientName(getName())
        .setWaitingProcessMap(waitingForMoveMap);

    // http://www.jetbrains.org/intellij/sdk/docs/basics/persisting_state_of_components.html
    PropertiesComponent propComp = PropertiesComponent.getInstance();
    propComp.setValue(MarkdownFileFilter.FILTER_KEY, "");

    // 开启后台任务
    new ActionTask(project, MikBundle.message("mik.action.move.process", getName()),
                   ActionManager.buildMoveImageChain(data)).queue();
}
 
Example 17
Source File: GotoFileModel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void saveInitialCheckBoxState(boolean state) {
  PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject);
  if (propertiesComponent.isTrueValue("GoToClass.toSaveIncludeLibraries")) {
    propertiesComponent.setValue("GoToFile.includeJavaFiles", Boolean.toString(state));
  }
}
 
Example 18
Source File: ModuleChooserDialogHelper.java    From ADBWIFI with Apache License 2.0 4 votes vote down vote up
private static void saveModuleName(Project project, String moduleName) {
    final PropertiesComponent properties = PropertiesComponent.getInstance(project);
    properties.setValue(SELECTED_MODULE_PROPERTY, moduleName);
}
 
Example 19
Source File: DeviceChooserDialog.java    From ADB-Duang with MIT License 4 votes vote down vote up
private void persistSelectedSerialsToPreferences() {
    final PropertiesComponent properties = PropertiesComponent.getInstance(myProject);
    properties.setValue(SELECTED_SERIALS_PROPERTY, toString(myDeviceChooser.getSelectedDevices()));
}
 
Example 20
Source File: DeviceChooserDialog.java    From ADBWIFI with Apache License 2.0 4 votes vote down vote up
private void persistSelectedSerialsToPreferences() {
    final PropertiesComponent properties = PropertiesComponent.getInstance(myProject);
    properties.setValue(SELECTED_SERIALS_PROPERTY, toString(myDeviceChooser.getSelectedDevices()));
}