コード例 #1
0
  /** Initializes the wizard page controls with data. */
  protected void initControls() {
    String configId = config != null ? config.getGuid() : ""; // $NON-NLS-1$

    if ((config != null)
        && ConfigFreeProcessPublishUtil.getInstance().isSameMethodConfiguration(config)) {
      // For config free process publish
      processViewer.setContentProvider(new ProcessViewerOfConfigFreeContentProvider());
      publishConfigRadioButton.setEnabled(false);
      publishConfigRadioButton.setSelection(false);
      publishProcessesRadioButton.setSelection(true);
      processViewer.getControl().setEnabled(true);

      List<String> processIds = PublishingUIPreferences.getProcesses(configId);
      List<Process> processes = new ArrayList<Process>();
      if (processIds != null) {
        for (String guid : processIds) {
          MethodElement e =
              LibraryService.getInstance().getCurrentLibraryManager().getMethodElement(guid);
          if (e instanceof Process) {
            processes.add((Process) e);
          }
        }
      }
      processViewer.setCheckedElements(processes.toArray());

      boolean includeBaseProcess = PublishingUIPreferences.getIncludeBaseProcesses(configId);
      includeBaseProcessesCheckbox.setSelection(includeBaseProcess);

      updateCheckedStates();
    } else {
      processViewer.setContentProvider(new ProcessViewerContentProvider());
      boolean publishConfig = PublishingUIPreferences.getPublishEntireConfig(configId);
      publishConfigRadioButton.setEnabled(true);
      publishConfigRadioButton.setSelection(publishConfig);
      publishProcessesRadioButton.setSelection(!publishConfig);
      processViewer.getControl().setEnabled(!publishConfig);

      if (!publishConfig) {
        List<String> processIds = PublishingUIPreferences.getProcesses(configId);
        List<Process> processes = new ArrayList<Process>();
        if (processIds != null) {
          for (String guid : processIds) {
            MethodElement e =
                LibraryService.getInstance().getCurrentLibraryManager().getMethodElement(guid);
            if (e instanceof Process) {
              processes.add((Process) e);
            }
          }
        }
        processViewer.setCheckedElements(processes.toArray());
      }

      boolean includeBaseProcess = PublishingUIPreferences.getIncludeBaseProcesses(configId);
      includeBaseProcessesCheckbox.setSelection(includeBaseProcess);

      updateCheckedStates();
    }
  }
コード例 #2
0
  public void setPackagePresentation(String command, boolean update) {

    if (command.contains("flat")) {
      patternsTreeViewer.setContentProvider(flatCP);
      patternsTreeViewer.setLabelProvider(flatLP);
    } else {
      patternsTreeViewer.setContentProvider(hierarchicalCP);
      patternsTreeViewer.setLabelProvider(hierarchicalLP);
    }

    if (update) {
      patternsViewerInput.getGeneratedPatternsRoot().updateSelection(patternsTreeViewer);
      patternsViewerInput.getGenericPatternsRoot().updateSelection(patternsTreeViewer);
    }
  }
コード例 #3
0
  private void createTaskTree(Composite parent) {
    PatternFilter filter = new PatternFilter();
    FilteredTree filteredTree =
        new FilteredTree(parent, SWT.CHECK | SWT.BORDER, filter, true) {
          @Override
          protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
            return new ContainerCheckedTreeViewer(parent, style);
          }
        };
    taskSelectionTreeViewer = (CheckboxTreeViewer) filteredTree.getViewer();
    filteredTree.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Add multi column support
    Tree tree = taskSelectionTreeViewer.getTree();
    tree.setHeaderVisible(true);
    TreeColumn column1 = new TreeColumn(tree, SWT.LEFT);
    column1.setText("Project/Task");
    TreeColumn column2 = new TreeColumn(tree, SWT.LEFT);
    column2.setText("Description");
    column1.pack();
    column2.pack();

    taskSelectionTreeViewer.setLabelProvider(new GradleTaskTreeLabelProvider());
    taskSelectionTreeViewer.setContentProvider(
        new GradleTaskTreeContentProvider(taskSelectionTreeViewer, true));
    taskSelectionTreeViewer.setCheckStateProvider(tasksChecked);
    taskSelectionTreeViewer.addCheckStateListener(tasksChecked);

    if (project != null) {
      setTreeInput(project);
    }
  }
