コード例 #1
0
  private void validatePage() {
    String errorMessage = null;
    String newText = fWorkingSetName.getText();

    if (newText.trim().length() == 0) {
      errorMessage = PDEUIMessages.PluginWorkingSet_emptyName;
      if (fFirstCheck) {
        setPageComplete(false);
        fFirstCheck = false;
        return;
      }
    }
    if (errorMessage == null && fTree.getCheckboxTreeViewer().getCheckedElements().length == 0) {
      errorMessage = PDEUIMessages.PluginWorkingSet_noPluginsChecked;
    }

    if (errorMessage == null && fWorkingSet == null) {
      IWorkingSet[] workingSets = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSets();
      for (int i = 0; i < workingSets.length; i++) {
        if (newText.equals(workingSets[i].getName())) {
          errorMessage = PDEUIMessages.PluginWorkingSet_nameInUse;
          break;
        }
      }
    }
    setErrorMessage(errorMessage);
    setPageComplete(errorMessage == null);
  }
コード例 #2
0
ファイル: UIUtils.java プロジェクト: ralic/dbeaver
 @Nullable
 public static Integer getTextInteger(Text text) {
   String str = text.getText();
   str = str.trim();
   if (str.length() == 0) {
     return null;
   }
   try {
     return Integer.valueOf(str);
   } catch (NumberFormatException e) {
     log.debug(e);
     return null;
   }
 }
コード例 #3
0
  /* (non-Javadoc)
   * @see org.eclipse.ui.dialogs.IWorkingSetPage#finish()
   */
  public void finish() {
    Object[] checked = fTree.getCheckboxTreeViewer().getCheckedElements();
    ArrayList<PersistablePluginObject> list = new ArrayList<PersistablePluginObject>();
    for (int i = 0; i < checked.length; i++) {
      String id = ((IPluginModelBase) checked[i]).getPluginBase().getId();
      if (id != null && id.length() > 0) list.add(new PersistablePluginObject(id));
    }
    PersistablePluginObject[] objects = list.toArray(new PersistablePluginObject[list.size()]);

    String workingSetName = fWorkingSetName.getText().trim();
    if (fWorkingSet == null) {
      IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager();
      fWorkingSet = workingSetManager.createWorkingSet(workingSetName, objects);
    } else {
      fWorkingSet.setName(workingSetName);
      fWorkingSet.setElements(objects);
    }
  }