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

The following examples show how to use com.intellij.ide.util.PropertiesComponent#getInstance() . 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: HaskellToolsConfigurable.java    From intellij-haskforce with Apache License 2.0 6 votes vote down vote up
public HaskellToolsConfigurable(@NotNull Project project) {
    this.propertiesComponent = PropertiesComponent.getInstance(project);
    properties = Arrays.asList(
            new Tool(project, "stylish-haskell", ToolKey.STYLISH_HASKELL_KEY, stylishPath, stylishFlags,
                    stylishAutoFind, stylishVersion, "--help"),
            new Tool(project, "hlint", ToolKey.HLINT_KEY, hlintPath, hlintFlags,
                     hlintAutoFind, hlintVersion),
            new Tool(project, "ghc-mod", ToolKey.GHC_MOD_KEY, ghcModPath, ghcModFlags,
                     ghcModAutoFind, ghcModVersion, "version"),
            new Tool(project, "ghc-modi", ToolKey.GHC_MODI_KEY, ghcModiPath, ghcModiFlags,
                     ghcModiAutoFind, ghcModiVersion, "version", SettingsChangeNotifier.GHC_MODI_TOPIC),
            new PropertyField(ToolKey.GHC_MODI_RESPONSE_TIMEOUT_KEY, ghcModiResponseTimeout, Long.toString(ToolKey.getGhcModiResponseTimeout(project))),
            new PropertyField(ToolKey.GHC_MODI_KILL_IDLE_TIMEOUT_KEY, ghcModiKillIdleTimeout, Long.toString(ToolKey.getGhcModiKillIdleTimeout(project))),
            new Tool(project, "hindent", ToolKey.HINDENT_KEY, hindentPath, hindentFlags,
                hindentAutoFind, hindentVersion)
    );

    setNumericInputVerifier(ghcModiResponseTimeout);
    setNumericInputVerifier(ghcModiKillIdleTimeout);
}
 
Example 2
Source File: FlutterSdkUtil.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void updateKnownPaths(@SuppressWarnings("SameParameterValue") @NotNull final String propertyKey,
                                     @NotNull final String newPath) {
  final Set<String> allPaths = new LinkedHashSet<>();

  // Add the new value first; this ensures that it's the 'default' flutter sdk.
  allPaths.add(newPath);

  final PropertiesComponent props = PropertiesComponent.getInstance();

  // Add the existing known paths.
  final String[] oldPaths = props.getValues(propertyKey);
  if (oldPaths != null) {
    allPaths.addAll(Arrays.asList(oldPaths));
  }

  // Store the values back.
  if (allPaths.isEmpty()) {
    props.unsetValue(propertyKey);
  }
  else {
    props.setValues(propertyKey, ArrayUtil.toStringArray(allPaths));
  }
}
 
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: SettingConfigurable.java    From AndroidStringsOneTabTranslation with Apache License 2.0 6 votes vote down vote up
@Override
public void reset() {
    if (settingPanel == null || languageEngineBox == null || filterList == null
            || btnAddFilter == null || btnDeleteFilter == null)
        return;
    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();

    currentEngine = TranslationEngineType.fromName(
            propertiesComponent.getValue(StorageDataKey.SettingLanguageEngine));
    languageEngineBox.setSelectedItem(currentEngine);
    languageEngineChanged = false;
    initUI(currentEngine);

    Log.i("reset, current engine: " + currentEngine);

    languageEngineBox.requestFocus();

    // filter rules
    filterRulesChanged = false;
    resetFilterList();
}
 
Example 5
Source File: MultiSelectDialog.java    From AndroidStringsOneTabTranslation with Apache License 2.0 6 votes vote down vote up
protected void _init(Project project,
                     String title,
                     String message,
                     @Nullable String checkboxText,
                     boolean checkboxStatus,
                     @Nullable DoNotAskOption doNotAskOption) {
    setTitle(title);
    if (Messages.isMacSheetEmulation()) {
        setUndecorated(true);
    }
    propertiesComponent = PropertiesComponent.getInstance(project);
    myMessage = message;
    myCheckboxText = checkboxText;
    myChecked = checkboxStatus;
    setButtonsAlignment(SwingConstants.RIGHT);
    setDoNotAskOption(doNotAskOption);
    init();
    if (Messages.isMacSheetEmulation()) {
        MacUtil.adjustFocusTraversal(myDisposable);
    }
}
 
Example 6
Source File: I18nReferenceProvider.java    From yiistorm with MIT License 5 votes vote down vote up
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) {
    project = element.getProject();
    properties = PropertiesComponent.getInstance(project);
    String searchStringFull = CommonHelper.rmQuotes(element.getText());
    String searchString = searchStringFull;
    PsiFile currentFile = element.getContainingFile();

    String protectedPath = CommonHelper.searchCurrentProtected(CommonHelper.getFilePath(currentFile));
    if (protectedPath != null) {
        protectedPath = CommonHelper.getRelativePath(project, protectedPath);
        String[] result = I18NHelper.findMessageSource(searchStringFull, protectedPath, project);
        if (result != null) {
            protectedPath = result[0];
            searchString = result[2];
        } else {
            protectedPath += "/messages/" + I18NHelper.getLang(project);
        }
        try {
            String relativePath = protectedPath + "/" + searchString + ".php";
            VirtualFile viewfile = project.getBaseDir().findFileByRelativePath(relativePath);

            if (viewfile != null) {
                PsiReference ref = new I18nFileReference(
                        viewfile,
                        element,
                        element.getTextRange(),
                        project);
                return new PsiReference[]{ref};
            }
        } catch (Exception e) {
            System.err.println("error" + e.getMessage());
        }
    }
    return PsiReference.EMPTY_ARRAY;
}
 