コード例 #4
0
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    composite.setLayout(new GridLayout(1, false));

    treeViewer = new CheckboxTreeViewer(composite, SWT.CHECK | SWT.BORDER);
    treeViewer.setContentProvider(
        new ReferenceTreeContentProvider(DatabasePackage.Literals.TABLE_RESOURCE_DATA__COLUMNS));
    treeViewer.getTree().setHeaderVisible(true);
    treeViewer.getTree().setLinesVisible(true);
    createColumns(treeViewer);

    //		treeViewer.addCheckStateListener(new ICheckStateListener() {
    //			@Override
    //			public void checkStateChanged(CheckStateChangedEvent event) {
    //				Object[] objects = treeViewer.getCheckedElements();
    //				List<TableColumn> columnList = new ArrayList<TableColumn>();
    //				for (Object obj : objects) {
    //					if (obj instanceof TableColumn) {
    //						columnList.add((TableColumn) obj);
    //					}
    //				}
    //				result = columnList.toArray(new TableColumn[0]);
    //			}
    //		});
    treeViewer.setInput(input);
    GridDataFactory.fillDefaults().hint(-1, 300).applyTo(treeViewer.getTree());
    return composite;
  }
コード例 #5
0
ファイル: EventTreeDialog.java プロジェクト: eclipse/ptp
  @Override
  protected Control createDialogArea(Composite top) {
    top.getShell().setText(Messages.EventTreeDialog_PapiEventSelection);
    final Composite parent = (Composite) super.createDialogArea(top);
    final GridLayout gl = new GridLayout();
    parent.setLayout(gl);

    final GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 500;
    gd.widthHint = 350;

    treeV = new CheckboxTreeViewer(parent, SWT.BORDER);

    ColumnViewerToolTipSupport.enableFor(treeV);

    // et=new EventTree();

    cSelect = new PapiCSelect(toolPath, utilBlob); // "E:\\PAPIProject\\ptest2.xml");//
    et = cSelect.getEventTree();

    treeV.setContentProvider(et);

    // tree=treeV.getTree();

    treeV.getTree().setLayoutData(gd);
    // tree.setLayoutData(gd);
    treeV.setLabelProvider(new ETreeCellLabelProvider());

    treeV.setInput(et);
    treeV.setGrayedElements(new Object[0]);
    treeV.expandToLevel(3);
    treeV.addCheckStateListener(
        new ICheckStateListener() {

          public void checkStateChanged(CheckStateChangedEvent event) {
            final Object element = event.getElement();

            if (treeV.getGrayed(element)) {
              treeV.setChecked(element, true);
              return;
            }

            if (element instanceof ETItem) {
              doCheck((ETItem) element, event.getChecked());
            }
          }
        });

    return parent;
  }
コード例 #6
0
  /**
   * Creates this group's tree viewer.
   *
   * @param parent parent composite
   * @param width the width
   * @param height the height
   */
  protected void createTreeViewer(Composite parent, int width, int height) {
    Tree tree = new Tree(parent, SWT.CHECK | SWT.BORDER);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.widthHint = width;
    data.heightHint = height;
    tree.setLayoutData(data);

    fTreeViewer = new CheckboxTreeViewer(tree);
    fTreeViewer.setUseHashlookup(true);
    fTreeViewer.setContentProvider(fTreeContentProvider);
    fTreeViewer.setLabelProvider(fTreeLabelProvider);
    fTreeViewer.addTreeListener(this);
    fTreeViewer.addCheckStateListener(this);
    fTreeViewer.addSelectionChangedListener(this);
  }
コード例 #7
0
  /**
   * @see
   *     org.suggs.sandbox.swt.treesntables.treeviewer.FileTree#createContents(org.eclipse.swt.widgets.Composite)
   */
  @Override
  protected Control createContents(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(1, false));

    Button preserveCase = new Button(comp, SWT.CHECK);
    preserveCase.setSelection(true);
    preserveCase.setText("&Preserve Case");

    final CheckboxTreeViewer tv = new CheckboxTreeViewer(comp);
    tv.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    tv.setContentProvider(new FileTreeContentProvider());
    tv.setLabelProvider(new FileTreeLabelProvider());
    tv.setInput("root");

    // now add the listener
    preserveCase.addSelectionListener(
        new SelectionAdapter() {

          /**
           * @see
           *     org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
           */
          @Override
          public void widgetSelected(SelectionEvent event) {
            boolean pc = ((Button) event.widget).getSelection();
            FileTreeLabelProvider ftlp = (FileTreeLabelProvider) tv.getLabelProvider();
            ftlp.setPreserveCase(pc);
          }
        });

    tv.addCheckStateListener(
        new ICheckStateListener() {

          /**
           * @see
           *     org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
           */
          @Override
          public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) {
              tv.setSubtreeChecked(event.getElement(), true);
            }
          }
        });

    return comp;
  }
