コード例 #1
0
  protected void initializeViewer() {
    Object[] elems = fSelection.toArray();
    ArrayList checked = new ArrayList(elems.length);

    for (int i = 0; i < elems.length; i++) {
      Object elem = elems[i];
      IProject project = null;

      if (elem instanceof IFile) {
        IFile file = (IFile) elem;
        project = file.getProject();
      } else if (elem instanceof IProject) {
        project = (IProject) elem;
      } else if (elem instanceof IJavaProject) {
        project = ((IJavaProject) elem).getProject();
      }
      if (project != null) {
        IModel model = findModelFor(project);
        if (model != null && !checked.contains(model)) {
          checked.add(model);
        }
      }
    }
    fExportPart.setSelection(checked.toArray());
    if (checked.size() > 0) fExportPart.getTableViewer().reveal(checked.get(0));
  }
コード例 #2
0
 private void handleWorkingSets() {
   IWorkingSetManager manager = PlatformUI.getWorkbench().getWorkingSetManager();
   IWorkingSetSelectionDialog dialog = manager.createWorkingSetSelectionDialog(getShell(), true);
   if (dialog.open() == Window.OK) {
     ArrayList models = new ArrayList();
     IWorkingSet[] workingSets = dialog.getSelection();
     for (int i = 0; i < workingSets.length; i++) {
       IAdaptable[] elements = workingSets[i].getElements();
       for (int j = 0; j < elements.length; j++) {
         IModel model = findModelFor(elements[j]);
         if (isValidModel(model)) {
           models.add(model);
         }
       }
     }
     fExportPart.setSelection(models.toArray());
   }
 }