private void updateSelectedRolesFromServer(Event event) {
   syncInlineRolesWithSelectedRoles();
   if (event.detail == SWT.CHECK) {
     TableItem selectedRole = (TableItem) event.item;
     if (selectedRole.getChecked() && !selectedRoles.contains(selectedRole.getText(0).trim())) {
       selectedRoles.add(selectedRole.getText(0).trim());
     } else if (!selectedRole.getChecked()
         && selectedRoles.contains(selectedRole.getText(0).trim())) {
       selectedRoles.remove(selectedRole.getText(0).trim());
     }
     updateUserRolesInLine();
   }
 }
Example #2
0
  public static void sortTable(Table table, Comparator<TableItem> comparator) {
    int columnCount = table.getColumnCount();
    String[] values = new String[columnCount];
    TableItem[] items = table.getItems();
    for (int i = 1; i < items.length; i++) {
      for (int j = 0; j < i; j++) {
        TableItem item = items[i];
        if (comparator.compare(item, items[j]) < 0) {
          for (int k = 0; k < columnCount; k++) {
            values[k] = item.getText(k);
          }
          Object data = item.getData();
          boolean checked = item.getChecked();
          item.dispose();

          item = new TableItem(table, SWT.NONE, j);
          item.setText(values);
          item.setData(data);
          item.setChecked(checked);
          items = table.getItems();
          break;
        }
      }
    }
  }
Example #3
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt
   * .events.SelectionEvent)
   */
  public void widgetSelected(final SelectionEvent e) {
    ErlLogger.debug("widgetSelected: e.item = " + e.item);
    ErlLogger.debug("widgetSelected: e.widget = " + e.widget);

    if (e.widget == removeFunctionBtn) {
      final TableItem itemsToRemove[] = fTable.getSelection();
      for (final TableItem element : itemsToRemove) {
        fTable.remove(fTable.indexOf(element));
        if (element == fEditingItem) {
          fEditingItem = null;
        }
      }

    } else if (e.widget == editFunctionBtn) {
      if (fEditingItem != null) {
        removeEdit();
      }
      final int selectedIndex = fTable.getSelectionIndex();
      final TableItem selectedItem = fTable.getItem(selectedIndex);
      if (!"".equals(selectedItem.getText(0))) {
        fEditingItem = selectedItem;
        functionNameText.setText(selectedItem.getText(0));
        arityText.setText(selectedItem.getText(1));
        exportButtonBtn.setSelection(selectedItem.getChecked());
        fEditingItem.setText(0, selectedItem.getText(0) + "<<Being Edited>>");
      }
      // } else if (e.widget == addState) {

    }
    dialogChanged();
  }
  public List<IMethod> getSelectedMethods() {
    List<IMethod> result = Lists.newArrayList();
    for (TableItem ti : m_table.getItems()) {
      if (ti.getChecked()) {
        result.add((IMethod) ti.getData());
      }
    }

    return result;
  }
Example #5
0
 public Object[] getCheckedElements() {
   TableItem[] children = tableViewer.getTable().getItems();
   ArrayList v = new ArrayList(children.length);
   for (int i = 0; i < children.length; i++) {
     TableItem item = children[i];
     if (item.getChecked()) {
       v.add(item.getData());
     }
   }
   return v.toArray();
 }
