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();
}
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);
}
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);
}
}
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());
}
}
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);
}
Aggregations