From f0dc8e967d6e73a4464df6ae21c79a18cd30b103 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 18 Nov 2014 17:50:35 +0100 Subject: [PATCH] shared schemes concept is useless --- .../openapi/options/BaseSchemeProcessor.java | 4 +- .../openapi/options/ExternalInfo.java | 29 +-- .../openapi/options/SchemesManager.java | 23 +- .../options/SchemesManagerFactory.java | 5 - .../openapi/options/SharedScheme.java | 1 + .../options/AbstractSchemesManager.java | 29 ++- .../options/ImportSourceChooserDialog.java | 14 +- .../codeStyle/CodeStyleSchemesModel.java | 5 +- .../ManageCodeStyleSchemesDialog.java | 58 ++--- .../options/colors/ColorSettingsUtil.java | 4 +- .../options/colors/SchemesPanel.java | 74 +------ .../template/impl/TemplateListPanel.java | 86 +------- .../QuickChangeCodeStyleSchemeAction.java | 21 +- .../fileTypes/impl/FileTypeConfigurable.java | 90 +------- .../ui/SingleInspectionProfilePanel.java | 25 +-- .../source/codeStyle/CodeStyleSchemeImpl.java | 12 +- .../codeStyle/CodeStyleSchemesImpl.java | 27 +-- .../PersistableCodeStyleSchemes.java | 25 +-- .../options/ExportSchemeAction.java | 80 ------- .../options/ImportSchemeAction.java | 63 ------ .../options/SchemesToImportPopup.java | 49 ++--- .../actions/QuickChangeColorSchemeAction.java | 29 +-- .../ide/actions/QuickChangeKeymapAction.java | 31 +-- .../fileTypes/impl/FileTypeManagerImpl.java | 41 ++-- .../keymap/impl/KeymapManagerImpl.java | 1 + .../keymap/impl/ui/EditQuickListDialog.java | 4 +- .../openapi/keymap/impl/ui/KeymapPanel.java | 76 +------ .../keymap/impl/ui/QuickListPanel.java | 23 +- .../keymap/impl/ui/QuickListsPanel.java | 69 ++---- .../openapi/options/SchemeImporterEP.java | 3 +- .../options/SchemesManagerFactoryImpl.java | 17 +- .../openapi/options/SchemesManagerImpl.java | 198 +++--------------- .../src/messages/OptionsBundle.properties | 1 + .../src/messages/PsiBundle.properties | 1 - .../src/META-INF/LangExtensions.xml | 2 - .../src/META-INF/PlatformExtensionPoints.xml | 1 - .../src/META-INF/PlatformExtensions.xml | 1 - .../src/META-INF/PlatformLangPlugin.xml | 1 - resources/src/idea/RichPlatformPlugin.xml | 1 - 39 files changed, 242 insertions(+), 982 deletions(-) delete mode 100644 platform/platform-impl/src/com/intellij/application/options/ExportSchemeAction.java delete mode 100644 platform/platform-impl/src/com/intellij/application/options/ImportSchemeAction.java diff --git a/platform/core-api/src/com/intellij/openapi/options/BaseSchemeProcessor.java b/platform/core-api/src/com/intellij/openapi/options/BaseSchemeProcessor.java index a881d59e1761..a8629ea0cd88 100644 --- a/platform/core-api/src/com/intellij/openapi/options/BaseSchemeProcessor.java +++ b/platform/core-api/src/com/intellij/openapi/options/BaseSchemeProcessor.java @@ -20,6 +20,7 @@ import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.IOException; @@ -43,8 +44,9 @@ public abstract class BaseSchemeProcessor implem public void onCurrentSchemeChanged(final Scheme newCurrentScheme) { } + @Nullable public T readScheme(@NotNull Element element) throws InvalidDataException, IOException, JDOMException { - return readScheme(new Document(element)); + return readScheme(new Document((Element)element.detach())); } @Override diff --git a/platform/core-api/src/com/intellij/openapi/options/ExternalInfo.java b/platform/core-api/src/com/intellij/openapi/options/ExternalInfo.java index 80cf290f6504..d9556cfee86a 100644 --- a/platform/core-api/src/com/intellij/openapi/options/ExternalInfo.java +++ b/platform/core-api/src/com/intellij/openapi/options/ExternalInfo.java @@ -19,31 +19,34 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public final class ExternalInfo { - private boolean myIsImported; - private String myOriginalPath; - // we keep it to detect rename private String myPreviouslySavedName; private String myCurrentFileName; - private int mySavedHash; + private int myContentHash; private boolean myRemote; - public void setIsImported(final boolean isImported) { - myIsImported = isImported; + @SuppressWarnings({"UnusedParameters", "unused"}) + @Deprecated + public void setIsImported(boolean isImported) { } - public void setOriginalPath(final String originalPath) { - myOriginalPath = originalPath; + @SuppressWarnings("unused") + @Deprecated + public void setOriginalPath(String originalPath) { } + @SuppressWarnings("unused") + @Deprecated public boolean isIsImported() { - return myIsImported; + return false; } + @SuppressWarnings("unused") + @Deprecated public String getOriginalPath() { - return myOriginalPath; + return null; } public String getCurrentFileName() { @@ -56,8 +59,6 @@ public final class ExternalInfo { public void copy(@NotNull ExternalInfo externalInfo) { myCurrentFileName = externalInfo.myCurrentFileName; - myIsImported = externalInfo.isIsImported(); - myOriginalPath = externalInfo.myOriginalPath; } public String getPreviouslySavedName() { @@ -69,11 +70,11 @@ public final class ExternalInfo { } public int getHash() { - return mySavedHash; + return myContentHash; } public void setHash(int newHash) { - mySavedHash = newHash; + myContentHash = newHash; } public boolean isRemote() { diff --git a/platform/core-api/src/com/intellij/openapi/options/SchemesManager.java b/platform/core-api/src/com/intellij/openapi/options/SchemesManager.java index 73ba792ef1f5..6b13e51385d1 100644 --- a/platform/core-api/src/com/intellij/openapi/options/SchemesManager.java +++ b/platform/core-api/src/com/intellij/openapi/options/SchemesManager.java @@ -40,7 +40,7 @@ public interface SchemesManager loadSchemes(); - @NotNull Collection> loadSharedSchemes(); - @NotNull Collection> loadSharedSchemes(Collection currentSchemeList); + @Deprecated + @SuppressWarnings({"unused", "deprecation"}) + @NotNull + Collection> loadSharedSchemes(); + @SuppressWarnings({"unused", "deprecation"}) + @NotNull + @Deprecated + Collection> loadSharedSchemes(Collection currentSchemeList); + + @SuppressWarnings("unused") + @Deprecated void exportScheme(@NotNull E scheme, final String name, final String description) throws WriteExternalException, IOException; + @SuppressWarnings("unused") + @Deprecated boolean isImportAvailable(); + @SuppressWarnings("unused") + @Deprecated boolean isExportAvailable(); + @Deprecated boolean isShared(@NotNull Scheme scheme); void addNewScheme(@NotNull T scheme, final boolean replaceExisting); diff --git a/platform/core-api/src/com/intellij/openapi/options/SchemesManagerFactory.java b/platform/core-api/src/com/intellij/openapi/options/SchemesManagerFactory.java index db252c7a4d8b..e7a4b74ea46b 100644 --- a/platform/core-api/src/com/intellij/openapi/options/SchemesManagerFactory.java +++ b/platform/core-api/src/com/intellij/openapi/options/SchemesManagerFactory.java @@ -16,14 +16,10 @@ package com.intellij.openapi.options; import com.intellij.openapi.components.RoamingType; -import com.intellij.openapi.components.ServiceBean; import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.extensions.ExtensionPointName; import org.jetbrains.annotations.NotNull; public abstract class SchemesManagerFactory { - public static final ExtensionPointName SCHEME_OWNER = ExtensionPointName.create("com.intellij.schemeOwner"); - @NotNull public abstract SchemesManager createSchemesManager(@NotNull String fileSpec, @NotNull SchemeProcessor processor, @NotNull RoamingType roamingType); @@ -32,6 +28,5 @@ public abstract class SchemesManagerFactory { return ServiceManager.getService(SchemesManagerFactory.class); } - public abstract void updateConfigFilesFromStreamProviders(); } diff --git a/platform/core-api/src/com/intellij/openapi/options/SharedScheme.java b/platform/core-api/src/com/intellij/openapi/options/SharedScheme.java index ef3599350275..a0f59d39f521 100644 --- a/platform/core-api/src/com/intellij/openapi/options/SharedScheme.java +++ b/platform/core-api/src/com/intellij/openapi/options/SharedScheme.java @@ -17,6 +17,7 @@ package com.intellij.openapi.options; import org.jetbrains.annotations.NotNull; +@Deprecated public class SharedScheme { private final String myUserName; private final String myDescription; diff --git a/platform/core-impl/src/com/intellij/openapi/options/AbstractSchemesManager.java b/platform/core-impl/src/com/intellij/openapi/options/AbstractSchemesManager.java index 968a389673ad..a36968f3f251 100644 --- a/platform/core-impl/src/com/intellij/openapi/options/AbstractSchemesManager.java +++ b/platform/core-impl/src/com/intellij/openapi/options/AbstractSchemesManager.java @@ -22,10 +22,7 @@ import gnu.trove.THashSet; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; +import java.util.*; public abstract class AbstractSchemesManager implements SchemesManager { private static final Logger LOG = Logger.getInstance(AbstractSchemesManager.class); @@ -37,11 +34,9 @@ public abstract class AbstractSchemesManager> loadSharedSchemes(Collection currentSchemeList) { + return Collections.emptyList(); + } + + @SuppressWarnings("deprecation") @Override @NotNull public Collection> loadSharedSchemes() { - return loadSharedSchemes(getAllSchemes()); + return Collections.emptyList(); + } + + @Override + public boolean isShared(@NotNull Scheme scheme) { + return false; + } + + @Override + public boolean isExportAvailable() { + return false; } protected boolean isExternalizable(final T scheme) { diff --git a/platform/lang-impl/src/com/intellij/application/options/ImportSourceChooserDialog.java b/platform/lang-impl/src/com/intellij/application/options/ImportSourceChooserDialog.java index 067c86877201..7515bc631944 100644 --- a/platform/lang-impl/src/com/intellij/application/options/ImportSourceChooserDialog.java +++ b/platform/lang-impl/src/com/intellij/application/options/ImportSourceChooserDialog.java @@ -18,9 +18,7 @@ package com.intellij.application.options; import com.intellij.openapi.application.ApplicationBundle; import com.intellij.openapi.options.Scheme; import com.intellij.openapi.options.SchemeImporterEP; -import com.intellij.openapi.options.SchemesManager; import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.ui.components.JBCheckBox; import com.intellij.ui.components.JBList; import org.jetbrains.annotations.Nullable; @@ -40,10 +38,10 @@ public class ImportSourceChooserDialog extends DialogWrapper private final static String SHARED_IMPORT_SOURCE = ApplicationBundle.message("import.scheme.shared"); - public ImportSourceChooserDialog(JComponent parent, Class schemeClass, SchemesManager schemesManager) { + public ImportSourceChooserDialog(JComponent parent, Class schemeClass) { super(parent, true); setTitle(ApplicationBundle.message("title.import.scheme.from")); - myListModel = new SourceListModel(SchemeImporterEP.getExtensions(schemeClass), schemesManager.isImportAvailable()); + myListModel = new SourceListModel(SchemeImporterEP.getExtensions(schemeClass)); initSourceList(); init(); } @@ -83,15 +81,12 @@ public class ImportSourceChooserDialog extends DialogWrapper } private class SourceListModel extends DefaultListModel { - private List mySourceNames = new ArrayList(); + private final List mySourceNames = new ArrayList(); - public SourceListModel(Collection> extensions, boolean isSharedImportAvailable) { + public SourceListModel(Collection> extensions) { for (SchemeImporterEP extension : extensions) { mySourceNames.add(extension.name); } - if (isSharedImportAvailable) { - mySourceNames.add(SHARED_IMPORT_SOURCE); - } } @Override @@ -104,5 +99,4 @@ public class ImportSourceChooserDialog extends DialogWrapper return mySourceNames.get(index); } } - } diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSchemesModel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSchemesModel.java index 12dacff6b1bc..a3a0de673a3c 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSchemesModel.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSchemesModel.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.application.options.codeStyle; import com.intellij.openapi.options.SchemesManager; @@ -31,9 +30,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; - public class CodeStyleSchemesModel { - private final List mySchemes = new ArrayList(); private CodeStyleScheme myGlobalSelected; private final CodeStyleSchemeImpl myProjectScheme; @@ -198,7 +195,7 @@ public class CodeStyleSchemesModel { } public static boolean cannotBeModified(final CodeStyleScheme currentScheme) { - return currentScheme.isDefault() || getSchemesManager().isShared(currentScheme); + return currentScheme.isDefault(); } public static boolean cannotBeDeleted(final CodeStyleScheme currentScheme) { diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/ManageCodeStyleSchemesDialog.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/ManageCodeStyleSchemesDialog.java index 282f44d04a60..99fd1002c248 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/ManageCodeStyleSchemesDialog.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/ManageCodeStyleSchemesDialog.java @@ -15,7 +15,10 @@ */ package com.intellij.application.options.codeStyle; -import com.intellij.application.options.*; +import com.intellij.application.options.ImportSchemeChooserDialog; +import com.intellij.application.options.ImportSourceChooserDialog; +import com.intellij.application.options.SaveSchemeDialog; +import com.intellij.application.options.SchemesToImportPopup; import com.intellij.openapi.application.ApplicationBundle; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.FileChooserDialog; @@ -23,7 +26,6 @@ import com.intellij.openapi.fileChooser.FileChooserFactory; import com.intellij.openapi.options.SchemeImportException; import com.intellij.openapi.options.SchemeImporter; import com.intellij.openapi.options.SchemeImporterEP; -import com.intellij.openapi.options.SchemesManager; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.MessageType; @@ -35,7 +37,6 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.codeStyle.CodeStyleScheme; import com.intellij.psi.codeStyle.CodeStyleSchemes; -import com.intellij.psi.impl.source.codeStyle.CodeStyleSchemeImpl; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.table.JBTable; import org.jetbrains.annotations.NotNull; @@ -44,20 +45,21 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import javax.swing.table.*; +import javax.swing.table.AbstractTableModel; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.io.InputStream; -import java.util.*; +import java.util.ArrayList; import java.util.List; /** * @author: rvishnyakov */ public class ManageCodeStyleSchemesDialog extends DialogWrapper { - private JPanel myContentPane; private JBTable mySchemesTable; private JButton myDeleteButton; @@ -69,8 +71,6 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper { private final MySchemesTableModel mySchemesTableModel; private final CodeStyleSchemesModel myModel; private final Component myParent; - private final SchemesManager mySchemesManager; - protected ManageCodeStyleSchemesDialog(final Component parent, CodeStyleSchemesModel schemesModel) { super(parent, true); @@ -114,24 +114,12 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper { } }); - mySchemesManager = CodeStyleSchemesModel.getSchemesManager(); + myExportButton.setVisible(false); - if (mySchemesManager.isExportAvailable()) { - myExportButton.setVisible(true); - myExportButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(@NotNull final ActionEvent e) { - CodeStyleScheme selected = getSelectedScheme(); - ExportSchemeAction.doExport((CodeStyleSchemeImpl)selected, mySchemesManager); - } - }); - myExportButton.setMnemonic('S'); + if (SchemeImporterEP.getExtensions(CodeStyleScheme.class).isEmpty()) { + myImportButton.setVisible(false); } else { - myExportButton.setVisible(false); - } - - if (mySchemesManager.isImportAvailable() || SchemeImporterEP.getExtensions(CodeStyleScheme.class).size() > 0) { myImportButton.setVisible(true); myImportButton.addActionListener(new ActionListener() { @Override @@ -140,30 +128,24 @@ public class ManageCodeStyleSchemesDialog extends DialogWrapper { } }); } - else { - myImportButton.setVisible(false); - } init(); } - private void chooseAndImport() { ImportSourceChooserDialog importSourceChooserDialog = - new ImportSourceChooserDialog(myContentPane, CodeStyleScheme.class, mySchemesManager); + new ImportSourceChooserDialog(myContentPane, CodeStyleScheme.class); importSourceChooserDialog.show(); if (importSourceChooserDialog.isOK()) { if (importSourceChooserDialog.isImportFromSharedSelected()) { - SchemesToImportPopup popup = - new SchemesToImportPopup(myContentPane) { - @Override - protected void onSchemeSelected(final CodeStyleSchemeImpl scheme) { - if (scheme != null) { - myModel.addScheme(scheme, true); - } - } - }; - popup.show(mySchemesManager, myModel.getSchemes()); + new SchemesToImportPopup(myContentPane) { + @Override + protected void onSchemeSelected(CodeStyleScheme scheme) { + if (scheme != null) { + myModel.addScheme(scheme, true); + } + } + }.show(myModel.getSchemes()); } else { String selectedImporterName = importSourceChooserDialog.getSelectedSourceName(); diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorSettingsUtil.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorSettingsUtil.java index 275a0409b4a8..28123007bd2f 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorSettingsUtil.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorSettingsUtil.java @@ -19,10 +19,8 @@ package com.intellij.application.options.colors; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.SeveritiesProvider; import com.intellij.openapi.editor.colors.CodeInsightColors; -import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.editor.colors.impl.EditorColorsManagerImpl; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.options.OptionsBundle; import com.intellij.openapi.options.colors.AttributesDescriptor; @@ -75,7 +73,7 @@ public class ColorSettingsUtil { } static boolean isSharedScheme(EditorColorsScheme selected) { - return ((EditorColorsManagerImpl) EditorColorsManager.getInstance()).getSchemesManager().isShared(selected); + return false; } private static void addInspectionSeverityAttributes(List descriptors) { diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java b/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java index 4216a0ccea10..5dd572eb871b 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java @@ -16,17 +16,11 @@ package com.intellij.application.options.colors; -import com.intellij.application.options.ExportSchemeAction; import com.intellij.application.options.SaveSchemeDialog; -import com.intellij.application.options.SchemesToImportPopup; import com.intellij.application.options.SkipSelfSearchComponent; import com.intellij.openapi.application.ApplicationBundle; -import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; -import com.intellij.openapi.editor.colors.impl.EditorColorsManagerImpl; -import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl; import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.options.SchemesManager; import com.intellij.util.Consumer; import com.intellij.util.EventDispatcher; import com.intellij.util.containers.ContainerUtil; @@ -45,7 +39,6 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent { private JButton myDeleteButton; - private JButton myExportButton; private final EventDispatcher myDispatcher = EventDispatcher.create(ColorAndFontSettingsListener.class); @@ -65,25 +58,7 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent { public void actionPerformed(@NotNull ActionEvent e) { if (mySchemeComboBox.getSelectedIndex() != -1) { EditorColorsScheme selected = myOptions.selectScheme((String)mySchemeComboBox.getSelectedItem()); - if (ColorAndFontOptions.isReadOnly(selected)) { - myDeleteButton.setEnabled(false); - if (myExportButton != null) { - myExportButton.setEnabled(false); - } - } - else if (ColorSettingsUtil.isSharedScheme(selected)) { - myDeleteButton.setEnabled(true); - if (myExportButton != null) { - myExportButton.setEnabled(false); - } - } - else { - myDeleteButton.setEnabled(true); - if (myExportButton != null) { - myExportButton.setEnabled(true); - } - } - + myDeleteButton.setEnabled(!ColorAndFontOptions.isReadOnly(selected)); if (areSchemesLoaded()) { myDispatcher.getMulticaster().schemeChanged(SchemesPanel.this); } @@ -136,53 +111,6 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent { new GridBagConstraints(gridx++, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0)); - SchemesManager schemesManager = - ((EditorColorsManagerImpl)EditorColorsManager.getInstance()).getSchemesManager(); - if (schemesManager.isExportAvailable()) { - myExportButton = new JButton("Share..."); - myExportButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(@NotNull final ActionEvent e) { - EditorColorsScheme selected = myOptions.getOriginalSelectedScheme(); - ExportSchemeAction - .doExport((EditorColorsSchemeImpl)selected, ((EditorColorsManagerImpl)EditorColorsManager.getInstance()).getSchemesManager()); - } - }); - - panel.add(myExportButton, - new GridBagConstraints(gridx++, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, - 0)); - myExportButton.setMnemonic('S'); - - } - - if (schemesManager.isImportAvailable()) { - JButton myImportButton = new JButton("Import Shared..."); - myImportButton.setMnemonic('I'); - myImportButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(@NotNull final ActionEvent e) { - SchemesToImportPopup popup = - new SchemesToImportPopup(SchemesPanel.this) { - @Override - protected void onSchemeSelected(final EditorColorsSchemeImpl scheme) { - if (scheme != null) { - myOptions.addImportedScheme(scheme); - //changeToScheme(myOptions.getSelectedScheme()); - } - - } - }; - popup.show(((EditorColorsManagerImpl)EditorColorsManager.getInstance()).getSchemesManager(), myOptions.getSchemes()); - - } - }); - - panel.add(myImportButton, - new GridBagConstraints(gridx++, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, - 0)); - - } for (final ImportHandler importHandler : Extensions.getExtensions(ImportHandler.EP_NAME)) { final JButton button = new JButton(importHandler.getTitle()); button.addActionListener(new ActionListener() { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java index af6f2081e289..6eeb116e2d43 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateListPanel.java @@ -13,11 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.codeInsight.template.impl; -import com.intellij.application.options.ExportSchemeAction; -import com.intellij.application.options.SchemesToImportPopup; import com.intellij.codeInsight.CodeInsightBundle; import com.intellij.icons.AllIcons; import com.intellij.ide.DataManager; @@ -28,7 +25,6 @@ import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.options.ConfigurationException; -import com.intellij.openapi.options.SchemesManager; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.ui.*; import com.intellij.openapi.ui.popup.JBPopupFactory; @@ -60,14 +56,13 @@ import java.util.*; import java.util.List; public class TemplateListPanel extends JPanel implements Disposable { - private static final String NO_SELECTION = "NoSelection"; private static final String TEMPLATE_SETTINGS = "TemplateSettings"; private static final TemplateImpl MOCK_TEMPLATE = new TemplateImpl("mockTemplate-xxx", "mockTemplateGroup-yyy"); public static final String ABBREVIATION = ""; public static final Comparator TEMPLATE_COMPARATOR = new Comparator() { @Override - public int compare(final TemplateImpl o1, final TemplateImpl o2) { + public int compare(@NotNull final TemplateImpl o1, @NotNull final TemplateImpl o2) { return o1.getKey().compareToIgnoreCase(o2.getKey()); } }; @@ -126,7 +121,7 @@ public class TemplateListPanel extends JPanel implements Disposable { Collections.sort(groups, new Comparator() { @Override - public int compare(final TemplateGroup o1, final TemplateGroup o2) { + public int compare(@NotNull TemplateGroup o1, @NotNull TemplateGroup o2) { return o1.getName().compareToIgnoreCase(o2.getName()); } }); @@ -226,7 +221,7 @@ public class TemplateListPanel extends JPanel implements Disposable { } Collections.sort(result, new Comparator(){ @Override - public int compare(final TemplateImpl o1, final TemplateImpl o2) { + public int compare(@NotNull final TemplateImpl o1, @NotNull final TemplateImpl o2) { final int groupsEqual = o1.getGroupName().compareToIgnoreCase(o2.getGroupName()); if (groupsEqual != 0) { return groupsEqual; @@ -291,26 +286,6 @@ public class TemplateListPanel extends JPanel implements Disposable { myDetailsPanel.add(myCurrentTemplateEditor, TEMPLATE_SETTINGS); } - private Iterable collectAllTemplates() { - ArrayList result = new ArrayList(); - for (TemplateGroup templateGroup : myTemplateGroups) { - result.addAll(templateGroup.getElements()); - } - return result; - } - - private void exportCurrentGroup() { - int selected = getSingleSelectedIndex(); - if (selected < 0) return; - - ExportSchemeAction.doExport(getGroup(selected), getSchemesManager()); - - } - - private static SchemesManager getSchemesManager() { - return (TemplateSettings.getInstance()).getSchemesManager(); - } - @Nullable private TemplateImpl getTemplate(int row) { JTree tree = myTree; @@ -526,7 +501,7 @@ public class TemplateListPanel extends JPanel implements Disposable { myTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener(){ @Override - public void valueChanged(final TreeSelectionEvent e) { + public void valueChanged(@NotNull final TreeSelectionEvent e) { TemplateSettings templateSettings = TemplateSettings.getInstance(); TemplateImpl template = getTemplate(getSingleSelectedIndex()); if (template != null) { @@ -549,7 +524,7 @@ public class TemplateListPanel extends JPanel implements Disposable { myTree.registerKeyboardAction(new ActionListener() { @Override - public void actionPerformed(ActionEvent event) { + public void actionPerformed(@Nullable ActionEvent event) { myCurrentTemplateEditor.focusKey(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), JComponent.WHEN_FOCUSED); @@ -576,8 +551,7 @@ public class TemplateListPanel extends JPanel implements Disposable { @SuppressWarnings("unchecked") Set oldGroupNames = getAllGroups((Map)event.getAttachedObject()); TemplateGroup group = getDropGroup(event); boolean differentGroup = group != null && !oldGroupNames.contains(group.getName()); - boolean possible = differentGroup && !getSchemesManager().isShared(group); - event.setDropPossible(possible, differentGroup && !possible ? "Cannot modify a shared group" : ""); + event.setDropPossible(differentGroup, ""); return true; } }) @@ -661,50 +635,6 @@ public class TemplateListPanel extends JPanel implements Disposable { return super.isEnabled() && !TemplateSettings.getInstance().getDeletedTemplates().isEmpty(); } }); - if (getSchemesManager().isExportAvailable()) { - decorator.addExtraAction(new AnActionButton("Share...", PlatformIcons.EXPORT_ICON) { - @Override - public void actionPerformed(@NotNull AnActionEvent e) { - exportCurrentGroup(); - } - - @Override - public void updateButton(AnActionEvent e) { - TemplateGroup group = getGroup(getSingleSelectedIndex()); - e.getPresentation().setEnabled(group != null && !getSchemesManager().isShared(group)); - } - }); - } - if (getSchemesManager().isImportAvailable()) { - decorator.addExtraAction(new AnActionButton("Import Shared...", PlatformIcons.IMPORT_ICON) { - @Override - public void actionPerformed(@NotNull AnActionEvent e) { - new SchemesToImportPopup(TemplateListPanel.this){ - @Override - protected void onSchemeSelected(final TemplateGroup scheme) { - for (TemplateImpl newTemplate : scheme.getElements()) { - for (TemplateImpl existingTemplate : collectAllTemplates()) { - if (existingTemplate.getKey().equals(newTemplate.getKey())) { - Messages.showMessageDialog( - TemplateListPanel.this, - CodeInsightBundle - .message("dialog.edit.template.error.already.exists", existingTemplate.getKey(), existingTemplate.getGroupName()), - CodeInsightBundle.message("dialog.edit.template.error.title"), - Messages.getErrorIcon() - ); - return; - } - } - } - insertNewGroup(scheme); - for (TemplateImpl template : scheme.getElements()) { - registerTemplate(template); - } - } - }.show(getSchemesManager(), myTemplateGroups); - } - }); - } return decorator.setToolbarPosition(ActionToolbarPosition.RIGHT); } @@ -771,11 +701,9 @@ public class TemplateListPanel extends JPanel implements Disposable { Set oldGroups = getAllGroups(templates); removeAll(); - SchemesManager schemesManager = TemplateSettings.getInstance().getSchemesManager(); - for (TemplateGroup group : getTemplateGroups()) { final String newGroupName = group.getName(); - if (!oldGroups.contains(newGroupName) && !schemesManager.isShared(group)) { + if (!oldGroups.contains(newGroupName)) { add(new DumbAwareAction(newGroupName) { @Override public void actionPerformed(@NotNull AnActionEvent e) { diff --git a/platform/lang-impl/src/com/intellij/ide/actions/QuickChangeCodeStyleSchemeAction.java b/platform/lang-impl/src/com/intellij/ide/actions/QuickChangeCodeStyleSchemeAction.java index f1588b8e4f76..da3499735e35 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/QuickChangeCodeStyleSchemeAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/QuickChangeCodeStyleSchemeAction.java @@ -17,17 +17,12 @@ package com.intellij.ide.actions; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.editor.EditorFactory; -import com.intellij.openapi.options.SharedScheme; import com.intellij.openapi.project.Project; import com.intellij.psi.codeStyle.CodeStyleScheme; import com.intellij.psi.codeStyle.CodeStyleSchemes; import com.intellij.psi.codeStyle.CodeStyleSettingsManager; -import com.intellij.psi.impl.source.codeStyle.CodeStyleSchemeImpl; -import com.intellij.psi.impl.source.codeStyle.CodeStyleSchemesImpl; import org.jetbrains.annotations.NotNull; -import java.util.Collection; - /** * @author max */ @@ -46,22 +41,10 @@ public class QuickChangeCodeStyleSchemeAction extends QuickSwitchSchemeAction { }); } - final CodeStyleScheme[] schemes = CodeStyleSchemes.getInstance().getSchemes(); - final CodeStyleScheme currentScheme = CodeStyleSchemes.getInstance().getCurrentScheme(); - - for (final CodeStyleScheme scheme : schemes) { + CodeStyleScheme currentScheme = CodeStyleSchemes.getInstance().getCurrentScheme(); + for (CodeStyleScheme scheme : CodeStyleSchemes.getInstance().getSchemes()) { addScheme(group, manager, currentScheme, scheme, false); } - - - Collection> sharedSchemes = - ((CodeStyleSchemesImpl)CodeStyleSchemes.getInstance()).getSchemesManager().loadSharedSchemes(); - if (!sharedSchemes.isEmpty()) { - group.add(Separator.getInstance()); - for (SharedScheme scheme : sharedSchemes) { - addScheme(group, manager, currentScheme, scheme.getScheme(), true); - } - } } private static void addScheme(final DefaultActionGroup group, diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeConfigurable.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeConfigurable.java index a5d0cbbb39b9..353149a02059 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeConfigurable.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeConfigurable.java @@ -17,15 +17,11 @@ package com.intellij.openapi.fileTypes.impl; import com.intellij.CommonBundle; -import com.intellij.application.options.ExportSchemeAction; -import com.intellij.application.options.SchemesToImportPopup; import com.intellij.ide.highlighter.custom.SyntaxTable; -import com.intellij.ide.highlighter.custom.impl.ReadFileType; import com.intellij.lang.Language; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileTypes.*; -import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx; import com.intellij.openapi.options.*; import com.intellij.openapi.ui.DialogBuilder; import com.intellij.openapi.ui.DialogWrapper; @@ -37,7 +33,6 @@ import com.intellij.psi.templateLanguages.TemplateDataLanguagePatterns; import com.intellij.ui.*; import com.intellij.ui.components.JBList; import com.intellij.util.PairConvertor; -import com.intellij.util.PlatformIcons; import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -81,7 +76,7 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable myRecognizedFileType.attachActions(this); myRecognizedFileType.myFileTypesList.addListSelectionListener(new ListSelectionListener() { @Override - public void valueChanged(ListSelectionEvent e) { + public void valueChanged(@Nullable ListSelectionEvent e) { updateExtensionList(); } }); @@ -94,7 +89,7 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable FileType[] types = myTempFileTypes.toArray(new FileType[myTempFileTypes.size()]); Arrays.sort(types, new Comparator() { @Override - public int compare(Object o1, Object o2) { + public int compare(@NotNull Object o1, @NotNull Object o2) { FileType fileType1 = (FileType)o1; FileType fileType2 = (FileType)o2; return fileType1.getDescription().compareToIgnoreCase(fileType2.getDescription()); @@ -169,8 +164,9 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable } private static class ExtensionRenderer extends DefaultListCellRenderer { + @NotNull @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + public Component getListCellRendererComponent(@NotNull JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); setText(" " + getText()); return this; @@ -187,8 +183,7 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable if (type == null) return; List extensions = new ArrayList(); - final List assocs = myTempPatternsTable.getAssociations(type); - for (FileNameMatcher assoc : assocs) { + for (FileNameMatcher assoc : myTempPatternsTable.getAssociations(type)) { extensions.add(assoc.getPresentableString()); } @@ -205,8 +200,7 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable if (!canBeModified(fileType)) return; UserFileType ftToEdit = myOriginalToEditedMap.get(fileType); if (ftToEdit == null) ftToEdit = ((UserFileType)fileType).clone(); - TypeEditor editor = - new TypeEditor(myRecognizedFileType.myFileTypesList, ftToEdit, FileTypesBundle.message("filetype.edit.existing.title")); + TypeEditor editor = new TypeEditor(myRecognizedFileType.myFileTypesList, ftToEdit, FileTypesBundle.message("filetype.edit.existing.title")); editor.show(); if (editor.isOK()) { myOriginalToEditedMap.put((UserFileType)fileType, ftToEdit); @@ -419,46 +413,11 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable .setRemoveActionUpdater(new AnActionButtonUpdater() { @Override public boolean isEnabled(AnActionEvent e) { - FileType fileType = getSelectedFileType(); - return canBeModified(fileType) || getSchemesManager().isShared(fileType); + return canBeModified(getSelectedFileType()); } }) .disableUpDownActions(); - if (getSchemesManager().isImportAvailable()) { - toolbarDecorator.addExtraAction(new AnActionButton("Import Shared...", PlatformIcons.IMPORT_ICON) { - @Override - public void actionPerformed(AnActionEvent e) { - new SchemesToImportPopup(myFileTypesList) { - @Override - protected void onSchemeSelected(final AbstractFileType scheme) { - myController.importFileType(scheme); - } - }.show(getSchemesManager(), collectRegisteredFileTypes()); - } - }); - } - - if (getSchemesManager().isExportAvailable()) { - toolbarDecorator.addExtraAction(new AnActionButton("Share...", PlatformIcons.EXPORT_ICON) { - @Override - public void actionPerformed(AnActionEvent e) { - FileType selected = (FileType)myFileTypesList.getSelectedValue(); - if (selected instanceof AbstractFileType) { - ExportSchemeAction.doExport((AbstractFileType)selected, getSchemesManager()); - } - } - - @Override - public void updateButton(AnActionEvent e) { - FileType fileType = getSelectedFileType(); - boolean b = canBeModified(fileType); - boolean shared = getSchemesManager().isShared(fileType); - setEnabled(b && !shared); - } - }); - } - add(toolbarDecorator.createPanel(), BorderLayout.CENTER); setBorder(IdeBorderFactory.createTitledBorder(FileTypesBundle.message("filetypes.recognized.group"), false)); @@ -523,23 +482,11 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable } } - private static SchemesManager getSchemesManager() { - return ((FileTypeManagerEx)FileTypeManager.getInstance()).getSchemesManager(); - } - public void attachActions(final FileTypeConfigurable controller) { myController = controller; mySpeedSearch.myController = controller; } - private Collection collectRegisteredFileTypes() { - HashSet result = new HashSet(); - for (int i = 0; i < myFileTypesList.getModel().getSize(); i++) { - result.add((FileType)myFileTypesList.getModel().getElementAt(i)); - } - return result; - } - public FileType getSelectedFileType() { return (FileType)myFileTypesList.getSelectedValue(); } @@ -563,31 +510,12 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable return myFileTypesList.getSelectedIndex(); } - public void setSelectionIndex(int selectedIndex) { - myFileTypesList.setSelectedIndex(selectedIndex); - } - public void selectFileType(FileType fileType) { myFileTypesList.setSelectedValue(fileType, true); myFileTypesList.requestFocus(); } } - private void importFileType(final FileType type) { - ReadFileType readFileType = (ReadFileType)type; - ImportedFileType actualType = new ImportedFileType(readFileType.getSyntaxTable(), readFileType.getExternalInfo()); - actualType.setDescription(readFileType.getDescription()); - actualType.setName(readFileType.getName()); - actualType.readOriginalMatchers(readFileType.getElement()); - for (FileNameMatcher matcher : actualType.getOriginalPatterns()) { - myTempPatternsTable.addAssociation(matcher, actualType); - } - myTempFileTypes.add(actualType); - updateFileTypeList(); - updateExtensionList(); - myRecognizedFileType.selectFileType(type); - } - public static class PatternsPanel extends JPanel { private final JBList myPatternsList; private FileTypeConfigurable myController; @@ -663,10 +591,6 @@ public class FileTypeConfigurable extends BaseConfigurable implements Searchable } } - public boolean isListEmpty() { - return getListModel().isEmpty(); - } - public String removeSelected() { Object selectedValue = myPatternsList.getSelectedValue(); if (selectedValue == null) return null; diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java index 1ceec293a55a..17d27aa0dc52 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java @@ -22,7 +22,6 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; import com.intellij.codeInsight.daemon.impl.SeverityUtil; import com.intellij.codeInsight.hint.HintUtil; -import com.intellij.codeInspection.InspectionProfile; import com.intellij.codeInspection.InspectionsBundle; import com.intellij.codeInspection.ModifiableModel; import com.intellij.codeInspection.ex.*; @@ -51,7 +50,6 @@ import com.intellij.profile.ApplicationProfileManager; import com.intellij.profile.DefaultProjectProfileManager; import com.intellij.profile.ProfileManager; import com.intellij.profile.codeInspection.InspectionProfileManager; -import com.intellij.profile.codeInspection.InspectionProfileManagerImpl; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.profile.codeInspection.SeverityProvider; import com.intellij.profile.codeInspection.ui.filter.InspectionFilterAction; @@ -77,6 +75,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.swing.FocusManager; import javax.swing.*; import javax.swing.event.TreeExpansionEvent; import javax.swing.event.TreeExpansionListener; @@ -216,10 +215,10 @@ public class SingleInspectionProfilePanel extends JPanel { return StringUtil.capitalizeWords(severity.getName().toLowerCase(), true); } - private static void updateUpHierarchy(final InspectionConfigTreeNode node, final InspectionConfigTreeNode parent) { + private static void updateUpHierarchy(final InspectionConfigTreeNode parent) { if (parent != null) { parent.dropCache(); - updateUpHierarchy(parent, (InspectionConfigTreeNode)parent.getParent()); + updateUpHierarchy((InspectionConfigTreeNode)parent.getParent()); } } @@ -458,7 +457,7 @@ public class SingleInspectionProfilePanel extends JPanel { } }, 300); node.dropCache(); - updateUpHierarchy(node, (InspectionConfigTreeNode)node.getParent()); + updateUpHierarchy((InspectionConfigTreeNode)node.getParent()); } } } @@ -618,7 +617,7 @@ public class SingleInspectionProfilePanel extends JPanel { myTreeTable = InspectionsConfigTreeTable.create(new InspectionsConfigTreeTable.InspectionsConfigTreeTableSettings(myRoot, myProjectProfileManager.getProject()) { @Override protected void onChanged(final InspectionConfigTreeNode node) { - updateUpHierarchy(node, (InspectionConfigTreeNode)node.getParent()); + updateUpHierarchy((InspectionConfigTreeNode)node.getParent()); } @Override @@ -1152,14 +1151,6 @@ public class SingleInspectionProfilePanel extends JPanel { copyUsedSeveritiesIfUndefined(selectedProfile, profileManager); selectedProfile.setProfileManager(profileManager); } - final InspectionProfile parentProfile = selectedProfile.getParentProfile(); - - if (((InspectionProfileManagerImpl)InspectionProfileManager.getInstance()).getSchemesManager().isShared(selectedProfile)) { - if (descriptorsAreChanged()) { - throw new ConfigurationException("Shared profile cannot be modified. Please do \"Save As...\" first."); - } - - } try { selectedProfile.commit(); @@ -1167,7 +1158,7 @@ public class SingleInspectionProfilePanel extends JPanel { catch (IOException e) { throw new ConfigurationException(e.getMessage()); } - setSelectedProfile(parentProfile.getModifiableModel()); + setSelectedProfile(selectedProfile.getParentProfile().getModifiableModel()); setSelectedProfileModified(false); myModified = false; } @@ -1233,11 +1224,11 @@ public class SingleInspectionProfilePanel extends JPanel { final Object userObject = node.getUserObject(); if (userObject instanceof ToolDescriptors && (node.getScopeName() != null || node.isLeaf())) { updateErrorLevel(node, showOptionsAndDescriptorPanels, level); - updateUpHierarchy(node, parent); + updateUpHierarchy(parent); } else { updateErrorLevelUpInHierarchy(level, showOptionsAndDescriptorPanels, node); - updateUpHierarchy(node, parent); + updateUpHierarchy(parent); } } if (rows != null) { diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleSchemeImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleSchemeImpl.java index 18679b8dc78c..f8350cd7725a 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleSchemeImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleSchemeImpl.java @@ -130,15 +130,9 @@ public class CodeStyleSchemeImpl implements JDOMExternalizable, CodeStyleScheme, myCodeStyleSettings.readExternal(element); } - public static CodeStyleSchemeImpl readScheme(@NotNull Element element) throws InvalidDataException { - String schemeName = element.getAttributeValue(NAME); - String parentName = element.getAttributeValue(PARENT); - - if (schemeName == null) { - throw new InvalidDataException("Name attribute missing in code style scheme file"); - } - - return new CodeStyleSchemeImpl(schemeName, parentName, element); + @NotNull + public static CodeStyleSchemeImpl readScheme(@NotNull Element element) { + return new CodeStyleSchemeImpl(element.getAttributeValue(NAME), element.getAttributeValue(PARENT), element); } public void save(File dir) throws WriteExternalException{ diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleSchemesImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleSchemesImpl.java index 66752aa8ea21..40922312d3cd 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleSchemesImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleSchemesImpl.java @@ -15,16 +15,13 @@ */ package com.intellij.psi.impl.source.codeStyle; -import com.intellij.openapi.components.ExportableComponent; import com.intellij.openapi.components.RoamingType; import com.intellij.openapi.components.StoragePathMacros; import com.intellij.openapi.options.BaseSchemeProcessor; import com.intellij.openapi.options.SchemeProcessor; import com.intellij.openapi.options.SchemesManager; import com.intellij.openapi.options.SchemesManagerFactory; -import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; -import com.intellij.psi.PsiBundle; import com.intellij.psi.codeStyle.CodeStyleScheme; import com.intellij.psi.codeStyle.CodeStyleSchemes; import org.jdom.Element; @@ -33,24 +30,22 @@ import org.jetbrains.annotations.NotNull; import java.util.Collection; -/** - * @author MYakovlev - * Date: Jul 16, 2002 - */ -public abstract class CodeStyleSchemesImpl extends CodeStyleSchemes implements ExportableComponent { +public abstract class CodeStyleSchemesImpl extends CodeStyleSchemes { @NonNls public static final String DEFAULT_SCHEME_NAME = "Default"; + @SuppressWarnings("SpellCheckingInspection") + static final String CODE_STYLES_DIR_PATH = StoragePathMacros.ROOT_CONFIG + "/codestyles"; + public String CURRENT_SCHEME_NAME = DEFAULT_SCHEME_NAME; private boolean myIsInitialized = false; - @NonNls static final String CODE_STYLES_DIRECTORY = "codestyles"; private final SchemesManager mySchemesManager; - @NonNls private static final String FILE_SPEC = StoragePathMacros.ROOT_CONFIG + "/" + CODE_STYLES_DIRECTORY; public CodeStyleSchemesImpl(SchemesManagerFactory schemesManagerFactory) { SchemeProcessor processor = new BaseSchemeProcessor() { + @NotNull @Override - public CodeStyleSchemeImpl readScheme(@NotNull Element element) throws InvalidDataException { + public CodeStyleSchemeImpl readScheme(@NotNull Element element) { return CodeStyleSchemeImpl.readScheme(element); } @@ -70,7 +65,7 @@ public abstract class CodeStyleSchemesImpl extends CodeStyleSchemes implements E } }; - mySchemesManager = schemesManagerFactory.createSchemesManager(FILE_SPEC, processor, RoamingType.PER_USER); + mySchemesManager = schemesManagerFactory.createSchemesManager(CODE_STYLES_DIR_PATH, processor, RoamingType.PER_USER); init(); addScheme(new CodeStyleSchemeImpl(DEFAULT_SCHEME_NAME, true, null)); @@ -79,7 +74,7 @@ public abstract class CodeStyleSchemesImpl extends CodeStyleSchemes implements E @Override public CodeStyleScheme[] getSchemes() { - final Collection schemes = mySchemesManager.getAllSchemes(); + Collection schemes = mySchemesManager.getAllSchemes(); return schemes.toArray(new CodeStyleScheme[schemes.size()]); } @@ -159,12 +154,6 @@ public abstract class CodeStyleSchemesImpl extends CodeStyleSchemes implements E mySchemesManager.loadSchemes(); } - @Override - @NotNull - public String getPresentableName() { - return PsiBundle.message("codestyle.export.display.name"); - } - public SchemesManager getSchemesManager() { return mySchemesManager; } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/PersistableCodeStyleSchemes.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/PersistableCodeStyleSchemes.java index d04cc68967bc..64251aa45772 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/PersistableCodeStyleSchemes.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/PersistableCodeStyleSchemes.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -15,7 +15,6 @@ */ package com.intellij.psi.impl.source.codeStyle; -import com.intellij.openapi.application.PathManager; import com.intellij.openapi.components.*; import com.intellij.openapi.options.SchemesManagerFactory; import com.intellij.psi.codeStyle.CodeStyleScheme; @@ -27,18 +26,15 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.io.File; - /** * @author Rustam Vishnyakov */ @State( name = "CodeStyleSchemeSettings", - storages = {@Storage( - file = StoragePathMacros.APP_CONFIG + "/" + PersistableCodeStyleSchemes.CODE_STYLE_SCHEMES_FILE - )} + storages = @Storage(file = StoragePathMacros.APP_CONFIG + "/" + PersistableCodeStyleSchemes.CODE_STYLE_SCHEMES_FILE), + additionalExportFile = CodeStyleSchemesImpl.CODE_STYLES_DIR_PATH ) -public class PersistableCodeStyleSchemes extends CodeStyleSchemesImpl implements PersistentStateComponent, NamedComponent { +public class PersistableCodeStyleSchemes extends CodeStyleSchemesImpl implements PersistentStateComponent { @NonNls static final String CODE_STYLE_SCHEMES_FILE = "code.style.schemes.xml"; private boolean isLoaded; @@ -66,12 +62,6 @@ public class PersistableCodeStyleSchemes extends CodeStyleSchemesImpl implements updateCurrentScheme(); } - @NotNull - @Override - public String getComponentName() { - return "CodeStyleSchemeSettings"; - } - @Override public boolean isLoaded() { return isLoaded; @@ -93,11 +83,4 @@ public class PersistableCodeStyleSchemes extends CodeStyleSchemesImpl implements if (current == null) current = getDefaultScheme(); setCurrentScheme(current); } - - @Override - @NotNull - public File[] getExportFiles() { - return new File[]{new File(PathManager.getConfigPath() + File.separator + CODE_STYLES_DIRECTORY), - new File(PathManager.getOptionsPath() + File.separator + CODE_STYLE_SCHEMES_FILE)}; - } } diff --git a/platform/platform-impl/src/com/intellij/application/options/ExportSchemeAction.java b/platform/platform-impl/src/com/intellij/application/options/ExportSchemeAction.java deleted file mode 100644 index cee9580bafc9..000000000000 --- a/platform/platform-impl/src/com/intellij/application/options/ExportSchemeAction.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2000-2009 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.application.options; - -import com.intellij.icons.AllIcons; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.Presentation; -import com.intellij.openapi.options.ExternalizableScheme; -import com.intellij.openapi.options.Scheme; -import com.intellij.openapi.options.SchemesManager; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.util.WriteExternalException; - -import java.io.IOException; - -public abstract class ExportSchemeAction extends AnAction { - protected final SchemesManager mySchemesManager; - - public ExportSchemeAction(SchemesManager manager) { - super("Share", "Share scheme on server", AllIcons.Actions.Export); - mySchemesManager = manager; - } - - @Override - public void update(AnActionEvent e) { - final Presentation presentation = e.getPresentation(); - E profile = getSelectedScheme(); - presentation.setEnabled(profile != null && isAvailableFor(profile)); - } - - protected abstract E getSelectedScheme(); - - private boolean isAvailableFor(final E selected) { - return selected != null && !mySchemesManager.isShared(selected); - } - - @Override - public void actionPerformed(AnActionEvent e) { - doExport(getSelectedScheme(), mySchemesManager); - } - - public static void doExport(final E scheme, SchemesManager manager) { - if (scheme != null) { - try { - ShareSchemeDialog dialog = new ShareSchemeDialog(); - dialog.init(scheme); - - dialog.show(); - - if (dialog.isOK()) { - try { - manager.exportScheme(scheme, dialog.getName(), dialog.getDescription()); - Messages.showMessageDialog("Scheme '" + scheme.getName() + "' was shared successfully as '" + dialog.getName() + " '", "Share Scheme", - Messages.getInformationIcon()); - } - catch (IOException e) { - Messages.showErrorDialog("Cannot share scheme '" + scheme.getName() + "': " + e.getLocalizedMessage(), "Share Scheme"); - } - } - } - catch (WriteExternalException e1) { - Messages.showErrorDialog("Cannot share scheme: " + e1.getLocalizedMessage(), "Share Scheme"); - } - } - } -} diff --git a/platform/platform-impl/src/com/intellij/application/options/ImportSchemeAction.java b/platform/platform-impl/src/com/intellij/application/options/ImportSchemeAction.java deleted file mode 100644 index 4c0fdeb37305..000000000000 --- a/platform/platform-impl/src/com/intellij/application/options/ImportSchemeAction.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2000-2009 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.application.options; - -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.Presentation; -import com.intellij.openapi.options.ExternalizableScheme; -import com.intellij.openapi.options.Scheme; -import com.intellij.openapi.options.SchemesManager; -import com.intellij.util.PlatformIcons; - -import java.awt.*; -import java.util.Collection; - - -public abstract class ImportSchemeAction extends AnAction { - protected final SchemesManager mySchemesManager; - - - public ImportSchemeAction(SchemesManager manager) { - super("Import", "Import", PlatformIcons.IMPORT_ICON); - mySchemesManager = manager; - } - - public void update(AnActionEvent e) { - final Presentation presentation = e.getPresentation(); - presentation.setEnabled(true); - } - - public void actionPerformed(AnActionEvent e) { - SchemesToImportPopup popup = new SchemesToImportPopup(getPanel()){ - protected void onSchemeSelected(final E scheme) { - if (scheme != null) { - importScheme(scheme); - - } - - } - }; - popup.show(mySchemesManager, collectCurrentSchemes()); - - } - - protected abstract Collection collectCurrentSchemes(); - - protected abstract Component getPanel(); - - protected abstract void importScheme(E scheme); -} diff --git a/platform/platform-impl/src/com/intellij/application/options/SchemesToImportPopup.java b/platform/platform-impl/src/com/intellij/application/options/SchemesToImportPopup.java index 0c27a3eb33d8..3a15c1ccbd50 100644 --- a/platform/platform-impl/src/com/intellij/application/options/SchemesToImportPopup.java +++ b/platform/platform-impl/src/com/intellij/application/options/SchemesToImportPopup.java @@ -15,85 +15,67 @@ */ package com.intellij.application.options; -import com.intellij.openapi.options.ExternalizableScheme; import com.intellij.openapi.options.Scheme; -import com.intellij.openapi.options.SchemesManager; -import com.intellij.openapi.options.SharedScheme; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.popup.PopupChooserBuilder; +import com.intellij.ui.CollectionListModel; import com.intellij.ui.components.JBList; import com.intellij.util.ui.UIUtil; +import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.awt.*; import java.util.Collection; - -public abstract class SchemesToImportPopup { - +public abstract class SchemesToImportPopup { private final Component myParent; public SchemesToImportPopup(final Component parent) { myParent = parent; } - public void show(SchemesManager schemesManager, Collection currentSchemeNames) { - Collection> schemes = schemesManager.loadSharedSchemes(currentSchemeNames); - + public void show(Collection schemes) { if (schemes.isEmpty()) { Messages.showMessageDialog("There are no available schemes to import", "Import", Messages.getWarningIcon()); return; } - final JList list = new JBList(createModel(schemes)); + final JList list = new JBList(new CollectionListModel(schemes)); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setCellRenderer(new SchemesToImportListCellRenderer()); - - Runnable selectAction = new Runnable() { + @Override public void run() { - onSchemeSelected(((SharedScheme)list.getSelectedValue()).getScheme()); + onSchemeSelected((T)list.getSelectedValue()); } }; showList(list, selectAction); } - private ListModel createModel(Collection> cc) { - DefaultListModel m = new DefaultListModel(); - for (SharedScheme c : cc) { - m.addElement(c); - } - return m; - } - private void showList(JList list, Runnable selectAction) { new PopupChooserBuilder(list). - setTitle(getTitle()). + setTitle("Import Scheme"). setItemChoosenCallback(selectAction). createPopup(). showInCenterOf(myParent); } - private String getTitle() { - return "Import Scheme"; - } - private static class SchemesToImportListCellRenderer implements ListCellRenderer { private final JPanel myPanel = new JPanel(new BorderLayout()); - private final JLabel myNameLabel = new JLabel("", JLabel.LEFT); + private final JLabel myNameLabel = new JLabel("", SwingConstants.LEFT); public SchemesToImportListCellRenderer() { myPanel.add(myNameLabel, BorderLayout.CENTER); } - public Component getListCellRendererComponent(JList l, Object val, int i, boolean isSelected, boolean cellHasFocus) { - SharedScheme c = (SharedScheme)val; - myNameLabel.setText(c.getScheme().getName()); + @Override + public Component getListCellRendererComponent(@NotNull JList list, Object val, int i, boolean isSelected, boolean cellHasFocus) { + Scheme c = (Scheme)val; + myNameLabel.setText(c.getName()); updateColors(isSelected); - myPanel.setToolTipText("

Shared by " + c.getUserName() + "
" + c.getDescription() + "

"); return myPanel; } @@ -104,7 +86,7 @@ public abstract class SchemesToImportPopup> sharedSchemes = ((EditorColorsManagerImpl)EditorColorsManager.getInstance()).getSchemesManager().loadSharedSchemes(); - - if (!sharedSchemes.isEmpty()) { - group.add(Separator.getInstance()); - - for (SharedScheme sharedScheme : sharedSchemes) { - addScheme(group, current, sharedScheme.getScheme(), true); - } - } - } private static void addScheme(final DefaultActionGroup group, @@ -59,7 +42,8 @@ public class QuickChangeColorSchemeAction extends QuickSwitchSchemeAction { final EditorColorsScheme scheme, final boolean addScheme) { group.add(new DumbAwareAction(scheme.getName(), "", scheme == current ? ourCurrentAction : ourNotCurrentAction) { - public void actionPerformed(AnActionEvent e) { + @Override + public void actionPerformed(@Nullable AnActionEvent e) { if (addScheme) { EditorColorsManager.getInstance().addColorsScheme(scheme); } @@ -68,7 +52,8 @@ public class QuickChangeColorSchemeAction extends QuickSwitchSchemeAction { }); } + @Override protected boolean isEnabled() { - return EditorColorsManager.getInstance().getAllSchemes().length > 1 || ((EditorColorsManagerImpl)EditorColorsManager.getInstance()).getSchemesManager().isImportAvailable(); + return EditorColorsManager.getInstance().getAllSchemes().length > 1; } } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/QuickChangeKeymapAction.java b/platform/platform-impl/src/com/intellij/ide/actions/QuickChangeKeymapAction.java index 28a70b32a0be..bd1820570a07 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/QuickChangeKeymapAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/QuickChangeKeymapAction.java @@ -15,42 +15,32 @@ */ package com.intellij.ide.actions; -import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.DataContext; +import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.keymap.Keymap; import com.intellij.openapi.keymap.KeymapManager; import com.intellij.openapi.keymap.ex.KeymapManagerEx; -import com.intellij.openapi.keymap.impl.KeymapImpl; -import com.intellij.openapi.options.SharedScheme; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; -import java.util.Collection; - /** * @author max */ public class QuickChangeKeymapAction extends QuickSwitchSchemeAction { + @Override protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) { - final KeymapManagerEx manager = (KeymapManagerEx) KeymapManager.getInstance(); - final Keymap current = manager.getActiveKeymap(); - - for (final Keymap keymap : manager.getAllKeymaps()) { + KeymapManagerEx manager = (KeymapManagerEx) KeymapManager.getInstance(); + Keymap current = manager.getActiveKeymap(); + for (Keymap keymap : manager.getAllKeymaps()) { addKeymapAction(group, manager, current, keymap, false); } - - Collection> sharedSchemes = ((KeymapManagerEx)KeymapManagerEx.getInstance()).getSchemesManager().loadSharedSchemes(); - - if (!sharedSchemes.isEmpty()) { - group.add(Separator.getInstance()); - for (SharedScheme sharedScheme : sharedSchemes) { - addKeymapAction(group, manager,current, sharedScheme.getScheme(), true); - } - } - } - private void addKeymapAction(final DefaultActionGroup group, final KeymapManagerEx manager, final Keymap current, final Keymap keymap, final boolean addScheme) { + private static void addKeymapAction(final DefaultActionGroup group, final KeymapManagerEx manager, final Keymap current, final Keymap keymap, final boolean addScheme) { group.add(new AnAction(keymap.getPresentableName(), "", keymap == current ? ourCurrentAction : ourNotCurrentAction) { + @Override public void actionPerformed(AnActionEvent e) { if (addScheme) { manager.getSchemesManager().addNewScheme(keymap, false); @@ -60,6 +50,7 @@ public class QuickChangeKeymapAction extends QuickSwitchSchemeAction { }); } + @Override protected boolean isEnabled() { return ((KeymapManagerEx) KeymapManager.getInstance()).getAllKeymaps().length > 1; } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java index 60860026cdbe..fcaef3a505c3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java @@ -181,24 +181,15 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME public FileTypeManagerImpl(MessageBus bus, SchemesManagerFactory schemesManagerFactory) { myMessageBus = bus; mySchemesManager = schemesManagerFactory.createSchemesManager(FILE_SPEC, new BaseSchemeProcessor() { + @NotNull @Override public AbstractFileType readScheme(@NotNull Element root) { - Element element = root.getChild(AbstractFileType.ELEMENT_HIGHLIGHTING); - if (element != null) { - final SyntaxTable table = AbstractFileType.readSyntaxTable(element); - if (table != null) { - ReadFileType type = new ReadFileType(table, root); - String fileTypeName = root.getAttributeValue(ATTRIBUTE_NAME); - String fileTypeDescr = root.getAttributeValue(ATTRIBUTE_DESCRIPTION); - String iconPath = root.getAttributeValue(ATTRIBUTE_ICON); - - setFileTypeAttributes(fileTypeName, fileTypeDescr, iconPath, type); - - return type; - } - } - - return null; + ReadFileType type = new ReadFileType(AbstractFileType.readSyntaxTable(root.getChild(AbstractFileType.ELEMENT_HIGHLIGHTING)), root); + String fileTypeName = root.getAttributeValue(ATTRIBUTE_NAME); + String fileTypeDescr = root.getAttributeValue(ATTRIBUTE_DESCRIPTION); + String iconPath = root.getAttributeValue(ATTRIBUTE_ICON); + setFileTypeAttributes(fileTypeName, fileTypeDescr, iconPath, type); + return type; } @Override @@ -210,7 +201,10 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME public Element writeScheme(@NotNull final AbstractFileType fileType) throws WriteExternalException { Element root = new Element(ELEMENT_FILETYPE); - writeHeader(root, fileType); + root.setAttribute(ATTRIBUTE_BINARY, String.valueOf(fileType.isBinary())); + root.setAttribute(ATTRIBUTE_DEFAULT_EXTENSION, fileType.getDefaultExtension()); + root.setAttribute(ATTRIBUTE_DESCRIPTION, fileType.getDescription()); + root.setAttribute(ATTRIBUTE_NAME, fileType.getName()); fileType.writeExternal(root); @@ -223,7 +217,6 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME else { writeExtensionsMap(map, fileType, false); } - return root; } @@ -621,7 +614,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME return fileType; } - catch (IOException e) { + catch (IOException ignored) { return UnknownFileType.INSTANCE; // return unknown, do not cache } } @@ -1114,8 +1107,7 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME } private FileType loadFileType(@NotNull ReadFileType readFileType) { - ExternalInfo info = mySchemesManager.isShared(readFileType) ? readFileType.getExternalInfo() : null; - return loadFileType(readFileType.getElement(), false, info, + return loadFileType(readFileType.getElement(), false, readFileType.getExternalInfo(), true, readFileType.getExternalInfo().getCurrentFileName()); } @@ -1253,13 +1245,6 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME return fileType != FileTypes.UNKNOWN && !fileType.isReadOnly(); } - private static void writeHeader(Element root, FileType fileType) { - root.setAttribute(ATTRIBUTE_BINARY, String.valueOf(fileType.isBinary())); - root.setAttribute(ATTRIBUTE_DEFAULT_EXTENSION, fileType.getDefaultExtension()); - root.setAttribute(ATTRIBUTE_DESCRIPTION, fileType.getDescription()); - root.setAttribute(ATTRIBUTE_NAME, fileType.getName()); - } - // ------------------------------------------------------------------------- // Setup // ------------------------------------------------------------------------- diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapManagerImpl.java index c130f28b6ccf..30956c28a412 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/KeymapManagerImpl.java @@ -56,6 +56,7 @@ public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStat KeymapManagerImpl(DefaultKeymap defaultKeymap, SchemesManagerFactory factory) { mySchemesManager = factory.createSchemesManager(KEYMAPS_DIR_PATH, new BaseSchemeProcessor() { + @NotNull @Override public KeymapImpl readScheme(@NotNull Element element) throws InvalidDataException { KeymapImpl keymap = new KeymapImpl(); diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/EditQuickListDialog.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/EditQuickListDialog.java index 88f36728669c..cf4441d1ada3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/EditQuickListDialog.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/EditQuickListDialog.java @@ -16,9 +16,9 @@ package com.intellij.openapi.keymap.impl.ui; import com.intellij.openapi.actionSystem.ex.QuickList; +import com.intellij.openapi.keymap.KeyMapBundle; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.keymap.KeyMapBundle; import javax.swing.*; @@ -38,7 +38,7 @@ public class EditQuickListDialog extends DialogWrapper { } protected JComponent createCenterPanel() { - myPanel = new QuickListPanel(myList, myAllQuickLists, myProject); + myPanel = new QuickListPanel(myList, myAllQuickLists); return myPanel.getPanel(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java index 86ba9b05ecf0..a7ef486ce28e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java @@ -16,8 +16,6 @@ package com.intellij.openapi.keymap.impl.ui; import com.intellij.CommonBundle; -import com.intellij.application.options.ExportSchemeAction; -import com.intellij.application.options.SchemesToImportPopup; import com.intellij.icons.AllIcons; import com.intellij.ide.CommonActionsManager; import com.intellij.ide.DataManager; @@ -76,11 +74,12 @@ import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class KeymapPanel extends JPanel implements SearchableConfigurable, Configurable.NoScroll, KeymapListener, Disposable { - private JComboBox myKeymapList; private final DefaultComboBoxModel myKeymapListModel = new DefaultComboBoxModel(); @@ -200,17 +199,15 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi Keymap parent = mySelectedKeymap.getParent(); if (parent != null && mySelectedKeymap.canModify()) { myBaseKeymapLabel.setText(KeyMapBundle.message("based.on.keymap.label", parent.getPresentableName())); - if (mySelectedKeymap.canModify() && mySelectedKeymap.getOwnActionIds().length > 0){ + if (mySelectedKeymap.canModify() && mySelectedKeymap.getOwnActionIds().length > 0) { myResetToDefault.setEnabled(true); } } - if(mySelectedKeymap.canModify()) { + if (mySelectedKeymap.canModify()) { myDeleteButton.setEnabled(true); - if (!getSchemesManager().isShared(mySelectedKeymap)) { - if (myExportButton != null) { - myExportButton.setEnabled(true); - } + if (myExportButton != null) { + myExportButton.setEnabled(true); } } @@ -230,7 +227,6 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi return result; } - private JPanel createKeymapButtonsPanel() { final JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0)); @@ -248,55 +244,6 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi gc.weightx = 1; panel.add(myDeleteButton, gc); - final SchemesManager schemesManager = getSchemesManager(); - if (schemesManager.isExportAvailable()) { - myExportButton = new JButton("Share..."); - myExportButton.setMnemonic('S'); - myExportButton.addActionListener(new ActionListener(){ - @Override - public void actionPerformed(@NotNull ActionEvent e) { - KeymapImpl selected = getSelectedKeymap(); - ExportSchemeAction.doExport(selected, schemesManager); - } - }); - myExportButton.setMargin(insets); - - - panel.add(myExportButton, gc); - - - } - - if (schemesManager.isImportAvailable()) { - JButton importButton = new JButton("Import Shared..."); - importButton.setMnemonic('I'); - importButton.addActionListener(new ActionListener(){ - @Override - public void actionPerformed(@NotNull final ActionEvent e) { - SchemesToImportPopup popup = new SchemesToImportPopup(panel){ - @Override - protected void onSchemeSelected(final KeymapImpl scheme) { - if (scheme != null) { - scheme.setCanModify(true); - myKeymapListModel.addElement(scheme); - myKeymapList.setSelectedItem(scheme); - processCurrentKeymapChanged(getCurrentQuickListIds()); - - } - - } - }; - popup.show(schemesManager, collectKeymaps(myKeymapListModel)); - - } - }); - - importButton.setMargin(insets); - panel.add(importButton,gc); - - } - - myCopyButton.addActionListener( new ActionListener() { @Override @@ -326,15 +273,6 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi return panel; } - private static Collection collectKeymaps(final DefaultComboBoxModel list) { - HashSet names = new HashSet(); - for (int i = 0; i < list.getSize(); i++) { - names.add((Keymap)list.getElementAt(i)); - - } - return names; - } - private static SchemesManager getSchemesManager() { return ((KeymapManagerEx)KeymapManager.getInstance()).getSchemesManager(); } diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListPanel.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListPanel.java index 93e43040370b..7f2c8b1c3b0e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListPanel.java @@ -20,12 +20,12 @@ import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ex.QuickList; -import com.intellij.openapi.actionSystem.ex.QuickListsManager; import com.intellij.openapi.keymap.KeyMapBundle; import com.intellij.openapi.keymap.KeymapManager; -import com.intellij.openapi.project.Project; import com.intellij.ui.*; import com.intellij.ui.components.JBList; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; @@ -33,19 +33,19 @@ import java.awt.event.MouseEvent; public class QuickListPanel { private JPanel myPanel; - private JBList myActionsList; + private final JBList myActionsList; private JTextField myDisplayName; private JTextField myDescription; private JPanel myListPanel; private final QuickList[] myAllQuickLists; - public QuickListPanel(QuickList origin, final QuickList[] allQuickLists, Project project) { + public QuickListPanel(QuickList origin, final QuickList[] allQuickLists) { myAllQuickLists = allQuickLists; myActionsList = new JBList(new DefaultListModel()); myActionsList.setCellRenderer(new MyListCellRenderer()); myActionsList.getEmptyText().setText(KeyMapBundle.message("no.actions")); - myActionsList.setEnabled(!QuickListsManager.getInstance().getSchemesManager().isShared(origin)); + myActionsList.setEnabled(true); new DoubleClickListener() { @Override @@ -64,7 +64,7 @@ public class QuickListPanel { } }).addExtraAction(new AnActionButton("Add Separator", AllIcons.General.SeparatorH) { @Override - public void actionPerformed(AnActionEvent e) { + public void actionPerformed(@Nullable AnActionEvent e) { addSeparator(); } }).setButtonComparator("Add", "Add Separator", "Remove", "Up", "Down").createPanel(), BorderLayout.CENTER); @@ -118,8 +118,7 @@ public class QuickListPanel { } private void addSeparator() { - DefaultListModel model = (DefaultListModel)myActionsList.getModel(); - model.addElement(QuickList.SEPARATOR_ID); + ((DefaultListModel)myActionsList.getModel()).addElement(QuickList.SEPARATOR_ID); } public JList getActionsList() { @@ -136,7 +135,9 @@ public class QuickListPanel { private void includeActionId(String id) { DefaultListModel model = (DefaultListModel)myActionsList.getModel(); - if (!QuickList.SEPARATOR_ID.equals(id) && model.contains(id)) return; + if (!QuickList.SEPARATOR_ID.equals(id) && model.contains(id)) { + return; + } model.addElement(id); } @@ -146,7 +147,9 @@ public class QuickListPanel { } private static class MyListCellRenderer extends DefaultListCellRenderer { - public Component getListCellRendererComponent(JList list, + @NotNull + @Override + public Component getListCellRendererComponent(@NotNull JList list, Object value, int index, boolean isSelected, diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListsPanel.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListsPanel.java index 888ea8cee4c9..a4a3e083db6c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListsPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/QuickListsPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -13,22 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.intellij.openapi.keymap.impl.ui; -import com.intellij.application.options.ExportSchemeAction; -import com.intellij.application.options.ImportSchemeAction; -import com.intellij.ide.DataManager; -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.actionSystem.ex.QuickList; import com.intellij.openapi.actionSystem.ex.QuickListsManager; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.keymap.KeyMapBundle; import com.intellij.openapi.options.Configurable; -import com.intellij.openapi.options.SchemesManager; import com.intellij.openapi.options.SearchableConfigurable; -import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.util.Comparing; import com.intellij.ui.*; @@ -45,8 +37,6 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; /** * User: anna @@ -69,6 +59,7 @@ public class QuickListsPanel extends JPanel implements SearchableConfigurable, C add(splitter, BorderLayout.CENTER); } + @Override public void reset() { myQuickListsModel.removeAllElements(); QuickList[] allQuickLists = QuickListsManager.getInstance().getAllQuickLists(); @@ -77,6 +68,7 @@ public class QuickListsPanel extends JPanel implements SearchableConfigurable, C } SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { if (myQuickListsModel.size() > 0) { myQuickListsList.setSelectedIndex(0); @@ -85,12 +77,14 @@ public class QuickListsPanel extends JPanel implements SearchableConfigurable, C }); } + @Override public boolean isModified() { QuickList[] storedLists = QuickListsManager.getInstance().getAllQuickLists(); QuickList[] modelLists = getCurrentQuickListIds(); return !Comparing.equal(storedLists, modelLists); } + @Override public void apply() { QuickListsManager.getInstance().removeAllQuickLists(); final QuickList[] currentQuickLists = getCurrentQuickListIds(); @@ -105,6 +99,7 @@ public class QuickListsPanel extends JPanel implements SearchableConfigurable, C myQuickListsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myQuickListsList.setCellRenderer(new MyQuickListCellRenderer()); myQuickListsList.addListSelectionListener(new ListSelectionListener() { + @Override public void valueChanged(ListSelectionEvent e) { myRightPanel.removeAll(); final Object selectedValue = myQuickListsList.getSelectedValue(); @@ -139,35 +134,6 @@ public class QuickListsPanel extends JPanel implements SearchableConfigurable, C myKeymapListener.processCurrentKeymapChanged(getCurrentQuickListIds()); } }).disableUpDownActions(); - - SchemesManager schemesManager = QuickListsManager.getInstance().getSchemesManager(); - if (schemesManager.isExportAvailable()) { - toolbarDecorator.addExtraAction(AnActionButton.fromAction(new ExportSchemeAction(schemesManager) { - protected QuickList getSelectedScheme() { - return (QuickList)myQuickListsList.getSelectedValue(); - } - })); - } - - if (schemesManager.isImportAvailable()) { - toolbarDecorator.addExtraAction( - AnActionButton.fromAction(new ImportSchemeAction(QuickListsManager.getInstance().getSchemesManager()) { - protected Collection collectCurrentSchemes() { - return collectElements(); - } - - protected Component getPanel() { - return myQuickListsList; - } - - protected void importScheme(final QuickList scheme) { - myQuickListsModel.addElement(scheme); - myQuickListsList.clearSelection(); - ListScrollingUtil.selectItem(myQuickListsList, scheme); - } - })); - } - return toolbarDecorator.createPanel(); } @@ -179,15 +145,6 @@ public class QuickListsPanel extends JPanel implements SearchableConfigurable, C myRightPanel.add(descLabel, BorderLayout.CENTER); } - - private Collection collectElements() { - HashSet result = new HashSet(); - for (int i = 0; i < myQuickListsModel.getSize(); i++) { - result.add((QuickList)myQuickListsModel.getElementAt(i)); - } - return result; - } - private String createUniqueName() { String str = KeyMapBundle.message("unnamed.list.display.name"); final ArrayList names = new ArrayList(); @@ -208,9 +165,9 @@ public class QuickListsPanel extends JPanel implements SearchableConfigurable, C updateList(myCurrentIndex); myKeymapListener.processCurrentKeymapChanged(getCurrentQuickListIds()); } - Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(this)); - myQuickListPanel = new QuickListPanel(quickList, getCurrentQuickListIds(), project); + myQuickListPanel = new QuickListPanel(quickList, getCurrentQuickListIds()); final DocumentAdapter documentAdapter = new DocumentAdapter() { + @Override protected void textChanged(DocumentEvent e) { updateList(index); } @@ -245,11 +202,9 @@ public class QuickListsPanel extends JPanel implements SearchableConfigurable, C for (int i = 0; i < size; i++) { ids[i] = (String)model.getElementAt(i); } - QuickList newQuickList = new QuickList(myQuickListPanel.getDisplayName(), myQuickListPanel.getDescription(), ids, false); - return newQuickList; + return new QuickList(myQuickListPanel.getDisplayName(), myQuickListPanel.getDescription(), ids, false); } - public QuickList[] getCurrentQuickListIds() { if (myCurrentIndex > -1 && myQuickListsModel.getSize() > myCurrentIndex) { updateList(myCurrentIndex); @@ -262,11 +217,13 @@ public class QuickListsPanel extends JPanel implements SearchableConfigurable, C return lists; } + @Override @NotNull public String getId() { return getHelpTopic(); } + @Override public Runnable enableSearch(String option) { return null; } @@ -280,19 +237,23 @@ public class QuickListsPanel extends JPanel implements SearchableConfigurable, C } } + @Override @Nls public String getDisplayName() { return "Quick Lists"; } + @Override public String getHelpTopic() { return "reference.idesettings.quicklists"; } + @Override public JComponent createComponent() { return this; } + @Override public void disposeUIResources() { } } diff --git a/platform/platform-impl/src/com/intellij/openapi/options/SchemeImporterEP.java b/platform/platform-impl/src/com/intellij/openapi/options/SchemeImporterEP.java index 4202ee4d7e68..87a354f1bf08 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/SchemeImporterEP.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/SchemeImporterEP.java @@ -30,8 +30,7 @@ import java.util.List; * @author Rustam Vishnyakov */ public class SchemeImporterEP extends AbstractExtensionPointBean { - - public static ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.schemeImporter"); + public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.schemeImporter"); @Attribute("name") public String name; 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 dbb3c9530d7c..ae6789d8a480 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerFactoryImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerFactoryImpl.java @@ -18,9 +18,8 @@ package com.intellij.openapi.options; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.impl.ApplicationImpl; import com.intellij.openapi.components.RoamingType; -import com.intellij.openapi.components.ServiceBean; import com.intellij.openapi.components.SettingsSavingComponent; -import com.intellij.openapi.components.impl.stores.IApplicationStore; +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.containers.ContainerUtil; @@ -29,7 +28,7 @@ import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.List; -public class SchemesManagerFactoryImpl extends SchemesManagerFactory implements SettingsSavingComponent { +final class SchemesManagerFactoryImpl extends SchemesManagerFactory implements SettingsSavingComponent { private static final Logger LOG = Logger.getInstance(SchemesManagerFactoryImpl.class); private final List myRegisteredManagers = ContainerUtil.createLockFreeCopyOnWriteList(); @@ -39,9 +38,9 @@ public class SchemesManagerFactoryImpl extends SchemesManagerFactory implements public SchemesManager createSchemesManager(@NotNull String fileSpec, @NotNull SchemeProcessor processor, @NotNull RoamingType roamingType) { - IApplicationStore applicationStore = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore(); - String baseDirPath = applicationStore.getStateStorageManager().expandMacros(fileSpec); - StreamProvider provider = applicationStore.getStateStorageManager().getStreamProvider(); + StateStorageManager storageManager = ((ApplicationImpl)ApplicationManager.getApplication()).getStateStore().getStateStorageManager(); + String baseDirPath = storageManager.expandMacros(fileSpec); + StreamProvider provider = storageManager.getStreamProvider(); SchemesManagerImpl manager = new SchemesManagerImpl(fileSpec, processor, roamingType, provider, new File(baseDirPath)); myRegisteredManagers.add(manager); return manager; @@ -49,26 +48,24 @@ public class SchemesManagerFactoryImpl extends SchemesManagerFactory implements @Override public void updateConfigFilesFromStreamProviders() { - ServiceBean.loadServicesFromBeans(SCHEME_OWNER, Object.class); for (SchemesManagerImpl registeredManager : myRegisteredManagers) { try { registeredManager.updateConfigFilesFromStreamProviders(); } catch (Throwable e) { - LOG.info("Cannot save settings for " + registeredManager.getClass().getName(), e); + LOG.error("Cannot reload settings for " + registeredManager.getClass().getName(), e); } } } @Override public void save() { - ServiceBean.loadServicesFromBeans(SCHEME_OWNER, Object.class); for (SchemesManager registeredManager : myRegisteredManagers) { try { registeredManager.save(); } catch (Throwable e) { - LOG.info("Cannot save settings for " + registeredManager.getClass().getName(), e); + LOG.error("Cannot save settings for " + registeredManager.getClass().getName(), e); } } } 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 f67c6afb2677..0a571c9fdf0c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/options/SchemesManagerImpl.java @@ -42,7 +42,6 @@ import com.intellij.openapi.vfs.VirtualFileEvent; import com.intellij.openapi.vfs.tracker.VirtualFileTracker; import com.intellij.util.containers.ContainerUtilRt; import com.intellij.util.text.UniqueNameGenerator; -import gnu.trove.THashMap; import gnu.trove.THashSet; import org.jdom.Document; import org.jdom.Element; @@ -59,14 +58,7 @@ import java.util.*; public class SchemesManagerImpl extends AbstractSchemesManager { private static final Logger LOG = Logger.getInstance(SchemesManagerFactoryImpl.class); - private static final String DESCRIPTION = "description"; - private static final String USER = "user"; - - private static final String SHARED_SCHEME = "shared-scheme"; - private static final String SHARED_SCHEME_ORIGINAL = "shared-scheme-original"; private static final String NAME = "name"; - private static final String ORIGINAL_SCHEME_PATH = "original-scheme-path"; - private static final String SCHEME_LOCAL_COPY = "scheme-local-copy"; private final String myFileSpec; private final SchemeProcessor myProcessor; @@ -242,7 +234,7 @@ public class SchemesManagerImpl filter) throws InvalidDataException, IOException, JDOMException { - if (element.getName().equals(SHARED_SCHEME)) { + if (element.getName().equals("shared-scheme")) { String schemeName = element.getAttributeValue(NAME); if (filter.containsKey(schemeName)) { return null; } - String schemePath = element.getAttributeValue(ORIGINAL_SCHEME_PATH); - + String schemePath = element.getAttributeValue("original-scheme-path"); Element sharedElement = myProvider != null && myProvider.isEnabled() ? StorageUtil.loadElement(myProvider.loadContent(schemePath, myRoamingType)) : null; - if (sharedElement != null) { + if (sharedElement == null) { + Element localCopyElement = element.getChild("scheme-local-copy"); + E scheme = localCopyElement == null ? null : doReadScheme(localCopyElement.getChildren().get(0)); + return scheme == null || filter.containsKey(scheme.getName()) ? null : scheme; + } + else { E result = readScheme(sharedElement, Collections.emptyMap()); if (result != null) { renameScheme(result, schemeName); - result.getExternalInfo().setOriginalPath(schemePath); - result.getExternalInfo().setIsImported(true); } return result; } - else { - Element localCopyElement = element.getChild(SCHEME_LOCAL_COPY); - if (localCopyElement == null) { - return null; - } - else { - E scheme = doReadScheme(localCopyElement.getChildren().get(0).clone()); - return filter.containsKey(scheme.getName()) ? null : scheme; - } - } } - else if (element.getName().equals(SHARED_SCHEME_ORIGINAL)) { - SharedSchemeData schemeData = unwrap(element); - E scheme = doReadScheme(schemeData.original); + else if (element.getName().equals("shared-scheme-original")) { + E scheme = doReadScheme(element.getChildren().get(0)); if (scheme == null || filter.containsKey(scheme.getName())) { return null; } - renameScheme(scheme, schemeData.name); + renameScheme(scheme, element.getAttributeValue(NAME)); return scheme; } else { E scheme = doReadScheme(element); - return filter.containsKey(scheme.getName()) ? null : scheme; + return scheme == null || filter.containsKey(scheme.getName()) ? null : scheme; } } + @Nullable private E doReadScheme(Element element) throws InvalidDataException, IOException, JDOMException { + E scheme; if (myProcessor instanceof BaseSchemeProcessor) { - return ((BaseSchemeProcessor)myProcessor).readScheme(element); + scheme = ((BaseSchemeProcessor)myProcessor).readScheme(element); } else { //noinspection deprecation - return myProcessor.readScheme(new Document(element)); + scheme = myProcessor.readScheme(new Document((Element)element.detach())); } + if (scheme != null) { + scheme.getExternalInfo().setHash(JDOMUtil.getTreeHash(element)); + } + return scheme; } @NotNull @@ -435,159 +423,23 @@ public class SchemesManagerImpl> loadSharedSchemes(Collection currentSchemeList) { - if (myProvider == null || !myProvider.isEnabled()) { - return Collections.emptyList(); - } - - Collection names = getAllSchemeNames(currentSchemeList); - Map> result = new THashMap>(); - for (String subPath : myProvider.listSubFiles(myFileSpec, myRoamingType)) { - try { - Element element = StorageUtil.loadElement(myProvider.loadContent(getFileFullPath(subPath), myRoamingType)); - if (element != null) { - SharedSchemeData original = unwrap(element); - E scheme = doReadScheme(original.original); - if (!alreadyShared(subPath, currentSchemeList)) { - String schemeName = original.name; - String uniqueName = UniqueNameGenerator.generateUniqueName("[shared] " + schemeName, names); - renameScheme(scheme, uniqueName); - schemeName = uniqueName; - scheme.getExternalInfo().setOriginalPath(getFileFullPath(subPath)); - scheme.getExternalInfo().setIsImported(true); - result.put(schemeName, new SharedScheme(original.user == null ? "unknown" : original.user, original.description, scheme)); - } - } - } - catch (Exception e) { - LOG.debug("Cannot load data from IDEAServer: " + e.getLocalizedMessage()); - } - } - - for (SharedScheme t : result.values()) { - myProcessor.initScheme(t.getScheme()); - } - - return result.values(); - } - - @NotNull - private static SharedSchemeData unwrap(@NotNull Element element) { - String name = element.getAttributeValue(NAME); - if (element.getName().equals(SHARED_SCHEME_ORIGINAL)) { - return new SharedSchemeData(element.getChildren().get(0).clone(), name, element.getAttributeValue(USER), element.getAttributeValue(DESCRIPTION)); - } - else { - return new SharedSchemeData(element, name, null, null); - } - } - - private boolean alreadyShared(final String subPath, final Collection currentSchemeList) { - for (T t : currentSchemeList) { - if (t instanceof ExternalizableScheme) { - ExternalInfo info = ((ExternalizableScheme)t).getExternalInfo(); - if (info.isIsImported()) { - if (getFileFullPath(subPath).equals(info.getOriginalPath())) { - return true; - } - } - } - } - return false; + // todo } private String getFileFullPath(@NotNull String subPath) { return myFileSpec + '/' + subPath; } - @SuppressWarnings("deprecation") @Override public void exportScheme(@NotNull final E scheme, final String name, final String description) throws WriteExternalException, IOException { - if (myProvider == null) { - return; - } - - Parent document = myProcessor.writeScheme(scheme); - if (document != null) { - String fileSpec = getFileFullPath(FileUtil.sanitizeName(scheme.getName())) + mySchemeExtension; - if (!myProvider.isApplicable(fileSpec, myRoamingType)) { - return; - } - - StorageUtil.sendContent(myProvider, fileSpec, wrap(document, name, description), myRoamingType, false); - } - } - - @NotNull - private static Element wrap(@NotNull Parent original, @NotNull String name, @NotNull String description) { - Element sharedElement = new Element(SHARED_SCHEME_ORIGINAL); - sharedElement.setAttribute(NAME, name); - sharedElement.setAttribute(DESCRIPTION, description); - sharedElement.addContent(getClone(original)); - return sharedElement; } @Override public boolean isImportAvailable() { - return myProvider != null; - } - - @Override - public boolean isExportAvailable() { return false; } - @Override - public boolean isShared(@NotNull final Scheme scheme) { - return scheme instanceof ExternalizableScheme && ((ExternalizableScheme)scheme).getExternalInfo().isIsImported(); - } - @Override public void save() { boolean hasSchemes = false; @@ -652,7 +504,7 @@ public class SchemesManagerImpl - - diff --git a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml index 2120b400d732..8decdfad8ca2 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml @@ -64,7 +64,6 @@ interface="com.intellij.openapi.ide.CutElementMarker"/> - diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index 4d6c82ec53e5..9c45928419fc 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -146,7 +146,6 @@ - diff --git a/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml b/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml index 44ef7698cac6..5499be7f5418 100644 --- a/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml +++ b/platform/platform-resources/src/META-INF/PlatformLangPlugin.xml @@ -35,7 +35,6 @@ serviceImplementation="com.intellij.profile.codeInspection.InspectionProfileManagerImpl"/> - diff --git a/resources/src/idea/RichPlatformPlugin.xml b/resources/src/idea/RichPlatformPlugin.xml index 3416371383e6..2256fa870e81 100644 --- a/resources/src/idea/RichPlatformPlugin.xml +++ b/resources/src/idea/RichPlatformPlugin.xml @@ -346,7 +346,6 @@ -