コード例 #1
0
  public Composite createComposite(Composite parent, IWizardHandle handle) {
    this.handle = handle;
    handle.setTitle(Messages.ArchiveTitle);
    handle.setDescription(Messages.ArchiveDescription);
    handle.setImageDescriptor(JavaPluginImages.DESC_WIZBAN_ADD_LIBRARY);

    Composite c = new Composite(parent, SWT.NONE);
    PlatformUI.getWorkbench()
        .getHelpSystem()
        .setHelp(c, IJstCommonUIContextIds.DEPLOYMENT_ASSEMBLY_NEW_ARCHIVE_REFERENCE_P1);
    c.setLayout(new GridLayout(2, false));
    viewer = new TreeViewer(c, SWT.MULTI | SWT.BORDER);
    viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    viewer.setContentProvider(getContentProvider());
    viewer.setLabelProvider(getLabelProvider());
    viewer.setInput(ResourcesPlugin.getWorkspace());

    Composite buttonColumn = new Composite(c, SWT.NONE);
    buttonColumn.setLayoutData(new GridData(GridData.FILL_VERTICAL));

    final GridLayout gl = new GridLayout();
    gl.marginWidth = 0;
    gl.marginHeight = 0;

    buttonColumn.setLayout(gl);

    add = new Button(buttonColumn, SWT.NONE);
    add.setText(Messages.Add);
    GridDataFactory.defaultsFor(add).applyTo(add);

    remove = new Button(buttonColumn, SWT.NONE);
    remove.setText(Messages.Remove);
    GridDataFactory.defaultsFor(remove).applyTo(remove);

    add.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            buttonPressed();
          }

          public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
          }
        });

    remove.addSelectionListener(
        new SelectionListener() {
          public void widgetSelected(SelectionEvent e) {
            removeButtonPressed();
          }

          public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
          }
        });
    return c;
  }
コード例 #2
0
  protected void removeButtonPressed() {
    TreeItem[] toRemove = viewer.getTree().getSelection();

    if (toRemove != null && toRemove.length > 0) {
      for (int i = 0; i < toRemove.length; i++) {
        Path path = (Path) toRemove[i].getData();
        if (archives.containsKey(path)) {
          archives.remove(path);
        }
      }

      viewer.refresh();
      if (archives != null && archives.size() > 0) {
        isComplete = true;
      } else {
        isComplete = false;
      }
      handle.update();
    }
  }
コード例 #3
0
  protected void buttonPressed() {
    IProject project = (IProject) getTaskModel().getObject(IReferenceWizardConstants.PROJECT);
    selected = chooseEntries(add.getShell(), project.getFullPath());

    if (selected != null) {
      removeInvalidArchiveFiles();

      for (IPath path : selected) {
        if (!archives.containsKey(path)) {
          archives.put(path, path);
        }
      }

      viewer.refresh();
      if (archives != null && archives.size() > 0) {
        isComplete = true;
      } else {
        isComplete = false;
      }
      handle.update();
    }
  }