Replace OptionalConfigurable with ConfigurableProvider

This commit is contained in:
Sergey Malenkov
2014-12-19 15:14:25 +03:00
parent c57b73d20c
commit d966d9191a
14 changed files with 219 additions and 53 deletions
@@ -44,7 +44,7 @@ import java.awt.*;
import java.nio.charset.Charset;
import java.util.Map;
public class FileEncodingConfigurable implements SearchableConfigurable, OptionalConfigurable, Configurable.NoScroll {
public class FileEncodingConfigurable implements SearchableConfigurable, Configurable.NoScroll {
private final Project myProject;
private EncodingFileTreeTable myTreeView;
private JScrollPane myTreePanel;
@@ -205,10 +205,4 @@ public class FileEncodingConfigurable implements SearchableConfigurable, Optiona
private void createUIComponents() {
myTreePanel = ScrollPaneFactory.createScrollPane(new JBTable());
}
@Override
public boolean needDisplay() {
// TODO[yole] cleaner API
return !PlatformUtils.isRubyMine();
}
}
@@ -0,0 +1,42 @@
/*
* Copyright 2000-2014 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.
*/
package com.intellij.openapi.vfs.encoding;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurableProvider;
import com.intellij.openapi.project.Project;
import com.intellij.util.PlatformUtils;
/**
* @author Sergey.Malenkov
*/
public final class FileEncodingConfigurableProvider extends ConfigurableProvider {
private final Project myProject;
public FileEncodingConfigurableProvider(Project project) {
myProject = project;
}
@Override
public boolean canCreateConfigurable() {
return !PlatformUtils.isRubyMine();
}
@Override
public Configurable createConfigurable() {
return new FileEncodingConfigurable(myProject);
}
}
@@ -29,7 +29,7 @@ import javax.swing.*;
/**
* @author spleaner
*/
public class NotificationsConfigurable implements Configurable, SearchableConfigurable, OptionalConfigurable, Configurable.NoScroll {
public class NotificationsConfigurable implements Configurable, SearchableConfigurable, Configurable.NoScroll {
public static final String DISPLAY_NAME = "Notifications";
private NotificationsConfigurablePanel myComponent;
@@ -85,9 +85,4 @@ public class NotificationsConfigurable implements Configurable, SearchableConfig
public Runnable enableSearch(final String option) {
return null;
}
@Override
public boolean needDisplay() {
return NotificationsConfigurationImpl.getInstanceImpl().getAllSettings().length > 0;
}
}
@@ -0,0 +1,34 @@
/*
* Copyright 2000-2014 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.
*/
package com.intellij.notification.impl;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurableProvider;
/**
* @author Sergey.Malenkov
*/
public final class NotificationsConfigurableProvider extends ConfigurableProvider {
@Override
public boolean canCreateConfigurable() {
return NotificationsConfigurationImpl.getInstanceImpl().getAllSettings().length > 0;
}
@Override
public Configurable createConfigurable() {
return new NotificationsConfigurable();
}
}
@@ -737,7 +737,12 @@
<psi.fileReferenceHelper implementation="com.intellij.psi.impl.source.resolve.reference.impl.providers.HttpFileReferenceHelper"/>
<psi.fileReferenceHelper implementation="com.intellij.psi.impl.source.resolve.reference.impl.providers.NullFileReferenceHelper" order="last"/>
<projectConfigurable groupId="editor" groupWeight="140" key="file.encodings.configurable" bundle="messages.IdeBundle" id="File.Encoding" instance="com.intellij.openapi.vfs.encoding.FileEncodingConfigurable"/>
<projectConfigurable groupId="editor"
groupWeight="140"
key="file.encodings.configurable"
bundle="messages.IdeBundle"
id="File.Encoding"
provider="com.intellij.openapi.vfs.encoding.FileEncodingConfigurableProvider"/>
<projectConfigurable groupId="appearance" groupWeight="112" instance="com.intellij.ui.tabs.FileColorsConfigurable" id="reference.settings.ide.settings.file-colors" displayName="File Colors"/>
<uiDebuggerExtension implementation="com.intellij.ui.debugger.extensions.PlaybackDebugger"/>
@@ -231,7 +231,11 @@
key="title.customizations" bundle="messages.IdeBundle"/>
<!-- Notifications -->
<applicationConfigurable groupId="appearance" groupWeight="110" displayName="Notifications" id="reference.settings.ide.settings.notifications" instance="com.intellij.notification.impl.NotificationsConfigurable"/>
<applicationConfigurable groupId="appearance"
groupWeight="110"
displayName="Notifications"
id="reference.settings.ide.settings.notifications"
provider="com.intellij.notification.impl.NotificationsConfigurableProvider"/>
<!-- Plugins -->
<applicationConfigurable groupId="root" groupWeight="55" instance="com.intellij.ide.plugins.PluginManagerConfigurable" id="preferences.pluginManager"
@@ -17,7 +17,10 @@
serviceImplementation="com.intellij.remoteServer.agent.impl.RemoteAgentManagerImpl"/>
<applicationService serviceInterface="com.intellij.remoteServer.runtime.clientLibrary.ClientLibraryManager"
serviceImplementation="com.intellij.remoteServer.impl.runtime.clientLibrary.ClientLibraryManagerImpl"/>
<applicationConfigurable groupId="build" displayName="Clouds" id="RemoteServers" instance="com.intellij.remoteServer.impl.configuration.RemoteServerListConfigurable"/>
<applicationConfigurable groupId="build"
displayName="Clouds"
id="RemoteServers"
provider="com.intellij.remoteServer.impl.configuration.RemoteServerListConfigurableProvider"/>
<programRunner implementation="com.intellij.remoteServer.impl.runtime.DeployToServerRunner"/>
<projectService serviceInterface="com.intellij.remoteServer.runtime.ui.RemoteServersView"
serviceImplementation="com.intellij.remoteServer.impl.runtime.ui.RemoteServersViewImpl"/>
@@ -30,7 +30,7 @@ import java.util.Set;
/**
* @author nik
*/
public class RemoteServerListConfigurable extends MasterDetailsComponent implements OptionalConfigurable, SearchableConfigurable {
public class RemoteServerListConfigurable extends MasterDetailsComponent implements SearchableConfigurable {
private final RemoteServersManager myServersManager;
@Nullable private final ServerType<?> myServerType;
private RemoteServer<?> myLastSelectedServer;
@@ -138,11 +138,6 @@ public class RemoteServerListConfigurable extends MasterDetailsComponent impleme
return actions;
}
@Override
public boolean needDisplay() {
return ServerType.EP_NAME.getExtensions().length > 0;
}
@Override
protected boolean wasObjectStored(Object editableObject) {
return true;
@@ -0,0 +1,36 @@
/*
* Copyright 2000-2014 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.
*/
package com.intellij.remoteServer.impl.configuration;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurableProvider;
import com.intellij.remoteServer.ServerType;
import com.intellij.remoteServer.configuration.RemoteServersManager;
/**
* @author Sergey.Malenkov
*/
public final class RemoteServerListConfigurableProvider extends ConfigurableProvider {
@Override
public boolean canCreateConfigurable() {
return ServerType.EP_NAME.getExtensions().length > 0;
}
@Override
public Configurable createConfigurable() {
return new RemoteServerListConfigurable(RemoteServersManager.getInstance());
}
}
@@ -17,8 +17,6 @@ package com.jetbrains.python.configuration;
import com.intellij.application.options.ModuleAwareProjectConfigurable;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.options.OptionalConfigurable;
import com.intellij.openapi.options.UnnamedConfigurable;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
@@ -26,12 +24,9 @@ import org.jetbrains.annotations.NotNull;
/**
* @author yole
*/
public class PyDependenciesConfigurable extends ModuleAwareProjectConfigurable implements OptionalConfigurable {
private final Project myProject;
public class PyDependenciesConfigurable extends ModuleAwareProjectConfigurable {
public PyDependenciesConfigurable(Project project) {
super(project, "Project Dependencies", "reference.settingsdialog.project.dependencies");
myProject = project;
}
@NotNull
@@ -39,9 +34,4 @@ public class PyDependenciesConfigurable extends ModuleAwareProjectConfigurable i
protected UnnamedConfigurable createModuleConfigurable(Module module) {
return new PyModuleDependenciesConfigurable(module);
}
@Override
public boolean needDisplay() {
return ModuleManager.getInstance(myProject).getModules().length > 1;
}
}
@@ -0,0 +1,42 @@
/*
* Copyright 2000-2014 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.
*/
package com.jetbrains.python.configuration;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurableProvider;
import com.intellij.openapi.project.Project;
/**
* @author Sergey.Malenkov
*/
public final class PyDependenciesConfigurableProvider extends ConfigurableProvider {
private final Project myProject;
public PyDependenciesConfigurableProvider(Project project) {
myProject = project;
}
@Override
public boolean canCreateConfigurable() {
return ModuleManager.getInstance(myProject).getModules().length > 1;
}
@Override
public Configurable createConfigurable() {
return new PyDependenciesConfigurable(myProject);
}
}
@@ -17,37 +17,20 @@ package com.jetbrains.python.configuration;
import com.intellij.application.options.ModuleAwareProjectConfigurable;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.NonDefaultProjectConfigurable;
import com.intellij.openapi.options.OptionalConfigurable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ui.configuration.PlatformContentEntriesConfigurable;
import com.intellij.util.ArrayUtil;
import com.intellij.util.PlatformUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.java.JavaSourceRootType;
/**
* @author yole
*/
public class PythonContentEntriesConfigurable extends ModuleAwareProjectConfigurable implements NonDefaultProjectConfigurable, OptionalConfigurable {
private final Project myProject;
public class PythonContentEntriesConfigurable extends ModuleAwareProjectConfigurable implements NonDefaultProjectConfigurable {
public PythonContentEntriesConfigurable(final Project project) {
super(project, "Project Structure", "reference.settingsdialog.project.structure");
myProject = project;
}
@Nullable
private static Module getSingleModule(Project project) {
return ArrayUtil.getFirstElement(ModuleManager.getInstance(project).getModules());
}
@Override
public boolean needDisplay() {
return getSingleModule(myProject) != null;
}
@NotNull
@@ -0,0 +1,43 @@
/*
* Copyright 2000-2014 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.
*/
package com.jetbrains.python.configuration;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurableProvider;
import com.intellij.openapi.project.Project;
import com.intellij.util.ArrayUtil;
/**
* @author Sergey.Malenkov
*/
public final class PythonContentEntriesConfigurableProvider extends ConfigurableProvider {
private final Project myProject;
public PythonContentEntriesConfigurableProvider(Project project) {
myProject = project;
}
@Override
public boolean canCreateConfigurable() {
return ArrayUtil.getFirstElement(ModuleManager.getInstance(myProject).getModules()) != null;
}
@Override
public Configurable createConfigurable() {
return new PythonContentEntriesConfigurable(myProject);
}
}
+2 -2
View File
@@ -40,7 +40,7 @@
<projectConfigurable groupId="project"
id="com.jetbrains.python.configuration.PythonContentEntriesConfigurable"
displayName="Project Structure"
instance="com.jetbrains.python.configuration.PythonContentEntriesConfigurable"/>
provider="com.jetbrains.python.configuration.PythonContentEntriesConfigurableProvider"/>
<projectConfigurable groupId="build"
id="com.jetbrains.python.buildout.BuildoutModulesConfigurable"
displayName="Buildout Support"
@@ -52,7 +52,7 @@
<projectConfigurable groupId="project"
id="com.jetbrains.python.configuration.PyDependenciesConfigurable"
displayName="Project Dependencies"
instance="com.jetbrains.python.configuration.PyDependenciesConfigurable"/>
provider="com.jetbrains.python.configuration.PyDependenciesConfigurableProvider"/>
<directoryProjectConfigurator implementation="com.jetbrains.python.PythonSdkConfigurator" id="sdk"
order="after PlatformProjectConfigurator"/>