diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactsStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactsStructureConfigurable.java index ba924d081e86..7aa723491598 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactsStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/artifacts/ArtifactsStructureConfigurable.java @@ -1,17 +1,5 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.openapi.roots.ui.configuration.artifacts; @@ -23,7 +11,9 @@ import com.intellij.openapi.application.Result; import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.module.Module; import com.intellij.openapi.options.ConfigurationException; -import com.intellij.openapi.project.*; +import com.intellij.openapi.project.DumbAwareAction; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.roots.ModifiableRootModel; import com.intellij.openapi.roots.impl.libraries.LibraryTableImplUtil; import com.intellij.openapi.roots.libraries.Library; @@ -96,10 +86,6 @@ public class ArtifactsStructureConfigurable extends BaseStructureConfigurable { onElementDeleted(); } } - - @Override - public void itemsExternallyChanged() { - } }; moduleStructureConfigurable.addItemsChangeListener(listener); projectLibrariesConfig.addItemsChangeListener(listener); @@ -346,15 +332,6 @@ public class ArtifactsStructureConfigurable extends BaseStructureConfigurable { return Collections.singletonList(new ArtifactRemoveHandler()); } - @Override - protected void processRemovedItems() { - } - - @Override - protected boolean wasObjectStored(Object editableObject) { - return false; - } - @Override @NotNull public String getId() { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/dependencyAnalysis/AnalyzeDependenciesComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/dependencyAnalysis/AnalyzeDependenciesComponent.java index 02ed6d5d11c4..463e37b7fb60 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/dependencyAnalysis/AnalyzeDependenciesComponent.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/dependencyAnalysis/AnalyzeDependenciesComponent.java @@ -1,17 +1,5 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.openapi.roots.ui.configuration.dependencyAnalysis; @@ -54,6 +42,7 @@ import javax.swing.tree.TreeSelectionModel; import java.awt.*; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; /** * The classpath details component @@ -62,7 +51,7 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent { /** * Data key for order path element */ - public static DataKey ORDER_PATH_ELEMENT_KEY = DataKey.create("ORDER_PATH_ELEMENT"); + public static final DataKey ORDER_PATH_ELEMENT_KEY = DataKey.create("ORDER_PATH_ELEMENT"); /** * The module being analyzed */ @@ -146,17 +135,16 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent { * {@inheritDoc} */ @Override - protected ArrayList createActions(boolean fromPopup) { - if (!fromPopup) { - ArrayList rc = new ArrayList<>(); - rc.add(new ClasspathTypeAction()); - rc.add(new SdkFilterAction()); - rc.add(new UrlModeAction()); - return rc; - } - else { - return super.createActions(fromPopup); + protected List createActions(boolean fromPopup) { + if (fromPopup) { + return super.createActions(true); } + + List rc = new ArrayList<>(); + rc.add(new ClasspathTypeAction()); + rc.add(new SdkFilterAction()); + rc.add(new UrlModeAction()); + return rc; } /** @@ -485,7 +473,6 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent { * Cell renderer for explanation tree */ static class ExplanationTreeRenderer extends ColoredTreeCellRenderer { - @Override public void customizeCellRenderer(JTree tree, Object value, @@ -771,7 +758,7 @@ public class AnalyzeDependenciesComponent extends MasterDetailsComponent { /** * The enumeration type that represents classpath entry filter */ - private static enum ClasspathType { + private enum ClasspathType { /** * The production compile mode */ diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java index fbf6a2dd71ab..14e226c94467 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/BaseLibrariesConfigurable.java @@ -62,15 +62,6 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl public abstract LibraryTablePresentation getLibraryTablePresentation(); - @Override - protected void processRemovedItems() { - } - - @Override - protected boolean wasObjectStored(final Object editableObject) { - return false; - } - @Override @Nullable @NonNls diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetStructureConfigurable.java index 9ac40aad5bf2..33700a78aa87 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/FacetStructureConfigurable.java @@ -1,17 +1,5 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.openapi.roots.ui.configuration.projectRoot; @@ -343,15 +331,6 @@ public class FacetStructureConfigurable extends BaseStructureConfigurable { return Collections.singletonList(new FacetRemoveHandler()); } - @Override - protected void processRemovedItems() { - } - - @Override - protected boolean wasObjectStored(final Object editableObject) { - return false; - } - @Override public String getDisplayName() { return ProjectBundle.message("project.facets.display.name"); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/JdkListConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/JdkListConfigurable.java index 232bbf3c6dcb..18d76d5cc108 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/JdkListConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/JdkListConfigurable.java @@ -1,17 +1,5 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.intellij.openapi.roots.ui.configuration.projectRoot; @@ -83,15 +71,6 @@ public class JdkListConfigurable extends BaseStructureConfigurable { return "JdkListConfigurable.UI"; } - @Override - protected void processRemovedItems() { - } - - @Override - protected boolean wasObjectStored(final Object editableObject) { - return false; - } - @Override @Nls public String getDisplayName() { @@ -150,6 +129,7 @@ public class JdkListConfigurable extends BaseStructureConfigurable { myJdksTreeModel.disposeUIResources(); } + @NotNull public ProjectSdksModel getJdksTreeModel() { return myJdksTreeModel; } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java index 2c0abaa8329b..e4b32cd2fb0e 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ModuleStructureConfigurable.java @@ -326,11 +326,6 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple myContext.getDaemonAnalyzer().removeElement(new LibraryProjectStructureElement(myContext, library)); } } - - @Override - public void itemsExternallyChanged() { - //do nothing - } }); } @@ -399,16 +394,6 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple return new MyDataProviderWrapper(super.createComponent()); } - @Override - protected void processRemovedItems() { - // do nothing - } - - @Override - protected boolean wasObjectStored(Object editableObject) { - return false; - } - @Override public String getDisplayName() { return ProjectBundle.message("project.roots.display.name"); diff --git a/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsConfigurable.java b/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsConfigurable.java index 497dbda7ff56..8e6b1a361df0 100644 --- a/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsConfigurable.java +++ b/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsConfigurable.java @@ -1,17 +1,5 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package com.jetbrains.jsonSchema; @@ -290,16 +278,6 @@ public class JsonSchemaMappingsConfigurable extends MasterDetailsComponent imple return ((JsonSchemaConfigurable) node.getConfigurable()).getSchema(); } - @Override - protected void processRemovedItems() { - - } - - @Override - protected boolean wasObjectStored(Object editableObject) { - return false; - } - @Nls @Override public String getDisplayName() { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java index a6ed1f2789bb..1b31c1165ab2 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java @@ -254,7 +254,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom } protected DefaultActionGroup createToolbarActionGroup() { - final ArrayList actions = createActions(false); + final List actions = createActions(false); if (actions != null) { final DefaultActionGroup group = new DefaultActionGroup(); for (AnAction action : actions) { @@ -430,11 +430,10 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom } @Nullable - protected ArrayList createActions(final boolean fromPopup) { + protected List createActions(boolean fromPopup) { return null; } - protected void initTree() { ((DefaultTreeModel)myTree.getModel()).setRoot(myRoot); myTree.setRootVisible(false); @@ -465,7 +464,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom } } }); - ArrayList actions = createActions(true); + List actions = createActions(true); if (actions != null) { final DefaultActionGroup group = new DefaultActionGroup(); for (AnAction action : actions) { @@ -908,7 +907,8 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom protected interface ItemsChangeListener { void itemChanged(@Nullable Object deletedItem); - void itemsExternallyChanged(); + default void itemsExternallyChanged() { + } } public interface ActionGroupWithPreselection { diff --git a/platform/platform-api/src/com/intellij/openapi/ui/NamedItemsListEditor.java b/platform/platform-api/src/com/intellij/openapi/ui/NamedItemsListEditor.java index 7a87f954e60b..3bf9d25162b2 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/NamedItemsListEditor.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/NamedItemsListEditor.java @@ -31,304 +31,300 @@ import java.util.Collections; import java.util.List; public abstract class NamedItemsListEditor extends MasterDetailsComponent { - private final Namer myNamer; - private final Factory myFactory; - private final Cloner myCloner; - private final List myItems = new ArrayList<>(); - private final Equality myComparer; - private List myResultItems; - private final List myOriginalItems; - private boolean myShowIcons; + private final Namer myNamer; + private final Factory myFactory; + private final Cloner myCloner; + private final List myItems = new ArrayList<>(); + private final Equality myComparer; + private List myResultItems; + private final List myOriginalItems; + private boolean myShowIcons; - protected NamedItemsListEditor(Namer namer, - Factory factory, - Cloner cloner, - Equality comparer, - List items) { - this(namer, factory, cloner, comparer, items, true); + protected NamedItemsListEditor(Namer namer, + Factory factory, + Cloner cloner, + Equality comparer, + List items) { + this(namer, factory, cloner, comparer, items, true); + } + + protected NamedItemsListEditor(Namer namer, + Factory factory, + Cloner cloner, + Equality comparer, + List items, + boolean initInConstructor) { + myNamer = namer; + myFactory = factory; + myCloner = cloner; + myComparer = comparer; + + myOriginalItems = items; + myResultItems = items; + if (initInConstructor) { + reset(); + initTree(); + } + } + + @Override + public void reset() { + myResultItems = myOriginalItems; + myItems.clear(); + + clearChildren(); + for (T item : myOriginalItems) { + addNewNode(myCloner.cloneOf(item)); } - protected NamedItemsListEditor(Namer namer, - Factory factory, - Cloner cloner, - Equality comparer, - List items, - boolean initInConstructor) { - myNamer = namer; - myFactory = factory; - myCloner = cloner; - myComparer = comparer; + super.reset(); + } - myOriginalItems = items; - myResultItems = items; - if (initInConstructor) { - reset(); - initTree(); - } + @Override + protected boolean wasObjectStored(Object editableObject) { + return true; + } + + protected String subjDisplayName() { + return "item"; + } + + @Nullable + public String askForProfileName(String titlePattern) { + String title = MessageFormat.format(titlePattern, subjDisplayName()); + return Messages.showInputDialog("New " + subjDisplayName() + " name:", title, Messages.getQuestionIcon(), "", new InputValidator() { + @Override + public boolean checkInput(String s) { + return s.length() > 0 && findByName(s) == null; + } + + @Override + public boolean canClose(String s) { + return checkInput(s); + } + }); + } + + @Nullable + protected T findByName(String name) { + for (T item : myItems) { + if (Comparing.equal(name, myNamer.getName(item))) return item; } - @Override - public void reset() { - myResultItems = myOriginalItems; - myItems.clear(); + return null; + } - clearChildren(); - for (T item : myOriginalItems) { - addNewNode(myCloner.cloneOf(item)); - } + @Override + @Nullable + protected List createActions(boolean fromPopup) { + ArrayList result = new ArrayList<>(); + result.add(new AddAction()); + result.add(new MyDeleteAction(forAll(o -> canDelete((T)((MyNode)o).getConfigurable().getEditableObject())))); + result.add(new CopyAction()); + return result; + } - super.reset(); - } + private void addNewNode(T item) { + addNode(new MyNode(new ItemConfigurable(item)), myRoot); + myItems.add(item); + } - @Override - protected boolean wasObjectStored(Object editableObject) { + protected boolean canDelete(T item) { + return true; + } + + protected abstract UnnamedConfigurable createConfigurable(T item); + + @Override + protected void onItemDeleted(Object item) { + //noinspection unchecked + myItems.remove((T)item); + } + + protected void setDisplayName(T item, String name) { + myNamer.setName(item, name); + } + + public void setShowIcons(boolean showIcons) { + myShowIcons = showIcons; + } + + @Nullable + protected UnnamedConfigurable getItemConfigurable(final T item) { + final Ref result = new Ref<>(); + TreeUtil.traverse((TreeNode)myTree.getModel().getRoot(), node -> { + final NamedConfigurable configurable = (NamedConfigurable)((DefaultMutableTreeNode)node).getUserObject(); + if (configurable.getEditableObject() == item) { + //noinspection unchecked + result.set(((ItemConfigurable)configurable).myConfigurable); + return false; + } + else { return true; - } - - protected String subjDisplayName() { - return "item"; - } - - @Nullable - public String askForProfileName(String titlePattern) { - String title = MessageFormat.format(titlePattern, subjDisplayName()); - return Messages.showInputDialog("New " + subjDisplayName() + " name:", title, Messages.getQuestionIcon(), "", new InputValidator() { - @Override - public boolean checkInput(String s) { - return s.length() > 0 && findByName(s) == null; - } - - @Override - public boolean canClose(String s) { - return checkInput(s); - } - }); - } - - @Nullable - protected T findByName(String name) { - for (T item : myItems) { - if (Comparing.equal(name, myNamer.getName(item))) return item; - } - - return null; - } - - @Override - @Nullable - protected ArrayList createActions(boolean fromPopup) { - ArrayList result = new ArrayList<>(); - result.add(new AddAction()); - - result.add(new MyDeleteAction(forAll(o -> canDelete((T) ((MyNode) o).getConfigurable().getEditableObject())))); - - result.add(new CopyAction()); - - return result; - } - - private void addNewNode(T item) { - addNode(new MyNode(new ItemConfigurable(item)), myRoot); - myItems.add(item); - } - - protected boolean canDelete(T item) { - return true; - } - - protected abstract UnnamedConfigurable createConfigurable(T item); - - @Override - protected void onItemDeleted(Object item) { - //noinspection unchecked - myItems.remove((T)item); - } - - protected void setDisplayName(T item, String name) { - myNamer.setName(item, name); - } - - public void setShowIcons(boolean showIcons) { - myShowIcons = showIcons; - } - - @Nullable - protected UnnamedConfigurable getItemConfigurable(final T item) { - final Ref result = new Ref<>(); - TreeUtil.traverse((TreeNode)myTree.getModel().getRoot(), node -> { - final NamedConfigurable configurable = (NamedConfigurable)((DefaultMutableTreeNode)node).getUserObject(); - if (configurable.getEditableObject() == item) { - //noinspection unchecked - result.set(((ItemConfigurable)configurable).myConfigurable); - return false; - } - else { - return true; - } - }); - return result.get(); - } + } + }); + return result.get(); + } private class ItemConfigurable extends NamedConfigurable { - private final T myItem; - private final UnnamedConfigurable myConfigurable; + private final T myItem; + private final UnnamedConfigurable myConfigurable; - public ItemConfigurable(T item) { - super(myNamer.canRename(item), TREE_UPDATER); - myItem = item; - myConfigurable = createConfigurable(item); - } + public ItemConfigurable(T item) { + super(myNamer.canRename(item), TREE_UPDATER); + myItem = item; + myConfigurable = createConfigurable(item); + } - @Override - public void setDisplayName(String name) { - NamedItemsListEditor.this.setDisplayName(myItem, name); - } + @Override + public void setDisplayName(String name) { + NamedItemsListEditor.this.setDisplayName(myItem, name); + } - @Override - public Object getEditableObject() { - return myItem; - } + @Override + public Object getEditableObject() { + return myItem; + } - @Override - public String getBannerSlogan() { - return myNamer.getName(myItem); - } + @Override + public String getBannerSlogan() { + return myNamer.getName(myItem); + } - @Override - public JComponent createOptionsPanel() { - return myConfigurable.createComponent(); - } + @Override + public JComponent createOptionsPanel() { + return myConfigurable.createComponent(); + } - @Override - public String getDisplayName() { - return myNamer.getName(myItem); - } + @Override + public String getDisplayName() { + return myNamer.getName(myItem); + } - @Override - public Icon getIcon(boolean expanded) { - if (myShowIcons && myConfigurable instanceof Iconable) { - return ((Iconable)myConfigurable).getIcon(0); - } - return null; - } + @Override + public Icon getIcon(boolean expanded) { + if (myShowIcons && myConfigurable instanceof Iconable) { + return ((Iconable)myConfigurable).getIcon(0); + } + return null; + } @Override public String getHelpTopic() { - return null; - } - - @Override - public boolean isModified() { - return myConfigurable.isModified(); - } - - @Override - public void apply() throws ConfigurationException { - myConfigurable.apply(); - } - - @Override - public void reset() { - myConfigurable.reset(); - } - - @Override - public void disposeUIResources() { - myConfigurable.disposeUIResources(); - } + return null; } @Override public boolean isModified() { - if (myResultItems.size() != myItems.size()) return true; - - for (int i = 0; i < myItems.size(); i++) { - if (!myComparer.equals(myItems.get(i), myResultItems.get(i))) return true; - } - - return super.isModified(); + return myConfigurable.isModified(); } @Override public void apply() throws ConfigurationException { - super.apply(); - myResultItems = myItems; + myConfigurable.apply(); } - protected List getCurrentItems() { - return Collections.unmodifiableList(myItems); + @Override + public void reset() { + myConfigurable.reset(); } - public List getItems() { - return myResultItems; + @Override + public void disposeUIResources() { + myConfigurable.disposeUIResources(); + } + } + + @Override + public boolean isModified() { + if (myResultItems.size() != myItems.size()) return true; + + for (int i = 0; i < myItems.size(); i++) { + if (!myComparer.equals(myItems.get(i), myResultItems.get(i))) return true; } - public T getSelectedItem() { - //noinspection unchecked - return (T) getSelectedObject(); + return super.isModified(); + } + + @Override + public void apply() throws ConfigurationException { + super.apply(); + myResultItems = myItems; + } + + protected List getCurrentItems() { + return Collections.unmodifiableList(myItems); + } + + public List getItems() { + return myResultItems; + } + + public T getSelectedItem() { + //noinspection unchecked + return (T)getSelectedObject(); + } + + + private class CopyAction extends DumbAwareAction { + public CopyAction() { + super("Copy", "Copy", MasterDetailsComponent.COPY_ICON); + registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK)), myTree); + } + + @Override + public void actionPerformed(AnActionEvent event) { + final String profileName = askForProfileName("Copy {0}"); + if (profileName == null) return; + + @SuppressWarnings("unchecked") final T clone = myCloner.copyOf((T)getSelectedObject()); + myNamer.setName(clone, profileName); + addNewNode(clone); + selectNodeInTree(clone); + onItemCloned(clone); } - private class CopyAction extends DumbAwareAction { - public CopyAction() { - super("Copy", "Copy", MasterDetailsComponent.COPY_ICON); - registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK)), myTree); - } - - @Override - public void actionPerformed(AnActionEvent event) { - final String profileName = askForProfileName("Copy {0}"); - if (profileName == null) return; - - @SuppressWarnings("unchecked") final T clone = myCloner.copyOf((T) getSelectedObject()); - myNamer.setName(clone, profileName); - addNewNode(clone); - selectNodeInTree(clone); - onItemCloned(clone); - } - - - @Override - public void update(AnActionEvent event) { - super.update(event); - event.getPresentation().setEnabled(getSelectedObject() != null); - } + @Override + public void update(AnActionEvent event) { + super.update(event); + event.getPresentation().setEnabled(getSelectedObject() != null); } + } - protected void onItemCloned(T clone) { - } + protected void onItemCloned(T clone) { + } private class AddAction extends DumbAwareAction { - public AddAction() { - super("Add", "Add", IconUtil.getAddIcon()); - registerCustomShortcutSet(CommonShortcuts.INSERT, myTree); - } - - @Override - public void actionPerformed(AnActionEvent event) { - final T newItem = createItem(); - if (newItem != null) { - onItemCreated(newItem); - } - } + public AddAction() { + super("Add", "Add", IconUtil.getAddIcon()); + registerCustomShortcutSet(CommonShortcuts.INSERT, myTree); } - public void selectItem(T item) { - selectNodeInTree(findByName(myNamer.getName(item))); + @Override + public void actionPerformed(AnActionEvent event) { + final T newItem = createItem(); + if (newItem != null) { + onItemCreated(newItem); + } } + } - @Nullable - protected T createItem() { - final String name = askForProfileName("Create new {0}"); - if (name == null) return null; - final T newItem = myFactory.create(); - myNamer.setName(newItem, name); - return newItem; - } + public void selectItem(T item) { + selectNodeInTree(findByName(myNamer.getName(item))); + } - protected void onItemCreated(T newItem) { - addNewNode(newItem); - selectNodeInTree(newItem); - } + @Nullable + protected T createItem() { + final String name = askForProfileName("Create new {0}"); + if (name == null) return null; + final T newItem = myFactory.create(); + myNamer.setName(newItem, name); + return newItem; + } + protected void onItemCreated(T newItem) { + addNewNode(newItem); + selectNodeInTree(newItem); + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceDetails.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceDetails.java index 7a42a29d218f..5e72ef6913e7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceDetails.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceDetails.java @@ -1,22 +1,9 @@ /* - * 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. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. */ package org.jetbrains.idea.svn.history; import com.intellij.openapi.application.ModalityState; -import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.MasterDetailsComponent; @@ -87,14 +74,6 @@ public class SvnMergeSourceDetails extends MasterDetailsComponent { } } - protected void processRemovedItems() { - - } - - protected boolean wasObjectStored(final Object editableObject) { - return false; - } - @Nls public String getDisplayName() { return null;