コード例 #8
0
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    composite.setLayout(new GridLayout(1, false));

    treeViewer = new CheckboxTreeViewer(composite, SWT.CHECK | SWT.BORDER);
    treeViewer.setContentProvider(
        new ReferenceTreeContentProvider(DatabasePackage.Literals.TABLE_RESOURCE_DATA__INDEXES));
    treeViewer.getTree().setHeaderVisible(true);
    treeViewer.getTree().setLinesVisible(true);
    createColumns(treeViewer);

    treeViewer.setInput(input);
    GridDataFactory.fillDefaults().hint(-1, 300).applyTo(treeViewer.getTree());
    return composite;
  }
コード例 #9
0
  /**
   * Creates the tree viewer.
   *
   * @param parent the parent composite
   * @return the tree viewer
   */
  protected CheckboxTreeViewer createTreeViewer(Composite parent) {
    fViewer = new CheckboxTreeViewer(parent, SWT.BORDER);

    fViewer.setContentProvider(fContentProvider);
    fViewer.setLabelProvider(fLabelProvider);
    fViewer.addCheckStateListener(
        new ICheckStateListener() {
          public void checkStateChanged(CheckStateChangedEvent event) {
            updateOKStatus();
          }
        });

    fViewer.setComparator(new ResourceComparator(ResourceComparator.NAME));
    if (fFilters != null) {
      for (int i = 0; i != fFilters.size(); i++) fViewer.addFilter(fFilters.get(i));
    }

    fViewer.setInput(fInput);

    return fViewer;
  }
コード例 #10
0
  /*
   * @see PreferencePage#createContents(Composite)
   */
  @Override
  protected Control createContents(final Composite parent) {
    // create composite
    final Composite comp = parent;

    final GridLayout topLayout = new GridLayout();
    comp.setLayout(topLayout);

    final Group tracedModulesGroup = new Group(comp, SWT.NONE);
    tracedModulesGroup.setText("Traced modules");
    final GridData gd_interpretedModulesGroup = new GridData();
    tracedModulesGroup.setLayoutData(gd_interpretedModulesGroup);
    tracedModulesGroup.setLayout(new GridLayout());

    checkboxTreeViewer = new CheckboxTreeViewer(tracedModulesGroup, SWT.BORDER);
    checkboxTreeViewer.addCheckStateListener(
        new ICheckStateListener() {
          @SuppressWarnings("synthetic-access")
          public void checkStateChanged(final CheckStateChangedEvent event) {
            final DebugTab.DebugTreeItem dti = (DebugTreeItem) event.getElement();
            checkboxTreeViewer.setGrayed(dti, false);
            final boolean checked = event.getChecked();
            setSubtreeChecked(dti, checked, tracedModules, checkboxTreeViewer);
            DebugTab.checkUpwards(checkboxTreeViewer, dti, checked, false);
          }
        });
    checkboxTreeViewer.setLabelProvider(new TreeLabelProvider());
    checkboxTreeViewer.setContentProvider(new TreeContentProvider());
    final Tree tree = checkboxTreeViewer.getTree();
    final GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd_tree.minimumWidth = 250;
    gd_tree.minimumHeight = 120;
    gd_tree.widthHint = 256;
    gd_tree.heightHint = 220;
    tree.setLayoutData(gd_tree);

    applyDialogFont(comp);
    return comp;
  }
