com.intellij.ide.util.PropertiesComponent Java Examples

The following examples show how to use com.intellij.ide.util.PropertiesComponent. 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: KotlinParamsStringBuilder.java    From OkHttpParamsGet with Apache License 2.0 6 votes vote down vote up
@Override
protected void addNullableValue(PsiField field, StringBuilder sb, String defaultName) {
    boolean add = PropertiesComponent.getInstance().getBoolean(Constant.VALUE_NULL, false);
    if (!add) {
        sb.append(field.getName()).append("?.also{\n");
        sb.append(mFieldName).append("[");
        if (defaultName == null) {
            sb.append('"').append(field.getName()).append('"');
        } else {
            sb.append(defaultName);
        }
        sb.append("] = ").append(toString(field, false, "it")).append("\n}\n");
    } else {
        sb.append(mFieldName).append("[");
        if (defaultName == null) {
            sb.append('"').append(field.getName()).append('"');
        } else {
            sb.append(defaultName);
        }
        sb.append("] = ").append(toString(field, true, null)).append("?: \"\"\n");
    }
}
 
Example #2
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 #3
Source File: FlutterSdkUtil.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
public static String[] getKnownFlutterSdkPaths() {
  final Set<String> paths = new HashSet<>();

  // scan current projects for existing flutter sdk settings
  for (Project project : ProjectManager.getInstance().getOpenProjects()) {
    final FlutterSdk flutterSdk = FlutterSdk.getFlutterSdk(project);
    if (flutterSdk != null) {
      paths.add(flutterSdk.getHomePath());
    }
  }

  // use the list of paths they've entered in the past
  final String[] knownPaths = PropertiesComponent.getInstance().getValues(FLUTTER_SDK_KNOWN_PATHS);
  if (knownPaths != null) {
    paths.addAll(Arrays.asList(knownPaths));
  }

  // search the user's path
  final String fromUserPath = locateSdkFromPath();
  if (fromUserPath != null) {
    paths.add(fromUserPath);
  }

  return paths.toArray(new String[0]);
}
 
Example #4
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 #5
Source File: BlazeEditProjectViewControl.java    From intellij with Apache License 2.0 6 votes vote down vote up
private String getDefaultProjectDataDirectory(String projectName) {
  File canonicalProjectDataLocation = workspaceData.canonicalProjectDataLocation();
  if (canonicalProjectDataLocation != null) {
    return canonicalProjectDataLocation.getPath();
  }
  String lastProjectLocation =
      PropertiesComponent.getInstance().getValue(LAST_PROJECT_LOCATION_PROPERTY);
  if (lastProjectLocation == null) {
    // TODO(brendandouglas): remove this temporary fall-back once LAST_PROJECT_LOCATION_PROPERTY
    // is populated
    lastProjectLocation = RecentProjectsManager.getInstance().getLastProjectCreationLocation();
  }
  if (lastProjectLocation == null) {
    return newUniquePath(new File(getDefaultProjectsDirectory(), projectName));
  }
  // Because RecentProjectsManager uses PathUtil.toSystemIndependentName.
  lastProjectLocation = lastProjectLocation.replace('/', File.separatorChar);
  File lastProjectParent = new File(lastProjectLocation);
  if (lastProjectParent.getName().equals(BlazeDataStorage.PROJECT_DATA_SUBDIRECTORY)) {
    lastProjectParent = lastProjectParent.getParentFile();
  }
  return newUniquePath(new File(lastProjectParent, projectName));
}
 
Example #6
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 #7
Source File: XmlInstantSorterAction.java    From android-xml-sorter with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent event) {

    final Project project = getEventProject(event);
    final Editor editor = event.getData(PlatformDataKeys.EDITOR);
    XmlSorterDialog dialog = new XmlSorterDialog(project);

    PropertiesComponent pc = PropertiesComponent.getInstance();
    execute(project,
            editor,
            pc.getInt(PC_KEY_INPUT_CASE, 0) == 0,
            dialog.getPrefixSpacePositionValueAt(pc.getInt(PC_KEY_PREFIX_SPACE_POS, 0)),
            pc.getBoolean(PC_KEY_SPACE_BETWEEN_PREFIX, true),
            pc.getBoolean(PC_KEY_INSERT_XML_INFO, true),
            pc.getBoolean(PC_KEY_DELETE_COMMENT, false),
            dialog.getCodeIndentValueAt(pc.getInt(PC_KEY_CODE_INDENT, 1)),
            pc.getBoolean(PC_KEY_SEPARATE_NON_TRANSLATABLE, false));
}
 