Example #6
0
 /* (non-Javadoc)
  * @see org.eclipse.jface.dialogs.Dialog#okPressed()
  */
 @Override
 protected void okPressed() {
   tags = new TreeSet<ITag>();
   TableItem[] items = tableViewer.getTable().getItems();
   for (TableItem item : items) {
     if (item.getChecked()) {
       tags.add((ITag) item.getData());
     }
   }
   super.okPressed();
 }
 @Override
 protected void performApply() {
   beforeAction.clear();
   for (TableItem item : keyTable.getItems()) {
     if (item.getChecked()) {
       String key = item.getText(1);
       String des = item.getText(2);
       beforeAction.put(key, des);
     }
   }
   keySetPro = beforeAction;
   CommonFuncUtilities.refreshPrefsContent(
       new Object[] {keySetClass, keySetInd, keySetPro},
       new String[] {"OWLClass_", "OWLIndividual_", "OWLProperty_"},
       keySetOWL);
 }
 @Override
 protected void okPressed() {
   if (inlineRadioButton.getSelection()) {
     String inlineUserRoles = inlineUserRolesText.getText();
     if (StringUtils.isNotBlank(inlineUserRoles)) {
       String[] roles = inlineUserRoles.split(",");
       for (int i = 0; i < roles.length; i++) {
         if (StringUtils.isNotBlank(roles[i])) {
           selectedRoles.add(roles[i].trim());
         }
       }
     }
   } else {
     for (TableItem item : userRolesTable.getItems()) {
       if (item.getChecked()) {
         selectedRoles.add(item.getText(1));
       }
     }
   }
   super.okPressed();
 }
  /**
   * @param item
   * @param text
   */
  private void corectValueTest(final TableItem item, String text) {
    TypeEditorValidator tEV = typeEditorValidators.get(table1.indexOf(item));
    String s = tEV.isValid(text);
    if (item.getChecked()) {
      if (s == null) {
        item.getParent().setToolTipText("");
        if (vavueCorect.get(tEV) != corect) {
          vavueCorect.put(tEV, corect);
        }
      } else {
        item.getParent().setToolTipText(s);
        if (vavueCorect.get(tEV) != incorect) {
          vavueCorect.put(tEV, incorect);
        }
      }

    } else {
      vavueCorect.remove(tEV);
    }
    refreshOkButton();
  }
Example #10
0
 public void setCheckedElements(Object[] elements) {
   for (Object element : elements) {
     assert (element != null);
   }
   HashSet<Object> set = new HashSet<Object>();
   for (int i = 0; i < elements.length; ++i) {
     set.add(elements[i]);
   }
   TableItem[] items = tableViewer.getTable().getItems();
   for (int i = 0; i < items.length; ++i) {
     TableItem item = items[i];
     Object element = item.getData();
     if (element != null) {
       boolean check = set.contains(element);
       // only set if different, to avoid flicker
       if (item.getChecked() != check) {
         item.setChecked(check);
       }
     }
   }
 }
Example #11
0
  public Function[] getFunctionData() {
    removeEdit();

    final TableItem function[] = fTable.getItems();
    final ArrayList<Function> functionList = new ArrayList<Function>();
    for (final TableItem element : function) {
      if (!"".equals(element.getText(0))) {
        final Function f = new Function();
        f.arity = Integer.parseInt(element.getText(1));
        f.isExported = element.getChecked();
        final String[] part = element.getText(0).split("\\(");
        f.isState = "State)".equals(part[part.length - 1]);
        if (f.isState) {
          f.name = element.getText(0).substring(0, element.getText(0).length() - 7);
        } else {
          f.name = element.getText(0);
        }
        functionList.add(f);
      }
    }
    final Function[] functions = functionList.toArray(new Function[functionList.size()]);

    return functions;
  }
 private void selectionHelper(Boolean active) {
   for (TableItem ti : available.getItems()) {
     if (active == null) ti.setChecked(!ti.getChecked());
     else ti.setChecked(active);
   }
 }
 public void widgetSelected(SelectionEvent e) {
   TableItem ti = (TableItem) e.item;
   if (ti.getChecked()) ++selectionCount;
   else --selectionCount;
   setPageComplete(canFlipToNextPage());
 }
 public java.util.List<Deployment> getDeploymentList() {
   java.util.List<Deployment> selected = new ArrayList<Deployment>(available.getItemCount());
   for (TableItem ti : available.getItems())
     if (ti.getChecked()) selected.add((Deployment) ti.getData());
   return selected;
 }
 public Set<Deployment> getDeploymentSet() {
   Set<Deployment> selected = new HashSet<Deployment>(available.getItemCount());
   for (TableItem ti : available.getItems())
     if (ti.getChecked()) selected.add((Deployment) ti.getData());
   return selected;
 }
 private void storeItem(TableItem item) {
   TeaVMProfile profile = (TeaVMProfile) item.getData();
   profile.setEnabled(item.getChecked());
 }