コード例 #11
0
  /**
   * Creates the tree viewer.
   *
   * @param parent the parent composite
   * @return the tree viewer
   */
  protected CheckboxTreeViewer createTreeViewer(Composite parent) {
    if (fContainerMode) {
      fViewer = new ContainerCheckedTreeViewer(parent, this.fStyle);
    } else {
      fViewer = new CheckboxTreeViewer(parent, this.fStyle);
    }
    fViewer.setContentProvider(fContentProvider);
    fViewer.setLabelProvider(fLabelProvider);
    fViewer.addCheckStateListener(
        new ICheckStateListener() {

          public void checkStateChanged(CheckStateChangedEvent event) {
            updateOKStatus();
          }
        });
    fViewer.setComparator(fComparator);
    if (fFilters != null) {
      for (int i = 0; i != fFilters.size(); i++) {
        fViewer.addFilter((ViewerFilter) fFilters.get(i));
      }
    }
    fViewer.setInput(fInput);
    return fViewer;
  }
コード例 #12
0
  @Override
  protected Control createExtendedContentArea(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().applyTo(composite);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(composite);

    Label label = new Label(composite, SWT.NONE);
    label.setText("Select the connections to be searched for opening pages:");

    CheckboxTreeViewer dataManagerTreeViewers = new CheckboxTreeViewer(composite, SWT.BORDER);
    GridDataFactory.fillDefaults()
        .align(SWT.FILL, SWT.CENTER)
        .grab(true, false)
        .applyTo(dataManagerTreeViewers.getControl());
    dataManagerTreeViewers.setContentProvider(
        new ITreeContentProvider() {

          public Object[] getChildren(Object parentElement) {
            // TODO Auto-generated method stub
            return null;
          }

          public Object getParent(Object element) {
            // TODO Auto-generated method stub
            return null;
          }

          public boolean hasChildren(Object element) {
            // TODO Auto-generated method stub
            return false;
          }

          public Object[] getElements(Object inputElement) {
            return DataManagerRegistry.getDefault().getDataManagers().toArray();
          }

          public void dispose() {
            // TODO Auto-generated method stub

          }

          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            // TODO Auto-generated method stub

          }
        });
    dataManagerTreeViewers.setLabelProvider(new WorkbenchLabelProvider());
    dataManagerTreeViewers.setInput(this);

    for (DataManager dataManager : targetDataManagers)
      dataManagerTreeViewers.setChecked(dataManager, true);

    dataManagerTreeViewers.addCheckStateListener(
        new ICheckStateListener() {
          public void checkStateChanged(CheckStateChangedEvent event) {
            if (event.getChecked()) targetDataManagers.add((DataManager) event.getElement());
            else targetDataManagers.remove(event.getElement());
          }
        });

    return composite;
  }
コード例 #13
0
 /**
  * Sets the tree viewer's providers to those passed
  *
  * @param contentProvider ITreeContentProvider
  * @param labelProvider ILabelProvider
  */
 public void setTreeProviders(ITreeContentProvider contentProvider, ILabelProvider labelProvider) {
   fTreeViewer.setContentProvider(contentProvider);
   fTreeViewer.setLabelProvider(labelProvider);
 }
