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

The following examples show how to use com.intellij.ide.util.PropertiesComponent#getValue() . 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: OpenProjectDirectoryAction.java    From IDEA-Native-Terminal-Plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
protected String getDirectory(AnActionEvent event, PluginSettingsState settings) {  // todo: settings are not required anymore
    Project project = getEventProject(event);
    if (project == null) {
        return System.getProperty("user.home");
    }

    PropertiesComponent properties = PropertiesComponent.getInstance(project);
    String defaultDirectory = properties.getValue(DEFAULT_DIRECTORY_PROPERTY_KEY);

    if (defaultDirectory == null) {
        defaultDirectory = project.getBasePath();
        if (defaultDirectory == null) {
            defaultDirectory = System.getProperty("user.home");
        }
    }
    return defaultDirectory;
}
 
Example 2
Source File: ProjectStructureConfigurable.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public ProjectStructureConfigurable(final Project project,
                                    final ProjectLibrariesConfigurable projectLibrariesConfigurable,
                                    final ModuleStructureConfigurable moduleStructureConfigurable,
                                    ArtifactsStructureConfigurable artifactsStructureConfigurable) {
  myProject = project;
  myArtifactsStructureConfigurable = artifactsStructureConfigurable;

  myModuleConfigurator = new ModulesConfigurator(myProject);
  myContext = new StructureConfigurableContext(myProject, myModuleConfigurator);
  myModuleConfigurator.setContext(myContext);

  myProjectLibrariesConfig = projectLibrariesConfigurable;
  myModulesConfig = moduleStructureConfigurable;

  myProjectLibrariesConfig.init(myContext);
  myModulesConfig.init(myContext);
  if (!project.isDefault()) {
    myArtifactsStructureConfigurable.init(myContext, myModulesConfig, myProjectLibrariesConfig);
  }

  myProjectConfig = new ProjectConfigurable(project, getContext(), getModuleConfigurator());
  final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject);
  myUiState.lastEditedConfigurable = propertiesComponent.getValue("project.structure.last.edited");
}
 
Example 3
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 4
Source File: PantsToBspProjectAction.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
private void dependingOnBspProjectExistence(Project project, Runnable onNoBspProject, Consumer<String> onBspProject) {
  PropertiesComponent properties = PropertiesComponent.getInstance(project);

  String linkedBspProject = properties.getValue(BSP_LINKED_PROJECT_PATH);
  if (linkedBspProject == null) {
    onNoBspProject.run();
  }
  else {
    if (LocalFileSystem.getInstance().findFileByPath(linkedBspProject) == null) {
      properties.unsetValue(BSP_LINKED_PROJECT_PATH);
      onNoBspProject.run();
    }
    else {
      onBspProject.accept(linkedBspProject);
    }
  }
}
 
Example 5
Source File: RandomBackgroundTask.java    From backgroundImagePlus with MIT License 6 votes vote down vote up
@Override
public void run() {
    PropertiesComponent prop = PropertiesComponent.getInstance();
    String folder = prop.getValue(Settings.FOLDER);
    if (folder == null || folder.isEmpty()) {
        NotificationCenter.notice("Image folder not set");
        return;
    }
    File file = new File(folder);
    if (!file.exists()) {
        NotificationCenter.notice("Image folder not set");
        return;
    }
    String image = imagesHandler.getRandomImage(folder);
    if (image == null) {
        NotificationCenter.notice("No image found");
        return;
    }
    if (image.contains(",")) {
        NotificationCenter.notice("Intellij wont load images with ',' character\n" + image);
    }
    prop.setValue(IdeBackgroundUtil.FRAME_PROP, null);
    prop.setValue(IdeBackgroundUtil.EDITOR_PROP, image);
    // NotificationCenter.notice("Image: " + image.replace(folder + File.separator, ""));
    IdeBackgroundUtil.repaintAllWindows();
}
 
Example 6
Source File: DeviceChooserDialog.java    From ADB-Duang with MIT License 5 votes vote down vote up
@Nullable
private String[] getSelectedSerialsFromPreferences(PropertiesComponent properties) {
    final String[] selectedSerials;
    final String serialsStr = properties.getValue(SELECTED_SERIALS_PROPERTY);
    if (serialsStr != null) {
        selectedSerials = serialsStr.split(" ");
    } else {
        selectedSerials = null;
    }
    return selectedSerials;
}
 
