artifacts ui fixes & more detailed options to show content of elements

This commit is contained in:
nik
2009-10-06 12:23:46 +04:00
parent ce3f09de1f
commit bfc4d7044b
14 changed files with 225 additions and 38 deletions
@@ -5,8 +5,8 @@ import com.intellij.openapi.project.Project;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.artifacts.ArtifactManager;
import com.intellij.packaging.artifacts.ArtifactPointerManager;
import com.intellij.packaging.elements.ComplexPackagingElementType;
import com.intellij.packaging.elements.CompositePackagingElement;
import com.intellij.packaging.elements.PackagingElementType;
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
import com.intellij.packaging.impl.artifacts.PlainArtifactType;
import com.intellij.packaging.ui.ArtifactEditorContext;
@@ -19,7 +19,7 @@ import java.util.*;
/**
* @author nik
*/
public class ArtifactElementType extends PackagingElementType<ArtifactPackagingElement> {
public class ArtifactElementType extends ComplexPackagingElementType<ArtifactPackagingElement> {
public static final ArtifactElementType ARTIFACT_ELEMENT_TYPE = new ArtifactElementType();
ArtifactElementType() {
@@ -80,4 +80,9 @@ public class ArtifactElementType extends PackagingElementType<ArtifactPackagingE
public ArtifactPackagingElement createEmpty(@NotNull Project project) {
return new ArtifactPackagingElement(project);
}
@Override
public String getShowContentActionText() {
return "Show Content of Included Artifacts";
}
}
@@ -6,8 +6,8 @@ import com.intellij.openapi.project.ProjectBundle;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.elements.ComplexPackagingElementType;
import com.intellij.packaging.elements.CompositePackagingElement;
import com.intellij.packaging.elements.PackagingElementType;
import com.intellij.packaging.ui.ArtifactEditorContext;
import com.intellij.util.Icons;
import org.jetbrains.annotations.NotNull;
@@ -20,7 +20,7 @@ import java.util.List;
/**
* @author nik
*/
public class LibraryElementType extends PackagingElementType<LibraryPackagingElement> {
public class LibraryElementType extends ComplexPackagingElementType<LibraryPackagingElement> {
public static final LibraryElementType LIBRARY_ELEMENT_TYPE = new LibraryElementType();
LibraryElementType() {
@@ -48,7 +48,7 @@ public class LibraryElementType extends PackagingElementType<LibraryPackagingEle
return elements;
}
private List<Library> getAllLibraries(ArtifactEditorContext context) {
private static List<Library> getAllLibraries(ArtifactEditorContext context) {
List<Library> libraries = new ArrayList<Library>();
libraries.addAll(Arrays.asList(LibraryTablesRegistrar.getInstance().getLibraryTable().getLibraries()));
libraries.addAll(Arrays.asList(LibraryTablesRegistrar.getInstance().getLibraryTable(context.getProject()).getLibraries()));
@@ -59,4 +59,9 @@ public class LibraryElementType extends PackagingElementType<LibraryPackagingEle
public LibraryPackagingElement createEmpty(@NotNull Project project) {
return new LibraryPackagingElement();
}
@Override
public String getShowContentActionText() {
return "Show Library Files";
}
}
@@ -1,28 +1,33 @@
package com.intellij.packaging.impl.elements;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.elements.CompositePackagingElement;
import com.intellij.packaging.elements.PackagingElementType;
import com.intellij.packaging.ui.ArtifactEditorContext;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.elements.ComplexPackagingElementType;
import com.intellij.packaging.elements.CompositePackagingElement;
import com.intellij.packaging.ui.ArtifactEditorContext;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.List;
import java.util.ArrayList;
import java.util.List;
/**
* @author nik
*/
public class ModuleWithDependenciesElementType extends PackagingElementType<ModuleWithDependenciesPackagingElement> {
public class ModuleWithDependenciesElementType extends ComplexPackagingElementType<ModuleWithDependenciesPackagingElement> {
public static final ModuleWithDependenciesElementType MODULE_WITH_DEPENDENCIES_TYPE = new ModuleWithDependenciesElementType();
public ModuleWithDependenciesElementType() {
super("module-with-dependencies", "Module With Dependencies");
}
@Override
public String getShowContentActionText() {
return "Module with dependencies";
}
@Override
public Icon getCreateElementIcon() {
return IconLoader.getIcon("/nodes/ModuleOpen.png");
@@ -62,6 +62,18 @@ public class PackagingElementFactoryImpl extends PackagingElementFactory {
return elementTypes.toArray(new PackagingElementType[elementTypes.size()]);
}
@Override
@NotNull
public ComplexPackagingElementType<?>[] getComplexElementTypes() {
List<ComplexPackagingElementType<?>> types = new ArrayList<ComplexPackagingElementType<?>>();
for (PackagingElementType type : getAllElementTypes()) {
if (type instanceof ComplexPackagingElementType) {
types.add((ComplexPackagingElementType)type);
}
}
return types.toArray(new ComplexPackagingElementType[types.size()]);
}
@NotNull
@Override
public CompositePackagingElementType<?>[] getCompositeElementTypes() {
@@ -0,0 +1,31 @@
/*
* Copyright 2000-2009 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.packaging.elements;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public abstract class ComplexPackagingElementType<E extends ComplexPackagingElement<?>> extends PackagingElementType<E> {
protected ComplexPackagingElementType(@NotNull @NonNls String id, @NotNull String presentableName) {
super(id, presentableName);
}
public abstract String getShowContentActionText();
}
@@ -82,4 +82,6 @@ public abstract class PackagingElementFactory {
@NotNull
public abstract PackagingElementType[] getAllElementTypes();
@NotNull
public abstract ComplexPackagingElementType<?>[] getComplexElementTypes();
}
@@ -12,6 +12,7 @@ import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.ui.configuration.artifacts.actions.*;
import com.intellij.openapi.roots.ui.configuration.artifacts.sourceItems.LibrarySourceItem;
import com.intellij.openapi.roots.ui.configuration.artifacts.sourceItems.SourceItemsTree;
import com.intellij.openapi.ui.FixedSizeButton;
import com.intellij.openapi.ui.Splitter;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.util.Comparing;
@@ -20,7 +21,9 @@ import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.packaging.artifacts.Artifact;
import com.intellij.packaging.artifacts.ModifiableArtifact;
import com.intellij.packaging.elements.ComplexPackagingElementType;
import com.intellij.packaging.elements.CompositePackagingElement;
import com.intellij.packaging.elements.PackagingElementFactory;
import com.intellij.packaging.elements.PackagingElementType;
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
import com.intellij.packaging.impl.elements.ArchivePackagingElement;
@@ -30,6 +33,7 @@ import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.TabbedPaneWrapper;
import com.intellij.ui.TreeToolTipHandler;
import com.intellij.util.EventDispatcher;
import com.intellij.util.ui.ThreeStateCheckBox;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -49,9 +53,11 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
private JPanel myMainPanel;
private JCheckBox myBuildOnMakeCheckBox;
private TextFieldWithBrowseButton myOutputDirectoryField;
private JCheckBox myShowIncludedCheckBox;
private JPanel myEditorPanel;
private JPanel myErrorPanelPlace;
private ThreeStateCheckBox myShowContentCheckBox;
private FixedSizeButton myShowSpecificContentOptionsButton;
private ActionGroup myShowSpecificContentOptionsGroup;
private Splitter mySplitter;
private final Project myProject;
private final ComplexElementSubstitutionParameters mySubstitutionParameters = new ComplexElementSubstitutionParameters();
@@ -79,9 +85,24 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
CompilerBundle.message("chooser.description.select.output.directory.for.0.artifact",
getArtifact().getName()), myProject,
FileChooserDescriptorFactory.createSingleFolderDescriptor());
myShowSpecificContentOptionsGroup = createShowSpecificContentOptionsGroup();
myShowSpecificContentOptionsButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, myShowSpecificContentOptionsGroup).getComponent().show(myShowSpecificContentOptionsButton, 0, 0);
}
});
setOutputPath(outputPath);
myValidationManager = new ArtifactValidationManagerImpl(this);
myContext.setValidationManager(myValidationManager);
updateShowContentCheckbox();
}
private ActionGroup createShowSpecificContentOptionsGroup() {
final DefaultActionGroup group = new DefaultActionGroup();
for (ComplexPackagingElementType<?> type : PackagingElementFactory.getInstance().getComplexElementTypes()) {
group.add(new ToggleShowElementContentAction(type, this));
}
return group;
}
private void setOutputPath(@Nullable String outputPath) {
@@ -162,15 +183,17 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
mySplitter.setSecondComponent(rightPanel);
myShowIncludedCheckBox.addActionListener(new ActionListener() {
myShowContentCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (myShowIncludedCheckBox.isSelected()) {
final ThreeStateCheckBox.State state = myShowContentCheckBox.getState();
if (state == ThreeStateCheckBox.State.SELECTED) {
mySubstitutionParameters.setSubstituteAll();
}
else {
else if (state == ThreeStateCheckBox.State.NOT_SELECTED) {
mySubstitutionParameters.setSubstituteNone();
}
rebuildTries();
myShowContentCheckBox.setThirdStateEnabled(false);
myLayoutTreeComponent.rebuildTree();
}
});
@@ -190,6 +213,21 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
return getMainComponent();
}
public void updateShowContentCheckbox() {
final ThreeStateCheckBox.State state;
if (mySubstitutionParameters.isAllSubstituted()) {
state = ThreeStateCheckBox.State.SELECTED;
}
else if (mySubstitutionParameters.isNoneSubstituted()) {
state = ThreeStateCheckBox.State.NOT_SELECTED;
}
else {
state = ThreeStateCheckBox.State.DONT_CARE;
}
myShowContentCheckBox.setThirdStateEnabled(state == ThreeStateCheckBox.State.DONT_CARE);
myShowContentCheckBox.setState(state);
}
private DefaultActionGroup createToolbarActionGroup() {
final DefaultActionGroup toolbarActionGroup = new DefaultActionGroup();
@@ -201,6 +239,7 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
toolbarActionGroup.add(createAddAction(false));
toolbarActionGroup.add(new RemovePackagingElementAction(this));
toolbarActionGroup.add(Separator.getInstance());
toolbarActionGroup.add(new SortElementsToggleAction(this.getLayoutTreeComponent()));
toolbarActionGroup.add(new MoveElementAction(myLayoutTreeComponent, "Move Up", "", IconLoader.getIcon("/actions/moveUp.png"), -1));
toolbarActionGroup.add(new MoveElementAction(myLayoutTreeComponent, "Move Down", "", IconLoader.getIcon("/actions/moveDown.png"), 1));
@@ -55,14 +55,6 @@
</grid>
</children>
</grid>
<component id="32726" class="javax.swing.JCheckBox" binding="myShowIncludedCheckBox">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Show included content"/>
</properties>
</component>
<grid id="b1ae" binding="myEditorPanel" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -81,6 +73,35 @@
<border type="none"/>
<children/>
</grid>
<grid id="7b56f" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="4157d" class="com.intellij.util.ui.ThreeStateCheckBox" binding="myShowContentCheckBox">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Show content of elements"/>
</properties>
</component>
<component id="d5f3d" class="com.intellij.openapi.ui.FixedSizeButton" binding="myShowSpecificContentOptionsButton">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<hspacer id="eeea0">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
</children>
</grid>
</form>
@@ -2,36 +2,69 @@ package com.intellij.openapi.roots.ui.configuration.artifacts;
import com.intellij.openapi.roots.ui.configuration.artifacts.nodes.ComplexPackagingElementNode;
import com.intellij.packaging.elements.ComplexPackagingElement;
import com.intellij.packaging.elements.ComplexPackagingElementType;
import com.intellij.packaging.elements.PackagingElementFactory;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
/**
* @author nik
*/
public class ComplexElementSubstitutionParameters {
private boolean mySubstituteAll;
private Set<ComplexPackagingElement> mySubstituted = new HashSet<ComplexPackagingElement>();
private Set<ComplexPackagingElementType<?>> myTypesToSubstitute = new HashSet<ComplexPackagingElementType<?>>();
private Set<ComplexPackagingElement<?>> mySubstituted = new HashSet<ComplexPackagingElement<?>>();
public void setSubstituteAll() {
mySubstituteAll = true;
myTypesToSubstitute.addAll(Arrays.asList(PackagingElementFactory.getInstance().getComplexElementTypes()));
mySubstituted.clear();
}
public void setSubstituteNone() {
myTypesToSubstitute.clear();
mySubstituted.clear();
mySubstituteAll = false;
}
public boolean shouldSubstitute(@NotNull ComplexPackagingElement element) {
return mySubstituteAll || mySubstituted.contains(element);
public boolean shouldSubstitute(@NotNull ComplexPackagingElement<?> element) {
final ComplexPackagingElementType<?> type = (ComplexPackagingElementType<?>)element.getType();
return myTypesToSubstitute.contains(type) || mySubstituted.contains(element);
}
public void substitute(ComplexPackagingElementNode complexNode) {
public void setShowContent(ComplexPackagingElementType<?> type, boolean showContent) {
if (showContent) {
myTypesToSubstitute.add(type);
}
else {
myTypesToSubstitute.remove(type);
}
final Iterator<ComplexPackagingElement<?>> iterator = mySubstituted.iterator();
while (iterator.hasNext()) {
if (iterator.next().getType().equals(type)) {
iterator.remove();
}
}
}
public void setShowContent(ComplexPackagingElementNode complexNode) {
mySubstituted.addAll(complexNode.getPackagingElements());
}
public void dontSubstitute(ComplexPackagingElement<?> element) {
public void doNotSubstitute(ComplexPackagingElement<?> element) {
mySubstituted.remove(element);
}
public boolean isShowContentForType(@NotNull ComplexPackagingElementType type) {
return myTypesToSubstitute.contains(type);
}
public boolean isAllSubstituted() {
return myTypesToSubstitute.containsAll(Arrays.asList(PackagingElementFactory.getInstance().getComplexElementTypes()));
}
public boolean isNoneSubstituted() {
return myTypesToSubstitute.isEmpty() && mySubstituted.isEmpty();
}
}
@@ -0,0 +1,32 @@
package com.intellij.openapi.roots.ui.configuration.artifacts;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.packaging.elements.ComplexPackagingElementType;
/**
* @author nik
*/
public class ToggleShowElementContentAction extends ToggleAction implements DumbAware {
private final ComplexPackagingElementType<?> myType;
private final ArtifactEditorImpl myEditor;
public ToggleShowElementContentAction(ComplexPackagingElementType<?> type, ArtifactEditorImpl editor) {
super(type.getShowContentActionText());
myType = type;
myEditor = editor;
}
@Override
public boolean isSelected(AnActionEvent e) {
return myEditor.getSubstitutionParameters().isShowContentForType(myType);
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
myEditor.getSubstitutionParameters().setShowContent(myType, state);
myEditor.updateShowContentCheckbox();
myEditor.getLayoutTreeComponent().rebuildTree();
}
}
@@ -49,7 +49,7 @@ public class HideContentAction extends DumbAwareAction {
final Collection<PackagingNodeSource> sources = node.getNodeSources();
for (PackagingNodeSource source : sources) {
myArtifactEditor.getSubstitutionParameters().dontSubstitute(source.getSourceElement());
myArtifactEditor.getSubstitutionParameters().doNotSubstitute(source.getSourceElement());
myArtifactEditor.getLayoutTreeComponent().getLayoutTree().addSubtreeToUpdate(source.getSourceParentNode());
}
}
@@ -27,7 +27,9 @@ public class MoveElementAction extends DumbAwareAction {
@Override
public void update(AnActionEvent e) {
e.getPresentation().setEnabled(isEnabled());
final boolean b = isEnabled();
e.getPresentation().setEnabled(b);
e.getPresentation().setText(getTemplatePresentation().getText() + " (disabled if elements are sorted)");
}
private boolean isEnabled() {
@@ -13,7 +13,7 @@ public class SortElementsToggleAction extends ToggleAction implements DumbAware
private LayoutTreeComponent myLayoutTreeComponent;
public SortElementsToggleAction(final LayoutTreeComponent layoutTreeComponent) {
super("Sort", "Sort Elements by Names and Types", IconLoader.getIcon("/objectBrowser/sorted.png"));
super("Sort Elements by Names and Types", "Sort Elements by Names and Types", IconLoader.getIcon("/objectBrowser/sorted.png"));
myLayoutTreeComponent = layoutTreeComponent;
}
@@ -25,7 +25,7 @@ public class ComplexPackagingElementNode extends PackagingElementNode<ComplexPac
@Override
public void handleDoubleClickOrEnter(SimpleTree tree, InputEvent inputEvent) {
mySubstitutionParameters.substitute(this);
mySubstitutionParameters.setShowContent(this);
final LayoutTree layoutTree = (LayoutTree)tree;
final CompositePackagingElementNode parentNode = getParentNode();
if (parentNode != null) {