mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Flex IDE settings (initial)
This commit is contained in:
+5
-1
@@ -68,7 +68,7 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
private final UIState myUiState = new UIState();
|
||||
private Splitter mySplitter;
|
||||
private JComponent myToolbarComponent;
|
||||
@NonNls private static final String CATEGORY = "category";
|
||||
@NonNls public static final String CATEGORY = "category";
|
||||
private JComponent myToFocus;
|
||||
private boolean myWasUiDisposed;
|
||||
private ConfigurationErrorsComponent myErrorsComponent;
|
||||
@@ -324,6 +324,10 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se
|
||||
}
|
||||
}
|
||||
|
||||
public void hideSidePanel() {
|
||||
mySplitter.getFirstComponent().setVisible(false);
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
if (!myWasIntialized) return;
|
||||
final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject);
|
||||
|
||||
+36
-21
@@ -368,12 +368,7 @@ public abstract class BaseStructureConfigurable extends MasterDetailsComponent i
|
||||
if (object instanceof MyNode) {
|
||||
final NamedConfigurable namedConfigurable = ((MyNode)object).getConfigurable();
|
||||
if (namedConfigurable != null) {
|
||||
final Object editableObject = namedConfigurable.getEditableObject();
|
||||
if (editableObject instanceof Sdk || editableObject instanceof Module || editableObject instanceof Facet || editableObject instanceof Artifact) return true;
|
||||
if (editableObject instanceof Library) {
|
||||
final LibraryTable table = ((Library)editableObject).getTable();
|
||||
return table == null || table.isEditable();
|
||||
}
|
||||
return canBeRemoved(namedConfigurable.getEditableObject());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -402,23 +397,43 @@ public abstract class BaseStructureConfigurable extends MasterDetailsComponent i
|
||||
final MyNode node = (MyNode)last;
|
||||
final NamedConfigurable configurable = node.getConfigurable();
|
||||
final Object editableObject = configurable.getEditableObject();
|
||||
if (editableObject instanceof Sdk) {
|
||||
removeJdk((Sdk)editableObject);
|
||||
}
|
||||
else if (editableObject instanceof Module) {
|
||||
if (!removeModule((Module)editableObject)) return false;
|
||||
}
|
||||
else if (editableObject instanceof Facet) {
|
||||
if (removeFacet((Facet)editableObject).isEmpty()) return false;
|
||||
}
|
||||
else if (editableObject instanceof Library) {
|
||||
if (!removeLibrary((Library)editableObject)) return false;
|
||||
}
|
||||
else if (editableObject instanceof Artifact) {
|
||||
removeArtifact((Artifact)editableObject);
|
||||
}
|
||||
|
||||
return removeObject(editableObject);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean canBeRemoved(final Object editableObject) {
|
||||
if (editableObject instanceof Sdk ||
|
||||
editableObject instanceof Module ||
|
||||
editableObject instanceof Facet ||
|
||||
editableObject instanceof Artifact) {
|
||||
return true;
|
||||
}
|
||||
if (editableObject instanceof Library) {
|
||||
final LibraryTable table = ((Library)editableObject).getTable();
|
||||
return table == null || table.isEditable();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean removeObject(final Object editableObject) {
|
||||
// todo keep only removeModule() and removeFacet() here because other removeXXX() are empty here and overridden in subclasses? Override removeObject() instead?
|
||||
if (editableObject instanceof Sdk) {
|
||||
removeJdk((Sdk)editableObject);
|
||||
}
|
||||
else if (editableObject instanceof Module) {
|
||||
if (!removeModule((Module)editableObject)) return false;
|
||||
}
|
||||
else if (editableObject instanceof Facet) {
|
||||
if (removeFacet((Facet)editableObject).isEmpty()) return false;
|
||||
}
|
||||
else if (editableObject instanceof Library) {
|
||||
if (!removeLibrary((Library)editableObject)) return false;
|
||||
}
|
||||
else if (editableObject instanceof Artifact) {
|
||||
removeArtifact((Artifact)editableObject);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void removeArtifact(Artifact artifact) {
|
||||
|
||||
+91
-5
@@ -54,6 +54,7 @@ import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.NamedConfigurable;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
@@ -218,8 +219,9 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
for (final Module module : modules) {
|
||||
ModuleConfigurable configurable = new ModuleConfigurable(myContext.myModulesConfigurator, module, TREE_UPDATER);
|
||||
final MyNode moduleNode = new MyNode(configurable);
|
||||
final boolean facetsExist = myFacetEditorFacade.addFacetsNodes(module, moduleNode);
|
||||
if (facetsExist) {
|
||||
boolean nodesAdded = myFacetEditorFacade.addFacetsNodes(module, moduleNode);
|
||||
nodesAdded |= addNodesFromExtensions(module, moduleNode);
|
||||
if (nodesAdded) {
|
||||
myTree.setShowsRootHandles(true);
|
||||
}
|
||||
final String[] groupPath = myPlainMode ? null : myContext.myModulesConfigurator.getModuleModel().getModuleGroupPath(module);
|
||||
@@ -254,6 +256,14 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
//myProjectNode.add(myLevel2Nodes.get(LibraryTablesRegistrar.PROJECT_LEVEL));
|
||||
}
|
||||
|
||||
private boolean addNodesFromExtensions(final Module module, final MyNode moduleNode) {
|
||||
boolean nodesAdded= false;
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
nodesAdded |= extension.addModuleNodeChildren(module, moduleNode, TREE_UPDATER);
|
||||
}
|
||||
return nodesAdded;
|
||||
}
|
||||
|
||||
public boolean updateProjectTree(final Module[] modules, final ModuleGroup group) {
|
||||
if (myRoot.getChildCount() == 0) return false; //isn't visible
|
||||
final MyNode [] nodes = new MyNode[modules.length];
|
||||
@@ -290,6 +300,7 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
addNode(moduleNode, moduleGroupNode);
|
||||
}
|
||||
myFacetEditorFacade.addFacetsNodes((Module)moduleNode.getConfigurable().getEditableObject(), moduleNode);
|
||||
addNodesFromExtensions((Module)moduleNode.getConfigurable().getEditableObject(), moduleNode);
|
||||
}
|
||||
((DefaultTreeModel)myTree.getModel()).reload(myRoot);
|
||||
return true;
|
||||
@@ -326,6 +337,9 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
|
||||
public void reset() {
|
||||
super.reset();
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
extension.reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -335,10 +349,24 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
checkApply(roots, ProjectBundle.message("rename.message.prefix.module"), ProjectBundle.message("rename.module.title"));
|
||||
|
||||
if (myContext.myModulesConfigurator.isModified()) myContext.myModulesConfigurator.apply();
|
||||
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
extension.apply();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return myContext.myModulesConfigurator.isModified();
|
||||
if (myContext.myModulesConfigurator.isModified()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
if (extension.isModified()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
@@ -346,6 +374,10 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
myFacetEditorFacade.clearMaps(true);
|
||||
myContext.myModulesConfigurator.disposeUIResources();
|
||||
ModuleStructureConfigurable.super.disposeUIResources();
|
||||
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
extension.disposeUIResources();
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {}
|
||||
@@ -494,6 +526,7 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
if (parent == null) parent = myRoot;
|
||||
addNode(node, parent);
|
||||
myFacetEditorFacade.addFacetsNodes(module, node);
|
||||
addNodesFromExtensions(module, node);
|
||||
((DefaultTreeModel)myTree.getModel()).reload(parent);
|
||||
selectNodeInTree(node);
|
||||
final ProjectStructureDaemonAnalyzer daemonAnalyzer = myContext.getDaemonAnalyzer();
|
||||
@@ -545,6 +578,43 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
PlatformIcons.OPENED_MODULE_GROUP_ICON, PlatformIcons.CLOSED_MODULE_GROUP_ICON);
|
||||
}
|
||||
|
||||
protected boolean canBeRemoved(final Object editableObject) {
|
||||
if (super.canBeRemoved(editableObject)) {
|
||||
return true;
|
||||
}
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
if (extension.canBeRemoved(editableObject)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean removeObject(final Object editableObject) {
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
if (extension.removeObject(editableObject)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.removeObject(editableObject);
|
||||
}
|
||||
|
||||
private boolean canBeCopiedByExtension(final NamedConfigurable confugurable) {
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
if (extension.canBeCopied(confugurable)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void copyByExtension(final NamedConfigurable configurable) {
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
extension.copy(configurable, TREE_UPDATER);
|
||||
}
|
||||
}
|
||||
|
||||
private class MyDataProviderWrapper extends JPanel implements DataProvider {
|
||||
public MyDataProviderWrapper(final JComponent component) {
|
||||
super(new BorderLayout());
|
||||
@@ -659,6 +729,15 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
result.addAll(libraryActions);
|
||||
}
|
||||
|
||||
final Computable<Object> selectedObjectRetriever = new Computable<Object>() {
|
||||
public Object compute() {
|
||||
return getSelectedObject();
|
||||
}
|
||||
};
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
result.addAll(extension.createAddActions(selectedObjectRetriever, TREE_UPDATER));
|
||||
}
|
||||
|
||||
return result.toArray(new AnAction[result.size()]);
|
||||
}
|
||||
};
|
||||
@@ -679,6 +758,10 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
List<Facet> removed = modulesConfigurator.getFacetsConfigurator().removeAllFacets(module);
|
||||
FacetStructureConfigurable.getInstance(myProject).removeFacetNodes(removed);
|
||||
myContext.getDaemonAnalyzer().removeElement(new ModuleProjectStructureElement(myContext, module));
|
||||
|
||||
for (final ModuleStructureExtension extension : ModuleStructureExtension.EP_NAME.getExtensions()) {
|
||||
extension.moduleRemoved(module);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -785,6 +868,9 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
LOG.error(e1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
copyByExtension(namedConfigurable);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(final AnActionEvent e) {
|
||||
@@ -792,12 +878,12 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
if (selectionPaths == null || selectionPaths.length != 1) {
|
||||
e.getPresentation().setEnabled(false);
|
||||
} else {
|
||||
e.getPresentation().setEnabled(getSelectedConfugurable() instanceof ModuleConfigurable);
|
||||
final NamedConfigurable selectedConfigurable = getSelectedConfugurable();
|
||||
e.getPresentation().setEnabled(selectedConfigurable instanceof ModuleConfigurable || canBeCopiedByExtension(selectedConfigurable));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class AddModuleAction extends AnAction implements DumbAware {
|
||||
public AddModuleAction() {
|
||||
super(ProjectBundle.message("add.new.module.text.full"), null, IconLoader.getIcon("/actions/modul.png"));
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package com.intellij.openapi.roots.ui.configuration.projectRoot;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.ui.MasterDetailsComponent;
|
||||
import com.intellij.openapi.ui.NamedConfigurable;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public abstract class ModuleStructureExtension {
|
||||
|
||||
public static final ExtensionPointName<ModuleStructureExtension> EP_NAME =
|
||||
ExtensionPointName.create("com.intellij.configuration.ModuleStructureExtension");
|
||||
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
public boolean addModuleNodeChildren(Module module, MasterDetailsComponent.MyNode moduleNode, Runnable treeNodeNameUpdater) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//public void moduleAdded(final Module module, final Runnable treeNodeNameUpdater) {
|
||||
//}
|
||||
|
||||
public void moduleRemoved(final Module module) {
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void apply() throws ConfigurationException {
|
||||
}
|
||||
|
||||
public void disposeUIResources() {
|
||||
}
|
||||
|
||||
public boolean canBeRemoved(final Object editableObject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeObject(final Object editableObject) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Collection<AnAction> createAddActions(final Computable<Object> selectedObjectRetriever, final Runnable treeNodeNameUpdater) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public boolean canBeCopied(final NamedConfigurable confugurable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void copy(final NamedConfigurable confugurable, final Runnable treeNodeNameUpdater) {
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,7 @@
|
||||
<extensionPoint name="libraryTable.attachHandler" interface="com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryTableAttachHandler"/>
|
||||
|
||||
<extensionPoint name="java.compiler" area="IDEA_PROJECT" interface="com.intellij.compiler.impl.javaCompiler.BackendCompiler"/>
|
||||
<extensionPoint name="configuration.ModuleStructureExtension" interface="com.intellij.openapi.roots.ui.configuration.projectRoot.ModuleStructureExtension"/>
|
||||
</extensionPoints>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
|
||||
Reference in New Issue
Block a user