'Show project structure' actions moved to idea-ui module
authornik <Nikolay.Chashnikov@jetbrains.com>
Tue, 31 Aug 2010 08:21:29 +0000 (12:21 +0400)
committernik <Nikolay.Chashnikov@jetbrains.com>
Tue, 31 Aug 2010 08:21:45 +0000 (12:21 +0400)
java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java [moved from platform/platform-impl/src/com/intellij/ide/actions/ShowStructureSettingsAction.java with 69% similarity]
java/idea-ui/src/com/intellij/ide/actions/TemplateProjectStructureAction.java [moved from platform/platform-impl/src/com/intellij/ide/actions/TemplateProjectStructureAction.java with 78% similarity]
platform/platform-api/src/com/intellij/openapi/options/ShowSettingsUtil.java
platform/platform-impl/src/com/intellij/ide/actions/ShowSettingsUtilImpl.java
platform/platform-impl/src/com/intellij/openapi/options/ex/ProjectConfigurablesGroup.java

similarity index 69%
rename from platform/platform-impl/src/com/intellij/ide/actions/ShowStructureSettingsAction.java
rename to java/idea-ui/src/com/intellij/ide/actions/ShowStructureSettingsAction.java
index a4781c8a0235f8078acbe5e4665d218569c01509..6f4e0fa08cc7def04d20b4f785209ad314307811 100644 (file)
@@ -18,30 +18,20 @@ package com.intellij.ide.actions;
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.options.Configurable;
 import com.intellij.openapi.options.ShowSettingsUtil;
 import com.intellij.openapi.options.newEditor.OptionsEditorDialog;
-import com.intellij.openapi.options.ex.ProjectConfigurablesGroup;
+import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectManager;
-import com.intellij.openapi.project.DumbAware;
-import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
 
 public class ShowStructureSettingsAction extends AnAction implements DumbAware {
-
-  private static final Logger LOG = Logger.getInstance("#com.intellij.ide.actions.ShowStructureSettingsAction");
-
   public void actionPerformed(AnActionEvent e) {
     Project project = PlatformDataKeys.PROJECT.getData(e.getDataContext());
     if (project == null) {
       project = ProjectManager.getInstance().getDefaultProject();
     }
 
-    final Configurable configurable = ProjectConfigurablesGroup.getProjectStructureConfigurable(project);
-    if (configurable != null) {
-      ShowSettingsUtil.getInstance().editConfigurable(project, OptionsEditorDialog.DIMENSION_KEY, configurable);
-    } else {
-      LOG.info("No project structure configurable found");
-    }
+    ShowSettingsUtil.getInstance().editProjectConfigurable(project, ProjectStructureConfigurable.class, OptionsEditorDialog.DIMENSION_KEY);
   }
 }
\ No newline at end of file
similarity index 78%
rename from platform/platform-impl/src/com/intellij/ide/actions/TemplateProjectStructureAction.java
rename to java/idea-ui/src/com/intellij/ide/actions/TemplateProjectStructureAction.java
index 22b98d5b36de864c1edafb0df84fb4bcc29bba70..8386a91d80370ece19aa92fb3267373ffad30aa1 100644 (file)
@@ -17,18 +17,16 @@ package com.intellij.ide.actions;
 
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.options.Configurable;
 import com.intellij.openapi.options.ShowSettingsUtil;
 import com.intellij.openapi.options.newEditor.OptionsEditorDialog;
-import com.intellij.openapi.options.ex.ProjectConfigurablesGroup;
-import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ex.ProjectManagerEx;
+import com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable;
 
 public class TemplateProjectStructureAction extends AnAction implements DumbAware {
   public void actionPerformed(final AnActionEvent e) {
     Project defaultProject = ProjectManagerEx.getInstanceEx().getDefaultProject();
-    final Configurable configurable = ProjectConfigurablesGroup.getProjectStructureConfigurable(defaultProject);
-    ShowSettingsUtil.getInstance().editConfigurable(defaultProject, OptionsEditorDialog.DIMENSION_KEY, configurable);
+    ShowSettingsUtil.getInstance().editProjectConfigurable(defaultProject, ProjectStructureConfigurable.class, OptionsEditorDialog.DIMENSION_KEY);
   }
 }
