From 27a3796490de4255ad987d40526d8e41048fe08f Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 9 Mar 2015 18:08:29 +0100 Subject: [PATCH 1/4] we cannot check isDirectory because file may not exist (we don't create empty directory for schema manager anymore) --- .../ide/actions/ImportSettingsAction.java | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ImportSettingsAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ImportSettingsAction.java index 6b08f5ec897a..db61dbc06aaa 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ImportSettingsAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ImportSettingsAction.java @@ -38,17 +38,14 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.io.FileUtilRt; import com.intellij.util.Consumer; import com.intellij.util.containers.MultiMap; -import com.intellij.util.io.ZipUtil; import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import java.awt.*; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; +import java.util.*; import java.util.List; -import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipFile; @@ -146,19 +143,33 @@ public class ImportSettingsAction extends AnAction implements DumbAware { } @NotNull - private static List getComponentsStored(@NotNull File zipFile, + private static List getComponentsStored(@NotNull File settings, @NotNull Collection registeredComponents) throws IOException { + THashSet zipEntries = new THashSet(); + ZipFile zip = new ZipFile(settings); + try { + Enumeration enumeration = zip.entries(); + while (enumeration.hasMoreElements()) { + ZipEntry zipEntry = (ZipEntry)enumeration.nextElement(); + zipEntries.add(zipEntry.getName()); + } + } + finally { + zip.close(); + } + File configPath = new File(PathManager.getConfigPath()); List components = new ArrayList(); + for (ExportableComponent component : registeredComponents) { for (File exportFile : component.getExportFiles()) { - String rPath = FileUtilRt.getRelativePath(configPath, exportFile); - assert rPath != null; - String relativePath = FileUtilRt.toSystemIndependentName(rPath); - if (exportFile.isDirectory()) { + String relativePath = FileUtilRt.getRelativePath(configPath, exportFile); + assert relativePath != null; + relativePath = FileUtilRt.toSystemIndependentName(relativePath); + if (exportFile.getName().indexOf('.') == -1 && !exportFile.isFile()) { relativePath += '/'; } - if (ZipUtil.isZipContainsEntry(zipFile, relativePath)) { + if (zipEntries.contains(relativePath)) { components.add(component); break; } From 27244ef04c1c8a87a9336f1b75999cbda65a069f Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 9 Mar 2015 18:10:48 +0100 Subject: [PATCH 2/4] =?UTF-8?q?save=20settings=20component=20shoud=20not?= =?UTF-8?q?=20handle=20errors=20=E2=80=94=20just=20rethrow.=20Otherwise=20?= =?UTF-8?q?our=20modern,=20"up-to-date"=20logic=20is=20not=20involved=20(o?= =?UTF-8?q?ld=20impl=20=E2=80=94=20modal=20error=20dialog,=20new=20logic?= =?UTF-8?q?=20in=20platform=20=E2=80=94=20notification)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/stores/ComponentStoreImpl.java | 20 +++++++++------- .../impl/stores/ProjectStoreImpl.java | 9 ++++---- .../options/SchemesManagerFactoryImpl.java | 12 ++++++++-- .../openapi/options/SchemesManagerImpl.java | 23 ++++++++----------- .../util/lang/CompoundRuntimeException.java | 23 +++++++++++++------ 5 files changed, 52 insertions(+), 35 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java index 14ecef7775b7..9b8f767c9240 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java @@ -103,16 +103,21 @@ public abstract class ComponentStoreImpl implements IComponentStore.Reloadable { } } + List errors = null; for (SettingsSavingComponent settingsSavingComponent : mySettingsSavingComponents) { try { settingsSavingComponent.save(); } catch (Throwable e) { - LOG.error(e); + if (errors == null) { + errors = new SmartList(); + } + errors.add(e); } } - doSave(externalizationSession == null ? null : externalizationSession.createSaveSessions(), readonlyFiles); + errors = doSave(externalizationSession == null ? null : externalizationSession.createSaveSessions(), readonlyFiles, errors); + CompoundRuntimeException.doThrow(errors); } @TestOnly @@ -143,7 +148,7 @@ public abstract class ComponentStoreImpl implements IComponentStore.Reloadable { AccessToken token = WriteAction.start(); try { VfsRootAccess.allowRootAccess(file.getAbsolutePath()); - doSave(sessions, Collections.>emptyList()); + CompoundRuntimeException.doThrow(doSave(sessions, Collections.>emptyList(), null)); } finally { try { @@ -173,16 +178,15 @@ public abstract class ComponentStoreImpl implements IComponentStore.Reloadable { } } - protected void doSave(@Nullable List saveSessions, @NotNull List> readonlyFiles) { + @Nullable + protected List doSave(@Nullable List saveSessions, @NotNull List> readonlyFiles, @Nullable List errors) { if (saveSessions != null) { - List errors = null; for (SaveSession session : saveSessions) { errors = executeSave(session, readonlyFiles, errors); } - if (errors != null) { - throw new CompoundRuntimeException(errors); - } } + + return errors; } @Nullable diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java index 851b1eb2eefa..357eed947d85 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java @@ -445,7 +445,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject } @Override - protected final void doSave(@Nullable List saveSessions, @NotNull List> readonlyFiles) { + protected final List doSave(@Nullable List saveSessions, @NotNull List> readonlyFiles, @Nullable List errors) { ProjectImpl.UnableToSaveProjectNotification[] notifications = NotificationsManager.getNotificationsManager().getNotificationsOfType(ProjectImpl.UnableToSaveProjectNotification.class, myProject); if (notifications.length > 0) { @@ -454,7 +454,7 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject beforeSave(readonlyFiles); - super.doSave(saveSessions, readonlyFiles); + super.doSave(saveSessions, readonlyFiles, errors); if (!readonlyFiles.isEmpty()) { ReadonlyStatusHandler.OperationStatus status; @@ -473,13 +473,12 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject else { List> oldList = new ArrayList>(readonlyFiles); readonlyFiles.clear(); - List errors = null; for (Pair entry : oldList) { errors = executeSave(entry.first, readonlyFiles, errors); } if (errors != null) { - throw new CompoundRuntimeException(errors); + CompoundRuntimeException.doThrow(errors); } if (!readonlyFiles.isEmpty()) { @@ -488,6 +487,8 @@ class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements IProject } } } + + return errors; } protected void beforeSave(@NotNull List> readonlyFiles) { diff --git a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerFactoryImpl.java b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerFactoryImpl.java index ae6789d8a480..d329ce207d82 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerFactoryImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerFactoryImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,9 @@ import com.intellij.openapi.components.SettingsSavingComponent; import com.intellij.openapi.components.impl.stores.StateStorageManager; import com.intellij.openapi.components.impl.stores.StreamProvider; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.lang.CompoundRuntimeException; import org.jetbrains.annotations.NotNull; import java.io.File; @@ -60,13 +62,19 @@ final class SchemesManagerFactoryImpl extends SchemesManagerFactory implements S @Override public void save() { + List errors = null; for (SchemesManager registeredManager : myRegisteredManagers) { try { registeredManager.save(); } catch (Throwable e) { - LOG.error("Cannot save settings for " + registeredManager.getClass().getName(), e); + if (errors == null) { + errors = new SmartList(); + } + errors.add(e); } } + + CompoundRuntimeException.doThrow(errors); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java index edcf4a45e8d4..eab56840f234 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java @@ -16,7 +16,6 @@ package com.intellij.openapi.options; import com.intellij.openapi.application.AccessToken; -import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ex.DecodeDefaultsUtil; import com.intellij.openapi.components.RoamingType; @@ -46,6 +45,7 @@ import com.intellij.util.SmartList; import com.intellij.util.ThrowableConvertor; import com.intellij.util.containers.ContainerUtilRt; import com.intellij.util.io.URLUtil; +import com.intellij.util.lang.CompoundRuntimeException; import com.intellij.util.text.UniqueNameGenerator; import gnu.trove.THashSet; import org.jdom.Document; @@ -517,27 +517,22 @@ public class SchemesManagerImpl errors = null; + for (E scheme : schemesToSave) { try { saveScheme(scheme, nameGenerator); } - catch (final Exception e) { - Application app = ApplicationManager.getApplication(); - if (app.isUnitTestMode() || app.isCommandLine()) { - LOG.error("Cannot write scheme " + scheme.getName() + " in '" + myFileSpec + "': " + e.getLocalizedMessage(), e); - } - else { - app.invokeLater(new Runnable() { - @Override - public void run() { - Messages.showErrorDialog("Cannot save scheme '" + scheme.getName() + ": " + e.getMessage(), "Save Settings"); - } - }); + catch (Throwable e) { + if (errors == null) { + errors = new SmartList(); } + errors.add(e); } } deleteFiles(dir); + + CompoundRuntimeException.doThrow(errors); } private void saveScheme(@NotNull E scheme, @NotNull UniqueNameGenerator nameGenerator) throws WriteExternalException, IOException { diff --git a/platform/util/src/com/intellij/util/lang/CompoundRuntimeException.java b/platform/util/src/com/intellij/util/lang/CompoundRuntimeException.java index d0d89f12aff7..28ccf8d25eea 100644 --- a/platform/util/src/com/intellij/util/lang/CompoundRuntimeException.java +++ b/platform/util/src/com/intellij/util/lang/CompoundRuntimeException.java @@ -15,7 +15,9 @@ */ package com.intellij.util.lang; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.PrintStream; import java.io.PrintWriter; @@ -34,7 +36,6 @@ public class CompoundRuntimeException extends RuntimeException { myThrowables = throwables; } - @Override public void printStackTrace(PrintStream s) { for (Throwable throwable : myThrowables) { @@ -50,17 +51,25 @@ public class CompoundRuntimeException extends RuntimeException { } } - public static void doThrow(@NotNull List throwables) { + public static void doThrow(@Nullable List throwables) { + if (ContainerUtil.isEmpty(throwables)) { + return; + } + if (throwables.size() == 1) { - @SuppressWarnings("ThrowableResultOfMethodCallIgnored") Throwable throwable = throwables.get(0); - if (throwable instanceof RuntimeException) { - throw (RuntimeException)throwable; - } if (throwable instanceof Error) { throw (Error)throwable; } + else if (throwable instanceof RuntimeException) { + throw (RuntimeException)throwable; + } + else { + throw new RuntimeException(throwable); + } + } + else { + throw new CompoundRuntimeException(throwables); } - throw new CompoundRuntimeException(throwables); } } From afc2593429c4d4e5ef39cbbc7f9f49e8ac36c961 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 9 Mar 2015 18:26:13 +0100 Subject: [PATCH 3/4] =?UTF-8?q?IDETalk,=20Commander=20and=20Visual=20Sourc?= =?UTF-8?q?eSafe=20Integration=20=E2=80=94=20set=20"idea-version"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/commander/src/META-INF/plugin.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/commander/src/META-INF/plugin.xml b/plugins/commander/src/META-INF/plugin.xml index 4894970d7908..eb00cbece872 100644 --- a/plugins/commander/src/META-INF/plugin.xml +++ b/plugins/commander/src/META-INF/plugin.xml @@ -2,7 +2,8 @@ com.intellij.commander Commander Provides a two-panel view for navigating and working with the project structure - 1.0.0 + 999.999 + JetBrains com.intellij.ide.commander.CommanderBundle From 842422bb81e1baba0c14d70f80896a3526056224 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Mon, 9 Mar 2015 18:57:35 +0100 Subject: [PATCH 4/4] support multiple navigations --- .../com/intellij/find/impl/FindDialog.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java index dcc5405ef432..10bd7bf8454e 100644 --- a/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java +++ b/platform/lang-impl/src/com/intellij/find/impl/FindDialog.java @@ -66,10 +66,7 @@ import com.intellij.ui.table.JBTable; import com.intellij.usageView.UsageInfo; import com.intellij.usages.*; import com.intellij.usages.impl.UsagePreviewPanel; -import com.intellij.util.Alarm; -import com.intellij.util.ArrayUtil; -import com.intellij.util.Consumer; -import com.intellij.util.Processor; +import com.intellij.util.*; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -1511,12 +1508,22 @@ public class FindDialog extends DialogWrapper { } private void navigateToSelectedUsage(JBTable source) { - int row = source.getSelectedRow(); - Object valueAt = source.getModel().getValueAt(row, 0); - if (valueAt instanceof Usage) { + int[] rows = source.getSelectedRows(); + List navigations = null; + for(int row:rows) { + Object valueAt = source.getModel().getValueAt(row, 0); + if (valueAt instanceof Usage) { + if (navigations == null) navigations = new SmartList(); + Usage at = (Usage)valueAt; + navigations.add(at); + } + } + + if (navigations != null) { applyTo(FindManager.getInstance(myProject).getFindInProjectModel(), false); doCancelAction(); - ((Usage)valueAt).navigate(true); + navigations.get(0).navigate(true); + for(int i = 1; i < navigations.size(); ++i) navigations.get(i).highlightInEditor(); } }