public void addImportedScheme(@NotNull final EditorColorsScheme imported) { MyColorScheme newScheme = new MyColorScheme(imported); initScheme(newScheme); mySchemes.put(imported.getName(), newScheme); selectScheme(newScheme.getName()); resetSchemesCombo(null); }
private boolean isSchemeListModified() { if (mySomeSchemesDeleted) return true; if (!mySelectedScheme .getName() .equals(EditorColorsManager.getInstance().getGlobalScheme().getName())) return true; for (MyColorScheme scheme : mySchemes.values()) { if (scheme.isNew()) return true; } return false; }
private void initAll() { EditorColorsManager colorsManager = EditorColorsManager.getInstance(); EditorColorsScheme[] allSchemes = colorsManager.getAllSchemes(); mySchemes = new HashMap<String, MyColorScheme>(); for (EditorColorsScheme allScheme : allSchemes) { MyColorScheme schemeDelegate = new MyColorScheme(allScheme); initScheme(schemeDelegate); mySchemes.put(schemeDelegate.getName(), schemeDelegate); } mySelectedScheme = mySchemes.get(EditorColorsManager.getInstance().getGlobalScheme().getName()); assert mySelectedScheme != null : EditorColorsManager.getInstance().getGlobalScheme().getName() + "; myschemes=" + mySchemes; }
public void removeScheme(String name) { if (mySelectedScheme.getName().equals(name)) { //noinspection HardCodedStringLiteral selectScheme("Default"); } boolean deletedNewlyCreated = false; MyColorScheme toDelete = mySchemes.get(name); if (toDelete != null) { deletedNewlyCreated = toDelete.isNew(); } mySchemes.remove(name); resetSchemesCombo(null); mySomeSchemesDeleted = mySomeSchemesDeleted || !deletedNewlyCreated; }
public void saveSchemeAs(String name) { MyColorScheme scheme = mySelectedScheme; if (scheme == null) return; EditorColorsScheme clone = (EditorColorsScheme) scheme.getOriginalScheme().clone(); scheme.apply(clone); clone.setName(name); MyColorScheme newScheme = new MyColorScheme(clone); initScheme(newScheme); newScheme.setIsNew(); mySchemes.put(name, newScheme); selectScheme(newScheme.getName()); resetSchemesCombo(null); }
@NotNull public String[] getSchemeNames() { List<MyColorScheme> schemes = new ArrayList<MyColorScheme>(mySchemes.values()); Collections.sort( schemes, new Comparator<MyColorScheme>() { @Override public int compare(@NotNull MyColorScheme o1, @NotNull MyColorScheme o2) { if (isReadOnly(o1) && !isReadOnly(o2)) return -1; if (!isReadOnly(o1) && isReadOnly(o2)) return 1; return o1.getName().compareToIgnoreCase(o2.getName()); } }); List<String> names = new ArrayList<String>(schemes.size()); for (MyColorScheme scheme : schemes) { names.add(scheme.getName()); } return ArrayUtil.toStringArray(names); }