Package org.eclipse.jface.viewers

Examples of org.eclipse.jface.viewers.ComboBoxCellEditor


    private class ReassignmentTypeEditing extends EditingSupport {
        private ComboBoxCellEditor cellEditor;

        public ReassignmentTypeEditing(TableViewer viewer) {
            super(viewer);
            cellEditor = new ComboBoxCellEditor(viewer.getTable(), new String[]{"not-started", "not-completed"});
        }
View Full Code Here


    TreeViewerColumn dstColumn = new TreeViewerColumn(treeViewer, SWT.LEAD);
    dstColumn.getColumn().setText(
        UIText.GitBranchSynchronizeWizardPage_destination);
    dstColumn.getColumn().setImage(branchImage);
    dstColumn.getColumn().setWidth(200);
    final ComboBoxCellEditor branchesEditor = new ComboBoxCellEditor(
        treeViewer.getTree(), new String[0]);
    branchesEditor
        .setActivationStyle(ComboBoxCellEditor.DROP_DOWN_ON_KEY_ACTIVATION
            | ComboBoxCellEditor.DROP_DOWN_ON_MOUSE_ACTIVATION);
    ((CCombo) branchesEditor.getControl()).addSelectionListener(new SelectionAdapter() {
      @Override
      public void widgetSelected(SelectionEvent e) {
        CCombo combo = (CCombo) e.widget;
        TreeSelection sel = (TreeSelection) treeViewer.getSelection();
        int selectedIdx = combo.getSelectionIndex();
        Repository repo = (Repository) sel.getFirstElement();

        if (selectedIdx != -1) {
          selectedBranches.put(repo, combo.getItem(selectedIdx));
          setPageComplete(true);
        } else {
          selectedBranches.put(repo, null);
          setPageComplete(false);
        }
      }
    });
    dstColumn.setEditingSupport(new EditingSupport(treeViewer) {
      @Override
      protected void setValue(Object element, Object value) {
        int intValue = ((Integer) value).intValue();
        if (intValue == -1)
          return;

        CCombo combo = (CCombo) branchesEditor.getControl();
        String branch = combo.getItem(intValue);

        selectedBranches.put((Repository) element, branch);
        treeViewer.refresh(element, true);

        validatePage();
      }

      @Override
      protected Object getValue(Object element) {
        String branch = selectedBranches.get(element);
        CCombo combo = (CCombo) branchesEditor.getControl();
        int index = branch == null ? 0 : combo.indexOf(branch);
        return Integer.valueOf(index);
      }

      @Override
      protected CellEditor getCellEditor(Object element) {
        Repository repo = (Repository) element;
        List<String> refs = new LinkedList<String>(repo.getAllRefs()
            .keySet());

        List<Ref> additionalRefs;
        try {
          additionalRefs = repo.getRefDatabase().getAdditionalRefs();
        } catch (IOException e) {
          additionalRefs = null;
        }
        if (additionalRefs != null)
          for (Ref ref : additionalRefs)
            refs.add(ref.getName());

        Collections.sort(refs, CommonUtils.STRING_ASCENDING_COMPARATOR);

        branchesEditor.setItems(refs.toArray(new String[refs.size()]));

        return branchesEditor;
      }

      @Override
View Full Code Here

        if (value.getFeature().getRange().isPrimitive()) {

          CellEditor editor;

          if (value.getFeature().getRange().getName().equals(CAS.TYPE_NAME_BOOLEAN)) {
            editor = new ComboBoxCellEditor(viewer.getTree(), new String[]{"false", "true"},
                    SWT.READ_ONLY);
          }
          else {
            editor = new TextCellEditor(viewer.getTree());
            editor.setValidator(CellEditorValidatorFacotory.createValidator(Primitives
                    .getPrimitiveClass(value.getFeature())));
          }

          return editor;
        }
        else {
          return null;
        }
      } else if (element instanceof ArrayValue) {

        ArrayValue arrayValue = (ArrayValue) element;

        FeatureStructure arrayFS = arrayValue.getFeatureStructure();

        CellEditor editor;

        if (arrayFS instanceof BooleanArrayFS) {
          editor = new ComboBoxCellEditor(viewer.getTree(), new String[]{"false", "true"},
                  SWT.READ_ONLY);
          editor.setStyle(SWT.READ_ONLY);
        }
        else {
          editor = new TextCellEditor(viewer.getTree());
View Full Code Here

   
    // Create the cell editors
    CellEditor[] editors = new CellEditor[2];
    editors[0] = new TextCellEditor(fTable);
    editors[1] = new ComboBoxCellEditor(fTable, Priorities.INSTANCES, SWT.READ_ONLY);

    // Add a new task tag when the user clicks button
    newTaskTag.addSelectionListener(new SelectionAdapter() {
      public void widgetSelected(SelectionEvent event) {
        TaskTag p = new TaskTag();
View Full Code Here

        String[] names = new String[comboBoxItems.size()];
        int index = 0;
        for (Object item : comboBoxItems)
            names[index++] = item == null ? "" : item.toString(); //$NON-NLS-1$

        return new ComboBoxCellEditor(composite, names, SWT.READ_ONLY);
    }
View Full Code Here

    }

    @Override
    public CellEditor createEditor(Composite composite)
    {
        return new ComboBoxCellEditor(composite, options, SWT.READ_ONLY);
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jface.viewers.ComboBoxCellEditor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.