mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Code style & color scheme panels refactoring (IDEA-165087, IDEA-165088)
This commit is contained in:
-9
@@ -27,7 +27,6 @@ import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager;
|
||||
import com.intellij.openapi.editor.markup.EffectType;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.options.FontSize;
|
||||
import com.intellij.openapi.options.SchemeManager;
|
||||
import com.intellij.openapi.options.SchemeState;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.util.JdomKt;
|
||||
@@ -871,14 +870,6 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme, Serial
|
||||
public static boolean isVisible(@NotNull EditorColorsScheme scheme) {
|
||||
return !(scheme instanceof AbstractColorsScheme) || ((AbstractColorsScheme)scheme).isVisible();
|
||||
}
|
||||
|
||||
public static String getDisplayName(@NotNull EditorColorsScheme scheme) {
|
||||
String schemeName = scheme.getName();
|
||||
return
|
||||
schemeName.startsWith(SchemeManager.EDITABLE_COPY_PREFIX) ?
|
||||
schemeName.substring(SchemeManager.EDITABLE_COPY_PREFIX.length()) :
|
||||
schemeName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public AbstractColorsScheme getOriginal() {
|
||||
|
||||
+2
-2
@@ -37,11 +37,11 @@ import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.application.impl.ApplicationImpl;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.impl.AbstractColorsScheme;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.keymap.impl.DefaultKeymap;
|
||||
import com.intellij.openapi.keymap.impl.KeymapManagerImpl;
|
||||
import com.intellij.openapi.options.SchemeManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
@@ -151,7 +151,7 @@ public class InitialConfigurationDialog extends DialogWrapper {
|
||||
@Override
|
||||
public void customize(JList list, Object value, int index, boolean selected, boolean cellHasFocus) {
|
||||
if (value != null) {
|
||||
setText(AbstractColorsScheme.getDisplayName((EditorColorsScheme)value));
|
||||
setText(SchemeManager.getDisplayName((EditorColorsScheme)value));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ public class CodeStyleMainPanel extends JPanel implements TabbedLanguageCodeStyl
|
||||
link.setVerticalAlignment(SwingConstants.BOTTOM);
|
||||
|
||||
JPanel top = new JPanel(new BorderLayout());
|
||||
top.add(BorderLayout.WEST, mySchemesPanel.getRootPanel());
|
||||
top.add(BorderLayout.WEST, mySchemesPanel);
|
||||
top.add(BorderLayout.EAST, link);
|
||||
top.setBorder(JBUI.Borders.empty(10));
|
||||
add(top, BorderLayout.NORTH);
|
||||
|
||||
+13
-8
@@ -17,6 +17,7 @@ package com.intellij.application.options.codeStyle;
|
||||
|
||||
import com.intellij.application.options.SaveSchemeDialog;
|
||||
import com.intellij.application.options.SchemesToImportPopup;
|
||||
import com.intellij.application.options.schemes.AbstractSchemesPanel;
|
||||
import com.intellij.application.options.schemes.DefaultSchemeActions;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
@@ -47,6 +48,10 @@ abstract class CodeStyleSchemesActions extends DefaultSchemeActions<CodeStyleSch
|
||||
|
||||
private final static String SHARED_IMPORT_SOURCE = ApplicationBundle.message("import.scheme.shared");
|
||||
|
||||
protected CodeStyleSchemesActions(@NotNull AbstractSchemesPanel<CodeStyleScheme> schemesPanel) {
|
||||
super(schemesPanel);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void addAdditionalActions(@NotNull List<AnAction> defaultActions) {
|
||||
@@ -117,7 +122,7 @@ abstract class CodeStyleSchemesActions extends DefaultSchemeActions<CodeStyleSch
|
||||
String selectedName = scheme.getName();
|
||||
Collection<String> names = CodeStyleSchemesImpl.getSchemeManager().getAllSchemeNames();
|
||||
SaveSchemeDialog saveDialog =
|
||||
new SaveSchemeDialog(getParentComponent(), ApplicationBundle.message("title.save.code.style.scheme.as"), names, selectedName);
|
||||
new SaveSchemeDialog(getSchemesPanel(), ApplicationBundle.message("title.save.code.style.scheme.as"), names, selectedName);
|
||||
if (saveDialog.showAndGet()) {
|
||||
CodeStyleScheme newScheme = getSchemesModel().createNewScheme(saveDialog.getSchemeName(), getCurrentScheme());
|
||||
getSchemesModel().addScheme(newScheme, true);
|
||||
@@ -167,7 +172,7 @@ abstract class CodeStyleSchemesActions extends DefaultSchemeActions<CodeStyleSch
|
||||
|
||||
private void chooseAndImport(@NotNull CodeStyleScheme currentScheme, @NotNull String importerName) {
|
||||
if (importerName.equals(SHARED_IMPORT_SOURCE)) {
|
||||
new SchemesToImportPopup<CodeStyleScheme>(getParentComponent()) {
|
||||
new SchemesToImportPopup<CodeStyleScheme>(getSchemesPanel()) {
|
||||
@Override
|
||||
protected void onSchemeSelected(CodeStyleScheme scheme) {
|
||||
if (scheme != null) {
|
||||
@@ -184,7 +189,7 @@ abstract class CodeStyleSchemesActions extends DefaultSchemeActions<CodeStyleSch
|
||||
if (scheme != null) {
|
||||
final String additionalImportInfo = StringUtil.notNullize(importer.getAdditionalImportInfo(scheme));
|
||||
SchemeImportUtil
|
||||
.showStatus(getParentComponent(),
|
||||
.showStatus(getSchemesPanel(),
|
||||
ApplicationBundle.message("message.code.style.scheme.import.success", importerName, scheme.getName(),
|
||||
additionalImportInfo),
|
||||
MessageType.INFO);
|
||||
@@ -192,11 +197,11 @@ abstract class CodeStyleSchemesActions extends DefaultSchemeActions<CodeStyleSch
|
||||
}
|
||||
catch (SchemeImportException e) {
|
||||
if (e.isWarning()) {
|
||||
SchemeImportUtil.showStatus(getParentComponent(), e.getMessage(), MessageType.WARNING);
|
||||
SchemeImportUtil.showStatus(getSchemesPanel(), e.getMessage(), MessageType.WARNING);
|
||||
return;
|
||||
}
|
||||
final String message = ApplicationBundle.message("message.code.style.scheme.import.failure", importerName, e.getMessage());
|
||||
SchemeImportUtil.showStatus(getParentComponent(), message, MessageType.ERROR);
|
||||
SchemeImportUtil.showStatus(getSchemesPanel(), message, MessageType.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -205,7 +210,7 @@ abstract class CodeStyleSchemesActions extends DefaultSchemeActions<CodeStyleSch
|
||||
private CodeStyleScheme importExternalCodeStyle(final SchemeImporter<CodeStyleScheme> importer, @NotNull CodeStyleScheme currentScheme)
|
||||
throws SchemeImportException {
|
||||
final VirtualFile selectedFile = SchemeImportUtil
|
||||
.selectImportSource(importer.getSourceExtensions(), getParentComponent(), CodeStyleSchemesUIConfiguration.Util.getRecentImportFile());
|
||||
.selectImportSource(importer.getSourceExtensions(), getSchemesPanel(), CodeStyleSchemesUIConfiguration.Util.getRecentImportFile());
|
||||
if (selectedFile != null) {
|
||||
CodeStyleSchemesUIConfiguration.Util.setRecentImportFile(selectedFile);
|
||||
final SchemeCreator schemeCreator = new SchemeCreator();
|
||||
@@ -268,7 +273,7 @@ abstract class CodeStyleSchemesActions extends DefaultSchemeActions<CodeStyleSch
|
||||
.createSaveFileDialog(new FileSaverDescriptor(
|
||||
ApplicationBundle.message("scheme.exporter.ui.file.chooser.title"),
|
||||
ApplicationBundle.message("scheme.exporter.ui.file.chooser.message"),
|
||||
ext), getParentComponent());
|
||||
ext), getSchemesPanel());
|
||||
VirtualFileWrapper target = saver.save(null, scheme.getName() + "." + ext);
|
||||
if (target != null) {
|
||||
VirtualFile targetFile = target.getVirtualFile(true);
|
||||
@@ -298,7 +303,7 @@ abstract class CodeStyleSchemesActions extends DefaultSchemeActions<CodeStyleSch
|
||||
message = ApplicationBundle.message("scheme.exporter.ui.cannot.write.message");
|
||||
messageType = MessageType.ERROR;
|
||||
}
|
||||
SchemeImportUtil.showStatus(getParentComponent(), message, messageType);
|
||||
SchemeImportUtil.showStatus(getSchemesPanel(), message, messageType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+21
-60
@@ -20,16 +20,10 @@ package com.intellij.application.options.codeStyle;
|
||||
import com.intellij.application.options.schemes.AbstractSchemesPanel;
|
||||
import com.intellij.application.options.schemes.DefaultSchemeActions;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.psi.codeStyle.CodeStyleScheme;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,8 +32,6 @@ public class CodeStyleSchemesPanel extends AbstractSchemesPanel<CodeStyleScheme>
|
||||
private final CodeStyleSchemesModel myModel;
|
||||
|
||||
private boolean myIsReset = false;
|
||||
private Font myDefaultComboFont;
|
||||
private Font myBoldComboFont;
|
||||
|
||||
public CodeStyleSchemesPanel(CodeStyleSchemesModel model) {
|
||||
myModel = model;
|
||||
@@ -58,27 +50,17 @@ public class CodeStyleSchemesPanel extends AbstractSchemesPanel<CodeStyleScheme>
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private CodeStyleScheme getSelectedScheme() {
|
||||
Object selected = getSchemesCombo().getSelectedItem();
|
||||
if (selected instanceof CodeStyleScheme) {
|
||||
return (CodeStyleScheme)selected;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void resetSchemesCombo() {
|
||||
myIsReset = true;
|
||||
try {
|
||||
List<CodeStyleScheme> schemes = new ArrayList<>();
|
||||
schemes.addAll(myModel.getAllSortedSchemes());
|
||||
DefaultComboBoxModel model = new DefaultComboBoxModel(schemes.toArray());
|
||||
getSchemesCombo().setModel(model);
|
||||
resetSchemes(schemes);
|
||||
if (myModel.isUsePerProjectSettings()) {
|
||||
getSchemesCombo().setSelectedItem(myModel.getProjectScheme());
|
||||
selectScheme(myModel.getProjectScheme());
|
||||
}
|
||||
else {
|
||||
getSchemesCombo().setSelectedItem(myModel.getSelectedGlobalScheme());
|
||||
selectScheme(myModel.getSelectedGlobalScheme());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
@@ -90,10 +72,10 @@ public class CodeStyleSchemesPanel extends AbstractSchemesPanel<CodeStyleScheme>
|
||||
myIsReset = true;
|
||||
try {
|
||||
if (myModel.isUsePerProjectSettings()) {
|
||||
getSchemesCombo().setSelectedItem(myModel.getProjectScheme());
|
||||
selectScheme(myModel.getProjectScheme());
|
||||
}
|
||||
else {
|
||||
getSchemesCombo().setSelectedItem(myModel.getSelectedGlobalScheme());
|
||||
selectScheme(myModel.getSelectedGlobalScheme());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
@@ -103,51 +85,18 @@ public class CodeStyleSchemesPanel extends AbstractSchemesPanel<CodeStyleScheme>
|
||||
|
||||
public void usePerProjectSettingsOptionChanged() {
|
||||
if (myModel.isProjectScheme(myModel.getSelectedScheme())) {
|
||||
getSchemesCombo().setSelectedItem(myModel.getProjectScheme());
|
||||
selectScheme(myModel.getProjectScheme());
|
||||
}
|
||||
else {
|
||||
getSchemesCombo().setSelectedItem(myModel.getSelectedScheme());
|
||||
selectScheme(myModel.getSelectedScheme());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ComboBox createSchemesCombo() {
|
||||
ComboBox schemesCombo = new ComboBox();
|
||||
myDefaultComboFont = schemesCombo.getFont();
|
||||
myBoldComboFont = myDefaultComboFont.deriveFont(Font.BOLD);
|
||||
schemesCombo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull ActionEvent e) {
|
||||
if (!myIsReset) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> onCombo());
|
||||
}
|
||||
}
|
||||
});
|
||||
schemesCombo.setRenderer(new ListCellRendererWrapper() {
|
||||
@Override
|
||||
public void customize(final JList list, final Object value, final int index, final boolean selected, final boolean hasFocus) {
|
||||
Font font = myDefaultComboFont;
|
||||
if (value instanceof CodeStyleScheme) {
|
||||
CodeStyleScheme scheme = (CodeStyleScheme)value;
|
||||
if (scheme.isDefault() || myModel.isProjectScheme(scheme)) {
|
||||
font = myBoldComboFont;
|
||||
}
|
||||
}
|
||||
setFont(font);
|
||||
}
|
||||
});
|
||||
return schemesCombo;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected DefaultSchemeActions<CodeStyleScheme> createSchemeActions() {
|
||||
return
|
||||
new CodeStyleSchemesActions() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected JComponent getParentComponent() {
|
||||
return getToolbarPanel();
|
||||
}
|
||||
new CodeStyleSchemesActions(this) {
|
||||
|
||||
@Override
|
||||
protected CodeStyleSchemesModel getSchemesModel() {
|
||||
@@ -159,6 +108,18 @@ public class CodeStyleSchemesPanel extends AbstractSchemesPanel<CodeStyleScheme>
|
||||
protected CodeStyleScheme getCurrentScheme() {
|
||||
return getSelectedScheme();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchemeLevel getSchemeLevel(@NotNull CodeStyleScheme scheme) {
|
||||
return myModel.isProjectScheme(scheme) ? SchemeLevel.Project : SchemeLevel.IDE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSchemeChanged(@Nullable CodeStyleScheme scheme) {
|
||||
if (!myIsReset) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> onCombo());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+10
-6
@@ -178,16 +178,20 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
|
||||
@NotNull
|
||||
public String[] getSchemeNames() {
|
||||
List<MyColorScheme> schemes = new ArrayList<>(mySchemes.values());
|
||||
Collections.sort(schemes, EditorColorSchemesComparator.INSTANCE);
|
||||
|
||||
List<String> names = new ArrayList<>(schemes.size());
|
||||
for (MyColorScheme scheme : schemes) {
|
||||
List<String> names = new ArrayList<>();
|
||||
for (EditorColorsScheme scheme : getOrderedSchemes()) {
|
||||
names.add(scheme.getName());
|
||||
}
|
||||
|
||||
return ArrayUtil.toStringArray(names);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<EditorColorsScheme> getOrderedSchemes() {
|
||||
List<EditorColorsScheme> schemes = new ArrayList<>(mySchemes.values());
|
||||
Collections.sort(schemes, EditorColorSchemesComparator.INSTANCE);
|
||||
return schemes;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<EditorColorsScheme> getSchemes() {
|
||||
@@ -376,7 +380,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
if (myRootSchemesPanel == null) {
|
||||
ensureSchemesPanel();
|
||||
}
|
||||
return myRootSchemesPanel.getRootPanel();
|
||||
return myRootSchemesPanel;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-6
@@ -16,6 +16,7 @@
|
||||
package com.intellij.application.options.colors;
|
||||
|
||||
import com.intellij.application.options.SaveSchemeDialog;
|
||||
import com.intellij.application.options.schemes.AbstractSchemesPanel;
|
||||
import com.intellij.application.options.schemes.DefaultSchemeActions;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
@@ -32,13 +33,16 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ColorSchemeActions extends DefaultSchemeActions<EditorColorsScheme> {
|
||||
|
||||
protected ColorSchemeActions(@NotNull AbstractSchemesPanel<EditorColorsScheme> schemesPanel) {
|
||||
super(schemesPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<String> getSchemeImportersNames() {
|
||||
List<String> importersNames = new ArrayList<>();
|
||||
@@ -56,7 +60,7 @@ public abstract class ColorSchemeActions extends DefaultSchemeActions<EditorColo
|
||||
}
|
||||
final SchemeImporter<EditorColorsScheme> importer = SchemeImporterEP.getImporter(importerName, EditorColorsScheme.class);
|
||||
if (importer != null) {
|
||||
VirtualFile importSource = SchemeImportUtil.selectImportSource(importer.getSourceExtensions(), getParentComponent(), null);
|
||||
VirtualFile importSource = SchemeImportUtil.selectImportSource(importer.getSourceExtensions(), getSchemesPanel(), null);
|
||||
if (importSource != null) {
|
||||
try {
|
||||
EditorColorsScheme imported =
|
||||
@@ -73,7 +77,7 @@ public abstract class ColorSchemeActions extends DefaultSchemeActions<EditorColo
|
||||
}
|
||||
}
|
||||
catch (SchemeImportException e) {
|
||||
SchemeImportUtil.showStatus(getParentComponent(), "Import failed: " + e.getMessage(), MessageType.ERROR);
|
||||
SchemeImportUtil.showStatus(getSchemesPanel(), "Import failed: " + e.getMessage(), MessageType.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,7 +86,7 @@ public abstract class ColorSchemeActions extends DefaultSchemeActions<EditorColo
|
||||
private boolean tryImportWithImportHandler(@NotNull String importerName) {
|
||||
for (ImportHandler importHandler : Extensions.getExtensions(ImportHandler.EP_NAME)) {
|
||||
if (importerName.equals(importHandler.getTitle())) {
|
||||
importHandler.performImport(getParentComponent(), scheme -> {
|
||||
importHandler.performImport(getSchemesPanel(), scheme -> {
|
||||
if (scheme != null) getOptions().addImportedScheme(scheme);
|
||||
});
|
||||
return true;
|
||||
@@ -103,9 +107,9 @@ public abstract class ColorSchemeActions extends DefaultSchemeActions<EditorColo
|
||||
@Override
|
||||
protected void doSaveAs(@NotNull EditorColorsScheme scheme) {
|
||||
List<String> names = ContainerUtil.newArrayList(getOptions().getSchemeNames());
|
||||
String selectedName = AbstractColorsScheme.getDisplayName(scheme);
|
||||
String selectedName = SchemeManager.getDisplayName(scheme);
|
||||
SaveSchemeDialog dialog =
|
||||
new SaveSchemeDialog(getParentComponent(), ApplicationBundle.message("title.save.color.scheme.as"), names, selectedName);
|
||||
new SaveSchemeDialog(getSchemesPanel(), ApplicationBundle.message("title.save.color.scheme.as"), names, selectedName);
|
||||
if (dialog.showAndGet()) {
|
||||
getOptions().saveSchemeAs(dialog.getSchemeName());
|
||||
}
|
||||
|
||||
+3
-3
@@ -61,7 +61,7 @@ public class NewColorAndFontPanel extends JPanel {
|
||||
|
||||
JPanel top = new JPanel(new BorderLayout());
|
||||
|
||||
top.add(mySchemesPanel.getRootPanel(), BorderLayout.NORTH);
|
||||
top.add(mySchemesPanel, BorderLayout.NORTH);
|
||||
top.add(myOptionsPanel.getPanel(), BorderLayout.CENTER);
|
||||
if (optionsPanel instanceof ConsoleFontOptions) {
|
||||
JPanel wrapper = new JPanel(new FlowLayout(FlowLayout.TRAILING));
|
||||
@@ -220,7 +220,7 @@ public class NewColorAndFontPanel extends JPanel {
|
||||
.createBalloon();
|
||||
Disposer.register(ApplicationManager.getApplication(), balloon);
|
||||
balloon.show(new RelativePoint(
|
||||
mySchemesPanel.getRootPanel(),
|
||||
new Point(mySchemesPanel.getRootPanel().getWidth() / 10, mySchemesPanel.getRootPanel().getHeight())), Balloon.Position.below);
|
||||
mySchemesPanel,
|
||||
new Point(mySchemesPanel.getWidth() / 10, mySchemesPanel.getHeight())), Balloon.Position.below);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,16 +20,10 @@ import com.intellij.application.options.SkipSelfSearchComponent;
|
||||
import com.intellij.application.options.schemes.AbstractSchemesPanel;
|
||||
import com.intellij.application.options.schemes.DefaultSchemeActions;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.impl.AbstractColorsScheme;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class SchemesPanel extends AbstractSchemesPanel<EditorColorsScheme> implements SkipSelfSearchComponent {
|
||||
private final ColorAndFontOptions myOptions;
|
||||
|
||||
@@ -60,30 +54,14 @@ public class SchemesPanel extends AbstractSchemesPanel<EditorColorsScheme> imple
|
||||
public void resetSchemesCombo(final Object source) {
|
||||
if (this != source) {
|
||||
setListLoaded(false);
|
||||
|
||||
EditorColorsScheme selectedSchemeBackup = myOptions.getSelectedScheme();
|
||||
getSchemesCombo().removeAllItems();
|
||||
|
||||
String[] schemeNames = myOptions.getSchemeNames();
|
||||
MySchemeItem itemToSelect = null;
|
||||
for (String schemeName : schemeNames) {
|
||||
EditorColorsScheme scheme = myOptions.getScheme(schemeName);
|
||||
MySchemeItem item = new MySchemeItem(scheme);
|
||||
if (scheme == selectedSchemeBackup) itemToSelect = item;
|
||||
getSchemesCombo().addItem(item);
|
||||
}
|
||||
|
||||
getSchemesCombo().setSelectedItem(itemToSelect);
|
||||
resetSchemes(myOptions.getOrderedSchemes());
|
||||
selectScheme(selectedSchemeBackup);
|
||||
setListLoaded(true);
|
||||
|
||||
myDispatcher.getMulticaster().schemeChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getSelectedSchemeName() {
|
||||
return getSchemesCombo().getSelectedIndex() != -1 ? ((MySchemeItem)getSchemesCombo().getSelectedItem()).getSchemeName() : null;
|
||||
}
|
||||
|
||||
private void setListLoaded(final boolean b) {
|
||||
myListLoaded = b;
|
||||
@@ -93,63 +71,40 @@ public class SchemesPanel extends AbstractSchemesPanel<EditorColorsScheme> imple
|
||||
myDispatcher.addListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ComboBox createSchemesCombo() {
|
||||
ComboBox schemesCombo = new ComboBox();
|
||||
schemesCombo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull ActionEvent e) {
|
||||
String selectedName = getSelectedSchemeName();
|
||||
if (selectedName != null) {
|
||||
myOptions.selectScheme(selectedName);
|
||||
if (areSchemesLoaded()) {
|
||||
myDispatcher.getMulticaster().schemeChanged(SchemesPanel.this);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return schemesCombo;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DefaultSchemeActions<EditorColorsScheme> createSchemeActions() {
|
||||
return
|
||||
new ColorSchemeActions() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected JComponent getParentComponent() {
|
||||
return getToolbarPanel();
|
||||
}
|
||||
new ColorSchemeActions(this) {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected ColorAndFontOptions getOptions() {
|
||||
return myOptions;
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
protected ColorAndFontOptions getOptions() {
|
||||
return myOptions;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected EditorColorsScheme getCurrentScheme() {
|
||||
return myOptions != null ? myOptions.getScheme(getSelectedSchemeName()) : null;
|
||||
}
|
||||
};
|
||||
@Override
|
||||
protected void onSchemeChanged(@Nullable EditorColorsScheme scheme) {
|
||||
if (scheme != null) {
|
||||
myOptions.selectScheme(scheme.getName());
|
||||
if (areSchemesLoaded()) {
|
||||
myDispatcher.getMulticaster().schemeChanged(SchemesPanel.this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected EditorColorsScheme getCurrentScheme() {
|
||||
EditorColorsScheme selectedScheme = getSelectedScheme();
|
||||
return selectedScheme != null ? myOptions.getScheme(selectedScheme.getName()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchemeLevel getSchemeLevel(@NotNull EditorColorsScheme scheme) {
|
||||
return SchemeLevel.IDE_Only;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private final static class MySchemeItem {
|
||||
private EditorColorsScheme myScheme;
|
||||
|
||||
public MySchemeItem(EditorColorsScheme scheme) {
|
||||
myScheme = scheme;
|
||||
}
|
||||
|
||||
public String getSchemeName() {
|
||||
return myScheme.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return AbstractColorsScheme.getDisplayName(myScheme);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.application.options.schemes.AbstractSchemesPanel">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<hspacer id="3af34">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<grid id="3da00" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="5" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value=""/>
|
||||
</clientProperties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="9ba8c" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Scheme:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="1784" class="com.intellij.openapi.ui.ComboBox" binding="mySchemesCombo" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<grid id="3fb7" binding="myToolbarPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<vspacer id="775b2">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+40
-24
@@ -17,35 +17,41 @@ package com.intellij.application.options.schemes;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.options.Scheme;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class AbstractSchemesPanel<T extends Scheme> {
|
||||
public abstract class AbstractSchemesPanel<T extends Scheme> extends JPanel {
|
||||
|
||||
private ComboBox mySchemesCombo;
|
||||
private JPanel myPanel;
|
||||
private JPanel myToolbarPanel;
|
||||
private SchemesCombo<T> mySchemesCombo;
|
||||
private DefaultSchemeActions<T> myActions;
|
||||
private JComponent myToolbar;
|
||||
|
||||
public AbstractSchemesPanel() {
|
||||
myToolbarPanel.add(createToolbar());
|
||||
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
|
||||
createUIComponents();
|
||||
}
|
||||
|
||||
public JPanel getRootPanel() {
|
||||
return myPanel;
|
||||
}
|
||||
|
||||
public JPanel getToolbarPanel() {
|
||||
return myToolbarPanel;
|
||||
}
|
||||
|
||||
|
||||
private void createUIComponents() {
|
||||
mySchemesCombo = createSchemesCombo();
|
||||
JPanel controlsPanel = new JPanel();
|
||||
controlsPanel.setLayout(new BoxLayout(controlsPanel, BoxLayout.LINE_AXIS));
|
||||
controlsPanel.add(new JLabel(ApplicationBundle.message("editbox.scheme.name")));
|
||||
controlsPanel.add(Box.createRigidArea(new Dimension(10, 0)));
|
||||
myActions = createSchemeActions();
|
||||
mySchemesCombo = new SchemesCombo<>(myActions);
|
||||
controlsPanel.add(mySchemesCombo.getComboBox());
|
||||
myToolbar = createToolbar();
|
||||
controlsPanel.add(myToolbar);
|
||||
controlsPanel.setMaximumSize(new Dimension(controlsPanel.getMaximumSize().width, mySchemesCombo.getComboBox().getPreferredSize().height));
|
||||
add(controlsPanel);
|
||||
add(Box.createVerticalGlue());
|
||||
add(Box.createRigidArea(new Dimension(0, 10)));
|
||||
}
|
||||
|
||||
private JComponent createToolbar() {
|
||||
@@ -64,7 +70,7 @@ public abstract class AbstractSchemesPanel<T extends Scheme> {
|
||||
@NotNull
|
||||
@Override
|
||||
public AnAction[] getChildren(@Nullable AnActionEvent e) {
|
||||
Collection<AnAction> actions = createSchemeActions().getActions();
|
||||
Collection<AnAction> actions = myActions.getActions();
|
||||
return actions.toArray(new AnAction[actions.size()]);
|
||||
}
|
||||
|
||||
@@ -74,16 +80,26 @@ public abstract class AbstractSchemesPanel<T extends Scheme> {
|
||||
p.setIcon(AllIcons.General.GearPlain);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract ComboBox createSchemesCombo();
|
||||
|
||||
protected abstract DefaultSchemeActions<T> createSchemeActions();
|
||||
|
||||
public ComboBox getSchemesCombo() {
|
||||
return mySchemesCombo;
|
||||
public JComponent getToolbar() {
|
||||
return myToolbar;
|
||||
}
|
||||
|
||||
protected abstract DefaultSchemeActions<T> createSchemeActions();
|
||||
|
||||
public T getSelectedScheme() {
|
||||
return mySchemesCombo.getSelectedScheme();
|
||||
}
|
||||
|
||||
public void selectScheme(@Nullable T scheme) {
|
||||
mySchemesCombo.selectScheme(scheme);
|
||||
}
|
||||
|
||||
public void resetSchemes(@NotNull Collection<T> schemes) {
|
||||
mySchemesCombo.resetSchemes(schemes);
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
myPanel.removeAll();
|
||||
removeAll();
|
||||
}
|
||||
}
|
||||
|
||||
+15
-6
@@ -26,7 +26,6 @@ import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -34,8 +33,14 @@ import java.util.List;
|
||||
public abstract class DefaultSchemeActions<T extends Scheme> {
|
||||
private final Collection<String> mySchemeImportersNames;
|
||||
private final Collection<String> mySchemeExporterNames;
|
||||
private AbstractSchemesPanel<T> mySchemesPanel;
|
||||
|
||||
public enum SchemeLevel {
|
||||
IDE_Only, IDE, Project
|
||||
}
|
||||
|
||||
protected DefaultSchemeActions() {
|
||||
protected DefaultSchemeActions(@NotNull AbstractSchemesPanel<T> schemesPanel) {
|
||||
mySchemesPanel = schemesPanel;
|
||||
mySchemeImportersNames = getSchemeImportersNames();
|
||||
mySchemeExporterNames = getSchemeExporterNames();
|
||||
}
|
||||
@@ -173,7 +178,7 @@ public abstract class DefaultSchemeActions<T extends Scheme> {
|
||||
return namedActions.toArray(new AnAction[namedActions.size()]);
|
||||
}
|
||||
}, e.getDataContext(), null, true);
|
||||
listPopup.showUnderneathOf(getParentComponent());
|
||||
listPopup.showUnderneathOf(mySchemesPanel.getToolbar());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -232,13 +237,17 @@ public abstract class DefaultSchemeActions<T extends Scheme> {
|
||||
|
||||
protected abstract void doExport(@NotNull T scheme, @NotNull String exporterName);
|
||||
|
||||
protected abstract void onSchemeChanged(@Nullable T scheme);
|
||||
|
||||
@Nullable
|
||||
protected abstract T getCurrentScheme();
|
||||
|
||||
protected abstract Class<T> getSchemeType();
|
||||
|
||||
@NotNull
|
||||
protected abstract JComponent getParentComponent();
|
||||
|
||||
public AbstractSchemesPanel<T> getSchemesPanel() {
|
||||
return mySchemesPanel;
|
||||
}
|
||||
|
||||
public abstract SchemeLevel getSchemeLevel(@NotNull T scheme);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.schemes;
|
||||
|
||||
import com.intellij.openapi.options.Scheme;
|
||||
import com.intellij.openapi.options.SchemeManager;
|
||||
import com.intellij.openapi.ui.ComboBox;
|
||||
import com.intellij.ui.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Collection;
|
||||
|
||||
public class SchemesCombo<T extends Scheme> {
|
||||
private ComboBox<MySchemeItem> myComboBox;
|
||||
private DefaultSchemeActions<T> myActions;
|
||||
|
||||
public SchemesCombo(@NotNull DefaultSchemeActions<T> actions) {
|
||||
myActions = actions;
|
||||
myComboBox = new ComboBox<>();
|
||||
myComboBox.setRenderer(new MyListCellRenderer());
|
||||
myComboBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
myActions.onSchemeChanged(getSelectedScheme());
|
||||
}
|
||||
});
|
||||
myComboBox.setModel(new DefaultComboBoxModel<MySchemeItem>() {
|
||||
@Override
|
||||
public void setSelectedItem(Object anObject) {
|
||||
if (anObject instanceof OptionalSeparatorItem && ((OptionalSeparatorItem)anObject).isSeparator()) {
|
||||
return;
|
||||
}
|
||||
super.setSelectedItem(anObject);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private SimpleTextAttributes getSchemeAttributes(@NotNull T scheme) {
|
||||
return myActions.isDeleteAvailable(scheme) ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
|
||||
}
|
||||
|
||||
public void resetSchemes(@NotNull Collection<T> schemes) {
|
||||
myComboBox.removeAllItems();
|
||||
DefaultSchemeActions.SchemeLevel currSchemeLevel = DefaultSchemeActions.SchemeLevel.IDE_Only;
|
||||
for (T scheme : schemes) {
|
||||
DefaultSchemeActions.SchemeLevel schemeLevel = myActions.getSchemeLevel(scheme);
|
||||
if (!currSchemeLevel.equals(schemeLevel)) {
|
||||
currSchemeLevel = schemeLevel;
|
||||
if (!schemeLevel.equals(DefaultSchemeActions.SchemeLevel.IDE_Only)) {
|
||||
myComboBox.addItem(new MySchemeItem(currSchemeLevel.toString()));
|
||||
}
|
||||
}
|
||||
myComboBox.addItem(new MySchemeItem(scheme));
|
||||
}
|
||||
}
|
||||
|
||||
private class MyListCellRenderer extends ColoredListCellRenderer<MySchemeItem> {
|
||||
private ListCellRendererWrapper<MySchemeItem> myWrapper = new ListCellRendererWrapper<MySchemeItem>() {
|
||||
@Override
|
||||
public void customize(JList list,
|
||||
MySchemeItem value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
if (value.isSeparator()) {
|
||||
setText(" Stored in " + value.getPresentableText());
|
||||
setSeparator();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends MySchemeItem> list,
|
||||
MySchemeItem value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
if (value.isSeparator()) {
|
||||
Component c = myWrapper.getListCellRendererComponent(list, value, index, selected, hasFocus);
|
||||
if (c instanceof TitledSeparator) {
|
||||
((TitledSeparator)c).getLabel().setForeground(JBColor.GRAY);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
return super.getListCellRendererComponent(list, value, index, selected, hasFocus);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customizeCellRenderer(@NotNull JList<? extends MySchemeItem> list,
|
||||
MySchemeItem value,
|
||||
int index,
|
||||
boolean selected,
|
||||
boolean hasFocus) {
|
||||
if (value.getScheme() != null) {
|
||||
append(value.getPresentableText(), getSchemeAttributes(value.getScheme()));
|
||||
DefaultSchemeActions.SchemeLevel schemeLevel = myActions.getSchemeLevel(value.getScheme());
|
||||
if (index == -1 && !DefaultSchemeActions.SchemeLevel.IDE_Only.equals(schemeLevel)) {
|
||||
append(" " + schemeLevel.toString(), SimpleTextAttributes.GRAY_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getSelectedScheme() {
|
||||
int i = myComboBox.getSelectedIndex();
|
||||
return i >= 0 ? myComboBox.getItemAt(i).getScheme() : null;
|
||||
}
|
||||
|
||||
public void selectScheme(@Nullable T scheme) {
|
||||
for (int i = 0; i < myComboBox.getItemCount(); i ++) {
|
||||
if (myComboBox.getItemAt(i).getScheme() == scheme) {
|
||||
myComboBox.setSelectedIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ComboBox getComboBox() {
|
||||
return myComboBox;
|
||||
}
|
||||
|
||||
private interface OptionalSeparatorItem {
|
||||
boolean isSeparator();
|
||||
}
|
||||
|
||||
private final class MySchemeItem implements OptionalSeparatorItem {
|
||||
private @Nullable T myScheme;
|
||||
private @Nullable String myText;
|
||||
|
||||
public MySchemeItem(@NotNull String text) {
|
||||
myText = text;
|
||||
}
|
||||
|
||||
public MySchemeItem(@Nullable T scheme) {
|
||||
myScheme = scheme;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSchemeName() {
|
||||
return myScheme != null ? myScheme.getName() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getScheme() {
|
||||
return myScheme;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getPresentableText() {
|
||||
return myScheme != null ? SchemeManager.getDisplayName(myScheme) : myText != null ? myText : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSeparator() {
|
||||
return myScheme == null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -20,7 +20,7 @@ import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.impl.AbstractColorsScheme;
|
||||
import com.intellij.openapi.options.SchemeManager;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -42,7 +42,7 @@ public class QuickChangeColorSchemeAction extends QuickSwitchSchemeAction {
|
||||
final EditorColorsScheme current,
|
||||
final EditorColorsScheme scheme,
|
||||
final boolean addScheme) {
|
||||
group.add(new DumbAwareAction(AbstractColorsScheme.getDisplayName(scheme), "", scheme == current ? ourCurrentAction : ourNotCurrentAction) {
|
||||
group.add(new DumbAwareAction(SchemeManager.getDisplayName(scheme), "", scheme == current ? ourCurrentAction : ourNotCurrentAction) {
|
||||
@Override
|
||||
public void actionPerformed(@Nullable AnActionEvent e) {
|
||||
if (addScheme) {
|
||||
|
||||
@@ -122,4 +122,12 @@ public abstract class SchemeManager<T extends Scheme> {
|
||||
public boolean isMetadataEditable(@NotNull T scheme) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static String getDisplayName(@NotNull Scheme scheme) {
|
||||
String schemeName = scheme.getName();
|
||||
return
|
||||
schemeName.startsWith(EDITABLE_COPY_PREFIX) ?
|
||||
schemeName.substring(EDITABLE_COPY_PREFIX.length()) :
|
||||
schemeName;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user