mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Move removeScheme() to common model interface, confirmation dialog upon delete.
This commit is contained in:
-5
@@ -65,11 +65,6 @@ abstract class CodeStyleSchemesActions extends AbstractSchemeActions<CodeStyleSc
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteScheme(@NotNull CodeStyleScheme scheme) {
|
||||
getModel().removeScheme(scheme);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void importScheme(@NotNull String importerName) {
|
||||
CodeStyleScheme currentScheme = getCurrentScheme();
|
||||
|
||||
+2
-1
@@ -67,7 +67,8 @@ public class CodeStyleSchemesModel implements SchemesModel<CodeStyleScheme> {
|
||||
}
|
||||
}
|
||||
|
||||
public void removeScheme(final CodeStyleScheme scheme) {
|
||||
@Override
|
||||
public void removeScheme(@NotNull final CodeStyleScheme scheme) {
|
||||
mySchemes.remove(scheme);
|
||||
myDispatcher.getMulticaster().schemeListChanged();
|
||||
if (myGlobalSelected == scheme) {
|
||||
|
||||
+6
-4
@@ -255,20 +255,22 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
|
||||
resetSchemesCombo(null);
|
||||
}
|
||||
|
||||
public void removeScheme(String name) {
|
||||
if (mySelectedScheme.getName().equals(name)) {
|
||||
@Override
|
||||
public void removeScheme(@NotNull EditorColorsScheme scheme) {
|
||||
String schemeName = scheme.getName();
|
||||
if (mySelectedScheme.getName().equals(schemeName)) {
|
||||
selectDefaultScheme();
|
||||
}
|
||||
|
||||
boolean deletedNewlyCreated = false;
|
||||
|
||||
MyColorScheme toDelete = mySchemes.get(name);
|
||||
MyColorScheme toDelete = mySchemes.get(schemeName);
|
||||
|
||||
if (toDelete != null) {
|
||||
deletedNewlyCreated = toDelete.isNew();
|
||||
}
|
||||
|
||||
mySchemes.remove(name);
|
||||
mySchemes.remove(schemeName);
|
||||
resetSchemesCombo(null);
|
||||
mySomeSchemesDeleted = mySomeSchemesDeleted || !deletedNewlyCreated;
|
||||
}
|
||||
|
||||
@@ -112,11 +112,6 @@ public abstract class ColorSchemeActions extends AbstractSchemeActions<EditorCol
|
||||
getOptions().saveSchemeAs(scheme, newName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteScheme(@NotNull EditorColorsScheme scheme) {
|
||||
getOptions().removeScheme(scheme.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void exportScheme(@NotNull EditorColorsScheme scheme, @NotNull String exporterName) {
|
||||
// Unsupported for now.
|
||||
|
||||
@@ -96,7 +96,7 @@ public class SchemesPanel extends AbstractSchemesPanel<EditorColorsScheme> imple
|
||||
@Override
|
||||
protected void renameScheme(@NotNull EditorColorsScheme scheme, @NotNull String newName) {
|
||||
if (myOptions.saveSchemeAs(scheme, newName)) {
|
||||
myOptions.removeScheme(scheme.getName());
|
||||
myOptions.removeScheme(scheme);
|
||||
myOptions.selectScheme(newName);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -19,6 +19,7 @@ import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.options.*;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -348,7 +349,14 @@ public abstract class AbstractSchemeActions<T extends Scheme> {
|
||||
*
|
||||
* @param scheme The scheme to delete.
|
||||
*/
|
||||
protected abstract void deleteScheme(@NotNull T scheme);
|
||||
protected void deleteScheme(@NotNull T scheme) {
|
||||
if (Messages.showOkCancelDialog(
|
||||
"Do you want to delete \"" + scheme.getName() + "\" scheme?",
|
||||
"Delete Scheme",
|
||||
Messages.getQuestionIcon()) == Messages.OK) {
|
||||
mySchemesPanel.getModel().removeScheme(scheme);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the scheme using the given exporter name.
|
||||
|
||||
@@ -71,4 +71,6 @@ public interface SchemesModel<T extends Scheme> {
|
||||
* returns {@code true}.
|
||||
*/
|
||||
boolean differsFromDefault(@NotNull T scheme);
|
||||
|
||||
void removeScheme(@NotNull T scheme);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user