Search in sources :

Example 56 with PropertiesComponent

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

the class RepositoryAttachDialog method dispose.

@Override
protected void dispose() {
    Disposer.dispose(myProgressIcon);
    PropertiesComponent storage = PropertiesComponent.getInstance(myProject);
    storage.setValue(PROPERTY_DOWNLOAD_TO_PATH_ENABLED, String.valueOf(myDownloadToCheckBox.isSelected()));
    String downloadPath = myDirectoryField.getText();
    if (StringUtil.isEmptyOrSpaces(downloadPath))
        downloadPath = myDefaultDownloadFolder;
    storage.setValue(PROPERTY_DOWNLOAD_TO_PATH, downloadPath, myDefaultDownloadFolder);
    storage.setValue(PROPERTY_ATTACH_JAVADOC, String.valueOf(myJavaDocCheckBox.isSelected()));
    storage.setValue(PROPERTY_ATTACH_SOURCES, String.valueOf(mySourcesCheckBox.isSelected()));
    super.dispose();
}
Also used : PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 57 with PropertiesComponent

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

the class SearchEverywhereAction method saveHistory.

private static void saveHistory(Project project, String text, Object value) {
    if (project == null || project.isDisposed() || !project.isInitialized()) {
        return;
    }
    HistoryType type = null;
    String fqn = null;
    if (isActionValue(value)) {
        type = HistoryType.ACTION;
        AnAction action = (AnAction) (value instanceof GotoActionModel.ActionWrapper ? ((GotoActionModel.ActionWrapper) value).getAction() : value);
        fqn = ActionManager.getInstance().getId(action);
    } else if (value instanceof VirtualFile) {
        type = HistoryType.FILE;
        fqn = ((VirtualFile) value).getUrl();
    } else if (value instanceof ChooseRunConfigurationPopup.ItemWrapper) {
        type = HistoryType.RUN_CONFIGURATION;
        fqn = ((ChooseRunConfigurationPopup.ItemWrapper) value).getText();
    } else if (value instanceof PsiElement) {
        final PsiElement psiElement = (PsiElement) value;
        final Language language = psiElement.getLanguage();
        final String name = LanguagePsiElementExternalizer.INSTANCE.forLanguage(language).getQualifiedName(psiElement);
        if (name != null) {
            type = HistoryType.PSI;
            fqn = language.getID() + "://" + name;
        }
    }
    final PropertiesComponent storage = PropertiesComponent.getInstance(project);
    final String[] values = storage.getValues(SE_HISTORY_KEY);
    List<HistoryItem> history = new ArrayList<>();
    if (values != null) {
        for (String s : values) {
            final String[] split = s.split("\t");
            if (split.length != 3 || text.equals(split[0])) {
                continue;
            }
            if (!StringUtil.isEmpty(split[0])) {
                history.add(new HistoryItem(split[0], split[1], split[2]));
            }
        }
    }
    history.add(0, new HistoryItem(text, type == null ? null : type.name(), fqn));
    if (history.size() > MAX_SEARCH_EVERYWHERE_HISTORY) {
        history = history.subList(0, MAX_SEARCH_EVERYWHERE_HISTORY);
    }
    final String[] newValues = new String[history.size()];
    for (int i = 0; i < newValues.length; i++) {
        newValues[i] = history.get(i).toString();
    }
    storage.setValues(SE_HISTORY_KEY, newValues);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RelativePoint(com.intellij.ui.awt.RelativePoint) Language(com.intellij.lang.Language) ChooseRunConfigurationPopup(com.intellij.execution.actions.ChooseRunConfigurationPopup) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 58 with PropertiesComponent

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

the class CreateSetupPyAction method elementCreated.

@Override
protected void elementCreated(CreateFromTemplateDialog dialog, PsiElement createdElement) {
    final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance();
    final Properties properties = dialog.getEnteredProperties();
    final String author = properties.getProperty("Author");
    if (author != null) {
        propertiesComponent.setValue(AUTHOR_PROPERTY, author);
    }
    final String authorEmail = properties.getProperty("Author_email");
    if (authorEmail != null) {
        propertiesComponent.setValue(EMAIL_PROPERTY, authorEmail);
    }
}
Also used : Properties(java.util.Properties) SystemProperties(com.intellij.util.SystemProperties) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 59 with PropertiesComponent

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

the class PhoneGapProjectTemplateGenerator method generateProject.

@Override
public void generateProject(@NotNull final Project project, @NotNull final VirtualFile baseDir, @NotNull final PhoneGapProjectTemplateGenerator.PhoneGapProjectSettings settings, @NotNull Module module) {
    try {
        ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
            try {
                ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
                indicator.setText("Creating...");
                File tempProject = createTemp();
                PhoneGapCommandLine commandLine = new PhoneGapCommandLine(settings.getExecutable(), tempProject.getPath(), settings.getOptions());
                if (!commandLine.isCorrectExecutable()) {
                    showErrorMessage("Incorrect path");
                    return;
                }
                commandLine.createNewProject(settings.name(), indicator);
                File[] array = tempProject.listFiles();
                if (array != null && array.length != 0) {
                    File from = ContainerUtil.getFirstItem(ContainerUtil.newArrayList(array));
                    assert from != null;
                    FileUtil.copyDir(from, new File(baseDir.getPath()));
                    deleteTemp(tempProject);
                } else {
                    showErrorMessage(PhoneGapBundle.message("phonegap.project.template.create.no.files") + " " + tempProject.getAbsolutePath());
                }
            } catch (Exception e) {
                throw new RuntimeException(e.getMessage(), e);
            }
        }, PhoneGapBundle.message("phonegap.project.template.create.title"), false, project);
        ApplicationManager.getApplication().runWriteAction(() -> {
            PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
            propertiesComponent.setValue(PhoneGapSettings.PHONEGAP_WORK_DIRECTORY, project.getBasePath());
            PhoneGapSettings.State state = PhoneGapSettings.getInstance().getState();
            if (!StringUtil.equals(settings.getExecutable(), state.getExecutablePath())) {
                PhoneGapSettings.getInstance().loadState(new PhoneGapSettings.State(settings.executable, state.repositoriesList));
            }
            VfsUtil.markDirty(false, true, baseDir);
            createRunConfiguration(project, settings);
            baseDir.refresh(true, true, () -> {
                if (PhoneGapSettings.getInstance().isExcludePlatformFolder()) {
                    VirtualFile platformsFolder = baseDir.findChild(PhoneGapUtil.FOLDER_PLATFORMS);
                    if (platformsFolder != null) {
                        PhoneGapStartupActivity.excludeFolder(project, platformsFolder);
                    }
                    VirtualFile ionicConfig = baseDir.findChild(PhoneGapUtil.IONIC_CONFIG);
                    if (ionicConfig != null) {
                        VirtualFile wwwFolder = baseDir.findChild(PhoneGapUtil.FOLDER_WWW);
                        if (wwwFolder != null) {
                            PhoneGapStartupActivity.excludeFolder(project, wwwFolder);
                        }
                    }
                }
            });
        });
    } catch (Exception e) {
        LOG.warn(e);
        showErrorMessage(e.getMessage());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PhoneGapCommandLine(com.github.masahirosuzuka.PhoneGapIntelliJPlugin.commandLine.PhoneGapCommandLine) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) IOException(java.io.IOException) PhoneGapSettings(com.github.masahirosuzuka.PhoneGapIntelliJPlugin.settings.PhoneGapSettings)

Example 60 with PropertiesComponent

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

the class PhoneGapSettings method setWorkingDirectory.

public void setWorkingDirectory(@Nullable Project project, @Nullable String dir) {
    if (project == null)
        return;
    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
    propertiesComponent.setValue(PHONEGAP_WORK_DIRECTORY, dir);
}
Also used : PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

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