cleanup — default method

This commit is contained in:
Vladimir Krivosheev
2017-01-23 12:41:35 +01:00
parent 971ef4b079
commit d5ce9a7c64
12 changed files with 80 additions and 59 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -96,6 +96,7 @@ public class FacetTypeEditor extends UnnamedConfigurableGroup {
super.disposeUIResources();
}
@Override
public JComponent createComponent() {
MultipleFacetSettingsEditor allFacetsEditor = createAllFacetsEditor();
if (myAllFacetsEditor != null) {
@@ -142,28 +143,31 @@ public class FacetTypeEditor extends UnnamedConfigurableGroup {
myEditor = editor;
}
@Override
public String getDisplayName() {
return ProjectBundle.message("tab.name.all.facets");
}
@Override
public String getHelpTopic() {
return myEditor.getHelpTopic();
}
@Override
public JComponent createComponent() {
return myEditor.createComponent();
}
@Override
public boolean isModified() {
return false;
}
@Override
public void apply() throws ConfigurationException {
}
public void reset() {
}
@Override
public void disposeUIResources() {
myEditor.disposeUIResources();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -31,15 +31,6 @@ class ModuleConfigurableWrapper implements ModuleConfigurationEditor {
myModuleConfigurable = moduleConfigurable;
}
@Override
public void saveData() {
}
@Override
public void moduleStateChanged() {
}
@Override
public String getDisplayName() {
return myModuleConfigurable.getDisplayName();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -18,7 +18,11 @@ package com.intellij.openapi.module;
import com.intellij.openapi.options.Configurable;
public interface ModuleConfigurationEditor extends Configurable {
void saveData();
void moduleStateChanged();
default void saveData() {
}
default void moduleStateChanged() {
}
ModuleConfigurationEditor[] EMPTY = new ModuleConfigurationEditor[0];
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -52,10 +52,6 @@ public class PowerSaveHectorProvider implements HectorComponentPanelsProvider {
public void reset() {
myCheckBox.setSelected(PowerSaveMode.isEnabled());
}
@Override
public void disposeUIResources() {
}
};
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -340,10 +340,6 @@ public class CommonContentEntriesEditor extends ModuleElementsEditor {
return false;
}
@Override
public void saveData() {
}
protected void addContentEntryPanels(ContentEntry[] contentEntriesArray) {
for (ContentEntry contentEntry : contentEntriesArray) {
addContentEntryPanel(contentEntry.getUrl());
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -30,8 +30,8 @@ import javax.swing.*;
/**
* @author Eugene Zhuravlev
* Date: Oct 4, 2003
* Time: 7:24:37 PM
* Date: Oct 4, 2003
* Time: 7:24:37 PM
*/
public abstract class ModuleElementsEditor implements ModuleConfigurationEditor {
@NotNull protected final Project myProject;
@@ -65,13 +65,14 @@ public abstract class ModuleElementsEditor implements ModuleConfigurationEditor
}
public void canApply() throws ConfigurationException {}
@Override
public void apply() throws ConfigurationException {}
@Override
public void reset() {}
@Override
public void moduleStateChanged() {}
public void moduleCompileOutputChanged(final String baseUrl, final String moduleName){}
public void moduleCompileOutputChanged(final String baseUrl, final String moduleName) {}
@Override
public void disposeUIResources() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -75,10 +75,6 @@ public interface SearchableConfigurable extends Configurable {
public void apply() throws ConfigurationException {
}
@Override
public void reset() {
}
@Override
public void disposeUIResources() {
myKids = null;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -59,7 +59,8 @@ public interface UnnamedConfigurable {
* Loads the settings from the configurable component to the Swing form.
* This method is called on EDT immediately after the form creation or later upon user's request.
*/
void reset();
default void reset() {
}
/**
* Notifies the configurable component that the Swing form will be closed.
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -67,15 +67,18 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
@NonNls public static final String TREE_NAME = "treeName";
protected History myHistory = new History(new Place.Navigator() {
@Override
public void setHistory(final History history) {
myHistory = history;
}
@Override
@Nullable
public ActionCallback navigateTo(@Nullable final Place place, final boolean requestFocus) {
return null;
}
@Override
public void queryPlace(@NotNull final Place place) {
}
});
@@ -91,6 +94,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
{
TREE_UPDATER = new Runnable() {
@Override
public void run() {
final TreePath selectionPath = myTree.getSelectionPath();
if (selectionPath == null) return;
@@ -100,7 +104,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
myState.setLastEditedConfigurable(getNodePathString(node)); //survive after rename;
myDetails.setText(node.getConfigurable().getBannerSlogan());
node.reloadNode((DefaultTreeModel)MasterDetailsComponent.this.myTree.getModel());
node.reloadNode((DefaultTreeModel)myTree.getModel());
fireItemsChangedExternally();
}
};
@@ -141,6 +145,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
if (!myToReInitWholePanel) return;
myWholePanel = new JPanel(new BorderLayout()) {
@Override
public void addNotify() {
super.addNotify();
MasterDetailsComponent.this.addNotify();
@@ -162,6 +167,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
myWholePanel.add(mySplitter, BorderLayout.CENTER);
JPanel left = new JPanel(new BorderLayout()) {
@Override
public Dimension getMinimumSize() {
final Dimension original = super.getMinimumSize();
return new Dimension(Math.max(original.width, 100), original.height);
@@ -191,18 +197,22 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
private void installAutoScroll() {
myAutoScrollHandler = new AutoScrollToSourceHandler() {
@Override
protected boolean isAutoScrollMode() {
return isAutoScrollEnabled();
}
@Override
protected void setAutoScrollMode(boolean state) {
//do nothing
}
@Override
protected void scrollToSource(Component tree) {
updateSelectionFromTree();
}
@Override
protected boolean needToCheckFocus() {
return false;
}
@@ -244,6 +254,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
return false;
}
@Override
public DetailsComponent getDetailsComponent() {
return myDetails;
}
@@ -281,7 +292,8 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
return JBUI.size(800, 600);
}
@NotNull
@Override
@NotNull
public JComponent createComponent() {
myTree.updateUI();
reInitWholePanelIfNeeded();
@@ -289,6 +301,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
updateSelectionFromTree();
final JPanel panel = new JPanel(new BorderLayout()) {
@Override
public Dimension getPreferredSize() {
return getPanelPreferredSize();
}
@@ -297,6 +310,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
return panel;
}
@Override
public boolean isModified() {
if (myHasDeletedItems) return true;
final boolean[] modified = new boolean[1];
@@ -317,6 +331,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
return myInitializedConfigurables.contains(configurable);
}
@Override
public void apply() throws ConfigurationException {
processRemovedItems();
final ConfigurationException[] ex = new ConfigurationException[1];
@@ -345,6 +360,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
protected abstract boolean wasObjectStored(Object editableObject);
@Override
public void reset() {
loadComponentState();
myHasDeletedItems = false;
@@ -419,6 +435,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
XmlSerializerUtil.copyBean(object, myState);
}
@Override
public void disposeUIResources() {
myState.getProportions().saveSplitterProportions(myWholePanel);
myAutoScrollHandler.cancelAllRequests();
@@ -460,6 +477,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
UIUtil.setLineStyleAngled(myTree);
TreeUtil.installActions(myTree);
myTree.setCellRenderer(new ColoredTreeCellRenderer() {
@Override
public void customizeCellRenderer(JTree tree,
Object value,
boolean selected,
@@ -519,12 +537,14 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
private void createUIComponents() {
myTree = new Tree() {
@Override
public Dimension getPreferredScrollableViewportSize() {
Dimension size = super.getPreferredScrollableViewportSize();
size = new Dimension(size.width + 20, size.height);
return size;
}
@Override
@SuppressWarnings({"NonStaticInitializer"})
public JToolTip createToolTip() {
final JToolTip toolTip = new JToolTip() {
@@ -669,6 +689,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
myDetails.setEmptyContentText(getEmptySelectionString());
}
@Override
public String getHelpTopic() {
if (myCurrentConfigurable != null) {
return myCurrentConfigurable.getHelpTopic();
@@ -804,6 +825,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
myCondition = availableCondition;
}
@Override
public void update(AnActionEvent e) {
final Presentation presentation = e.getPresentation();
presentation.setEnabled(false);
@@ -815,6 +837,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
}
}
@Override
public void actionPerformed(AnActionEvent e) {
removePaths(myTree.getSelectionPaths());
}
@@ -879,44 +902,45 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
protected static class MyRootNode extends MyNode {
public MyRootNode() {
super(new NamedConfigurable(false, null) {
@Override
public void setDisplayName(String name) {
}
@Override
public Object getEditableObject() {
return null;
}
@Override
public String getBannerSlogan() {
return null;
}
@Override
public String getDisplayName() {
return "";
}
@Override
@Nullable
@NonNls
public String getHelpTopic() {
return null;
}
@Override
public JComponent createOptionsPanel() {
return null;
}
@Override
public boolean isModified() {
return false;
}
@Override
public void apply() throws ConfigurationException {
}
public void reset() {
}
public void disposeUIResources() {
}
}, false);
}
}
@@ -949,6 +973,7 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
registerCustomShortcutSet(actionGroup.getShortcutSet(), myTree);
}
@Override
public void actionPerformed(AnActionEvent e) {
final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
final DataContext dataContext = e.getDataContext();
@@ -965,21 +990,25 @@ public abstract class MasterDetailsComponent implements Configurable, DetailsCom
}
}
@Override
public JComponent getToolbar() {
myToReInitWholePanel = true;
return myNorthPanel;
}
@Override
public JComponent getMaster() {
myToReInitWholePanel = true;
return myMaster;
}
@Override
public DetailsComponent getDetails() {
myToReInitWholePanel = true;
return myDetails;
}
@Override
public void initUi() {
createComponent();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -60,11 +60,13 @@ public class PluginModuleBuildConfEditor implements ModuleConfigurationEditor {
myBuildProperties = PluginBuildConfiguration.getInstance(myModule);
}
@Override
public JComponent createComponent() {
myPluginXML.addActionListener(new BrowseFilesListener(myPluginXML.getTextField(), DevKitBundle.message("deployment.directory.location", META_INF), DevKitBundle.message("saved.message.common", META_INF + File.separator + PLUGIN_XML), BrowseFilesListener.SINGLE_DIRECTORY_DESCRIPTOR));
myManifest.addActionListener(new BrowseFilesListener(myManifest.getTextField(), DevKitBundle.message("deployment.view.select", MANIFEST_MF), DevKitBundle.message("manifest.selection", MANIFEST_MF), BrowseFilesListener.SINGLE_FILE_DESCRIPTOR));
myManifest.setEnabled(myBuildProperties.isUseUserManifest());
myUseUserManifest.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final boolean selected = myUseUserManifest.isSelected();
@@ -87,6 +89,7 @@ public class PluginModuleBuildConfEditor implements ModuleConfigurationEditor {
return myWholePanel;
}
@Override
public boolean isModified() {
final String pluginXmlPath = new File(myBuildProperties.getPluginXmlPath()).getParentFile().getParent(); //parent for meta-inf
boolean modified = !Comparing.strEqual(myPluginXML.getText(), pluginXmlPath);
@@ -98,6 +101,7 @@ public class PluginModuleBuildConfEditor implements ModuleConfigurationEditor {
return modified;
}
@Override
public void apply() throws ConfigurationException {
if (myUseUserManifest.isSelected() && myManifest.getText() != null && !new File(myManifest.getText()).exists()){
throw new ConfigurationException(DevKitBundle.message("error.file.not.found.message", myManifest.getText()));
@@ -118,24 +122,24 @@ public class PluginModuleBuildConfEditor implements ModuleConfigurationEditor {
myBuildProperties.setUseUserManifest(myUseUserManifest.isSelected());
}
@Override
public void reset() {
myPluginXML.setText(myBuildProperties.getPluginXmlPath().substring(0, myBuildProperties.getPluginXmlPath().length() - META_INF.length() - PLUGIN_XML.length() - 2));
myManifest.setText(myBuildProperties.getManifestPath());
myUseUserManifest.setSelected(myBuildProperties.isUseUserManifest());
}
public void disposeUIResources() {}
public void saveData() {}
@Override
public String getDisplayName() {
return DevKitBundle.message("deployment.title");
}
@Override
public String getHelpTopic() {
return "plugin.configuring";
}
@Override
public void moduleStateChanged() {
}
@@ -90,9 +90,6 @@ public class EditorConfigConfigurable extends CodeStyleSettingsProvider implemen
@Override
public void apply() throws ConfigurationException {}
@Override
public void reset() {}
@Override
public boolean hasSettingsPage() {
return false;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2017 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.
@@ -27,6 +27,7 @@ import com.intellij.util.IconUtil;
import com.intellij.util.PlatformIcons;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.svn.SvnBundle;
import org.jetbrains.idea.svn.SvnServerFileManager;
@@ -55,6 +56,7 @@ public class SvnConfigureProxiesComponent extends MasterDetailsComponent {
validator.add(this);
}
@NotNull
public JComponent createComponent() {
if (myComponent == null) {
myComponent = super.createComponent();