コード例 #14
0
  /*
   * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
   */
  public void createControl(Composite parent) {
    initializeDialogUnits(parent);

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
    setControl(composite);

    Label label = new Label(composite, SWT.WRAP);
    label.setText(WorkingSetMessages.ScriptWorkingSetPage_workingSet_name);
    GridData gd =
        new GridData(
            GridData.GRAB_HORIZONTAL
                | GridData.HORIZONTAL_ALIGN_FILL
                | GridData.VERTICAL_ALIGN_CENTER);
    label.setLayoutData(gd);

    fWorkingSetName = new Text(composite, SWT.SINGLE | SWT.BORDER);
    fWorkingSetName.setLayoutData(
        new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    fWorkingSetName.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            validateInput();
          }
        });
    fWorkingSetName.setFocus();

    label = new Label(composite, SWT.WRAP);
    label.setText(WorkingSetMessages.ScriptWorkingSetPage_workingSet_content);
    gd =
        new GridData(
            GridData.GRAB_HORIZONTAL
                | GridData.HORIZONTAL_ALIGN_FILL
                | GridData.VERTICAL_ALIGN_CENTER);
    label.setLayoutData(gd);

    fTree = new CheckboxTreeViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
    gd.heightHint = convertHeightInCharsToPixels(15);
    fTree.getControl().setLayoutData(gd);

    fTreeContentProvider = new ScriptWorkingSetPageContentProvider();
    fTree.setContentProvider(fTreeContentProvider);

    AppearanceAwareLabelProvider fScriptElementLabelProvider =
        new AppearanceAwareLabelProvider(
            AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | ScriptElementLabels.P_COMPRESSED,
            AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS
                | ScriptElementImageProvider.SMALL_ICONS,
            DLTKUIPlugin.getDefault().getPreferenceStore());

    fTree.setLabelProvider(new DecoratingModelLabelProvider(fScriptElementLabelProvider));
    fTree.setSorter(new ModelElementSorter());
    if (DLTKCore.DEBUG) {
      System.err.println("Add empty inner package filter support here..."); // $NON-NLS-1$
    }
    // fTree.addFilter(new EmptyInnerPackageFilter());
    fTree.setUseHashlookup(true);

    fTree.setInput(DLTKCore.create(ResourcesPlugin.getWorkspace().getRoot()));

    fTree.addCheckStateListener(
        new ICheckStateListener() {
          public void checkStateChanged(CheckStateChangedEvent event) {
            handleCheckStateChange(event);
          }
        });

    fTree.addTreeListener(
        new ITreeViewerListener() {
          public void treeCollapsed(TreeExpansionEvent event) {}

          public void treeExpanded(TreeExpansionEvent event) {
            final Object element = event.getElement();
            if (fTree.getGrayed(element) == false)
              BusyIndicator.showWhile(
                  getShell().getDisplay(),
                  new Runnable() {
                    public void run() {
                      setSubtreeChecked(element, fTree.getChecked(element), false);
                    }
                  });
          }
        });

    // Add select / deselect all buttons for bug 46669
    Composite buttonComposite = new Composite(composite, SWT.NONE);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    buttonComposite.setLayout(layout);
    buttonComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));

    Button selectAllButton = new Button(buttonComposite, SWT.PUSH);
    selectAllButton.setText(WorkingSetMessages.ScriptWorkingSetPage_selectAll_label);
    selectAllButton.setToolTipText(WorkingSetMessages.ScriptWorkingSetPage_selectAll_toolTip);
    selectAllButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent selectionEvent) {
            fTree.setCheckedElements(fTreeContentProvider.getElements(fTree.getInput()));
            validateInput();
          }
        });
    selectAllButton.setLayoutData(new GridData());
    SWTUtil.setButtonDimensionHint(selectAllButton);

    Button deselectAllButton = new Button(buttonComposite, SWT.PUSH);
    deselectAllButton.setText(WorkingSetMessages.ScriptWorkingSetPage_deselectAll_label);
    deselectAllButton.setToolTipText(WorkingSetMessages.ScriptWorkingSetPage_deselectAll_toolTip);
    deselectAllButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent selectionEvent) {
            fTree.setCheckedElements(new Object[0]);
            validateInput();
          }
        });
    deselectAllButton.setLayoutData(new GridData());
    SWTUtil.setButtonDimensionHint(deselectAllButton);

    if (fWorkingSet != null) fWorkingSetName.setText(fWorkingSet.getName());
    initializeCheckedState();
    validateInput();

    Dialog.applyDialogFont(composite);
    // Set help for the page
    if (DLTKCore.DEBUG) {
      System.err.println("Add help support here..."); // $NON-NLS-1$
    }
    // ScriptUIHelp.setHelp(fTree, IScriptHelpContextIds.Script_WORKING_SET_PAGE);
  }
