mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
update artifacts on module rename (IDEADEV-40824)
This commit is contained in:
+4
-2
@@ -17,6 +17,7 @@ package com.intellij.packaging.impl.elements;
|
||||
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModulePointerManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
@@ -56,8 +57,9 @@ public class ModuleOutputElementType extends PackagingElementType<ModuleOutputPa
|
||||
@NotNull CompositePackagingElement<?> parent) {
|
||||
List<Module> modules = chooseModules(context);
|
||||
final List<ModuleOutputPackagingElement> elements = new ArrayList<ModuleOutputPackagingElement>();
|
||||
final ModulePointerManager pointerManager = ModulePointerManager.getInstance(context.getProject());
|
||||
for (Module module : modules) {
|
||||
elements.add(new ModuleOutputPackagingElement(module.getName()));
|
||||
elements.add(new ModuleOutputPackagingElement(context.getProject(), pointerManager.create(module)));
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
@@ -68,6 +70,6 @@ public class ModuleOutputElementType extends PackagingElementType<ModuleOutputPa
|
||||
|
||||
@NotNull
|
||||
public ModuleOutputPackagingElement createEmpty(@NotNull Project project) {
|
||||
return new ModuleOutputPackagingElement();
|
||||
return new ModuleOutputPackagingElement(project);
|
||||
}
|
||||
}
|
||||
|
||||
+59
-29
@@ -15,21 +15,24 @@
|
||||
*/
|
||||
package com.intellij.packaging.impl.elements;
|
||||
|
||||
import com.intellij.compiler.ant.Generator;
|
||||
import com.intellij.compiler.ant.BuildProperties;
|
||||
import com.intellij.compiler.ant.Generator;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModulePointer;
|
||||
import com.intellij.openapi.module.ModulePointerManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.CompilerModuleExtension;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.elements.*;
|
||||
import com.intellij.packaging.impl.ui.ModuleElementPresentation;
|
||||
import com.intellij.packaging.impl.ui.DelegatedPackagingElementPresentation;
|
||||
import com.intellij.packaging.ui.PackagingElementPresentation;
|
||||
import com.intellij.packaging.ui.ArtifactEditorContext;
|
||||
import com.intellij.packaging.artifacts.ArtifactType;
|
||||
import com.intellij.packaging.elements.*;
|
||||
import com.intellij.packaging.impl.ui.DelegatedPackagingElementPresentation;
|
||||
import com.intellij.packaging.impl.ui.ModuleElementPresentation;
|
||||
import com.intellij.packaging.ui.ArtifactEditorContext;
|
||||
import com.intellij.packaging.ui.PackagingElementPresentation;
|
||||
import com.intellij.util.xmlb.annotations.Attribute;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -37,29 +40,35 @@ import java.util.List;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ModuleOutputPackagingElement extends PackagingElement<ModuleOutputPackagingElement> {
|
||||
public class ModuleOutputPackagingElement extends PackagingElement<ModuleOutputPackagingElement.ModuleOutputPackagingElementState> {
|
||||
@NonNls public static final String MODULE_NAME_ATTRIBUTE = "name";
|
||||
private String myModuleName;
|
||||
private ModulePointer myModulePointer;
|
||||
private final Project myProject;
|
||||
|
||||
public ModuleOutputPackagingElement() {
|
||||
public ModuleOutputPackagingElement(@NotNull Project project) {
|
||||
super(ModuleOutputElementType.MODULE_OUTPUT_ELEMENT_TYPE);
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public ModuleOutputPackagingElement(String moduleName) {
|
||||
public ModuleOutputPackagingElement(@NotNull Project project, @NotNull ModulePointer modulePointer) {
|
||||
super(ModuleOutputElementType.MODULE_OUTPUT_ELEMENT_TYPE);
|
||||
myModuleName = moduleName;
|
||||
myProject = project;
|
||||
myModulePointer = modulePointer;
|
||||
}
|
||||
|
||||
public PackagingElementPresentation createPresentation(@NotNull ArtifactEditorContext context) {
|
||||
return new DelegatedPackagingElementPresentation(new ModuleElementPresentation(myModuleName, findModule(context), context));
|
||||
return new DelegatedPackagingElementPresentation(new ModuleElementPresentation(myModulePointer, context));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Generator> computeAntInstructions(@NotNull PackagingElementResolvingContext resolvingContext, @NotNull AntCopyInstructionCreator creator,
|
||||
@NotNull ArtifactAntGenerationContext generationContext,
|
||||
@NotNull ArtifactType artifactType) {
|
||||
final String moduleOutput = BuildProperties.propertyRef(generationContext.getModuleOutputPath(myModuleName));
|
||||
return Collections.singletonList(creator.createDirectoryContentCopyInstruction(moduleOutput));
|
||||
if (myModulePointer != null) {
|
||||
final String moduleOutput = BuildProperties.propertyRef(generationContext.getModuleOutputPath(myModulePointer.getModuleName()));
|
||||
return Collections.singletonList(creator.createDirectoryContentCopyInstruction(moduleOutput));
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,34 +92,55 @@ public class ModuleOutputPackagingElement extends PackagingElement<ModuleOutputP
|
||||
|
||||
@Override
|
||||
public boolean isEqualTo(@NotNull PackagingElement<?> element) {
|
||||
return element instanceof ModuleOutputPackagingElement && myModuleName != null
|
||||
&& myModuleName.equals(((ModuleOutputPackagingElement)element).getModuleName());
|
||||
return element instanceof ModuleOutputPackagingElement && myModulePointer != null
|
||||
&& myModulePointer.equals(((ModuleOutputPackagingElement)element).myModulePointer);
|
||||
}
|
||||
|
||||
public ModuleOutputPackagingElement getState() {
|
||||
return this;
|
||||
public ModuleOutputPackagingElementState getState() {
|
||||
final ModuleOutputPackagingElementState state = new ModuleOutputPackagingElementState();
|
||||
if (myModulePointer != null) {
|
||||
state.setModuleName(myModulePointer.getModuleName());
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public void loadState(ModuleOutputPackagingElement state) {
|
||||
myModuleName = state.getModuleName();
|
||||
public void loadState(ModuleOutputPackagingElementState state) {
|
||||
final String moduleName = state.getModuleName();
|
||||
myModulePointer = moduleName != null ? ModulePointerManager.getInstance(myProject).create(moduleName) : null;
|
||||
}
|
||||
|
||||
@NonNls @Override
|
||||
public String toString() {
|
||||
return "module:" + myModuleName;
|
||||
return "module:" + getModuleName();
|
||||
}
|
||||
|
||||
@Attribute(MODULE_NAME_ATTRIBUTE)
|
||||
@Nullable
|
||||
public String getModuleName() {
|
||||
return myModuleName;
|
||||
}
|
||||
|
||||
public void setModuleName(String moduleName) {
|
||||
myModuleName = moduleName;
|
||||
return myModulePointer != null ? myModulePointer.getModuleName() : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Module findModule(PackagingElementResolvingContext context) {
|
||||
return context.getModulesProvider().getModule(myModuleName);
|
||||
if (myModulePointer != null) {
|
||||
final Module module = myModulePointer.getModule();
|
||||
if (module != null) {
|
||||
return module;
|
||||
}
|
||||
return context.getModulesProvider().getModule(myModulePointer.getModuleName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class ModuleOutputPackagingElementState {
|
||||
private String myModuleName;
|
||||
|
||||
@Attribute(MODULE_NAME_ATTRIBUTE)
|
||||
public String getModuleName() {
|
||||
return myModuleName;
|
||||
}
|
||||
|
||||
public void setModuleName(String moduleName) {
|
||||
myModuleName = moduleName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -17,6 +17,8 @@ package com.intellij.packaging.impl.elements;
|
||||
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModulePointer;
|
||||
import com.intellij.openapi.module.ModulePointerManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryImpl;
|
||||
@@ -173,14 +175,16 @@ public class PackagingElementFactoryImpl extends PackagingElementFactory {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PackagingElement<?> createModuleOutput(@NotNull String moduleName, Project project) {
|
||||
return new ModuleOutputPackagingElement(moduleName);
|
||||
public PackagingElement<?> createModuleOutput(@NotNull String moduleName, @NotNull Project project) {
|
||||
final ModulePointer pointer = ModulePointerManager.getInstance(project).create(moduleName);
|
||||
return new ModuleOutputPackagingElement(project, pointer);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PackagingElement<?> createModuleOutput(@NotNull Module module) {
|
||||
return new ModuleOutputPackagingElement(module.getName());
|
||||
final ModulePointer modulePointer = ModulePointerManager.getInstance(module.getProject()).create(module);
|
||||
return new ModuleOutputPackagingElement(module.getProject(), modulePointer);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+40
-17
@@ -17,7 +17,9 @@ package com.intellij.packaging.impl.ui;
|
||||
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModulePointer;
|
||||
import com.intellij.packaging.ui.PackagingElementWeights;
|
||||
import com.intellij.packaging.ui.TreeNodePresentation;
|
||||
import com.intellij.packaging.ui.ArtifactEditorContext;
|
||||
@@ -29,46 +31,67 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @author nik
|
||||
*/
|
||||
public class ModuleElementPresentation extends TreeNodePresentation {
|
||||
private final String myName;
|
||||
private final ModulePointer myModulePointer;
|
||||
private final ArtifactEditorContext myContext;
|
||||
private final Module myModule;
|
||||
|
||||
public ModuleElementPresentation(@NotNull String name, @Nullable Module module, ArtifactEditorContext context) {
|
||||
myModule = module;
|
||||
myName = name;
|
||||
public ModuleElementPresentation(@Nullable ModulePointer modulePointer, @NotNull ArtifactEditorContext context) {
|
||||
myModulePointer = modulePointer;
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
public String getPresentableName() {
|
||||
return myName;
|
||||
return myModulePointer != null ? myModulePointer.getModuleName() : "<unknown>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNavigateToSource() {
|
||||
return myModule != null;
|
||||
return findModule() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getSourceObject() {
|
||||
return myModule;
|
||||
return findModule();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Module findModule() {
|
||||
return myModulePointer != null ? myModulePointer.getModule() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigateToSource() {
|
||||
myContext.selectModule(myModule);
|
||||
final Module module = findModule();
|
||||
if (module != null) {
|
||||
myContext.selectModule(module);
|
||||
}
|
||||
}
|
||||
|
||||
public void render(@NotNull PresentationData presentationData, SimpleTextAttributes mainAttributes, SimpleTextAttributes commentAttributes) {
|
||||
if (myModule != null) {
|
||||
presentationData.setOpenIcon(myModule.getModuleType().getNodeIcon(true));
|
||||
presentationData.setClosedIcon(myModule.getModuleType().getNodeIcon(false));
|
||||
final Module module = findModule();
|
||||
if (module != null) {
|
||||
presentationData.setOpenIcon(module.getModuleType().getNodeIcon(true));
|
||||
presentationData.setClosedIcon(module.getModuleType().getNodeIcon(false));
|
||||
}
|
||||
String moduleName;
|
||||
if (module != null) {
|
||||
moduleName = module.getName();
|
||||
final ModifiableModuleModel moduleModel = myContext.getModifiableModuleModel();
|
||||
if (moduleModel != null) {
|
||||
final String newName = moduleModel.getNewName(module);
|
||||
if (newName != null) {
|
||||
moduleName = newName;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (myModulePointer != null) {
|
||||
moduleName = myModulePointer.getModuleName();
|
||||
}
|
||||
else {
|
||||
moduleName = "<unknown>";
|
||||
}
|
||||
presentationData.addText(getNodeText(),
|
||||
myModule != null ? mainAttributes : SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
}
|
||||
|
||||
protected String getNodeText() {
|
||||
return CompilerBundle.message("node.text.0.compile.output", myName);
|
||||
presentationData.addText(CompilerBundle.message("node.text.0.compile.output", moduleName),
|
||||
module != null ? mainAttributes : SimpleTextAttributes.ERROR_ATTRIBUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public abstract class PackagingElementFactory {
|
||||
public abstract CompositePackagingElement<?> createArchive(@NotNull @NonNls String archiveFileName);
|
||||
|
||||
@NotNull
|
||||
public abstract PackagingElement<?> createModuleOutput(@NotNull String moduleName, Project project);
|
||||
public abstract PackagingElement<?> createModuleOutput(@NotNull String moduleName, @NotNull Project project);
|
||||
|
||||
@NotNull
|
||||
public abstract PackagingElement<?> createModuleOutput(@NotNull Module module);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.packaging.ui;
|
||||
|
||||
import com.intellij.facet.Facet;
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
@@ -24,6 +25,7 @@ import com.intellij.packaging.artifacts.ModifiableArtifactModel;
|
||||
import com.intellij.packaging.elements.CompositePackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElementResolvingContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,7 +40,10 @@ public interface ArtifactEditorContext extends PackagingElementResolvingContext
|
||||
ArtifactType getArtifactType();
|
||||
|
||||
@NotNull
|
||||
ModifiableArtifactModel getModifiableArtifactModel();
|
||||
ModifiableArtifactModel getOrCreateModifiableArtifactModel();
|
||||
|
||||
@Nullable
|
||||
ModifiableModuleModel getModifiableModuleModel();
|
||||
|
||||
@NotNull
|
||||
ManifestFileConfiguration getManifestFile(CompositePackagingElement<?> element, ArtifactType artifactType);
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class ArtifactConfigurable extends ProjectStructureElementConfigurable<Ar
|
||||
public void setDisplayName(String name) {
|
||||
final String oldName = getArtifact().getName();
|
||||
if (name != null && !name.equals(oldName) && !myIsInUpdateName) {
|
||||
myArtifactsStructureContext.getModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact).setName(name);
|
||||
myArtifactsStructureContext.getOrCreateModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact).setName(name);
|
||||
myEditor.updateOutputPath(oldName, name);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.roots.ui.configuration.artifacts;
|
||||
|
||||
import com.intellij.facet.Facet;
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModuleRootModel;
|
||||
@@ -57,8 +58,12 @@ public class ArtifactEditorContextImpl implements ArtifactEditorContext {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ModifiableArtifactModel getModifiableArtifactModel() {
|
||||
return myParent.getModifiableArtifactModel();
|
||||
public ModifiableArtifactModel getOrCreateModifiableArtifactModel() {
|
||||
return myParent.getOrCreateModifiableArtifactModel();
|
||||
}
|
||||
|
||||
public ModifiableModuleModel getModifiableModuleModel() {
|
||||
return myParent.getModifiableModuleModel();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-2
@@ -128,7 +128,7 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
|
||||
}
|
||||
|
||||
public void apply() {
|
||||
final ModifiableArtifact modifiableArtifact = myContext.getModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact);
|
||||
final ModifiableArtifact modifiableArtifact = myContext.getOrCreateModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact);
|
||||
modifiableArtifact.setBuildOnMake(myBuildOnMakeCheckBox.isSelected());
|
||||
modifiableArtifact.setOutputPath(getConfiguredOutputPath());
|
||||
myPropertiesEditors.applyProperties();
|
||||
@@ -387,7 +387,7 @@ public class ArtifactEditorImpl implements ArtifactEditorEx {
|
||||
}
|
||||
|
||||
public void setArtifactType(ArtifactType artifactType) {
|
||||
final ModifiableArtifact modifiableArtifact = myContext.getModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact);
|
||||
final ModifiableArtifact modifiableArtifact = myContext.getOrCreateModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact);
|
||||
modifiableArtifact.setArtifactType(artifactType);
|
||||
|
||||
myPropertiesEditors.removeTabs(myTabbedPane);
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ public class ArtifactPropertiesEditors {
|
||||
|
||||
public void applyProperties() {
|
||||
myEditor.apply();
|
||||
final ModifiableArtifact artifact = myContext.getModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact);
|
||||
final ModifiableArtifact artifact = myContext.getOrCreateModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact);
|
||||
artifact.setProperties(myProvider, myProperties);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -125,7 +125,7 @@ public class ArtifactsStructureConfigurable extends BaseStructureConfigurable {
|
||||
}
|
||||
|
||||
public ModifiableArtifactModel getModifiableArtifactModel() {
|
||||
return myPackagingEditorContext.getModifiableArtifactModel();
|
||||
return myPackagingEditorContext.getOrCreateModifiableArtifactModel();
|
||||
}
|
||||
|
||||
protected AbstractAddGroup createAddAction() {
|
||||
@@ -178,7 +178,7 @@ public class ArtifactsStructureConfigurable extends BaseStructureConfigurable {
|
||||
name = DEFAULT_ARTIFACT_NAME + i;
|
||||
i++;
|
||||
}
|
||||
final ModifiableArtifact artifact = myPackagingEditorContext.getModifiableArtifactModel().addArtifact(name, type, artifactTemplate.createRootElement(name));
|
||||
final ModifiableArtifact artifact = myPackagingEditorContext.getOrCreateModifiableArtifactModel().addArtifact(name, type, artifactTemplate.createRootElement(name));
|
||||
selectNodeInTree(findNodeByObject(myRoot, artifact));
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ public class ArtifactsStructureConfigurable extends BaseStructureConfigurable {
|
||||
|
||||
@Override
|
||||
protected void removeArtifact(Artifact artifact) {
|
||||
myPackagingEditorContext.getModifiableArtifactModel().removeArtifact(artifact);
|
||||
myPackagingEditorContext.getOrCreateModifiableArtifactModel().removeArtifact(artifact);
|
||||
myContext.getDaemonAnalyzer().removeElement(new ArtifactProjectStructureElement(myContext, myPackagingEditorContext, artifact));
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.configuration.artifacts;
|
||||
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactType;
|
||||
import com.intellij.packaging.artifacts.ModifiableArtifactModel;
|
||||
@@ -23,13 +24,14 @@ import com.intellij.packaging.elements.PackagingElementResolvingContext;
|
||||
import com.intellij.packaging.ui.ArtifactEditor;
|
||||
import com.intellij.packaging.ui.ManifestFileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface ArtifactsStructureConfigurableContext extends PackagingElementResolvingContext {
|
||||
@NotNull
|
||||
ModifiableArtifactModel getModifiableArtifactModel();
|
||||
ModifiableArtifactModel getOrCreateModifiableArtifactModel();
|
||||
|
||||
@NotNull
|
||||
ManifestFileConfiguration getManifestFile(CompositePackagingElement<?> element, ArtifactType artifactType);
|
||||
@@ -44,4 +46,7 @@ public interface ArtifactsStructureConfigurableContext extends PackagingElementR
|
||||
|
||||
@NotNull
|
||||
Artifact getOriginalArtifact(@NotNull Artifact artifact);
|
||||
|
||||
@Nullable
|
||||
ModifiableModuleModel getModifiableModuleModel();
|
||||
}
|
||||
|
||||
+7
-2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.configuration.artifacts;
|
||||
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.configuration.FacetsProvider;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
@@ -73,6 +74,10 @@ class ArtifactsStructureConfigurableContextImpl implements ArtifactsStructureCon
|
||||
return artifact;
|
||||
}
|
||||
|
||||
public ModifiableModuleModel getModifiableModuleModel() {
|
||||
return myContext.getModulesConfigurator().getModuleModel();
|
||||
}
|
||||
|
||||
public CompositePackagingElement<?> getRootElement(@NotNull Artifact artifact) {
|
||||
artifact = getOriginalArtifact(artifact);
|
||||
if (myModifiableModel != null) {
|
||||
@@ -95,7 +100,7 @@ class ArtifactsStructureConfigurableContextImpl implements ArtifactsStructureCon
|
||||
|
||||
public void editLayout(@NotNull Artifact artifact, Runnable action) {
|
||||
artifact = getOriginalArtifact(artifact);
|
||||
final ModifiableArtifact modifiableArtifact = getModifiableArtifactModel().getOrCreateModifiableArtifact(artifact);
|
||||
final ModifiableArtifact modifiableArtifact = getOrCreateModifiableArtifactModel().getOrCreateModifiableArtifact(artifact);
|
||||
if (modifiableArtifact.getRootElement() == artifact.getRootElement()) {
|
||||
modifiableArtifact.setRootElement(getOrCreateModifiableRootElement(artifact));
|
||||
}
|
||||
@@ -120,7 +125,7 @@ class ArtifactsStructureConfigurableContextImpl implements ArtifactsStructureCon
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ModifiableArtifactModel getModifiableArtifactModel() {
|
||||
public ModifiableArtifactModel getOrCreateModifiableArtifactModel() {
|
||||
if (myModifiableModel == null) {
|
||||
myModifiableModel = ArtifactManager.getInstance(myProject).createModifiableModel();
|
||||
myModifiableModel.addListener(myModifiableModelListener);
|
||||
|
||||
+1
-1
@@ -390,7 +390,7 @@ public class LayoutTreeComponent implements DnDTarget, Disposable {
|
||||
}
|
||||
|
||||
public void setRootElement(CompositePackagingElement<?> rootElement) {
|
||||
myContext.getModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact).setRootElement(rootElement);
|
||||
myContext.getOrCreateModifiableArtifactModel().getOrCreateModifiableArtifact(myOriginalArtifact).setRootElement(rootElement);
|
||||
myTreeStructure.updateRootElement();
|
||||
final DefaultMutableTreeNode node = myTree.getRootNode();
|
||||
node.setUserObject(myTreeStructure.getRootElement());
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public class ExtractArtifactAction extends LayoutTreeActionBase {
|
||||
if (name != null) {
|
||||
final Project project = myArtifactEditor.getContext().getProject();
|
||||
//todo[nik] select type?
|
||||
final ModifiableArtifact artifact = myArtifactEditor.getContext().getModifiableArtifactModel().addArtifact(name, PlainArtifactType.getInstance());
|
||||
final ModifiableArtifact artifact = myArtifactEditor.getContext().getOrCreateModifiableArtifactModel().addArtifact(name, PlainArtifactType.getInstance());
|
||||
treeComponent.editLayout(new Runnable() {
|
||||
public void run() {
|
||||
for (PackagingElement<?> element : selectedElements) {
|
||||
|
||||
+6
-2
@@ -16,6 +16,8 @@
|
||||
package com.intellij.openapi.roots.ui.configuration.artifacts.sourceItems;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModulePointer;
|
||||
import com.intellij.openapi.module.ModulePointerManager;
|
||||
import com.intellij.packaging.elements.PackagingElement;
|
||||
import com.intellij.packaging.elements.PackagingElementOutputKind;
|
||||
import com.intellij.packaging.impl.elements.ModuleOutputPackagingElement;
|
||||
@@ -46,7 +48,8 @@ public class ModuleOutputSourceItem extends PackagingSourceItem {
|
||||
|
||||
@Override
|
||||
public SourceItemPresentation createPresentation(@NotNull ArtifactEditorContext context) {
|
||||
return new DelegatedSourceItemPresentation(new ModuleElementPresentation(myModule.getName(), myModule, context)) {
|
||||
final ModulePointer modulePointer = ModulePointerManager.getInstance(context.getProject()).create(myModule);
|
||||
return new DelegatedSourceItemPresentation(new ModuleElementPresentation(modulePointer, context)) {
|
||||
@Override
|
||||
public int getWeight() {
|
||||
return SourceItemWeights.MODULE_OUTPUT_WEIGHT;
|
||||
@@ -56,7 +59,8 @@ public class ModuleOutputSourceItem extends PackagingSourceItem {
|
||||
|
||||
@NotNull
|
||||
public List<? extends PackagingElement<?>> createElements(@NotNull ArtifactEditorContext context) {
|
||||
return Collections.singletonList(new ModuleOutputPackagingElement(myModule.getName()));
|
||||
final ModulePointer modulePointer = ModulePointerManager.getInstance(context.getProject()).create(myModule);
|
||||
return Collections.singletonList(new ModuleOutputPackagingElement(context.getProject(), modulePointer));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user