Java 类org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent 实例源码

项目:team-explorer-everywhere    文件:CellEditorAccessibility.java   
public static void setupAccessibleCellEditors(final TableViewer viewer, final int flags) {
    Check.notNull(viewer, "viewer"); //$NON-NLS-1$

    try {
        final MultiRowHighlighter cellHighlighter = new MultiRowHighlighter(viewer);

        final TableViewerFocusCellManager focusCellManager =
            new TableViewerFocusCellManager(viewer, cellHighlighter);

        final ColumnViewerEditorActivationStrategy activationStrategy =
            new ColumnViewerEditorActivationStrategy(viewer) {
                @Override
                protected boolean isEditorActivationEvent(final ColumnViewerEditorActivationEvent event) {
                    /*
                     * Deny any cell editor activation if there are multiple
                     * rows selected.
                     */
                    if (getViewer().getSelection() != null
                        && getViewer().getSelection() instanceof StructuredSelection
                        && ((StructuredSelection) getViewer().getSelection()).size() > 1) {
                        return false;
                    }

                    if (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
                        && event.keyCode == SWT.CR) {
                        return true;
                    }

                    return super.isEditorActivationEvent(event);
                }
            };

        TableViewerEditor.create(viewer, focusCellManager, activationStrategy, flags);
    } catch (final Exception e) {
        log.warn("Could not configure cell editor accessibility", e); //$NON-NLS-1$
    }
}
项目:TranskribusSwtGui    文件:StructureTreeWidget.java   
private void initEditOnDoubleClick() {
    TreeViewerFocusCellManager focusCellManager = new TreeViewerFocusCellManager(treeViewer, new FocusCellOwnerDrawHighlighter(treeViewer));
    ColumnViewerEditorActivationStrategy activationSupport = new ColumnViewerEditorActivationStrategy(treeViewer) {
        @Override
        protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
            // Enable editor only with mouse double click
            if (event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION) {
                EventObject source = event.sourceEvent;
                if (source instanceof MouseEvent && ((MouseEvent) source).button == 3)
                    return false;

                return true;
            }

            return false;
        }
    };
    TreeViewerEditor.create(treeViewer, focusCellManager, activationSupport,
    // ColumnViewerEditor.TABBING_HORIZONTAL |
            ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
}
项目:PDFReporter-Studio    文件:GalleryTreeViewer.java   
public void editElement(Object element, int column) {
    if (element instanceof TreePath) {
        setSelection(new TreeSelection((TreePath) element));
        GalleryItem[] items = gallery.getSelection();

        if (items.length == 1) {
            ViewerRow row = getViewerRowFromItem(items[0]);

            if (row != null) {
                ViewerCell cell = row.getCell(column);
                if (cell != null) {
                    getControl().setRedraw(false);
                    triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(cell));
                    getControl().setRedraw(true);
                }
            }
        }
    } else {
        super.editElement(element, column);
    }
}
项目:translationstudio8    文件:GridTableViewer.java   
/**
 * {@inheritDoc}
 */
public void editElement(Object element, int column) {
    try {
        getControl().setRedraw(false);
        Widget item = findItem(element);
        if (item != null) {
            ViewerRow row = getViewerRowFromItem(item);
            if (row != null) {
                ViewerCell cell = row.getCell(column);
                if (cell != null) {
                    triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(
                            cell));
                }
            }
        }
    } finally {
        getControl().setRedraw(true);
    }
    // }
}
项目:translationstudio8    文件:GridViewerEditor.java   
/**
 * {@inheritDoc}
 */
protected void updateFocusCell(ViewerCell focusCell, ColumnViewerEditorActivationEvent event) {
    Grid grid = ((Grid)getViewer().getControl());

    if (event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC
            || event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL) {
        grid.setFocusColumn(grid.getColumn(focusCell.getColumnIndex()));
        grid.setFocusItem((GridItem) focusCell.getItem());

        if( selectionFollowsEditor ) {
            grid.setCellSelection(new Point(focusCell.getColumnIndex(),grid.indexOf((GridItem)focusCell.getItem())));
        }
    }

    grid.showColumn(grid.getColumn(focusCell.getColumnIndex()));
    grid.showItem((GridItem) focusCell.getItem()); 
}
项目:tmxeditor8    文件:GridTableViewer.java   
/**
 * {@inheritDoc}
 */
