@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());
  }
Ejemplo n.º 2
0
 @NotNull
 public List<? extends PackagingElement<?>> createElements(
     @NotNull ArtifactEditorContext context) {
   return Collections.singletonList(
       PackagingElementFactory.getInstance()
           .createArtifactElement(myArtifact, context.getProject()));
 }
Ejemplo n.º 3
0
 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;
     }
   };
 }
 @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;
 }
  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();
  }
  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;
  }
  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();
          }
        });
  }