コード例 #15
0
  private void createProjectsList(final Composite workArea) {
    final Label projectsLabel = new Label(workArea, SWT.NULL);
    projectsLabel.setText("Projects:");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(projectsLabel);

    Composite projectListGroup = new Composite(workArea, SWT.NULL);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(projectListGroup);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(projectListGroup);
    projectList = new CheckboxTreeViewer(projectListGroup);
    PixelConverter pc = new PixelConverter(projectList.getControl());
    GridDataFactory.fillDefaults()
        .grab(true, true)
        .align(SWT.FILL, SWT.FILL)
        .hint(pc.convertWidthInCharsToPixels(25), pc.convertHeightInCharsToPixels(10))
        .applyTo(projectList.getControl());

    projectList.setLabelProvider(new ProjectCandidateLabelProvider());
    projectList.setContentProvider(
        new ITreeContentProvider() {

          @Override
          public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}

          @Override
          public void dispose() {}

          @Override
          public boolean hasChildren(Object element) {
            return false;
          }

          @Override
          public Object getParent(Object element) {
            return null;
          }

          @Override
          public Object[] getElements(Object inputElement) {
            if (candidates == null) return new ProjectCandidate[0];
            return candidates;
          }

          @Override
          public Object[] getChildren(Object parentElement) {
            return null;
          }
        });

    projectList.addCheckStateListener(
        new ICheckStateListener() {

          @Override
          public void checkStateChanged(CheckStateChangedEvent event) {
            ProjectCandidate candidate = (ProjectCandidate) event.getElement();
            // Cancel out existing projects
            if (candidate.exists()) {
              projectList.setChecked(candidate, false);
              return;
            }
            // Update conflicts
            for (ProjectCandidate elem : candidates) {
              Widget w1 = elem.getWidget();
              Widget w2 = candidate.getWidget();
              if (w1.getId().equals(w2.getId())
                  && w1.getName().equals(w2.getName())
                  && !elem.configLocation.equals(candidate.configLocation)) {
                if (projectList.getChecked(elem)) {
                  projectList.setChecked(candidate, false);
                } else {
                  elem.conflicts = event.getChecked();
                }
              }
            }
            projectList.refresh(true);
            setPageComplete(projectList.getCheckedElements().length > 0);
          }
        });

    final Composite selectButtonGroup = new Composite(projectListGroup, SWT.NULL);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(selectButtonGroup);
    GridLayoutFactory.fillDefaults().applyTo(selectButtonGroup);

    Button selectAll = new Button(selectButtonGroup, SWT.PUSH);
    selectAll.setText("Select All");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(selectAll);

    Button deselectAll = new Button(selectButtonGroup, SWT.PUSH);
    deselectAll.setText("Deselect All");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(deselectAll);

    Button refresh = new Button(selectButtonGroup, SWT.PUSH);
    refresh.setText("Refresh");
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(refresh);

    selectAll.addListener(
        SWT.Selection,
        new Listener() {

          @Override
          public void handleEvent(Event event) {
            if (candidates != null) {
              for (ProjectCandidate candie : candidates) {
                projectList.setChecked(candie, true);
              }
            }
            setPageComplete(projectList.getCheckedElements().length > 0);
          }
        });

    deselectAll.addListener(
        SWT.Selection,
        new Listener() {

          @Override
          public void handleEvent(Event event) {
            projectList.setCheckedElements(new Object[0]);
            setPageComplete(false);
          }
        });

    refresh.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            updateProjectsList(directoryPathField.getText());
          }
        });

    projectList.setInput(this);
  }
コード例 #16
0
  @Override
  protected Control createDialogArea(Composite parent) {
    Composite compLayout = (Composite) super.createDialogArea(parent);
    Composite container = new Composite(compLayout, SWT.NONE);
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout layout = new GridLayout();
    layout.verticalSpacing = 10;
    layout.marginTop = 10;
    container.setLayout(layout);

    Label lbl = new Label(container, SWT.NONE);
    lbl.setText("Select Resources from:");
    GridData gd;
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    lbl.setLayoutData(gd);

    Group resourceGroup = new Group(container, SWT.NONE);

    Color color = Display.getDefault().getSystemColor(SWT.COLOR_WHITE);

    resourceGroup.setLayout(new GridLayout());
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.heightHint = 300;
    gd.horizontalSpan = 2;
    resourceGroup.setLayoutData(gd);

    treeViewer = new CheckboxTreeViewer(resourceGroup);
    treeViewer.getTree().setBackground(color);
    gd = new GridData();
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    // gd.heightHint = 300;
    treeViewer.getTree().setLayoutData(gd);
    treeViewer.setContentProvider(new TreeContentProvider());
    treeViewer.setLabelProvider(new TreeLabelProvider());
    treeViewer.setInput(new Object());
    treeViewer.addCheckStateListener(
        new ICheckStateListener() {

          @Override
          public void checkStateChanged(CheckStateChangedEvent e) {
            Device dev = (Device) e.getElement();
            if (null != dev) {
              if (e.getChecked()) {
                selectedDeviceList.add(dev);
                System.out.println("Checked" + dev.getDeviceName());
              } else {
                selectedDeviceList.remove(dev);
                System.out.println("Unchecked:" + dev.getDeviceName());
              }
            }
          }
        });

    return compLayout;
  }