@Nullable public static VirtualFile showDialogAndCreateManifest( final ArtifactEditorContext context, final CompositePackagingElement<?> element) { FileChooserDescriptor descriptor = createDescriptorForManifestDirectory(); final VirtualFile directory = suggestManifestFileDirectory(element, context, context.getArtifactType()); final VirtualFile file = FileChooser.chooseFile(descriptor, context.getProject(), directory); if (file == null) { return null; } return createManifestFile(file, context.getProject()); }
private void updateManifest() { myManifestFileConfiguration = myContext.getManifestFile(myElement, myContext.getArtifactType()); final String card; if (myManifestFileConfiguration != null) { card = "properties"; myManifestPathField.setText( FileUtil.toSystemDependentName(myManifestFileConfiguration.getManifestFilePath())); myMainClassField.setText(StringUtil.notNullize(myManifestFileConfiguration.getMainClass())); myClasspathField.setText(StringUtil.join(myManifestFileConfiguration.getClasspath(), " ")); } else { card = "buttons"; myManifestPathField.setText(""); } ((CardLayout) myPropertiesPanel.getLayout()).show(myPropertiesPanel, card); }
public static void addManifestFileToLayout( final @NotNull String path, final @NotNull ArtifactEditorContext context, final @NotNull CompositePackagingElement<?> element) { context.editLayout( context.getArtifact(), new Runnable() { public void run() { final VirtualFile file = findManifestFile(element, context, context.getArtifactType()); if (file == null || !FileUtil.pathsEqual(file.getPath(), path)) { PackagingElementFactory.getInstance() .addFileCopy(element, MANIFEST_DIR_NAME, path, MANIFEST_FILE_NAME); } } }); }
private static Collection<? extends PackagingSourceItem> createClasspathItems( ArtifactEditorContext editorContext, Artifact artifact, @NotNull Module module) { final List<PackagingSourceItem> items = new ArrayList<PackagingSourceItem>(); final ModuleRootModel rootModel = editorContext.getModulesProvider().getRootModel(module); List<Library> libraries = new ArrayList<Library>(); for (OrderEntry orderEntry : rootModel.getOrderEntries()) { if (orderEntry instanceof LibraryOrderEntry) { final LibraryOrderEntry libraryEntry = (LibraryOrderEntry) orderEntry; final Library library = libraryEntry.getLibrary(); final DependencyScope scope = libraryEntry.getScope(); if (library != null && scope.isForProductionRuntime()) { libraries.add(library); } } } for (Module toAdd : getNotAddedModules(editorContext, artifact, module)) { items.add(new ModuleOutputSourceItem(toAdd)); } for (Library library : getNotAddedLibraries(editorContext, artifact, libraries)) { items.add(new LibrarySourceItem(library)); } return items; }
@NotNull public List<? extends PackagingElement<?>> createElements( @NotNull ArtifactEditorContext context) { return Collections.singletonList( PackagingElementFactory.getInstance() .createArtifactElement(myArtifact, context.getProject())); }
private void chooseManifest() { final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) { @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { return super.isFileVisible(file, showHiddenFiles) && (file.isDirectory() || file.getName().equalsIgnoreCase(ManifestFileUtil.MANIFEST_FILE_NAME)); } }; descriptor.setTitle("Specify Path to MANIFEST.MF file"); final VirtualFile[] files = FileChooser.chooseFiles(myContext.getProject(), descriptor); if (files.length != 1) return; ManifestFileUtil.addManifestFileToLayout(files[0].getPath(), myContext, myElement); updateManifest(); myContext.getThisArtifactEditor().updateLayoutTree(); }
public SourceItemPresentation createPresentation(@NotNull ArtifactEditorContext context) { final ArtifactPointer pointer = ArtifactPointerManager.getInstance(context.getProject()).create(myArtifact); return new DelegatedSourceItemPresentation(new ArtifactElementPresentation(pointer, context)) { @Override public int getWeight() { return SourceItemWeights.ARTIFACT_WEIGHT; } }; }
private void createManifest() { final VirtualFile file = ManifestFileUtil.showDialogAndCreateManifest(myContext, myElement); if (file == null) { return; } ManifestFileUtil.addManifestFileToLayout(file.getPath(), myContext, myElement); updateManifest(); myContext.getThisArtifactEditor().updateLayoutTree(); }
public void setRootElement(CompositePackagingElement<?> rootElement) { myContext .getOrCreateModifiableArtifactModel() .getOrCreateModifiableArtifact(myOriginalArtifact) .setRootElement(rootElement); myTreeStructure.updateRootElement(); final DefaultMutableTreeNode node = myTree.getRootNode(); node.setUserObject(myTreeStructure.getRootElement()); myBuilder.updateNode(node); rebuildTree(); myArtifactsEditor.getSourceItemsTree().rebuildTree(); }
private static Collection<? extends PackagingSourceItem> createModuleItems( ArtifactEditorContext editorContext, Artifact artifact, @NotNull String[] groupPath) { final Module[] modules = editorContext.getModulesProvider().getModules(); final List<PackagingSourceItem> items = new ArrayList<PackagingSourceItem>(); Set<String> groups = new HashSet<String>(); for (Module module : modules) { String[] path = ModuleManager.getInstance(editorContext.getProject()).getModuleGroupPath(module); if (path == null) { path = ArrayUtil.EMPTY_STRING_ARRAY; } if (Comparing.equal(path, groupPath)) { items.add(new ModuleSourceItemGroup(module)); } else if (ArrayUtil.startsWith(path, groupPath)) { groups.add(path[groupPath.length]); } } for (String group : groups) { items.add(0, new ModuleGroupItem(ArrayUtil.append(groupPath, group))); } return items; }
@NotNull public List<? extends DirectoryCopyPackagingElement> chooseAndCreate( @NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement<?> parent) { final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createMultipleFoldersDescriptor(); final VirtualFile[] files = FileChooser.chooseFiles(descriptor, context.getProject(), null); final List<DirectoryCopyPackagingElement> list = new ArrayList<DirectoryCopyPackagingElement>(); for (VirtualFile file : files) { list.add(new DirectoryCopyPackagingElement(file.getPath())); } return list; }
public ElementWithManifestPropertiesPanel(E element, final ArtifactEditorContext context) { myElement = element; myContext = context; ManifestFileUtil.setupMainClassField(context.getProject(), myMainClassField); myClasspathField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Messages.showTextAreaDialog( myClasspathField.getTextField(), "Edit Classpath", "classpath-attribute-editor"); } }); myClasspathField .getTextField() .getDocument() .addDocumentListener( new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { myContext.queueValidation(); } }); myUseExistingManifestButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { chooseManifest(); } }); myCreateManifestButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { createManifest(); } }); }
public CompositePackagingElement<?> getRootElement() { return myContext.getRootElement(myOriginalArtifact); }
public void editLayout(Runnable action) { myContext.editLayout(myOriginalArtifact, action); }