mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
shared schemes concept is useless
This commit is contained in:
@@ -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<T extends ExternalizableScheme> 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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -40,7 +40,7 @@ public interface SchemesManager <T extends Scheme, E extends ExternalizableSchem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportScheme(@NotNull final ExternalizableScheme scheme, final String name, final String description) {
|
||||
public void exportScheme(@NotNull ExternalizableScheme scheme, String name, String description) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,13 +54,12 @@ public interface SchemesManager <T extends Scheme, E extends ExternalizableSchem
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShared(@NotNull final Scheme scheme) {
|
||||
public boolean isShared(@NotNull Scheme scheme) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNewScheme(@NotNull final Scheme scheme, final boolean replaceExisting) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,15 +116,29 @@ public interface SchemesManager <T extends Scheme, E extends ExternalizableSchem
|
||||
|
||||
@NotNull Collection<E> loadSchemes();
|
||||
|
||||
@NotNull Collection<SharedScheme<E>> loadSharedSchemes();
|
||||
@NotNull Collection<SharedScheme<E>> loadSharedSchemes(Collection<T> currentSchemeList);
|
||||
@Deprecated
|
||||
@SuppressWarnings({"unused", "deprecation"})
|
||||
@NotNull
|
||||
Collection<SharedScheme<E>> loadSharedSchemes();
|
||||
|
||||
@SuppressWarnings({"unused", "deprecation"})
|
||||
@NotNull
|
||||
@Deprecated
|
||||
Collection<SharedScheme<E>> loadSharedSchemes(Collection<T> 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);
|
||||
|
||||
@@ -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<ServiceBean> SCHEME_OWNER = ExtensionPointName.create("com.intellij.schemeOwner");
|
||||
|
||||
@NotNull
|
||||
public abstract <T extends Scheme, E extends ExternalizableScheme> SchemesManager<T, E> createSchemesManager(@NotNull String fileSpec,
|
||||
@NotNull SchemeProcessor<E> processor, @NotNull RoamingType roamingType);
|
||||
@@ -32,6 +28,5 @@ public abstract class SchemesManagerFactory {
|
||||
return ServiceManager.getService(SchemesManagerFactory.class);
|
||||
}
|
||||
|
||||
|
||||
public abstract void updateConfigFilesFromStreamProviders();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.openapi.options;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Deprecated
|
||||
public class SharedScheme<E extends ExternalizableScheme> {
|
||||
private final String myUserName;
|
||||
private final String myDescription;
|
||||
|
||||
@@ -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<T extends Scheme, E extends ExternalizableScheme> implements SchemesManager<T, E> {
|
||||
private static final Logger LOG = Logger.getInstance(AbstractSchemesManager.class);
|
||||
@@ -37,11 +34,9 @@ public abstract class AbstractSchemesManager<T extends Scheme, E extends Externa
|
||||
@Override
|
||||
public void addNewScheme(@NotNull T scheme, boolean replaceExisting) {
|
||||
int toReplace = -1;
|
||||
boolean newSchemeIsShared = isShared(scheme);
|
||||
|
||||
for (int i = 0; i < mySchemes.size(); i++) {
|
||||
T existingScheme = mySchemes.get(i);
|
||||
if (existingScheme.getName().equals(scheme.getName()) && newSchemeIsShared == isShared(existingScheme)) {
|
||||
if (existingScheme.getName().equals(scheme.getName())) {
|
||||
toReplace = i;
|
||||
break;
|
||||
}
|
||||
@@ -162,10 +157,28 @@ public abstract class AbstractSchemesManager<T extends Scheme, E extends Externa
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<SharedScheme<E>> loadSharedSchemes(Collection<T> currentSchemeList) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
@NotNull
|
||||
public Collection<SharedScheme<E>> 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) {
|
||||
|
||||
+4
-10
@@ -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 <S extends Scheme> extends DialogWrapper
|
||||
|
||||
private final static String SHARED_IMPORT_SOURCE = ApplicationBundle.message("import.scheme.shared");
|
||||
|
||||
public ImportSourceChooserDialog(JComponent parent, Class<S> schemeClass, SchemesManager schemesManager) {
|
||||
public ImportSourceChooserDialog(JComponent parent, Class<S> 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 <S extends Scheme> extends DialogWrapper
|
||||
}
|
||||
|
||||
private class SourceListModel extends DefaultListModel {
|
||||
private List<String> mySourceNames = new ArrayList<String>();
|
||||
private final List<String> mySourceNames = new ArrayList<String>();
|
||||
|
||||
public SourceListModel(Collection<SchemeImporterEP<S>> extensions, boolean isSharedImportAvailable) {
|
||||
public SourceListModel(Collection<SchemeImporterEP<S>> extensions) {
|
||||
for (SchemeImporterEP extension : extensions) {
|
||||
mySourceNames.add(extension.name);
|
||||
}
|
||||
if (isSharedImportAvailable) {
|
||||
mySourceNames.add(SHARED_IMPORT_SOURCE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,5 +99,4 @@ public class ImportSourceChooserDialog <S extends Scheme> extends DialogWrapper
|
||||
return mySourceNames.get(index);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-4
@@ -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<CodeStyleScheme> mySchemes = new ArrayList<CodeStyleScheme>();
|
||||
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) {
|
||||
|
||||
+20
-38
@@ -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<CodeStyleScheme, CodeStyleSchemeImpl> 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<CodeStyleScheme> importSourceChooserDialog =
|
||||
new ImportSourceChooserDialog<CodeStyleScheme>(myContentPane, CodeStyleScheme.class, mySchemesManager);
|
||||
new ImportSourceChooserDialog<CodeStyleScheme>(myContentPane, CodeStyleScheme.class);
|
||||
importSourceChooserDialog.show();
|
||||
if (importSourceChooserDialog.isOK()) {
|
||||
if (importSourceChooserDialog.isImportFromSharedSelected()) {
|
||||
SchemesToImportPopup<CodeStyleScheme, CodeStyleSchemeImpl> popup =
|
||||
new SchemesToImportPopup<CodeStyleScheme, CodeStyleSchemeImpl>(myContentPane) {
|
||||
@Override
|
||||
protected void onSchemeSelected(final CodeStyleSchemeImpl scheme) {
|
||||
if (scheme != null) {
|
||||
myModel.addScheme(scheme, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
popup.show(mySchemesManager, myModel.getSchemes());
|
||||
new SchemesToImportPopup<CodeStyleScheme>(myContentPane) {
|
||||
@Override
|
||||
protected void onSchemeSelected(CodeStyleScheme scheme) {
|
||||
if (scheme != null) {
|
||||
myModel.addScheme(scheme, true);
|
||||
}
|
||||
}
|
||||
}.show(myModel.getSchemes());
|
||||
}
|
||||
else {
|
||||
String selectedImporterName = importSourceChooserDialog.getSelectedSourceName();
|
||||
|
||||
+1
-3
@@ -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<AttributesDescriptor> descriptors) {
|
||||
|
||||
@@ -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<ColorAndFontSettingsListener> 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<EditorColorsScheme, EditorColorsSchemeImpl> 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<EditorColorsScheme, EditorColorsSchemeImpl> popup =
|
||||
new SchemesToImportPopup<EditorColorsScheme, EditorColorsSchemeImpl>(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() {
|
||||
|
||||
+7
-79
@@ -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 = "<abbreviation>";
|
||||
public static final Comparator<TemplateImpl> TEMPLATE_COMPARATOR = new Comparator<TemplateImpl>() {
|
||||
@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<TemplateGroup>() {
|
||||
@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<TemplateImpl>(){
|
||||
@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<? extends TemplateImpl> collectAllTemplates() {
|
||||
ArrayList<TemplateImpl> result = new ArrayList<TemplateImpl>();
|
||||
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<TemplateGroup, TemplateGroup> 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<String> oldGroupNames = getAllGroups((Map<TemplateImpl, DefaultMutableTreeNode>)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<TemplateGroup, TemplateGroup>(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<String> oldGroups = getAllGroups(templates);
|
||||
|
||||
removeAll();
|
||||
SchemesManager<TemplateGroup, TemplateGroup> 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) {
|
||||
|
||||
+2
-19
@@ -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<SharedScheme<CodeStyleSchemeImpl>> sharedSchemes =
|
||||
((CodeStyleSchemesImpl)CodeStyleSchemes.getInstance()).getSchemesManager().loadSharedSchemes();
|
||||
if (!sharedSchemes.isEmpty()) {
|
||||
group.add(Separator.getInstance());
|
||||
for (SharedScheme<CodeStyleSchemeImpl> scheme : sharedSchemes) {
|
||||
addScheme(group, manager, currentScheme, scheme.getScheme(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addScheme(final DefaultActionGroup group,
|
||||
|
||||
+7
-83
@@ -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<String> extensions = new ArrayList<String>();
|
||||
|
||||
final List<FileNameMatcher> 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<FileType, AbstractFileType>(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<FileType, AbstractFileType> getSchemesManager() {
|
||||
return ((FileTypeManagerEx)FileTypeManager.getInstance()).getSchemesManager();
|
||||
}
|
||||
|
||||
public void attachActions(final FileTypeConfigurable controller) {
|
||||
myController = controller;
|
||||
mySpeedSearch.myController = controller;
|
||||
}
|
||||
|
||||
private Collection<FileType> collectRegisteredFileTypes() {
|
||||
HashSet<FileType> result = new HashSet<FileType>();
|
||||
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;
|
||||
|
||||
+8
-17
@@ -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) {
|
||||
|
||||
+3
-9
@@ -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{
|
||||
|
||||
+8
-19
@@ -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<CodeStyleScheme, CodeStyleSchemeImpl> mySchemesManager;
|
||||
@NonNls private static final String FILE_SPEC = StoragePathMacros.ROOT_CONFIG + "/" + CODE_STYLES_DIRECTORY;
|
||||
|
||||
public CodeStyleSchemesImpl(SchemesManagerFactory schemesManagerFactory) {
|
||||
SchemeProcessor<CodeStyleSchemeImpl> processor = new BaseSchemeProcessor<CodeStyleSchemeImpl>() {
|
||||
@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<CodeStyleScheme> schemes = mySchemesManager.getAllSchemes();
|
||||
Collection<CodeStyleScheme> 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<CodeStyleScheme, CodeStyleSchemeImpl> getSchemesManager() {
|
||||
return mySchemesManager;
|
||||
}
|
||||
|
||||
+4
-21
@@ -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<Element>, NamedComponent {
|
||||
public class PersistableCodeStyleSchemes extends CodeStyleSchemesImpl implements PersistentStateComponent<Element> {
|
||||
@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)};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T extends Scheme, E extends ExternalizableScheme> extends AnAction {
|
||||
protected final SchemesManager<T, E> mySchemesManager;
|
||||
|
||||
public ExportSchemeAction(SchemesManager<T, E> 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 <T extends Scheme, E extends ExternalizableScheme> void doExport(final E scheme, SchemesManager<T,E> 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<T extends Scheme, E extends ExternalizableScheme> extends AnAction {
|
||||
protected final SchemesManager<T,E> 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<T,E> popup = new SchemesToImportPopup<T,E>(getPanel()){
|
||||
protected void onSchemeSelected(final E scheme) {
|
||||
if (scheme != null) {
|
||||
importScheme(scheme);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
popup.show(mySchemesManager, collectCurrentSchemes());
|
||||
|
||||
}
|
||||
|
||||
protected abstract Collection<T> collectCurrentSchemes();
|
||||
|
||||
protected abstract Component getPanel();
|
||||
|
||||
protected abstract void importScheme(E scheme);
|
||||
}
|
||||
+15
-34
@@ -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<T extends Scheme, E extends ExternalizableScheme> {
|
||||
|
||||
public abstract class SchemesToImportPopup<T> {
|
||||
private final Component myParent;
|
||||
|
||||
public SchemesToImportPopup(final Component parent) {
|
||||
myParent = parent;
|
||||
}
|
||||
|
||||
public void show(SchemesManager<T, E> schemesManager, Collection<T> currentSchemeNames) {
|
||||
Collection<SharedScheme<E>> schemes = schemesManager.loadSharedSchemes(currentSchemeNames);
|
||||
|
||||
public void show(Collection<T> 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<T>(schemes));
|
||||
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
list.setCellRenderer(new SchemesToImportListCellRenderer());
|
||||
|
||||
|
||||
|
||||
Runnable selectAction = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
onSchemeSelected(((SharedScheme<E>)list.getSelectedValue()).getScheme());
|
||||
onSchemeSelected((T)list.getSelectedValue());
|
||||
}
|
||||
};
|
||||
|
||||
showList(list, selectAction);
|
||||
}
|
||||
|
||||
private ListModel createModel(Collection<SharedScheme<E>> 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("<html><p>Shared by <b>" + c.getUserName() + "</b><br>" + c.getDescription() + "</p></html>");
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
@@ -104,7 +86,7 @@ public abstract class SchemesToImportPopup<T extends Scheme, E extends Externali
|
||||
setColors(bg, fg, myPanel, myNameLabel);
|
||||
}
|
||||
|
||||
private void setColors(Color bg, Color fg, JComponent... cc) {
|
||||
private static void setColors(Color bg, Color fg, JComponent... cc) {
|
||||
for (JComponent c : cc) {
|
||||
c.setBackground(bg);
|
||||
c.setForeground(fg);
|
||||
@@ -112,6 +94,5 @@ public abstract class SchemesToImportPopup<T extends Scheme, E extends Externali
|
||||
}
|
||||
}
|
||||
|
||||
abstract protected void onSchemeSelected(E scheme);
|
||||
|
||||
abstract protected void onSchemeSelected(T scheme);
|
||||
}
|
||||
|
||||
+7
-22
@@ -18,40 +18,23 @@ package com.intellij.ide.actions;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.Separator;
|
||||
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.options.SharedScheme;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class QuickChangeColorSchemeAction extends QuickSwitchSchemeAction {
|
||||
@Override
|
||||
protected void fillActions(Project project, @NotNull DefaultActionGroup group, @NotNull DataContext dataContext) {
|
||||
final EditorColorsScheme[] schemes = EditorColorsManager.getInstance().getAllSchemes();
|
||||
EditorColorsScheme current = EditorColorsManager.getInstance().getGlobalScheme();
|
||||
for (final EditorColorsScheme scheme : schemes) {
|
||||
for (EditorColorsScheme scheme : EditorColorsManager.getInstance().getAllSchemes()) {
|
||||
addScheme(group, current, scheme, false);
|
||||
}
|
||||
|
||||
|
||||
Collection<SharedScheme<EditorColorsSchemeImpl>> sharedSchemes = ((EditorColorsManagerImpl)EditorColorsManager.getInstance()).getSchemesManager().loadSharedSchemes();
|
||||
|
||||
if (!sharedSchemes.isEmpty()) {
|
||||
group.add(Separator.getInstance());
|
||||
|
||||
for (SharedScheme<EditorColorsSchemeImpl> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<SharedScheme<KeymapImpl>> sharedSchemes = ((KeymapManagerEx)KeymapManagerEx.getInstance()).getSchemesManager().loadSharedSchemes();
|
||||
|
||||
if (!sharedSchemes.isEmpty()) {
|
||||
group.add(Separator.getInstance());
|
||||
for (SharedScheme<KeymapImpl> 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;
|
||||
}
|
||||
|
||||
+13
-28
@@ -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<AbstractFileType>() {
|
||||
@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
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@@ -56,6 +56,7 @@ public class KeymapManagerImpl extends KeymapManagerEx implements PersistentStat
|
||||
KeymapManagerImpl(DefaultKeymap defaultKeymap, SchemesManagerFactory factory) {
|
||||
mySchemesManager = factory.createSchemesManager(KEYMAPS_DIR_PATH,
|
||||
new BaseSchemeProcessor<KeymapImpl>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public KeymapImpl readScheme(@NotNull Element element) throws InvalidDataException {
|
||||
KeymapImpl keymap = new KeymapImpl();
|
||||
|
||||
+2
-2
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Keymap, KeymapImpl> 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<Keymap, KeymapImpl> popup = new SchemesToImportPopup<Keymap, KeymapImpl>(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<Keymap> collectKeymaps(final DefaultComboBoxModel list) {
|
||||
HashSet<Keymap> names = new HashSet<Keymap>();
|
||||
for (int i = 0; i < list.getSize(); i++) {
|
||||
names.add((Keymap)list.getElementAt(i));
|
||||
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
private static SchemesManager<Keymap,KeymapImpl> getSchemesManager() {
|
||||
return ((KeymapManagerEx)KeymapManager.getInstance()).getSchemesManager();
|
||||
}
|
||||
|
||||
+13
-10
@@ -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,
|
||||
|
||||
+15
-54
@@ -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<QuickList, QuickList> schemesManager = QuickListsManager.getInstance().getSchemesManager();
|
||||
if (schemesManager.isExportAvailable()) {
|
||||
toolbarDecorator.addExtraAction(AnActionButton.fromAction(new ExportSchemeAction<QuickList, QuickList>(schemesManager) {
|
||||
protected QuickList getSelectedScheme() {
|
||||
return (QuickList)myQuickListsList.getSelectedValue();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
if (schemesManager.isImportAvailable()) {
|
||||
toolbarDecorator.addExtraAction(
|
||||
AnActionButton.fromAction(new ImportSchemeAction<QuickList, QuickList>(QuickListsManager.getInstance().getSchemesManager()) {
|
||||
protected Collection<QuickList> 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<QuickList> collectElements() {
|
||||
HashSet<QuickList> result = new HashSet<QuickList>();
|
||||
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<String> names = new ArrayList<String>();
|
||||
@@ -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() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,7 @@ import java.util.List;
|
||||
* @author Rustam Vishnyakov
|
||||
*/
|
||||
public class SchemeImporterEP <S extends Scheme> extends AbstractExtensionPointBean {
|
||||
|
||||
public static ExtensionPointName<SchemeImporterEP> EP_NAME = ExtensionPointName.create("com.intellij.schemeImporter");
|
||||
public static final ExtensionPointName<SchemeImporterEP> EP_NAME = ExtensionPointName.create("com.intellij.schemeImporter");
|
||||
|
||||
@Attribute("name")
|
||||
public String name;
|
||||
|
||||
+7
-10
@@ -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<SchemesManagerImpl> myRegisteredManagers = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
@@ -39,9 +38,9 @@ public class SchemesManagerFactoryImpl extends SchemesManagerFactory implements
|
||||
public <T extends Scheme, E extends ExternalizableScheme> SchemesManager<T, E> createSchemesManager(@NotNull String fileSpec,
|
||||
@NotNull SchemeProcessor<E> 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<T, E> manager = new SchemesManagerImpl<T, E>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T extends Scheme, E extends ExternalizableScheme> extends AbstractSchemesManager<T, E> {
|
||||
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<E> myProcessor;
|
||||
@@ -242,7 +234,7 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
|
||||
deleteServerFile(subPath);
|
||||
}
|
||||
|
||||
loadScheme(scheme, false, fileName, element);
|
||||
loadScheme(scheme, false, fileName);
|
||||
scheme.getExternalInfo().markRemote();
|
||||
result.put(scheme.getName(), scheme);
|
||||
}
|
||||
@@ -283,7 +275,7 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
|
||||
return result;
|
||||
}
|
||||
|
||||
private void loadScheme(@NotNull E scheme, boolean forceAdd, @NotNull CharSequence fileName, @NotNull Element element) {
|
||||
private void loadScheme(@NotNull E scheme, boolean forceAdd, @NotNull CharSequence fileName) {
|
||||
String fileNameWithoutExtension = createFileName(fileName);
|
||||
if (!forceAdd && myFilesToDelete.contains(fileNameWithoutExtension)) {
|
||||
return;
|
||||
@@ -305,7 +297,6 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
|
||||
|
||||
//noinspection unchecked
|
||||
addNewScheme((T)scheme, true);
|
||||
scheme.getExternalInfo().setHash(JDOMUtil.getTreeHash(element));
|
||||
scheme.getExternalInfo().setPreviouslySavedName(scheme.getName());
|
||||
scheme.getExternalInfo().setCurrentFileName(fileNameWithoutExtension);
|
||||
}
|
||||
@@ -349,7 +340,7 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
|
||||
|
||||
E scheme = readScheme(element, filter);
|
||||
if (scheme != null) {
|
||||
loadScheme(scheme, forceAdd, file.getNameSequence(), element);
|
||||
loadScheme(scheme, forceAdd, file.getNameSequence());
|
||||
return scheme;
|
||||
}
|
||||
}
|
||||
@@ -370,58 +361,55 @@ public class SchemesManagerImpl<T extends Scheme, E extends ExternalizableScheme
|
||||
|
||||
@Nullable
|
||||
private E readScheme(@NotNull Element element, @NotNull Map<String, E> 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.<String, E>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<E>)myProcessor).readScheme(element);
|
||||
scheme = ((BaseSchemeProcessor<E>)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<T extends Scheme, E extends ExternalizableScheme
|
||||
return fileName.toString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Parent writeSchemeToDocument(@NotNull E scheme) throws WriteExternalException {
|
||||
if (isShared(scheme)) {
|
||||
String originalPath = scheme.getExternalInfo().getOriginalPath();
|
||||
if (originalPath != null) {
|
||||
Element root = new Element(SHARED_SCHEME);
|
||||
root.setAttribute(NAME, scheme.getName());
|
||||
root.setAttribute(ORIGINAL_SCHEME_PATH, originalPath);
|
||||
|
||||
Parent child = myProcessor.writeScheme(scheme);
|
||||
root.addContent(new Element(SCHEME_LOCAL_COPY).addContent(child instanceof Element ? (Element)child : ((Document)child).detachRootElement()));
|
||||
return root;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return myProcessor.writeScheme(scheme);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Element getClone(@NotNull Parent result) {
|
||||
return (result instanceof Element ? (Element)result : ((Document)result).getRootElement()).clone();
|
||||
}
|
||||
|
||||
public void updateConfigFilesFromStreamProviders() {
|
||||
}
|
||||
|
||||
private static class SharedSchemeData {
|
||||
@NotNull private final Element original;
|
||||
@NotNull private final String name;
|
||||
private final String user;
|
||||
private final String description;
|
||||
|
||||
private SharedSchemeData(@NotNull Element original, @NotNull String name, String user, String description) {
|
||||
this.original = original;
|
||||
this.name = name;
|
||||
this.user = user;
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Collection<SharedScheme<E>> loadSharedSchemes(Collection<T> currentSchemeList) {
|
||||
if (myProvider == null || !myProvider.isEnabled()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Collection<String> names = getAllSchemeNames(currentSchemeList);
|
||||
Map<String, SharedScheme<E>> result = new THashMap<String, SharedScheme<E>>();
|
||||
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<E>(original.user == null ? "unknown" : original.user, original.description, scheme));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.debug("Cannot load data from IDEAServer: " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
for (SharedScheme<E> 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<T> 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<T extends Scheme, E extends ExternalizableScheme
|
||||
private void saveScheme(@NotNull E scheme, @NotNull UniqueNameGenerator nameGenerator) throws WriteExternalException, IOException {
|
||||
ExternalInfo externalInfo = scheme.getExternalInfo();
|
||||
String currentFileNameWithoutExtension = externalInfo.getCurrentFileName();
|
||||
Parent parent = writeSchemeToDocument(scheme);
|
||||
Parent parent = myProcessor.writeScheme(scheme);
|
||||
Element element = parent == null || parent instanceof Element ? (Element)parent : ((Document)parent).detachRootElement();
|
||||
if (JDOMUtil.isEmpty(element)) {
|
||||
ContainerUtilRt.addIfNotNull(myFilesToDelete, currentFileNameWithoutExtension);
|
||||
|
||||
@@ -308,3 +308,4 @@ exportable.UsageViewSettings.presentable.name=Usage View
|
||||
exportable.BaseRefactoringSettings.presentable.name=Refactoring
|
||||
exportable.DuplocatorSettings.presentable.name=Duplocator
|
||||
exportable.MultiLanguageDuplocatorSettings.presentable.name=Duplocator
|
||||
exportable.CodeStyleSchemeSettings.presentable.name=Code Style
|
||||
|
||||
@@ -14,7 +14,6 @@ psi.search.scope.union=Union of {0} and {1}
|
||||
|
||||
# {0} - file path, {1} - localized IOException message.
|
||||
codestyle.cannot.save.scheme.file=Can''t save code style scheme {0}. {1}
|
||||
codestyle.export.display.name=Code style schemes
|
||||
codestyle.cannot.save.settings.directory.cant.be.created.message=Cannot save code style schemes. Directory {0} cannot be created.
|
||||
codestyle.cannot.save.settings.directory.cant.be.created.title=Cannot Save Settings
|
||||
|
||||
|
||||
@@ -108,8 +108,6 @@
|
||||
serviceImplementation="com.intellij.psi.impl.source.codeStyle.PersistableCodeStyleSchemes"/>
|
||||
<applicationService serviceInterface="com.intellij.psi.impl.source.codeStyle.LegacyCodeStyleSchemesSettings"
|
||||
serviceImplementation="com.intellij.psi.impl.source.codeStyle.LegacyCodeStyleSchemesSettings"/>
|
||||
<exportable serviceInterface="com.intellij.psi.codeStyle.CodeStyleSchemes"/>
|
||||
<schemeOwner serviceInterface="com.intellij.psi.codeStyle.CodeStyleSchemes"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.openapi.roots.libraries.LibraryTablesRegistrar"
|
||||
serviceImplementation="com.intellij.openapi.roots.impl.libraries.LibraryTablesRegistrarImpl"/>
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
interface="com.intellij.openapi.ide.CutElementMarker"/>
|
||||
|
||||
<extensionPoint name="exportable" beanClass="com.intellij.openapi.components.ServiceBean"/>
|
||||
<extensionPoint name="schemeOwner" beanClass="com.intellij.openapi.components.ServiceBean"/>
|
||||
|
||||
<extensionPoint name="ideRootPaneNorth" interface="com.intellij.openapi.wm.IdeRootPaneNorthExtension" area="IDEA_PROJECT"/>
|
||||
|
||||
|
||||
@@ -146,7 +146,6 @@
|
||||
<applicationService serviceInterface="com.intellij.openapi.editor.colors.EditorColorsManager"
|
||||
serviceImplementation="com.intellij.openapi.editor.colors.impl.EditorColorsManagerImpl"/>
|
||||
<exportable serviceInterface="com.intellij.openapi.editor.colors.EditorColorsManager"/>
|
||||
<schemeOwner serviceInterface="com.intellij.openapi.editor.colors.EditorColorsManager"/>
|
||||
|
||||
<applicationService serviceInterface="com.intellij.openapi.roots.ui.FileAppearanceService"
|
||||
serviceImplementation="com.intellij.openapi.roots.ui.FileAppearanceServiceImpl"/>
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
serviceImplementation="com.intellij.profile.codeInspection.InspectionProfileManagerImpl"/>
|
||||
|
||||
<exportable serviceInterface="com.intellij.profile.codeInspection.InspectionProfileManager"/>
|
||||
<schemeOwner serviceInterface="com.intellij.profile.codeInspection.InspectionProfileManager"/>
|
||||
|
||||
<exportable serviceInterface="com.intellij.openapi.projectRoots.ProjectJdkTable"/>
|
||||
|
||||
|
||||
@@ -346,7 +346,6 @@
|
||||
<errorQuickFixProvider implementation="com.intellij.psi.templateLanguages.TemplateLanguageErrorQuickFixProvider"/>
|
||||
|
||||
<exportable serviceInterface="com.intellij.profile.codeInspection.InspectionProfileManager"/>
|
||||
<schemeOwner serviceInterface="com.intellij.profile.codeInspection.InspectionProfileManager"/>
|
||||
|
||||
<fileTypeFactory implementation="com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeFactory"/>
|
||||
<applicationService serviceInterface="com.intellij.openapi.file.exclude.EnforcedPlainTextFileTypeManager"
|
||||
|
||||
Reference in New Issue
Block a user