public void editElement(Object element, int column) {
    try {
        getControl().setRedraw(false);
        Widget item = findItem(element);
        if (item != null) {
            ViewerRow row = getViewerRowFromItem(item);
            if (row != null) {
                ViewerCell cell = row.getCell(column);
                if (cell != null) {
                    triggerEditorActivationEvent(new ColumnViewerEditorActivationEvent(
                            cell));
                }
            }
        }
    } finally {
        getControl().setRedraw(true);
    }
    // }
}
项目:tmxeditor8    文件:GridViewerEditor.java   
/**
 * {@inheritDoc}
 */
protected void updateFocusCell(ViewerCell focusCell, ColumnViewerEditorActivationEvent event) {
    Grid grid = ((Grid)getViewer().getControl());

    if (event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC
            || event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL) {
        grid.setFocusColumn(grid.getColumn(focusCell.getColumnIndex()));
        grid.setFocusItem((GridItem) focusCell.getItem());

        if( selectionFollowsEditor ) {
            grid.setCellSelection(new Point(focusCell.getColumnIndex(),grid.indexOf((GridItem)focusCell.getItem())));
        }
    }

    grid.showColumn(grid.getColumn(focusCell.getColumnIndex()));
    grid.showItem((GridItem) focusCell.getItem()); 
}
项目:DynamicSpotter    文件:CustomComboBoxCellEditor.java   
@Override
public void activate(ColumnViewerEditorActivationEvent activationEvent) {
    super.activate(activationEvent);
    if (activationStyle != SWT.NONE) {

        boolean mouseSelection = activationEvent.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION
                || activationEvent.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION;
        boolean keyboardSelection = activationEvent.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED;
        boolean programmatic = activationEvent.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
        boolean traversal = activationEvent.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL;

        if (mouseSelection && (activationStyle & DROP_DOWN_ON_MOUSE_ACTIVATION) != 0 || keyboardSelection
                && (activationStyle & DROP_DOWN_ON_KEY_ACTIVATION) != 0 || programmatic
                && (activationStyle & DROP_DOWN_ON_PROGRAMMATIC_ACTIVATION) != 0 || traversal
                && (activationStyle & DROP_DOWN_ON_TRAVERSE_ACTIVATION) != 0) {

            comboBox.getDisplay().asyncExec(new Runnable() {
                @Override
                public void run() {
                    comboBox.setListVisible(true);
                }
            });

        }
    }
}
项目:convertigo-eclipse    文件:StringComboBoxPropertyDescriptor.java   
@Override
public void activate(ColumnViewerEditorActivationEvent activationEvent) {
    super.activate(activationEvent);
    boolean dropDown = true;
    if (dropDown) {
        getControl().getDisplay().asyncExec(new Runnable() {
            public void run() {
                ((CCombo) getControl()).setListVisible(true);
            }
        });

    }
}
项目:TranskribusSwtGui    文件:WordGraphEditor.java   
private void initEditBehaviour(final int type) {
        TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(tableViewer, new FocusCellOwnerDrawHighlighter(tableViewer));
        ColumnViewerEditorActivationStrategy activationSupport = new ColumnViewerEditorActivationStrategy(tableViewer) {
            @Override
            protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
                logger.debug(event.toString());

                boolean singleSelect = ((IStructuredSelection)tableViewer.getSelection()).size() == 1;

                int mouseActivationType= 
                        type == 0 ? ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION : ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION;

                boolean isLeftMouseSelect = event.eventType == mouseActivationType && ((MouseEvent)event.sourceEvent).button == 1;

                return singleSelect && (isLeftMouseSelect
                        || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC
                        || event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL);


                // Enable editor only with mouse double click
//              if (event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION) {
//                  EventObject source = event.sourceEvent;
//                  if (source instanceof MouseEvent && ((MouseEvent)source).button == 3)
//                      return false;
//
//                  return true;
//              }
//
//              return false;
            }
        };

        TableViewerEditor.create(tableViewer, focusCellManager, activationSupport, ColumnViewerEditor.TABBING_HORIZONTAL | 
                ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR | 
                ColumnViewerEditor.TABBING_VERTICAL |
                ColumnViewerEditor.KEYBOARD_ACTIVATION);
    }
