Пример #1
0
  /** After clicking execute button, all data in dialog is saved to GoIOptionsPack */
  public void storeValuesToOptionsPack(QueryOptionsPack opt) {
    // store Length Limit
    opt.setLengthLimit(Integer.parseInt(lengthLimit.getText()));

    // if currentView is selected
    if (currentViewButton.getSelection()) {
      opt.setCurrentView(true);
    }
    // if newView is selected
    else {
      opt.setCurrentView(false);
    }

    if (downstreamButton != null) {
      // if downstream is selected
      if (downstreamButton.getSelection()) {
        opt.setDownstream(true);
        opt.setUpstream(false);
      }
      // if upstream is selected
      else if (upstreamButton.getSelection()) {
        opt.setDownstream(false);
        opt.setUpstream(true);
      }
      // if both is selected
      else {
        opt.setDownstream(true);
        opt.setUpstream(true);
      }
    }

    // store stop distance according to user's selection
    if (shortestPlusKButton != null) {
      opt.setLimitType(!shortestPlusKButton.getSelection());
      opt.setShortestPlusKLimit(Integer.parseInt(shortestPlusK.getText()));
    }

    // if strict is selected.
    if (strictButton != null && strictButton.getSelection()) {
      opt.setStrict(true);
    } else {
      opt.setStrict(false);
    }

    if (sourceST != null) opt.setSourceList(sourceST.getSymbols());
    if (targetST != null) opt.setTargetList(targetST.getSymbols());

    if (forSIF) {
      opt.setSifTypes(selectedTypes);
    }
  }
 /* (non-Javadoc)
  * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
  */
 public void setEnabled(boolean enabled) {
   fTree.getControl().setEnabled(enabled);
   if (enabled) {
     updateButtons();
   } else {
     fSelectButton.setEnabled(false);
     fSelectAllButton.setEnabled(false);
     fDeselectButton.setEnabled(false);
     fDeselectAllButton.setEnabled(false);
     fSelectRequiredButton.setEnabled(false);
     fCountLabel.setText(""); // $NON-NLS-1$
   }
   fModeLabel.setEnabled(enabled);
   fPluginModeButton.setEnabled(enabled);
   fFeaureModeButton.setEnabled(enabled);
   fShowLabel.setEnabled(enabled);
   fShowPluginsButton.setEnabled(enabled);
   fShowSourceButton.setEnabled(enabled);
   boolean isPluginMode = !fFeaureModeButton.getSelection();
   fGroupLabel.setEnabled(enabled && isPluginMode);
   if (fGroupCombo != null) {
     fGroupCombo.setEnabled(enabled && isPluginMode);
   } else {
     fGroupComboPart.setEnabled(enabled && isPluginMode);
   }
 }
 private void setButtonEnabled(String configKey, Button b, boolean enabled) {
   Boolean previousValue = oldBulkAPIDependencies.put(b, b.getSelection());
   b.setSelection(
       enabled
           ? (previousValue != null
               ? previousValue
               : this.controller.getConfig().getBoolean(configKey))
           : false);
   b.setEnabled(enabled);
 }
  /** Called when the user confirms the dialog */
  private void ok() {
    // The "stepname" variable will be the return value for the open() method.
    // Setting to step name from the dialog control
    stepname = wStepname.getText();
    // Setting the  settings to the meta object
    meta.setConsecutiveDelimsAsOne(wRemoveBlanks.getSelection());
    int nrfields = wGroup.nrNonEmpty();
    meta.allocate(nrfields);
    for (int i = 0; i < nrfields; i++) {
      TableItem item = wGroup.getNonEmpty(i);
      meta.getSourceFields()[i] = item.getText(1);
      meta.getSourceDelims()[i] = item.getText(2);
      meta.getOutputFields()[i] = item.getText(3);
      meta.getOutputDelims()[i] = item.getText(4);
    }

    // close the SWT dialog window
    dispose();
  }
 private Object[] getBundleChildren(Object parent) {
   Object[] result = null;
   if (parent == null) {
     result = fAllBundles.toArray();
   } else if (fFeaureModeButton.getSelection() && parent == OTHER_CATEGORY) {
     result = ((TargetDefinition) fTargetDefinition).getOtherBundles();
   } else if (fGrouping == GROUP_BY_CONTAINER && parent instanceof IBundleContainer) {
     IBundleContainer container = (IBundleContainer) parent;
     result = container.getBundles();
   } else if (fGrouping == GROUP_BY_FILE_LOC && parent instanceof IPath) {
     List bundles = (List) getFileBundleMapping().get(parent);
     if (bundles != null && bundles.size() > 0) {
       result = bundles.toArray();
     }
   }
   if (result == null) {
     return new Object[0];
   }
   return result;
 }
 private void updateCheckState() {
   List result = new ArrayList();
   // Checked error statuses
   if (fMissing != null) {
     result.addAll(fMissing);
   }
   if (fFeaureModeButton.getSelection()) {
     // Checked features and plugins
     result.addAll(((TargetDefinition) fTargetDefinition).getFeaturesAndBundles());
   } else {
     // Bundles with errors are already included from fMissing, do not add twice
     IResolvedBundle[] bundles = fTargetDefinition.getBundles();
     for (int i = 0; i < bundles.length; i++) {
       if (bundles[i].getStatus().isOK()) {
         result.add(bundles[i]);
       }
     }
   }
   fTree.setCheckedElements(result.toArray());
 }