Example 7
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 8
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 9
Source File: Settings.java    From backgroundImagePlus with MIT License 5 votes vote down vote up
@Override
public boolean isModified() {
    PropertiesComponent prop = PropertiesComponent.getInstance();
    String storedFolder      = prop.getValue(FOLDER);
    String uiFolder          = imageFolder.getText();
    if (storedFolder == null) {
        storedFolder = "";
    }
    return !storedFolder.equals(uiFolder)
            || intervalModified(prop)
            || prop.getBoolean(AUTO_CHANGE) != autoChangeCheckBox.isSelected();
}
 
Example 10
Source File: DeviceChooserDialog.java    From ADBWIFI with Apache License 2.0 5 votes vote down vote up
@Nullable
private String[] getSelectedSerialsFromPreferences(PropertiesComponent properties) {
    final String[] selectedSerials;
    final String serialsStr = properties.getValue(SELECTED_SERIALS_PROPERTY);
    if (serialsStr != null) {
        selectedSerials = serialsStr.split(" ");
    } else {
        selectedSerials = null;
    }
    return selectedSerials;
}
 
Example 11
Source File: ProjectSettings.java    From dbunit-extractor with MIT License 5 votes vote down vote up
private static ExtractorProperties getExtractorProperties(final Project project) {
    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
    boolean includeSchema = propertiesComponent.getBoolean(DBUNIT_EXTRACTOR_INCLUDE_SCHEMA_PROPERTY, false);
    boolean skipNull = propertiesComponent.getBoolean(DBUNIT_EXTRACTOR_SKIP_NULL_PROPERTY, true);
    boolean skipEmpty = propertiesComponent.getBoolean(DBUNIT_EXTRACTOR_SKIP_EMPTY_PROPERTY, true);
    String excludedColumns = propertiesComponent.getValue(DBUNIT_EXTRACTOR_EXCLUDE_COLUMNS_PROPERTY, "");
    String selectedDataSource = propertiesComponent.getValue(DBUNIT_EXTRACTOR_SELECTED_DATASOURCE_PROPERTY, "");
    return new ExtractorProperties(includeSchema, skipNull, skipEmpty, excludedColumns, selectedDataSource);
}
 
Example 12
Source File: PluginPreferences.java    From dummytext-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Get preference: genre
 *
 * @return String	Genre code, e.g. "scifi", "pirates", "latin" (default)
 */
static String getGenreCode() {
    PropertiesComponent propertiesComponent = getPropertiesComponent();
    String genre = null;

    if (null != propertiesComponent) {
        genre = propertiesComponent.getValue(PROPERTY_GENRE);
    }

    return genre == null ? "latin" : genre;
}
 
Example 13
Source File: FileColorsModel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private String getColorNameForScope(PropertiesComponent propertyComponent, String scopeName, Map<String, String> scopeNameMap) {
  String colorName = propertyComponent.getValue(scopeNameMap.get(scopeName));
  if (colorName == null) {
    // backward compatibility, previously it was saved incorrectly as scope name instead of specified property key
    colorName = propertyComponent.getValue(scopeName);
    if (colorName == null) {
      colorName = myPredefinedScopeNameToColor.get(scopeName);
    }
  }
  return colorName;
}
 
Example 14
Source File: SearchTextFieldWithStoredHistory.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void reset() {
  final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
  final String history = propertiesComponent.getValue(myPropertyName);
  if (history != null) {
    final String[] items = history.split("\n");
    ArrayList<String> result = new ArrayList<>();
    for (String item : items) {
      if (item != null && item.length() > 0) {
        result.add(item);
      }
    }
    setHistory(result);
  }
  setSelectedItem("");
}
 
Example 15
Source File: TextFieldWithStoredHistory.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void reset() {
  final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
  final String history = propertiesComponent.getValue(myPropertyName);
  if (history != null) {
    final String[] items = history.split("\n");
    ArrayList<String> result = new ArrayList<String>();
    for (String item : items) {
      if (item != null && item.length() > 0) {
        result.add(item);
      }
    }
    setHistory(result);
    setSelectedItem("");
  }
}
 
Example 16
Source File: HookConfigurable.java    From trains-pycharm-plugin with Apache License 2.0 5 votes vote down vote up
private static void loadFromProperties(Project project){
    PropertiesComponent properties = PropertiesComponent.getInstance(project);
    storedKey = properties.getValue(PATH_KEY);
    storedSecret = properties.getValue(PATH_SECRET);
    storedAPI = properties.getValue(PATH_API);
    storedWEB = properties.getValue(PATH_WEB);
    storedFILES = properties.getValue(PATH_FILES);
}
 