项目:hssd    文件:EntryEditor.java   
@Override
protected boolean isEditorActivationEvent(
        ColumnViewerEditorActivationEvent event) {
    if (event.eventType != EVENT_TYPE_OF_INTEREST) {
        return false;
    }

    EventObject source = event.sourceEvent;
    if (source instanceof MouseEvent && ((MouseEvent)source).button == 3) {
        return false;
    }

    return true;
}
项目:PDFReporter-Studio    文件:UIUtil.java   
/**
 * Setups the start of cell editing on a {@link TableViewer} when a {@link DoubleClickEvent} occurs.
 * 
 * @param tviewer
 *          the table viewer
 */
public static void setViewerCellEditingOnDblClick(TableViewer tviewer) {
    ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(tviewer) {
        protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
            return event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION;
        }
    };

    TableViewerEditor.create(tviewer, actSupport, ColumnViewerEditor.DEFAULT);
}
项目:mytourbook    文件:UI.java   
/**
 * Initialize cell editing.
 * 
 * @param viewer
 */
public static void setCellEditSupport(final TableViewer viewer) {

    final TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(
            viewer,
            new FocusCellOwnerDrawHighlighter(viewer));

    final ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(viewer) {
        @Override
        protected boolean isEditorActivationEvent(final ColumnViewerEditorActivationEvent event) {

            return (event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL)
                    || (event.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION)
                    || ((event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED)
                            && (event.keyCode == SWT.CR))
                    || (event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC);
        }
    };

    TableViewerEditor.create(//
            viewer,
            focusCellManager,
            actSupport,
            ColumnViewerEditor.TABBING_HORIZONTAL //
                    | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR //
                    | ColumnViewerEditor.TABBING_VERTICAL
                    | ColumnViewerEditor.KEYBOARD_ACTIVATION);
}
项目:redmine.rap    文件:PlanView.java   
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
    boolean result;
    if (event.character == '\r') {
        result = true;
    }
    else {
        result = super.isEditorActivationEvent(event);
    }
    return result;
}
项目:redmine.rap    文件:ActivationStrategy.java   
@Override
protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
    // Locals
    Boolean result = null;

    if (event.character == '\r') {
        result = true;
    }
    else {
        result = super.isEditorActivationEvent(event);
    }
    return result;
}
项目:q7.quality.mockups    文件:AbstractComboBoxCellEditor.java   
public void activate(ColumnViewerEditorActivationEvent activationEvent) {
    super.activate(activationEvent);
    if (activationStyle != SWT.NONE) {
        boolean dropDown = false;
        if ((activationEvent.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION || activationEvent.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION)
                && (activationStyle & DROP_DOWN_ON_MOUSE_ACTIVATION) != 0) {
            dropDown = true;
        } else if (activationEvent.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
                && (activationStyle & DROP_DOWN_ON_KEY_ACTIVATION) != 0) {
            dropDown = true;
        } else if (activationEvent.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC
                && (activationStyle & DROP_DOWN_ON_PROGRAMMATIC_ACTIVATION) != 0) {
            dropDown = true;
        } else if (activationEvent.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
                && (activationStyle & DROP_DOWN_ON_TRAVERSE_ACTIVATION) != 0) {
            dropDown = true;
        }

        if (dropDown) {
            getControl().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    ((CCombo) getControl()).setListVisible(true);
                }

            });

        }
    }
}
项目:q7.quality.mockups    文件:AbstractComboBoxCellEditor.java   
public void activate(ColumnViewerEditorActivationEvent activationEvent) {
    super.activate(activationEvent);
    if (activationStyle != SWT.NONE) {
        boolean dropDown = false;
        if ((activationEvent.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION || activationEvent.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION)
                && (activationStyle & DROP_DOWN_ON_MOUSE_ACTIVATION) != 0 ) {
            dropDown = true;
        } else if (activationEvent.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
                && (activationStyle & DROP_DOWN_ON_KEY_ACTIVATION) != 0 ) {
            dropDown = true;
        } else if (activationEvent.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC
                && (activationStyle & DROP_DOWN_ON_PROGRAMMATIC_ACTIVATION) != 0) {
            dropDown = true;
        } else if (activationEvent.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
                && (activationStyle & DROP_DOWN_ON_TRAVERSE_ACTIVATION) != 0) {
            dropDown = true;
        }

        if (dropDown) {
            getControl().getDisplay().asyncExec(new Runnable() {

                public void run() {
                    ((CCombo) getControl()).setListVisible(true);
                }

            });

        }
    }
}
项目:hestia-engine-dev    文件:TreeViewerBuilder.java   
/**
 * @param activationStrategy
 * @param feature
 */