Example #8
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 #9
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 #10
Source File: BaseBuilder.java    From OkHttpParamsGet with Apache License 2.0 6 votes vote down vote up
protected boolean isNullable(@NotNull PsiElement element) {
    if (element instanceof PsiField) {
        PsiField field = (PsiField) element;
        if (field.getType() instanceof PsiPrimitiveType) {
            return false;
        }
        boolean defaultNullable = PropertiesComponent.getInstance().getBoolean(Constant.NULLABLE, true);
        if (defaultNullable) {
            return !NonNullFactory.hasNonNull(field.getAnnotations());
        }
        return NonNullFactory.hasNullable(field.getAnnotations());
    } else if (element instanceof KtProperty) {
        KtProperty property = (KtProperty) element;
        KtTypeReference reference = property.getTypeReference();
        return reference != null && reference.getTypeElement() instanceof KtNullableType;
    }
    return false;
}
 
Example #11
Source File: CommitChangeListDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void dispose() {
  myDisposed = true;
  Disposer.dispose(myBrowser);
  Disposer.dispose(myCommitMessageArea);
  Disposer.dispose(myOKButtonUpdateAlarm);
  myUpdateButtonsRunnable.cancel();
  super.dispose();
  Disposer.dispose(myDiffDetails);
  PropertiesComponent.getInstance().setValue(SPLITTER_PROPORTION_OPTION, mySplitter.getProportion(), SPLITTER_PROPORTION_OPTION_DEFAULT);
  float usedProportion = myDetailsSplitter.getUsedProportion();
  if (usedProportion > 0) {
    PropertiesComponent.getInstance().setValue(DETAILS_SPLITTER_PROPORTION_OPTION, usedProportion, DETAILS_SPLITTER_PROPORTION_OPTION_DEFAULT);
  }
  PropertiesComponent.getInstance().setValue(DETAILS_SHOW_OPTION, myDetailsSplitter.isOn(), DETAILS_SHOW_OPTION_DEFAULT);
}
 
Example #12
Source File: ComboBoxWithHistory.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void save() {
  final StringBuilder buf = new StringBuilder("<map>");
  for (Object key : myWeights.keySet()) {
    if (key != null) {
      final Long value = myWeights.get(key);
      if (value != null) {
        buf.append("<element>")
           .append("<key>").append(key).append("</key>")
           .append("<value>").append(value).append("</value>")
           .append("</element>");
      }
    }
  }

  final String xml = buf.append("</map>").toString();

  if (myProject == null) {
    PropertiesComponent.getInstance().setValue(myHistoryId, xml);
  } else {
    PropertiesComponent.getInstance(myProject).setValue(myHistoryId, xml);
  }
}
 
Example #13
Source File: YiiStormSettingsPage.java    From yiistorm with MIT License 6 votes vote down vote up
@Override
public void apply() throws ConfigurationException {
    PropertiesComponent properties = PropertiesComponent.getInstance(project);
    properties.setValue("enableYiiStorm", String.valueOf(enableYiiStorm.isSelected()));
    properties.setValue("themeName", themeNameField.getText());
    properties.setValue("langName", langField.getText());
    properties.setValue("yiicFile", yiicFileField.getText());
    // properties.setValue("yiiConfigPath", yiiConfigPath.getText());
    // properties.setValue("yiiLitePath", yiiLitePath.getText());
    // properties.setValue("useYiiCompleter", String.valueOf(useYiiCompleter.isSelected()));
    // properties.setValue("useYiiMigrations", String.valueOf(useMigrationsCheckbox.isSelected()));

    final ToolWindowManager manager = ToolWindowManager.getInstance(project);
    final ToolWindow tw = manager.getToolWindow("Migrations");
    if (tw != null) {
        tw.setAvailable(MigrationsCondition.makeCondition(project), null);
    }
   /* if (properties.getBoolean("useYiiCompleter", false)) {
        YiiStormProjectComponent.getInstance(project).loadConfigParser();
    } else {
        YiiStormProjectComponent.getInstance(project).clearConfigParser();
    } */

}
 
