Search in sources :

Example 1 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project intellij-community by JetBrains.

the class MavenModuleWizardStep method saveValue.

private static void saveValue(String key, String value) {
    PropertiesComponent props = PropertiesComponent.getInstance();
    props.setValue(key, value);
}
Also used : PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 2 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project intellij-community by JetBrains.

the class CreateSetupPyAction method getAttributesDefaults.

@Override
public AttributesDefaults getAttributesDefaults(DataContext dataContext) {
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    final AttributesDefaults defaults = new AttributesDefaults("setup.py").withFixedName(true);
    if (project != null) {
        defaults.add("Package_name", project.getName());
        final PropertiesComponent properties = PropertiesComponent.getInstance();
        defaults.add("Author", properties.getOrInit(AUTHOR_PROPERTY, SystemProperties.getUserName()));
        defaults.add("Author_email", properties.getOrInit(EMAIL_PROPERTY, ""));
        defaults.addPredefined("PackageList", getPackageList(dataContext));
        defaults.addPredefined("PackageDirs", getPackageDirs(dataContext));
    }
    return defaults;
}
Also used : Project(com.intellij.openapi.project.Project) AttributesDefaults(com.intellij.ide.fileTemplates.actions.AttributesDefaults) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 3 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project ideavim by JetBrains.

the class VimPlugin method setupStatisticsReporter.

/**
   * Reports statistics about installed IdeaVim and enabled Vim emulation.
   *
   * See https://github.com/go-lang-plugin-org/go-lang-idea-plugin/commit/5182ab4a1d01ad37f6786268a2fe5e908575a217
   */
private void setupStatisticsReporter(@NotNull EventFacade eventFacade) {
    final Application application = ApplicationManager.getApplication();
    eventFacade.addEditorFactoryListener(new EditorFactoryAdapter() {

        @Override
        public void editorCreated(@NotNull EditorFactoryEvent event) {
            final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
            final long lastUpdate = propertiesComponent.getOrInitLong(IDEAVIM_STATISTICS_TIMESTAMP_KEY, 0);
            final boolean outOfDate = lastUpdate == 0 || System.currentTimeMillis() - lastUpdate > TimeUnit.DAYS.toMillis(1);
            if (outOfDate && isEnabled()) {
                application.executeOnPooledThread(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            final String buildNumber = ApplicationInfo.getInstance().getBuild().asString();
                            final String pluginId = IDEAVIM_PLUGIN_ID;
                            final String version = URLEncoder.encode(getVersion(), CharsetToolkit.UTF8);
                            final String os = URLEncoder.encode(SystemInfo.OS_NAME + " " + SystemInfo.OS_VERSION, CharsetToolkit.UTF8);
                            final String uid = UpdateChecker.getInstallationUID(PropertiesComponent.getInstance());
                            final String url = "https://plugins.jetbrains.com/plugins/list" + "?pluginId=" + pluginId + "&build=" + buildNumber + "&pluginVersion=" + version + "&os=" + os + "&uuid=" + uid;
                            PropertiesComponent.getInstance().setValue(IDEAVIM_STATISTICS_TIMESTAMP_KEY, String.valueOf(System.currentTimeMillis()));
                            HttpRequests.request(url).connect(new HttpRequests.RequestProcessor<Object>() {

                                @Override
                                public Object process(@NotNull HttpRequests.Request request) throws IOException {
                                    LOG.info("Sending statistics: " + url);
                                    try {
                                        JDOMUtil.load(request.getInputStream());
                                    } catch (JDOMException e) {
                                        LOG.warn(e);
                                    }
                                    return null;
                                }
                            });
                        } catch (IOException e) {
                            LOG.warn(e);
                        }
                    }
                });
            }
        }
    }, application);
}
Also used : EditorFactoryAdapter(com.intellij.openapi.editor.event.EditorFactoryAdapter) EditorFactoryEvent(com.intellij.openapi.editor.event.EditorFactoryEvent) IOException(java.io.IOException) JDOMException(org.jdom.JDOMException) HttpRequests(com.intellij.util.io.HttpRequests) Application(com.intellij.openapi.application.Application) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 4 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project intellij-community by JetBrains.

the class GenerateAntBuildDialog method loadSettings.

