mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
+10
@@ -127,4 +127,14 @@ public abstract class CompositePackagingElement<S> extends PackagingElement<S> i
|
||||
public void removeAllChildren() {
|
||||
myChildren.clear();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CompositePackagingElement<?> findCompositeChild(@NotNull String name) {
|
||||
for (PackagingElement<?> child : myChildren) {
|
||||
if (child instanceof CompositePackagingElement && name.equals(((CompositePackagingElement)child).getName())) {
|
||||
return (CompositePackagingElement)child;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -19,6 +19,7 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.elements.CompositePackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElementType;
|
||||
import com.intellij.packaging.ui.ArtifactEditor;
|
||||
import com.intellij.packaging.ui.ArtifactEditorContext;
|
||||
@@ -37,6 +38,8 @@ public interface ArtifactEditorEx extends ArtifactEditor, Disposable {
|
||||
|
||||
void removeSelectedElements();
|
||||
|
||||
void removePackagingElement(@NotNull String pathToParent, @NotNull PackagingElement<?> element);
|
||||
|
||||
LayoutTreeComponent getLayoutTreeComponent();
|
||||
|
||||
Artifact getArtifact();
|
||||
|
||||
+35
-4
@@ -39,14 +39,12 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactType;
|
||||
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.elements.*;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactUtil;
|
||||
import com.intellij.packaging.impl.elements.ArchivePackagingElement;
|
||||
import com.intellij.packaging.impl.elements.ManifestFileUtil;
|
||||
@@ -361,6 +359,34 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
|
||||
myLayoutTreeComponent.removeSelectedElements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePackagingElement(@NotNull final String pathToParent, @NotNull final PackagingElement<?> element) {
|
||||
myLayoutTreeComponent.editLayout(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final CompositePackagingElement<?> parent = findCompositeElementByPath(pathToParent);
|
||||
if (parent == null) return;
|
||||
for (PackagingElement<?> child : parent.getChildren()) {
|
||||
if (child.isEqualTo(element)) {
|
||||
parent.removeChild(child);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
myLayoutTreeComponent.rebuildTree();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private CompositePackagingElement<?> findCompositeElementByPath(String pathToElement) {
|
||||
CompositePackagingElement<?> element = getRootElement();
|
||||
for (String name : StringUtil.split(pathToElement, "/")) {
|
||||
element = element.findCompositeChild(name);
|
||||
if (element == null) return null;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public boolean isModified() {
|
||||
return myBuildOnMakeCheckBox.isSelected() != myOriginalArtifact.isBuildOnMake()
|
||||
|| !Comparing.equal(getConfiguredOutputPath(), myOriginalArtifact.getOutputPath())
|
||||
@@ -451,6 +477,11 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
|
||||
return myValidationManager;
|
||||
}
|
||||
|
||||
private void createUIComponents() {
|
||||
myShowContentCheckBox = new ThreeStateCheckBox();
|
||||
myShowSpecificContentOptionsButton = new FixedSizeButton(16);
|
||||
}
|
||||
|
||||
private class MyDataProvider implements TypeSafeDataProvider {
|
||||
public void calcData(DataKey key, DataSink sink) {
|
||||
if (ARTIFACTS_EDITOR_KEY.equals(key)) {
|
||||
|
||||
+9
-6
@@ -67,23 +67,21 @@ public class ArtifactProjectStructureElement extends ProjectStructureElement {
|
||||
if (packagingElement instanceof ModuleOutputPackagingElement) {
|
||||
final Module module = ((ModuleOutputPackagingElement)packagingElement).findModule(myArtifactsStructureContext);
|
||||
if (module != null) {
|
||||
usages.add(new UsageInArtifact(myOriginalArtifact, myArtifactsStructureContext, new ModuleProjectStructureElement(myContext, module),
|
||||
ArtifactProjectStructureElement.this, path.getPathString(), packagingElement));
|
||||
usages.add(createUsage(packagingElement, path, new ModuleProjectStructureElement(myContext, module)));
|
||||
}
|
||||
}
|
||||
else if (packagingElement instanceof LibraryPackagingElement) {
|
||||
final Library library = ((LibraryPackagingElement)packagingElement).findLibrary(myArtifactsStructureContext);
|
||||
if (library != null) {
|
||||
usages.add(new UsageInArtifact(myOriginalArtifact, myArtifactsStructureContext, new LibraryProjectStructureElement(myContext, library),
|
||||
ArtifactProjectStructureElement.this, path.getPathString(), packagingElement));
|
||||
usages.add(createUsage(packagingElement, path,
|
||||
new LibraryProjectStructureElement(ArtifactProjectStructureElement.this.myContext, library)));
|
||||
}
|
||||
}
|
||||
else if (packagingElement instanceof ArtifactPackagingElement) {
|
||||
final Artifact usedArtifact = ((ArtifactPackagingElement)packagingElement).findArtifact(myArtifactsStructureContext);
|
||||
if (usedArtifact != null) {
|
||||
final ArtifactProjectStructureElement artifactElement = myArtifactsStructureContext.getOrCreateArtifactElement(usedArtifact);
|
||||
usages.add(new UsageInArtifact(myOriginalArtifact, myArtifactsStructureContext, artifactElement,
|
||||
ArtifactProjectStructureElement.this, path.getPathString(), packagingElement));
|
||||
usages.add(createUsage(packagingElement, path, artifactElement));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -92,6 +90,11 @@ public class ArtifactProjectStructureElement extends ProjectStructureElement {
|
||||
return usages;
|
||||
}
|
||||
|
||||
private UsageInArtifact createUsage(PackagingElement<?> packagingElement, PackagingElementPath path,
|
||||
final ProjectStructureElement element) {
|
||||
return new UsageInArtifact(myOriginalArtifact, myArtifactsStructureContext, element, this, path.getPathString(), packagingElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "artifact:" + myOriginalArtifact.getName();
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="4157d" class="com.intellij.util.ui.ThreeStateCheckBox" binding="myShowContentCheckBox">
|
||||
<component id="4157d" class="com.intellij.util.ui.ThreeStateCheckBox" binding="myShowContentCheckBox" custom-create="true">
|
||||
<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>
|
||||
@@ -89,7 +89,7 @@
|
||||
<text value="Show content of elements"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="d5f3d" class="com.intellij.openapi.ui.FixedSizeButton" binding="myShowSpecificContentOptionsButton">
|
||||
<component id="d5f3d" class="com.intellij.openapi.ui.FixedSizeButton" binding="myShowSpecificContentOptionsButton" custom-create="true">
|
||||
<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>
|
||||
|
||||
+5
@@ -51,6 +51,11 @@ public class UsageInArtifact extends ProjectStructureElementUsage {
|
||||
});
|
||||
}
|
||||
|
||||
public void removeElement() {
|
||||
final ArtifactEditorEx editor = (ArtifactEditorEx)myContext.getOrCreateEditor(myOriginalArtifact);
|
||||
editor.removePackagingElement(myParentPath, myPackagingElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
return myOriginalArtifact.getName();
|
||||
|
||||
+9
-8
@@ -42,10 +42,7 @@ import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.NullableComputable;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.ex.http.HttpFileSystem;
|
||||
@@ -100,9 +97,9 @@ public class LibraryRootsComponent implements Disposable {
|
||||
@Nullable private final Project myProject;
|
||||
|
||||
private final Map<DataKey, Object> myFileChooserUserData = new HashMap<DataKey, Object>();
|
||||
private final LibraryEditor myLibraryEditor;
|
||||
private final Computable<LibraryEditor> myLibraryEditor;
|
||||
|
||||
private LibraryRootsComponent(@Nullable Project project, @NotNull LibraryEditor libraryEditor) {
|
||||
private LibraryRootsComponent(@Nullable Project project, @NotNull Computable<LibraryEditor> libraryEditor) {
|
||||
myProject = project;
|
||||
myLibraryEditor = libraryEditor;
|
||||
updateProperties();
|
||||
@@ -110,7 +107,7 @@ public class LibraryRootsComponent implements Disposable {
|
||||
|
||||
private void updateProperties() {
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (String description : LibraryPresentationManager.getInstance().getDescriptions(myLibraryEditor.getFiles(OrderRootType.CLASSES))) {
|
||||
for (String description : LibraryPresentationManager.getInstance().getDescriptions(getLibraryEditor().getFiles(OrderRootType.CLASSES))) {
|
||||
if (text.length() > 0) {
|
||||
text.append("\n");
|
||||
}
|
||||
@@ -120,6 +117,10 @@ public class LibraryRootsComponent implements Disposable {
|
||||
}
|
||||
|
||||
public static LibraryRootsComponent createComponent(final @Nullable Project project, @NotNull LibraryEditor libraryEditor) {
|
||||
return createComponent(project, new Computable.PredefinedValueComputable<LibraryEditor>(libraryEditor));
|
||||
}
|
||||
|
||||
public static LibraryRootsComponent createComponent(final @Nullable Project project, @NotNull Computable<LibraryEditor> libraryEditor) {
|
||||
LibraryRootsComponent rootsComponent = new LibraryRootsComponent(project, libraryEditor);
|
||||
rootsComponent.init(new LibraryTreeStructure(rootsComponent));
|
||||
return rootsComponent;
|
||||
@@ -178,7 +179,7 @@ public class LibraryRootsComponent implements Disposable {
|
||||
}
|
||||
|
||||
public LibraryEditor getLibraryEditor() {
|
||||
return myLibraryEditor;
|
||||
return myLibraryEditor.compute();
|
||||
}
|
||||
|
||||
public boolean hasChanges() {
|
||||
|
||||
+1
-1
@@ -233,7 +233,7 @@ public abstract class BaseLibrariesConfigurable extends BaseStructureConfigurabl
|
||||
if (usage instanceof UsageInModuleClasspath) {
|
||||
rootConfigurable.removeLibraryOrderEntry(((ModuleProjectStructureElement)usage.getContainingElement()).getModule(), library);
|
||||
} else if (usage instanceof UsageInArtifact) {
|
||||
// TODO[nik] implement me
|
||||
((UsageInArtifact)usage).removeElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -26,6 +26,7 @@ import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryRootsComponent;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.LibraryProjectStructureElement;
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStructureElement;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -58,7 +59,12 @@ public class LibraryConfigurable extends ProjectStructureElementConfigurable<Lib
|
||||
}
|
||||
|
||||
public JComponent createOptionsPanel() {
|
||||
myLibraryEditor = LibraryRootsComponent.createComponent(myProject, myModel.getModifiableModel().getLibraryEditor(myLibrary));
|
||||
myLibraryEditor = LibraryRootsComponent.createComponent(myProject, new Computable<LibraryEditor>() {
|
||||
@Override
|
||||
public LibraryEditor compute() {
|
||||
return myModel.getModifiableModel().getLibraryEditor(myLibrary);
|
||||
}
|
||||
});
|
||||
final StructureConfigurableContext context = ModuleStructureConfigurable.getInstance(myProject).getContext();
|
||||
myLibraryEditor.addListener(new Runnable() {
|
||||
public void run() {
|
||||
|
||||
Reference in New Issue
Block a user