Example #14
Source File: NixIDEASettings.java    From nix-idea with Apache License 2.0 5 votes vote down vote up
NixIDEASettings(@NotNull Project project) {
    this.projectProperties = PropertiesComponent.getInstance(project);

    settings = Arrays.asList((Setting) new ResettableEnvField("NIX_PATH", (TextFriend) new TextComponent(nixPath))
            , (Setting) new ResettableEnvField("NIX_PROFILES", (TextFriend) new TextComponent(nixProfiles))
            , (Setting) new ResettableEnvField("NIX_OTHER_STORES", (TextFriend) new TextComponent(nixOtherStores))
            , (Setting) new ResettableEnvField("NIX_REMOTE", (TextFriend) new TextComponent(nixRemote))
            , (Setting) new ResettableEnvField("NIXPKGS_CONFIG", (TextFriend) new TextComponent(nixPkgsConfig))
            , (Setting) new ResettableEnvField("NIX_CONF_DIR", (TextFriend) new TextComponent(nixConfDir))
            , (Setting) new ResettableEnvField("NIX_USER_PROFILE_DIR", (TextFriend) new TextComponent(nixUserProfileDir))
    );

    final Color originalBackground = nixPath.getBackground();
    nixPath.setInputVerifier(new InputVerifier() {
        @Override
        public boolean verify(JComponent input) {
            JTextField tf = (JTextField) input;
            NixPathVerifier npv = new NixPathVerifier(tf.getText());
            if (npv.verify()) {
                input.setBackground(originalBackground);
                return true;
            } else {
                //Some parts of the paths are inaccessible
                //TODO: change to individual path strikeout
                input.setBackground(JBColor.RED);
                return false;
            }
        }
    });
}
 
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: KotlinParamsObjectBuilder.java    From OkHttpParamsGet with Apache License 2.0 5 votes vote down vote up
@Override
protected String[] getImports() {
    if (!PropertiesComponent.getInstance().getBoolean(Constant.ARRAY_MAP, true)) {
        return null;
    }
    return new String[]{PropertiesComponent.getInstance().getBoolean(Constant.ANDROIDX, true) ? "androidx.collection.ArrayMap" : "android.support.v4.util.ArrayMap"};
}
 
Example #17
Source File: FlutterSettings.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void sendSettingsToAnalytics(Analytics analytics) {
  final PropertiesComponent properties = getPropertiesComponent();

  // Send data on the number of experimental features enabled by users.
  analytics.sendEvent("settings", "ping");

  if (isReloadOnSave()) {
    analytics.sendEvent("settings", afterLastPeriod(reloadOnSaveKey));
  }
  if (isOpenInspectorOnAppLaunch()) {
    analytics.sendEvent("settings", afterLastPeriod(openInspectorOnAppLaunchKey));
  }
  if (isFormatCodeOnSave()) {
    analytics.sendEvent("settings", afterLastPeriod(formatCodeOnSaveKey));

    if (isOrganizeImportsOnSave()) {
      analytics.sendEvent("settings", afterLastPeriod(organizeImportsOnSaveKey));
    }
  }
  if (isShowOnlyWidgets()) {
    analytics.sendEvent("settings", afterLastPeriod(showOnlyWidgetsKey));
  }

  if (isSyncingAndroidLibraries()) {
    analytics.sendEvent("settings", afterLastPeriod(syncAndroidLibrariesKey));
  }
  if (isDisableTrackWidgetCreation()) {
    analytics.sendEvent("settings", afterLastPeriod(disableTrackWidgetCreationKey));
  }

  if (isShowBuildMethodGuides()) {
    analytics.sendEvent("settings", afterLastPeriod(showBuildMethodGuidesKey));
  }

  if (isShowStructuredErrors()) {
    analytics.sendEvent("settings", afterLastPeriod(showStructuredErrors));
  }
}
 