private void loadSettings() {
    final PropertiesComponent properties = PropertiesComponent.getInstance(myProject);
    if (properties.isValueSet(SINGLE_FILE_PROPERTY)) {
        final boolean singleFile = properties.isTrueValue(SINGLE_FILE_PROPERTY);
        myRbGenerateSingleFileBuild.setSelected(singleFile);
        myRbGenerateMultipleFilesBuild.setSelected(!singleFile);
    }
    if (properties.isValueSet(UI_FORM_PROPERTY)) {
        myCbEnableUIFormsCompilation.setSelected(properties.isTrueValue(UI_FORM_PROPERTY));
    }
    if (properties.isValueSet(FORCE_TARGET_JDK_PROPERTY)) {
        myCbForceTargetJdk.setSelected(properties.isTrueValue(FORCE_TARGET_JDK_PROPERTY));
    }
    if (properties.isValueSet(BACKUP_FILES_PROPERTY)) {
        final boolean backup = properties.isTrueValue(BACKUP_FILES_PROPERTY);
        myRbBackupFiles.setSelected(backup);
        myRbOverwriteFiles.setSelected(!backup);
    }
    if (properties.isValueSet(INLINE_RUNTIME_CLASSPATH_PROPERTY)) {
        myCbInlineRuntimeClasspath.setSelected(properties.isTrueValue(INLINE_RUNTIME_CLASSPATH_PROPERTY));
    }
    if (properties.isValueSet(GENERATE_IDEA_HOME_PROPERTY)) {
        myGenerateIdeaHomeProperty.setSelected(properties.isTrueValue(GENERATE_IDEA_HOME_PROPERTY));
    }
    if (properties.isValueSet(OUTPUT_FILE_NAME_PROPERTY)) {
        myOutputFileNameField.setText(properties.getValue(OUTPUT_FILE_NAME_PROPERTY));
    } else {
        myOutputFileNameField.setText(BuildProperties.getProjectBuildFileName(myProject));
    }
}
Also used : PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 5 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project intellij-community by JetBrains.

the class ToggleDistractionFreeModeAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    alternateCurrentDistractionFreeModeSetting();
    boolean enter = isDistractionFreeModeEnabled();
    if (project == null)
        return;
    PropertiesComponent p = PropertiesComponent.getInstance();
    UISettings ui = UISettings.getInstance();
    EditorSettingsExternalizable.OptionSet eo = EditorSettingsExternalizable.getInstance().getOptions();
    DaemonCodeAnalyzerSettings ds = DaemonCodeAnalyzerSettings.getInstance();
    String before = "BEFORE.DISTRACTION.MODE.";
    String after = "AFTER.DISTRACTION.MODE.";
    if (enter) {
        applyAndSave(p, ui, eo, ds, before, after, false);
        TogglePresentationModeAction.storeToolWindows(project);
    } else {
        applyAndSave(p, ui, eo, ds, after, before, true);
        TogglePresentationModeAction.restoreToolWindows(project, true, false);
    }
    UISettings.getInstance().fireUISettingsChanged();
    LafManager.getInstance().updateUI();
    EditorUtil.reinitSettings();
    DaemonCodeAnalyzer.getInstance(project).settingsChanged();
    EditorFactory.getInstance().refreshAllEditors();
}
Also used : DaemonCodeAnalyzerSettings(com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings) Project(com.intellij.openapi.project.Project) UISettings(com.intellij.ide.ui.UISettings) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) EditorSettingsExternalizable(com.intellij.openapi.editor.ex.EditorSettingsExternalizable)

Aggregations

PropertiesComponent (com.intellij.ide.util.PropertiesComponent)71 File (java.io.File)9 NotNull (org.jetbrains.annotations.NotNull)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 Project (com.intellij.openapi.project.Project)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)3 CommitStepException (com.intellij.ide.wizard.CommitStepException)3 Notification (com.intellij.notification.Notification)3 NotificationListener (com.intellij.notification.NotificationListener)3 JDOMException (org.jdom.JDOMException)3 Nullable (org.jetbrains.annotations.Nullable)3 SdkPaths.validateAndroidSdk (com.android.tools.idea.sdk.SdkPaths.validateAndroidSdk)2 Module (com.intellij.openapi.module.Module)2 ProjectTemplate (com.intellij.platform.ProjectTemplate)2 CollectionListModel (com.intellij.ui.CollectionListModel)2 THashMap (gnu.trove.THashMap)2 TIntArrayList (gnu.trove.TIntArrayList)2 Analytics (io.flutter.analytics.Analytics)2