mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup (default method impl), avoid ArrayList in API
This commit is contained in:
+4
-27
@@ -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() {
|
||||
|
||||
+13
-26
@@ -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<ModuleDependenciesAnalyzer.OrderPathElement> ORDER_PATH_ELEMENT_KEY = DataKey.create("ORDER_PATH_ELEMENT");
|
||||
public static final DataKey<ModuleDependenciesAnalyzer.OrderPathElement> 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<AnAction> createActions(boolean fromPopup) {
|
||||
if (!fromPopup) {
|
||||
ArrayList<AnAction> rc = new ArrayList<>();
|
||||
rc.add(new ClasspathTypeAction());
|
||||
rc.add(new SdkFilterAction());
|
||||
rc.add(new UrlModeAction());
|
||||
return rc;
|
||||
}
|
||||
else {
|
||||
return super.createActions(fromPopup);
|
||||
protected List<AnAction> createActions(boolean fromPopup) {
|
||||
if (fromPopup) {
|
||||
return super.createActions(true);
|
||||
}
|
||||
|
||||
List<AnAction> 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
|
||||
*/
|
||||
|
||||
-9
@@ -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
|
||||
|
||||
+1
-22
@@ -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");
|
||||
|
||||
+2
-22
@@ -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;
|
||||
}
|
||||
|
||||
-15
@@ -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");
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -254,7 +254,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
|
||||
}
|
||||
|
||||
protected DefaultActionGroup createToolbarActionGroup() {
|
||||
final ArrayList<AnAction> actions = createActions(false);
|
||||
final List<AnAction> 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<AnAction> createActions(final boolean fromPopup) {
|
||||
protected List<AnAction> 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<AnAction> actions = createActions(true);
|
||||
List<AnAction> 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 {
|
||||
|
||||
@@ -31,304 +31,300 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class NamedItemsListEditor<T> extends MasterDetailsComponent {
|
||||
private final Namer<T> myNamer;
|
||||
private final Factory<T> myFactory;
|
||||
private final Cloner<T> myCloner;
|
||||
private final List<T> myItems = new ArrayList<>();
|
||||
private final Equality<T> myComparer;
|
||||
private List<T> myResultItems;
|
||||
private final List<T> myOriginalItems;
|
||||
private boolean myShowIcons;
|
||||
private final Namer<T> myNamer;
|
||||
private final Factory<T> myFactory;
|
||||
private final Cloner<T> myCloner;
|
||||
private final List<T> myItems = new ArrayList<>();
|
||||
private final Equality<T> myComparer;
|
||||
private List<T> myResultItems;
|
||||
private final List<T> myOriginalItems;
|
||||
private boolean myShowIcons;
|
||||
|
||||
protected NamedItemsListEditor(Namer<T> namer,
|
||||
Factory<T> factory,
|
||||
Cloner<T> cloner,
|
||||
Equality<T> comparer,
|
||||
List<T> items) {
|
||||
this(namer, factory, cloner, comparer, items, true);
|
||||
protected NamedItemsListEditor(Namer<T> namer,
|
||||
Factory<T> factory,
|
||||
Cloner<T> cloner,
|
||||
Equality<T> comparer,
|
||||
List<T> items) {
|
||||
this(namer, factory, cloner, comparer, items, true);
|
||||
}
|
||||
|
||||
protected NamedItemsListEditor(Namer<T> namer,
|
||||
Factory<T> factory,
|
||||
Cloner<T> cloner,
|
||||
Equality<T> comparer,
|
||||
List<T> 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<T> namer,
|
||||
Factory<T> factory,
|
||||
Cloner<T> cloner,
|
||||
Equality<T> comparer,
|
||||
List<T> 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<AnAction> createActions(boolean fromPopup) {
|
||||
ArrayList<AnAction> 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<UnnamedConfigurable> 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<AnAction> createActions(boolean fromPopup) {
|
||||
ArrayList<AnAction> 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<UnnamedConfigurable> 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<T> getCurrentItems() {
|
||||
return Collections.unmodifiableList(myItems);
|
||||
@Override
|
||||
public void reset() {
|
||||
myConfigurable.reset();
|
||||
}
|
||||
|
||||
public List<T> 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<T> getCurrentItems() {
|
||||
return Collections.unmodifiableList(myItems);
|
||||
}
|
||||
|
||||
public List<T> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user