Example #18
Source File: FileColorsModel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void load(@Nonnull Element e, boolean isProjectLevel) {
  List<FileColorConfiguration> configurations = isProjectLevel ? myProjectLevelConfigurations : myApplicationLevelConfigurations;

  configurations.clear();

  Map<String, String> predefinedScopeNameToPropertyKey = new THashMap<>(myPredefinedScopeNameToPropertyKey);
  for (Element child : e.getChildren(FILE_COLOR)) {
    FileColorConfiguration configuration = FileColorConfiguration.load(child);
    if (configuration != null) {
      if (!isProjectLevel) {
        predefinedScopeNameToPropertyKey.remove(configuration.getScopeName());
      }
      configurations.add(configuration);
    }
  }

  if (!isProjectLevel) {
    PropertiesComponent properties = PropertiesComponent.getInstance();
    for (String scopeName : predefinedScopeNameToPropertyKey.keySet()) {
      String colorName = getColorNameForScope(properties, scopeName, predefinedScopeNameToPropertyKey);

      // empty means that value deleted
      if (!StringUtil.isEmpty(colorName)) {
        configurations.add(new FileColorConfiguration(scopeName, colorName));
      }
    }
  }
}
 
Example #19
Source File: DesktopToolWindowContentUi.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static AnAction createMergeTabsAction(final ContentManager manager, final String tabPrefix) {
  return new DumbAwareAction("Merge tabs to '" + tabPrefix + "' group") {
    @RequiredUIAccess
    @Override
    public void actionPerformed(@Nonnull AnActionEvent e) {
      final Content selectedContent = manager.getSelectedContent();
      final List<Pair<String, JComponent>> tabs = new ArrayList<Pair<String, JComponent>>();
      int selectedTab = -1;
      for (Content content : manager.getContents()) {
        if (tabPrefix.equals(content.getUserData(Content.TAB_GROUP_NAME_KEY))) {
          final String label = content.getTabName().substring(tabPrefix.length() + 2);
          final JComponent component = content.getComponent();
          if (content == selectedContent) {
            selectedTab = tabs.size();
          }
          tabs.add(Pair.create(label, component));
          manager.removeContent(content, false);
          content.setComponent(null);
          Disposer.dispose(content);
        }
      }
      PropertiesComponent.getInstance().unsetValue(TabbedContent.SPLIT_PROPERTY_PREFIX + tabPrefix);
      for (int i = 0; i < tabs.size(); i++) {
        final Pair<String, JComponent> tab = tabs.get(i);
        ContentUtilEx.addTabbedContent(manager, tab.second, tabPrefix, tab.first, i == selectedTab);
      }
    }
  };
}
 
Example #20
Source File: DocumentationComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static FontSize getQuickDocFontSize() {
  String strValue = PropertiesComponent.getInstance().getValue(QUICK_DOC_FONT_SIZE_PROPERTY);
  if (strValue != null) {
    try {
      return FontSize.valueOf(strValue);
    }
    catch (IllegalArgumentException iae) {
      // ignore, fall back to default font.
    }
  }
  return FontSize.SMALL;
}
 
Example #21
Source File: BingTranslationApi.java    From AndroidStringsOneTabTranslation with Apache License 2.0 5 votes vote down vote up
private static List<NameValuePair> getAccessTokenNameValuePair() {
    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    List<NameValuePair> params = new ArrayList<NameValuePair>(4);
    params.add(new BasicNameValuePair("client_id",
            propertiesComponent.getValue(StorageDataKey.BingClientIdStored, Key.BING_CLIENT_ID)));
    params.add(new BasicNameValuePair("client_secret",
            propertiesComponent.getValue(StorageDataKey.BingClientSecretStored, Key.BING_CLIENT_SECRET)));
    params.add(new BasicNameValuePair("scope", Key.BING_CLIENT_SCOPE));
    params.add(new BasicNameValuePair("grant_type", Key.BING_CLIENT_GRANT_TYPE));
    return params;
}
 
Example #22
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 #23
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 #24
Source File: KotlinParamsObjectBuilder.java    From OkHttpParamsGet with Apache License 2.0 5 votes vote down vote up
@Override
protected String getParamsType() {
    if (!PropertiesComponent.getInstance().getBoolean(Constant.ARRAY_MAP, true)) {
        return "HashMap<String, Any>";
    }
    return "ArrayMap<String, Any>";
}
 
