don't allow edit action if not editable

This commit is contained in:
Vladimir Krivosheev
2014-01-29 16:59:34 +01:00
parent 4b5b6e84ba
commit 27d736e8ba
3 changed files with 16 additions and 0 deletions
@@ -96,6 +96,12 @@ public class TableModelEditor<T> implements ElementProducer<T> {
table.requestFocus();
}
}
}).setEditActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
T item = table.getSelectedObject();
return item != null && ((DialogItemEditor<T>)TableModelEditor.this.itemEditor).isEditable(item);
}
});
}
}
@@ -142,6 +148,10 @@ public class TableModelEditor<T> implements ElementProducer<T> {
public abstract void edit(@NotNull T item, @NotNull Function<T, T> mutator);
public abstract void applyEdited(@NotNull T oldItem, @NotNull T newItem);
public boolean isEditable(@NotNull T item) {
return true;
}
}
@NotNull
@@ -256,6 +256,11 @@ public class BrowserSettingsPanel {
oldItem.setSpecificSettings(newItem.getSpecificSettings());
}
@Override
public boolean isEditable(@NotNull ConfigurableWebBrowser browser) {
return browser.getSpecificSettings() != null;
}
@Override
public boolean isRemovable(@NotNull ConfigurableWebBrowser item) {
return !WebBrowserManager.getInstance().isPredefinedBrowser(item);
@@ -47,6 +47,7 @@ public final class ChromeSettings extends BrowserSpecificSettings {
return myUseCustomProfile;
}
@Nullable
@Tag("command-line-options")
public String getCommandLineOptions() {
return myCommandLineOptions;