Example 17
Source File: ModuleChooserDialogHelper.java    From ADB-Duang with MIT License 4 votes vote down vote up
private static String getPreviousModuleName(Project project) {
    final PropertiesComponent properties = PropertiesComponent.getInstance(project);
    return properties.getValue(SELECTED_MODULE_PROPERTY);
}
 
Example 18
Source File: ModuleChooserDialogHelper.java    From ADBWIFI with Apache License 2.0 4 votes vote down vote up
private static String getPreviousModuleName(Project project) {
    final PropertiesComponent properties = PropertiesComponent.getInstance(project);
    return properties.getValue(SELECTED_MODULE_PROPERTY);
}
 
Example 19
Source File: SettingConfigurable.java    From AndroidStringsOneTabTranslation with Apache License 2.0 4 votes vote down vote up
private void initUI(TranslationEngineType engineType) {
    if (settingPanel == null)
        return;

    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    switch (engineType) {
        case Bing: {
            line1Text.setText("Client Id:");
            line2Text.setText("Client secret:");
            line2Text.setVisible(true);

            line2TextField.setVisible(true);

            howToLabel.setText(BING_HOW_TO);
            howToLabel.removeMouseMotionListener(googleHowTo);
            howToLabel.addMouseListener(bingHowTo);

            String bingClientIdStored = propertiesComponent.getValue(StorageDataKey.BingClientIdStored);
            String bingClientSecretStored = propertiesComponent.getValue(StorageDataKey.BingClientSecretStored);

            if (bingClientIdStored != null) {
                PromptSupport.setPrompt(bingClientIdStored, line1TextField);
            } else {
                PromptSupport.setPrompt(DEFAULT_CLIENT_ID, line1TextField);
            }
            line1TextField.setText("");

            if (bingClientSecretStored != null) {
                PromptSupport.setPrompt(bingClientSecretStored, line2TextField);
            } else {
                PromptSupport.setPrompt(DEFAULT_CLIENT_SECRET, line2TextField);
            }
            line2TextField.setText("");
        }
        break;
        case Google: {
            line1Text.setText("API key:");
            line2Text.setVisible(false);

            line2TextField.setVisible(false);

            howToLabel.setText(GOOGLE_HOW_TO);
            howToLabel.removeMouseListener(bingHowTo);
            howToLabel.addMouseListener(googleHowTo);

            String googleAPIKey = propertiesComponent.getValue(StorageDataKey.GoogleApiKeyStored);
            Log.i("apikey====" + PropertiesComponent.getInstance().getValue(StorageDataKey.GoogleApiKeyStored));
            if (googleAPIKey != null) {
                PromptSupport.setPrompt(googleAPIKey, line1TextField);
            } else {
                PromptSupport.setPrompt(DEFAULT_GOOGLE_API_KEY, line1TextField);
            }
            line1TextField.setText("");
        }
        break;
    }
}
 
Example 20
Source File: SettingConfigurable.java    From AndroidStringsOneTabTranslation with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isModified() {
    if (languageEngineChanged)
        return true;

    if (filterRulesChanged)
        return true;

    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    switch (currentEngine) {
        case Bing: {
            String bingClientIdStored = propertiesComponent.getValue(StorageDataKey.BingClientIdStored);
            String bingClientSecretStored = propertiesComponent.getValue(StorageDataKey.BingClientSecretStored);

            boolean bingClientIdChanged = false;
            boolean bingClientSecretChanged = false;

            if (bingClientIdStored == null) {
                if (!line1TextField.getText().isEmpty())
                    bingClientIdChanged = true;
            } else {
                if (!line1TextField.getText().equals(bingClientIdStored)
                        && !line1TextField.getText().trim().isEmpty())
                    bingClientIdChanged = true;
            }

            if (bingClientSecretStored == null) {
                if (!line2TextField.getText().isEmpty())
                    bingClientSecretChanged = true;
            } else {
                if (!line2TextField.getText().equals(bingClientSecretStored)
                        && !line2TextField.getText().trim().isEmpty())
                    bingClientSecretChanged = true;
            }

            return bingClientIdChanged || bingClientSecretChanged;
        }
        case Google: {
            String googleApiKeyStored = propertiesComponent.getValue(StorageDataKey.GoogleApiKeyStored);
            boolean googleApiKeyStoredChanged = false;

            if (googleApiKeyStored == null) {
                if (!line1TextField.getText().isEmpty())
                    googleApiKeyStoredChanged = true;
            } else {
                if (!line1TextField.getText().equals(googleApiKeyStored)
                        && !line1TextField.getText().trim().isEmpty())
                    googleApiKeyStoredChanged = true;
            }
            return googleApiKeyStoredChanged;
        }
    }
    return false;
}