Example #25
Source File: AbstractContextTest.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Before
public void setup() {
  container = ContextMocker.emptyContext();

  // mock IntelliJ dependencies
  mockStaticGetInstance(PropertiesComponent.class, null);

  // mock IntelliJ dependent calls to get current IDE and plugin version
  PowerMock.mockStaticPartial(
      IntellijVersionProvider.class, "getPluginVersion", "getBuildNumber");

  EasyMock.expect(IntellijVersionProvider.getPluginVersion()).andReturn("0.1.0");
  EasyMock.expect(IntellijVersionProvider.getBuildNumber()).andReturn("1");

  PowerMock.replay(IntellijVersionProvider.class);

  // mock application related requests
  MessageBusConnection messageBusConnection = EasyMock.createNiceMock(MessageBusConnection.class);
  EasyMock.replay(messageBusConnection);

  MessageBus messageBus = EasyMock.createNiceMock(MessageBus.class);
  EasyMock.expect(messageBus.connect()).andReturn(messageBusConnection);
  EasyMock.replay(messageBus);

  Application application = EasyMock.createNiceMock(Application.class);
  EasyMock.expect(application.getMessageBus()).andReturn(messageBus);
  EasyMock.replay(application);

  PowerMock.mockStaticPartial(ApplicationManager.class, "getApplication");
  EasyMock.expect(ApplicationManager.getApplication()).andReturn(application);
  PowerMock.replay(ApplicationManager.class);
}
 
Example #26
Source File: PlatformOrPluginUpdateChecker.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Validate force bundle jre flag. If flag set version changed - it will be dropped
 */
private static void validateForceBundledJreVersion() {
  String oldVer = PropertiesComponent.getInstance().getValue(ourForceJREBuildVersion);

  String curVer = ApplicationInfo.getInstance().getBuild().toString();

  if (!Objects.equals(oldVer, curVer)) {
    PropertiesComponent.getInstance().unsetValue(ourForceJREBuild);
  }
}
 
Example #27
Source File: KotlinParamsStringBuilder.java    From OkHttpParamsGet with Apache License 2.0 5 votes vote down vote up
@Override
protected String getParamsType() {
    if (!PropertiesComponent.getInstance().getBoolean(Constant.ARRAY_MAP, true)) {
        return "HashMap<String, String>";
    }
    return "ArrayMap<String, String>";
}
 
Example #28
Source File: CreateCustomGoalAction.java    From MavenHelper with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
	ApplicationService instance = ApplicationService.getInstance();
	ApplicationSettings state = instance.getState();

	DataContext context = e.getDataContext();
	Project project = MavenActionUtil.getProject(context);
	String pomDir = Utils.getPomDirAsString(context, mavenProject);
	MavenProjectsManager projectsManager = MavenActionUtil.getProjectsManager(context);
	PsiFile data = LangDataKeys.PSI_FILE.getData(e.getDataContext());
	ConfigurationContext configurationContext = ConfigurationContext.getFromContext(e.getDataContext());


	GoalEditor editor = new GoalEditor("Create and Run", "", state, true, e.getProject(), e.getDataContext());
	if (editor.showAndGet()) {
		String s = editor.getCmd();
		if (StringUtils.isNotBlank(s)) {

			Goal goal = new Goal(s);

			PropertiesComponent.getInstance().setValue(GoalEditor.SAVE, editor.isPersist(), true);
			if (editor.isPersist()) {
				state.getGoals().add(goal);
				instance.registerAction(goal, getRunGoalAction(goal));
			}

			if (runGoal) {
				getRunGoalAction(goal).actionPerformed(project, pomDir, projectsManager, data, configurationContext);
			}
		}
	}

}
 
Example #29
Source File: InnerBuilderOptionSelector.java    From innerbuilder with Apache License 2.0 5 votes vote down vote up
private static JCheckBox[] buildOptionCheckBoxes() {
    final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    final int optionCount = OPTIONS.size();
    final JCheckBox[] checkBoxesArray = new JCheckBox[optionCount];
    for (int i = 0; i < optionCount; i++) {
        checkBoxesArray[i] = buildOptionCheckBox(propertiesComponent, OPTIONS.get(i));
    }

    return checkBoxesArray;
}
 
Example #30
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("");
  }
}