Пример #7
0
 protected int getStyle() {
   int result = SWT.NONE;
   Control[] ctrls = styleComp.getChildren();
   if (ctrls.length == 0) {
     result = defaultStyle;
   } else {
     for (int i = 0; i < ctrls.length; i++) {
       if (ctrls[i] instanceof Button) {
         Button button = (Button) ctrls[i];
         if (button.getSelection()) {
           Object data = button.getData("style");
           if (data instanceof Integer) {
             int style = ((Integer) data).intValue();
             result |= style;
           }
         }
       }
     }
   }
   return result;
 }
 /* (non-Javadoc)
  * @see org.eclipse.pde.internal.ui.editor.StructuredViewerSection#buttonSelected(int)
  */
 protected void buttonSelected(int index) {
   switch (index) {
     case 0:
       handleAdd();
       break;
     case 1:
       handleAddWorkingSet();
       break;
     case 2:
       handleAddRequired(getProduct().getPlugins(), fIncludeOptionalButton.getSelection());
       break;
     case 3:
       handleDelete();
       break;
     case 4:
       handleRemoveAll();
       break;
     case 5:
       handleProperties();
       break;
   }
 }
  private void addFilters() {
    fVersionFilter = new VersionFilter();
    fVersionFilter.setModel(fModels);
    fSourceFilter = new SourcePluginFilter(fPage1.getState());
    fAvailableFilter = new AvailableFilter();
    fAvailableListViewer.addFilter(fAvailableFilter);
    if (fFilterOldVersionButton.getSelection()) {
      fAvailableListViewer.addFilter(fVersionFilter);
    }
    fAvailableListViewer.addFilter(fSourceFilter);
    fRepositoryFilter = new RepositoryFilter();
    fAvailableListViewer.addFilter(fRepositoryFilter);

    fFilterJob =
        new WorkbenchJob("FilterJob") { // $NON-NLS-1$
          @Override
          public IStatus runInUIThread(IProgressMonitor monitor) {
            handleFilter();
            return Status.OK_STATUS;
          }
        };
    fFilterJob.setSystem(true);
  }
 @Override
 public void storeSettings() {
   IDialogSettings settings = getDialogSettings();
   settings.put(SETTINGS_SHOW_LATEST, fFilterOldVersionButton.getSelection());
   super.storeSettings();
 }
 protected void updateJREWidgets() {
   fNamedJREsCombo.setEnabled(fNamedJREButton.getSelection());
   fExecEnvsCombo.setEnabled(fExecEnvButton.getSelection());
 }
 public boolean includeOptionalDependencies() {
   return fIncludeOptionalButton.getSelection();
 }
  private void updateButtons() {
    if (fTargetDefinition != null && !fTree.getSelection().isEmpty()) {
      Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray();
      boolean hasResolveBundle = false;
      boolean hasParent = false;
      boolean allSelected = true;
      boolean noneSelected = true;
      for (int i = 0; i < selection.length; i++) {
        if (!hasResolveBundle || !hasParent) {
          if (selection[i] instanceof IResolvedBundle) {
            hasResolveBundle = true;
          } else {
            hasParent = true;
          }
        }
        boolean checked = fTree.getChecked(selection[i]);
        if (checked) {
          noneSelected = false;
        } else {
          allSelected = false;
        }
      }
      // Selection is available if not everything is already selected and not both a parent and
      // child item are selected
      fSelectButton.setEnabled(!allSelected && !(hasResolveBundle && hasParent));
      fDeselectButton.setEnabled(!noneSelected && !(hasResolveBundle && hasParent));
    } else {
      fSelectButton.setEnabled(false);
      fDeselectButton.setEnabled(false);
    }

    int total = fAllBundles.size();
    if (fFeaureModeButton.getSelection()) {
      if (fTargetDefinition == null) {
        total = 0;
      } else {
        total = fTargetDefinition.getAllFeatures().length;
        total += ((TargetDefinition) fTargetDefinition).getOtherBundles().length;
      }
    }
    if (fMissing != null) {
      total += fMissing.size();
    }

    fSelectAllButton.setEnabled(fTargetDefinition != null && fTree.getCheckedLeafCount() != total);
    fDeselectAllButton.setEnabled(fTargetDefinition != null && fTree.getCheckedLeafCount() != 0);
    fSelectRequiredButton.setEnabled(
        fTargetDefinition != null
            && fTree.getCheckedLeafCount() > 0
            && fTree.getCheckedLeafCount() != total);

    if (fTargetDefinition != null) {
      fCountLabel.setText(
          MessageFormat.format(
              Messages.TargetContentsGroup_9,
              new String[] {
                Integer.toString(fTree.getCheckedLeafCount()), Integer.toString(total)
              }));
    } else {
      fCountLabel.setText(""); // $NON-NLS-1$
    }
  }
  public void saveIncludedBundleState() {
    if (fFeaureModeButton.getSelection()) {
      // Create a list of checked bundle infos
      List included = new ArrayList();
      int missingCount = 0;
      Object[] checked = fTree.getCheckedLeafElements();
      for (int i = 0; i < checked.length; i++) {
        if (checked[i] instanceof IFeatureModel) {
          included.add(
              new NameVersionDescriptor(
                  ((IFeatureModel) checked[i]).getFeature().getId(),
                  null,
                  NameVersionDescriptor.TYPE_FEATURE));
        }
        if (checked[i] instanceof IResolvedBundle) {
          // Missing features are included as IResolvedBundles, save them as features instead
          if (((IResolvedBundle) checked[i]).getStatus().getCode()
              == IResolvedBundle.STATUS_PLUGIN_DOES_NOT_EXIST) {
            included.add(
                new NameVersionDescriptor(
                    ((IResolvedBundle) checked[i]).getBundleInfo().getSymbolicName(),
                    null,
                    NameVersionDescriptor.TYPE_PLUGIN));
            missingCount++;
          } else if (((IResolvedBundle) checked[i]).getStatus().getCode()
              == IResolvedBundle.STATUS_FEATURE_DOES_NOT_EXIST) {
            included.add(
                new NameVersionDescriptor(
                    ((IResolvedBundle) checked[i]).getBundleInfo().getSymbolicName(),
                    null,
                    NameVersionDescriptor.TYPE_FEATURE));
            missingCount++;
          } else {
            included.add(
                new NameVersionDescriptor(
                    ((IResolvedBundle) checked[i]).getBundleInfo().getSymbolicName(), null));
          }
        }
      }

      if (included.size() == 0) {
        fTargetDefinition.setIncluded(new NameVersionDescriptor[0]);
      } else if (included.size() == 0
          || included.size() - missingCount
              == fTargetDefinition.getAllFeatures().length
                  + ((TargetDefinition) fTargetDefinition).getOtherBundles().length) {
        fTargetDefinition.setIncluded(null);
      } else {
        fTargetDefinition.setIncluded(
            (NameVersionDescriptor[]) included.toArray(new NameVersionDescriptor[included.size()]));
      }
    } else {
      // Figure out if there are multiple bundles sharing the same id
      Set multi = new HashSet(); // BSNs of bundles with multiple versions available
      Set all = new HashSet();
      for (Iterator iterator = fAllBundles.iterator(); iterator.hasNext(); ) {
        IResolvedBundle rb = (IResolvedBundle) iterator.next();
        if (!all.add(rb.getBundleInfo().getSymbolicName())) {
          multi.add(rb.getBundleInfo().getSymbolicName());
        }
      }

      // Create a list of checked bundle infos
      List included = new ArrayList();
      Object[] checked = fTree.getCheckedLeafElements();
      for (int i = 0; i < checked.length; i++) {
        if (checked[i] instanceof IResolvedBundle) {
          // Create the bundle info object
          String bsn = ((IResolvedBundle) checked[i]).getBundleInfo().getSymbolicName();
          NameVersionDescriptor info = null;
          if (multi.contains(bsn)) {
            // include version info
            info =
                new NameVersionDescriptor(
                    bsn, ((IResolvedBundle) checked[i]).getBundleInfo().getVersion());
          } else {
            // don't store version info
            info = new NameVersionDescriptor(bsn, null);
          }
          included.add(info);
        }
      }

      if (included.size() == 0) {
        fTargetDefinition.setIncluded(new NameVersionDescriptor[0]);
      } else if (included.size() == fAllBundles.size() + fMissing.size()) {
        fTargetDefinition.setIncluded(null);
      } else {
        fTargetDefinition.setIncluded(
            (NameVersionDescriptor[]) included.toArray(new NameVersionDescriptor[included.size()]));
      }
    }
  }