From 6189bb94de8f0e5656f34c33ded693abaa76cfe7 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 28 Apr 2017 15:05:25 +0300 Subject: [PATCH] cleanup --- .../ProjectStructureElementConfigurable.java | 8 --- .../com/intellij/lang/LanguageExtension.java | 1 - .../openapi/ui/MasterDetailsComponent.java | 58 ++++++++----------- 3 files changed, 24 insertions(+), 43 deletions(-) diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ProjectStructureElementConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ProjectStructureElementConfigurable.java index ddbf9f5e8b58..b12b46efdb5a 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ProjectStructureElementConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/ProjectStructureElementConfigurable.java @@ -19,8 +19,6 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStr import com.intellij.openapi.ui.NamedConfigurable; import org.jetbrains.annotations.Nullable; -import javax.swing.*; - /** * @author nik */ @@ -34,10 +32,4 @@ public abstract class ProjectStructureElementConfigurable extends NamedConfig @Nullable public abstract ProjectStructureElement getProjectStructureElement(); - - @Override - @Nullable - public Icon getIcon(boolean open) { - return null; - } } diff --git a/platform/core-api/src/com/intellij/lang/LanguageExtension.java b/platform/core-api/src/com/intellij/lang/LanguageExtension.java index f94c033acbbe..00f989797478 100644 --- a/platform/core-api/src/com/intellij/lang/LanguageExtension.java +++ b/platform/core-api/src/com/intellij/lang/LanguageExtension.java @@ -51,7 +51,6 @@ public class LanguageExtension extends KeyedExtensionCollector { return key.getID(); } - @SuppressWarnings("ConstantConditions") public T forLanguage(@NotNull Language l) { T cached = l.getUserData(IN_LANGUAGE_CACHE); if (cached != null) return cached; 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 721c1c8a9db5..ab2e811663a7 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/MasterDetailsComponent.java @@ -91,10 +91,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom protected final MasterDetailsState myState; - protected Runnable TREE_UPDATER; - - { - TREE_UPDATER = new Runnable() { + protected final Runnable TREE_UPDATER = new Runnable() { @Override public void run() { final TreePath selectionPath = myTree.getSelectionPath(); @@ -109,7 +106,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom fireItemsChangedExternally(); } }; - } + protected MyNode myRoot = new MyRootNode(); protected Tree myTree = new Tree(); @@ -454,7 +451,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom protected void clearChildren() { TreeUtil.traverseDepth(myRoot, node -> { if (node instanceof MyNode) { - final MyNode treeNode = ((MyNode)node); + final MyNode treeNode = (MyNode)node; treeNode.getConfigurable().disposeUIResources(); if (!(treeNode instanceof MyRootNode)) { treeNode.setUserObject(null); @@ -479,7 +476,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom TreeUtil.installActions(myTree); myTree.setCellRenderer(new ColoredTreeCellRenderer() { @Override - public void customizeCellRenderer(JTree tree, + public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, @@ -487,7 +484,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom int row, boolean hasFocus) { if (value instanceof MyNode) { - final MyNode node = ((MyNode)value); + final MyNode node = (MyNode)value; setIcon(node.getIcon(expanded)); final Font font = UIUtil.getTreeFont(); if (node.isDisplayInBold()) { @@ -524,7 +521,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom return null; } - public void fireItemsChangeListener(final Object editableObject) { + private void fireItemsChangeListener(final Object editableObject) { for (ItemsChangeListener listener : myListeners) { listener.itemChanged(editableObject); } @@ -546,7 +543,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom } @Override - @SuppressWarnings({"NonStaticInitializer"}) + @SuppressWarnings("NonStaticInitializer") public JToolTip createToolTip() { final JToolTip toolTip = new JToolTip() { { @@ -584,16 +581,12 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom public ActionCallback selectNodeInTree(final DefaultMutableTreeNode nodeToSelect, boolean center, final boolean requestFocus) { if (requestFocus) { - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> { - IdeFocusManager.getGlobalInstance().requestFocus(myTree, true); - }); + IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> IdeFocusManager.getGlobalInstance().requestFocus(myTree, true)); } if (nodeToSelect != null) { return TreeUtil.selectInTree(nodeToSelect, requestFocus, myTree, center); } - else { - return TreeUtil.selectFirstNode(myTree); - } + return TreeUtil.selectFirstNode(myTree); } @Nullable @@ -700,7 +693,8 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom return null; } - protected @Nullable String getEmptySelectionString() { + @Nullable + protected String getEmptySelectionString() { return null; } @@ -709,7 +703,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom } /** - * @deprecated use {@link #checkForEmptyAndDuplicatedNames(String, String, Class} instead + * @deprecated use {@link #checkForEmptyAndDuplicatedNames(String, String, Class)} instead */ protected void checkApply(Set rootNodes, String prefix, String title) throws ConfigurationException { for (MyNode rootNode : rootNodes) { @@ -734,7 +728,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom if (configurableClass.isInstance(scopeConfigurable)) { final String name = scopeConfigurable.getDisplayName(); - if (name.trim().length() == 0) { + if (name.trim().isEmpty()) { selectNodeInTree(node); throw new ConfigurationException("Name should contain non-space characters"); } @@ -791,13 +785,16 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom if (idx > 0 && parentNode.getChildCount() > 0) { if (idx - 1 < parentNode.getChildCount()) { toSelect = (DefaultMutableTreeNode) parentNode.getChildAt(idx - 1); - } else { + } + else { toSelect = (DefaultMutableTreeNode) parentNode.getFirstChild(); } - } else { + } + else { if (parentNode.isRoot() && myTree.isRootVisible()) { toSelect = parentNode; - } else if (parentNode.getChildCount() > 0) { + } + else if (parentNode.getChildCount() > 0) { toSelect = (DefaultMutableTreeNode) parentNode.getFirstChild(); } } @@ -835,7 +832,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom presentation.setEnabled(false); final TreePath[] selectionPath = myTree.getSelectionPaths(); if (selectionPath != null) { - Object[] nodes = ContainerUtil.map2Array(selectionPath, treePath -> treePath.getLastPathComponent()); + Object[] nodes = ContainerUtil.map2Array(selectionPath, TreePath::getLastPathComponent); if (!myCondition.value(nodes)) return; presentation.setEnabled(true); } @@ -870,7 +867,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom @NotNull public String getDisplayName() { - final NamedConfigurable configurable = ((NamedConfigurable)getUserObject()); + final NamedConfigurable configurable = (NamedConfigurable)getUserObject(); LOG.assertTrue(configurable != null, "Tree was already disposed"); return configurable.getDisplayName(); } @@ -902,7 +899,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom } } - @SuppressWarnings({"ConstantConditions"}) + @SuppressWarnings("ConstantConditions") protected static class MyRootNode extends MyNode { public MyRootNode() { super(new NamedConfigurable(false, null) { @@ -925,13 +922,6 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom return ""; } - @Override - @Nullable - @NonNls - public String getHelpTopic() { - return null; - } - @Override public JComponent createOptionsPanel() { return null; @@ -943,7 +933,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom } @Override - public void apply() throws ConfigurationException { + public void apply() { } }, false); } @@ -962,7 +952,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom } protected class MyActionGroupWrapper extends AnAction implements DumbAware { - private ActionGroup myActionGroup; + private final ActionGroup myActionGroup; private ActionGroupWithPreselection myPreselection; public MyActionGroupWrapper(final ActionGroupWithPreselection actionGroup) {