public TreeViewerBuilder makeEditable(ColumnViewerEditorActivationStrategy activationStrategy, int feature) {
    ColumnViewerEditorActivationStrategy defaultActivationStrategy = new ColumnViewerEditorActivationStrategy(
            viewer) {
        protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
            return event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
                    || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
        }
    };
    TreeViewerEditor.create(viewer, activationStrategy == null ? defaultActivationStrategy : activationStrategy,
            feature < 0 ? ColumnViewerEditor.DEFAULT : feature);
    return this;
}
项目:hestia-engine-dev    文件:TableViewerBuilder.java   
/**
 * @param activationStrategy
 * @param feature
 */
public TableViewerBuilder makeEditable(ColumnViewerEditorActivationStrategy activationStrategy, int feature) {
    ColumnViewerEditorActivationStrategy defaultActivationStrategy = new ColumnViewerEditorActivationStrategy(
            viewer) {
        protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
            return event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
                    || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
        }
    };
    TableViewerEditor.create(viewer, activationStrategy == null ? defaultActivationStrategy : activationStrategy,
            feature < 0 ? ColumnViewerEditor.DEFAULT : feature);
    return this;
}
项目:Hydrograph    文件:CustomAbstractComboBoxCellEditor.java   
public void activate(ColumnViewerEditorActivationEvent activationEvent) {
    super.activate(activationEvent);
}
项目:fluentmark    文件:TableDialog.java   
@Override
protected Control createCustomArea(final Composite parent) {
    Composite body = new Composite(parent, SWT.NONE);
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(body);
    GridLayoutFactory.fillDefaults().numColumns(2).applyTo(body);

    ToolBar bar = new ToolBar(body, SWT.HORIZONTAL);
    ToolBarManager barMgr = new ToolBarManager(bar);
    barMgr.add(new AlignLeftAction());
    barMgr.add(new AlignCenterAction());
    barMgr.add(new AlignRightAction());
    barMgr.add(new InsColBeforeAction());
    barMgr.add(new InsColAfterAction());
    barMgr.add(new RmvColAction());
    barMgr.add(new InsRowAboveAction());
    barMgr.add(new InsRowBelowAction());
    barMgr.add(new RmvRowAction());
    barMgr.update(true);
    bar.pack();

    viewer = new TableViewer(body, style);
    GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(viewer.getControl());

    table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    cellMgr = new TableViewerFocusCellManager(viewer, new FocusCellOwnerDrawHighlighter(viewer));

    ColumnViewerEditorActivationStrategy activator = new ColumnViewerEditorActivationStrategy(viewer) {

        @Override
        protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
            return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
                    || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
                    || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR)
                    || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
        }
    };

    TableViewerEditor.create(viewer, cellMgr, activator, features);

    MenuManager mgr = new MenuManager();
    mgr.add(new InsColBeforeAction());
    mgr.add(new InsColAfterAction());
    mgr.add(new RmvColAction());
    mgr.add(new Separator());
    mgr.add(new InsRowAboveAction());
    mgr.add(new InsRowBelowAction());
    mgr.add(new RmvRowAction());
    viewer.getControl().setMenu(mgr.createContextMenu(viewer.getControl()));

    tableModel = new TableModel();
    setInput(part);

    return body;
}
项目:scenarioo-example-swtbot-e4    文件:PositionsPage.java   
@Override
public void beforeEditorActivated(final ColumnViewerEditorActivationEvent event) {
    // Do Nothing
    // System.out.println("beforeEditorActivated");
}
项目:scenarioo-example-swtbot-e4    文件:PositionsPage.java   
@Override
public void afterEditorActivated(final ColumnViewerEditorActivationEvent event) {
    // Do Nothing
    // System.out.println("afterEditorActivated");

}
项目:PDFReporter-Studio    文件:CheckboxCellEditor.java   
@Override
public void activate(ColumnViewerEditorActivationEvent activationEvent) {
    if (activationEvent.eventType != ColumnViewerEditorActivationEvent.TRAVERSAL) {
        super.activate(activationEvent);
    }
}
项目:offspring    文件:GenerericTreeViewer.java   
@Override
public void setGenericTable(IGenericTable table) {
  this.table = table;

  setUseHashlookup(true);
  setContentProvider(table.getContentProvider());
  // if (!(table.getContentProvider() instanceof
  // IPageableStructeredContentProvider)) {
  // this.comparator = new GenericComparator(table);
  // setComparator(comparator);
  // }

  ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(
      this) {

    @Override
    protected boolean isEditorActivationEvent(
        ColumnViewerEditorActivationEvent event) {
      return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
          || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
          || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
    }
  };

  TreeViewerEditor.create(this, actSupport,
      ColumnViewerEditor.TABBING_HORIZONTAL
          | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
          | ColumnViewerEditor.TABBING_VERTICAL
          | ColumnViewerEditor.KEYBOARD_ACTIVATION);

  createColumns();

  // setInput(null);
  // getTree().setHeaderVisible(true);
  getTree().setLinesVisible(true);
  getTree().layout();

  for (final IGenericTableColumn c : table.getColumns()) {
    if (c.getCellActivateHandler() != null) {
      getTree().addMouseMoveListener(mouseMoveListener);
      getTree().addMouseListener(mouseListener);
      break;
    }
  }
}
项目:offspring    文件:GenerericTableViewer.java   
@Override
public void setGenericTable(IGenericTable table) {
  this.table = table;

  setUseHashlookup(true);
  setContentProvider(table.getContentProvider());
  if (!(table.getContentProvider() instanceof IPageableStructeredContentProvider)) {
    this.comparator = new GenericComparator(table);
    setComparator(comparator);
  }

  ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(
      this) {

    @Override
    protected boolean isEditorActivationEvent(
        ColumnViewerEditorActivationEvent event) {
      return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
          || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
          || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
    }
  };

  TableViewerEditor.create(this, actSupport,
      ColumnViewerEditor.TABBING_HORIZONTAL
          | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
          | ColumnViewerEditor.TABBING_VERTICAL
          | ColumnViewerEditor.KEYBOARD_ACTIVATION);

  createColumns();
  // try {
  // getTable().setRedraw(false);
  // calculateSizes();
  // }
  // finally {
  // getTable().setRedraw(true);
  // }

  // setInput(null);
  getTable().setHeaderVisible(true);
  getTable().setLinesVisible(true);
  getTable().layout();

  for (final IGenericTableColumn c : table.getColumns()) {
    if (c.getCellActivateHandler() != null) {
      getTable().addMouseMoveListener(mouseMoveListener);
      getTable().addMouseListener(mouseListener);
      break;
    }
  }
}
项目:ChangeScribe    文件:HistoryPage.java   
private void createViewer(Composite parent) {
    viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);

    TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer,
            new FocusCellOwnerDrawHighlighter(viewer));

    ColumnViewerEditorActivationStrategy activationSupport = new ColumnViewerEditorActivationStrategy(viewer) {
        protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
            // Enable editor only with mouse double click
            if (event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION) {
                EventObject source = event.sourceEvent;
                if (source instanceof MouseEvent && ((MouseEvent) source).button == 3)
                    return false;

                return true;
            }

            return false;
        }
    };

    TableViewerEditor.create(viewer, focusCellManager, activationSupport,
            ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR
                    | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);

    createColumns(parent, viewer);
    final Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    viewer.setContentProvider(new ArrayContentProvider());
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent arg0) {
            if (null != viewer.getTable() && viewer.getTable().getSelectionIndex() > 0) {
                setPageComplete(true);
            }
        }
    });
    // get the content for the viewer, setInput will call getElements in the
    // contentProvider
    viewer.setInput(commits);
    // make the selection available to other views
    // define layout for the viewer
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.FILL;
    gridData.horizontalSpan = 2;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    gridData.horizontalAlignment = GridData.FILL;
    viewer.getControl().setLayoutData(gridData);
}
项目:elexis-3-core    文件:LabOrderEditingSupport.java   
protected void setUpCellEditor(ColumnViewer viewer){
    // set up validation of the cell editors
    textCellEditor = new TextCellEditor((Composite) viewer.getControl());

    textCellEditor.addListener(new ICellEditorListener() {
        @Override
        public void editorValueChanged(boolean oldValidState, boolean newValidState){
            if (newValidState) {
                textCellEditor.getControl().setBackground(
                    Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
            } else {
                textCellEditor.getControl().setBackground(
                    Display.getCurrent().getSystemColor(SWT.COLOR_RED));
            }
        }

        @Override
        public void cancelEditor(){
            textCellEditor.getControl().setBackground(
                Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
        }

        @Override
        public void applyEditorValue(){
            textCellEditor.getControl().setBackground(
                Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
        }
    });

    focusCell =
        new TableViewerFocusCellManager((TableViewer) viewer, new FocusCellHighlighter(viewer) {

    });

    ColumnViewerEditorActivationStrategy actSupport =
        new ColumnViewerEditorActivationStrategy(viewer) {
            @Override
            protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event){
                return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
                    || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
                    || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR)
                    || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.KEYPAD_CR)
                    || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
            }
        };

    TableViewerEditor.create((TableViewer) viewer, focusCell, actSupport,
        ColumnViewerEditor.TABBING_VERTICAL
            | ColumnViewerEditor.KEYBOARD_ACTIVATION);
}
项目:elexis-3-core    文件:LabResultEditingSupport.java   
protected void setUpCellEditor(ColumnViewer viewer){
    // set up validation of the cell editors
    textCellEditor = new TextCellEditor((Composite) viewer.getControl());

    textCellEditor.addListener(new ICellEditorListener() {
        @Override
        public void editorValueChanged(boolean oldValidState, boolean newValidState){
            if (newValidState) {
                textCellEditor.getControl()
                    .setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
            } else {
                textCellEditor.getControl()
                    .setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
            }
        }

        @Override
        public void cancelEditor(){
            textCellEditor.getControl()
                .setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
        }

        @Override
        public void applyEditorValue(){
            textCellEditor.getControl()
                .setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
        }
    });

    focusCell =
        new TreeViewerFocusCellManager((TreeViewer) viewer, new FocusCellHighlighter(viewer) {

        });

    ColumnViewerEditorActivationStrategy actSupport =
        new ColumnViewerEditorActivationStrategy(viewer) {
            @Override
            protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event){
                return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
                    || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
                    || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
                        && event.keyCode == SWT.CR)
                    || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED
                        && event.keyCode == SWT.KEYPAD_CR)
                    || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
            }
        };

    TreeViewerEditor.create((TreeViewer) viewer, focusCell, actSupport,
        ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION);
}