Example 7
Source File: InnerBuilderGenerator.java    From innerbuilder with Apache License 2.0 5 votes vote down vote up
private static EnumSet<InnerBuilderOption> currentOptions() {
    final EnumSet<InnerBuilderOption> options = EnumSet.noneOf(InnerBuilderOption.class);
    final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    for (final InnerBuilderOption option : InnerBuilderOption.values()) {
        final boolean currentSetting = propertiesComponent.getBoolean(option.getProperty(), false);
        if (currentSetting) {
            options.add(option);
        }
    }
    return options;
}
 
Example 8
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 9
Source File: LayoutProjectCodeDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
public LayoutProjectCodeDialog(@Nonnull Project project,
                               @Nonnull String title,
                               @Nonnull String text,
                               boolean enableOnlyVCSChangedTextCb)
{
  super(project, false);
  myText = text;
  myProject = project;
  myEnableOnlyVCSChangedTextCb = enableOnlyVCSChangedTextCb;
  myLastRunOptions = new LastRunReformatCodeOptionsProvider(PropertiesComponent.getInstance());

  setOKButtonText(CodeInsightBundle.message("reformat.code.accept.button.text"));
  setTitle(title);
  init();
}
 
Example 10
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 11
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 12
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 13
Source File: PluginPreferences.java    From dummytext-plugin with Apache License 2.0 4 votes vote down vote up
/**
 * @return PropertiesComponent (project level)
 */
private static PropertiesComponent getPropertiesComponent() {
    Project project = getOpenProject();

    return project != null ? PropertiesComponent.getInstance(project) : null;
}
 
Example 14
Source File: Properties.java    From WIFIADB with Apache License 2.0 4 votes vote down vote up
Properties(@NotNull Project project) {
    mProjectLevel = PropertiesComponent.getInstance(project);
    mApplicationLevel = PropertiesComponent.getInstance();
}
 
Example 15
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 16
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 17
Source File: SpringFormatComponent.java    From spring-javaformat with Apache License 2.0 4 votes vote down vote up
protected SpringFormatComponent(Project project) {
	this.project = project;
	this.statusIndicator = new StatusIndicator(project);
	this.properties = PropertiesComponent.getInstance(project);
}
 
Example 18
Source File: ModuleChooserDialogHelper.java    From ADB-Duang with MIT License 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: LRUPopupBuilder.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected LRUPopupBuilder(@Nonnull Project project, @Nonnull String title) {
  myTitle = title;
  myPropertiesComponent = PropertiesComponent.getInstance(project);
}
 
Example 20
Source File: ControllerRenderViewReferenceProvider.java    From yiistorm with MIT License 4 votes vote down vote up
public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull final ProcessingContext context) {
    project = element.getProject();
    String elname = element.getClass().getName();
    properties = PropertiesComponent.getInstance(project);
    VirtualFile baseDir = project.getBaseDir();
    projectPath = baseDir.getCanonicalPath();
    if (elname.endsWith("StringLiteralExpressionImpl")) {

        try {
            PsiFile file = element.getContainingFile();
            VirtualFile vfile = file.getVirtualFile();
            if (vfile != null) {
                String path = vfile.getPath();
                String basePath = project.getBasePath();
                if (basePath != null) {

                    String themeName = properties.getValue("themeName");
                    Class elementClass = element.getClass();
                    String protectedPath = YiiRefsHelper.getCurrentProtected(path);
                    path = path.replace(projectPath, "");

                    String viewPathTheme = YiiRefsHelper.getRenderViewPath(path, themeName);
                    String viewPath = YiiRefsHelper.getRenderViewPath(path, null);

                    protectedPath = protectedPath.replace(projectPath, "")
                            .replaceAll("/controllers/[a-zA-Z0-9_]+?.(php|tpl)+", "");

                    Method method = elementClass.getMethod("getValueRange");
                    Object obj = method.invoke(element);
                    TextRange textRange = (TextRange) obj;
                    Class _PhpPsiElement = elementClass.getSuperclass().getSuperclass().getSuperclass();
                    Method phpPsiElementGetText = _PhpPsiElement.getMethod("getText");
                    Object obj2 = phpPsiElementGetText.invoke(element);
                    String str = obj2.toString();
                    String uri = str.substring(textRange.getStartOffset(), textRange.getEndOffset());
                    int start = textRange.getStartOffset();
                    int len = textRange.getLength();
                    String controllerName = YiiRefsHelper.getControllerClassName(path);


                    if (controllerName != null) {
                        if (baseDir != null) {
                            String inThemeFullPath = viewPathTheme + controllerName + "/" + uri
                                    + (uri.endsWith(".tpl") ? "" : ".php");
                            if (baseDir.findFileByRelativePath(inThemeFullPath) != null) {
                                viewPath = viewPathTheme;
                            }
                            VirtualFile appDir = baseDir.findFileByRelativePath(viewPath);
                            VirtualFile protectedPathDir = (!protectedPath.equals("")) ?
                                    baseDir.findFileByRelativePath(protectedPath) : null;
                            if (appDir != null) {
                                PsiReference ref = new ViewsReference(controllerName, uri, element,
                                        new TextRange(start, start + len), project, protectedPathDir, appDir);
                                return new PsiReference[]{ref};
                            }
                        }
                        return PsiReference.EMPTY_ARRAY;
                    }
                }
            }
        } catch (Exception e) {
            System.err.println("error" + e.getMessage());
        }
    }
    return PsiReference.EMPTY_ARRAY;
}