\ No newline at end of file
index ab78894a72d4b82bb6214d842c5d7d31cf334226..15589dd85a695918db745e05c14a2627fd3e906b 100644 (file)
@@ -46,6 +46,9 @@ public abstract class ShowSettingsUtil {
 
   public abstract boolean editConfigurable(Project project, @NonNls String dimensionServiceKey, Configurable configurable);
 
+  public abstract boolean editProjectConfigurable(@NotNull Project project, Class<? extends Configurable> configurableClass,
+                                                  @NonNls @Nullable String dimensionServiceKey);
+
   public abstract boolean editConfigurable(Component parent, String dimensionServiceKey, Configurable configurable);
 
   public abstract <T extends Configurable> T findProjectConfigurable(Project project, Class<T> confClass);
index 2492b85246b7a4c56273eec10a97c64dd74e5b04..f1feefdc86bcbb188888671781b7f513e7c3f251 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.ide.actions;
 
 import com.intellij.ide.util.PropertiesComponent;
 import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.options.Configurable;
 import com.intellij.openapi.options.ConfigurableGroup;
 import com.intellij.openapi.options.ShowSettingsUtil;
@@ -36,6 +37,7 @@ import java.util.List;
  * @author max
  */
 public class ShowSettingsUtilImpl extends ShowSettingsUtil {
+  private static final Logger LOG = Logger.getInstance("#com.intellij.ide.actions.ShowSettingsUtilImpl");
   @NonNls
   private static final String PREFER_CLASSIC_OPTIONS_EDITOR = "PREFER_CLASSIC_OPTIONS_EDITOR";
 
@@ -147,6 +149,21 @@ public class ShowSettingsUtilImpl extends ShowSettingsUtil {
     return configurableEditor.isOK();
   }
 
+  @Override
+  public boolean editProjectConfigurable(@NotNull Project project,
+                                         Class<? extends Configurable> configurableClass,
+                                         @NonNls String dimensionServiceKey) {
+    final Configurable configurable = findProjectConfigurable(project, configurableClass);
+    if (configurable == null) {
+      LOG.error("Cannot find project configurable for " + configurableClass);
+      return false;
+    }
+    if (dimensionServiceKey == null) {
+      dimensionServiceKey = createDimensionKey(configurable);
+    }
+    return editConfigurable(project, dimensionServiceKey, configurable);
+  }
+
   public boolean editConfigurable(Component parent, Configurable configurable) {
     final SingleConfigurableEditor configurableEditor = new SingleConfigurableEditor(parent, configurable, createDimensionKey(configurable));
     configurableEditor.show();
index 6a30cb8420121f2ebc5cc12717f69a0a967c97fe..8b898cf09c8f006bc120c95790ccfedba1f01f27 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.openapi.options.ex;
 import com.intellij.openapi.options.*;
 import com.intellij.openapi.project.Project;
 import com.intellij.util.containers.ContainerUtil;
-import org.jetbrains.annotations.Nullable;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -75,17 +74,6 @@ public class ProjectConfigurablesGroup implements ConfigurableGroup {
     return result.toArray(new Configurable[result.size()]);
   }
 
-  @Nullable
-  public static Configurable getProjectStructureConfigurable(Project project) {
-    final Configurable[] configurables = getConfigurables(project, new ConfigurableFilter() {
-      public boolean isIncluded(final Configurable configurable) {
-        return PROJECT_STRUCTURE_CLASS_FQ_NAME.equals(configurable.getClass().getName());
-      }
-    });
-
-    return configurables.length == 1 ? configurables[0] : null;
-  }
-
   static List<Configurable> buildConfigurablesList(final Configurable[] extensions, final Configurable[] components, ConfigurableFilter filter) {
     List<Configurable> result = new ArrayList<Configurable>();
     ContainerUtil.addAll(result, extensions);