List of usage examples for org.eclipse.jface.viewers ColumnViewer getCell
public ViewerCell getCell(Point point)
null if there is no cell at that location From source file:com.rcpcompany.uibindings.internal.ViewerBindingImpl.java
License:Open Source License
@Override public void updateSourceProviderState(ISourceProviderStateContext context) { final ColumnViewer viewer = getViewer(); context.putSourceValue(Constants.SOURCES_ACTIVE_CONTAINER_BINDING, this); context.putSourceValue(Constants.SOURCES_ACTIVE_CONTAINER_BINDING_NO_CAF, (viewer.getComparator() == null && viewer.getFilters().length == 0)); context.putSourceValue(Constants.SOURCES_ACTIVE_VIEWER_ELEMENT_TYPE, getModelType()); EObject element = null;/* w w w . ja va 2 s . co m*/ int columnIndex = -1; ContainerCellType type = null; ViewerCell cell; /* * If no specific position is specified in the event (x,y) = (0,0), then try using the * current focus cell. This is needed when navigating in the table. * * Also do this if the widget of the event is not this viewers control. That happens when * extra widgets are mapped to this binding with IBinding.registerWidget() */ final Event event = context.getEvent(); final Point point = context.getLocation(); if (event.x == 0 && event.y == 0 || event.widget != getControl()) { cell = viewer.getColumnViewerEditor().getFocusCell(); } else { cell = viewer.getCell(point); } if (cell != null) { element = (EObject) cell.getElement(); columnIndex = cell.getColumnIndex(); type = ContainerCellType.DATA; } else { final Control c = viewer.getControl(); if (c instanceof Table) { final Table t = (Table) c; final TableItem item = t.getItem(point); if (item != null) { element = (EObject) item.getData(); type = ContainerCellType.ROW_TRAILER; } else { /* * Below or above the table? */ if (point.y < 0) { type = ContainerCellType.COLUMN_HEADER; } else { type = ContainerCellType.COLUMN_TRAILER; } } } if (c instanceof Tree) { final Tree t = (Tree) c; final TreeItem item = t.getItem(point); if (item != null) { element = (EObject) item.getData(); type = ContainerCellType.ROW_TRAILER; } else { /* * Below or above the tree? */ if (point.y < 0) { type = ContainerCellType.COLUMN_HEADER; } else { type = ContainerCellType.COLUMN_TRAILER; } } } } if (type != null) { context.putSourceValue(Constants.SOURCES_ACTIVE_CONTAINER_CELL_TYPE, type.toString()); } if (element != null) { context.putSourceValue(Constants.SOURCES_ACTIVE_VIEWER_ELEMENT, element); context.putSourceValue(Constants.SOURCES_ACTIVE_VIEWER_ELEMENT_MOVE_UP, UIHandlerUtils.moveElement(this, element, -1, true)); context.putSourceValue(Constants.SOURCES_ACTIVE_VIEWER_ELEMENT_MOVE_DOWN, UIHandlerUtils.moveElement(this, element, 1, true)); } if (columnIndex >= getFirstTableColumnOffset() && element != null) { final IColumnBindingCellInformation ci = getCell(columnIndex - getFirstTableColumnOffset(), element); final IObservableValue objectValue = ci.getObjectValue(); final Object value = objectValue.getValue(); final IValueBinding labelBinding = ci.getLabelBinding(); context.putSourceValue(Constants.SOURCES_ACTIVE_BINDING, labelBinding); context.putSourceValue(Constants.SOURCES_ACTIVE_BINDING_RO, !ci.isChangeable()); context.putSourceValue(Constants.SOURCES_ACTIVE_BINDING_VALUE, value); context.putSourceValue(Constants.SOURCES_ACTIVE_BINDING_TYPE, ""); //$NON-NLS-1$ if (labelBinding != null) { context.putSourceValue(Constants.SOURCES_ACTIVE_BINDING_MODEL_OBJECT, labelBinding.getModelObject()); context.putSourceValue(Constants.SOURCES_ACTIVE_BINDING_FEATURE, labelBinding.getModelFeature()); context.putSourceValue(Constants.SOURCES_ACTIVE_BINDING_UNSETTABLE, labelBinding.getDataType().isUnsettable()); context.putSourceValue(Constants.SOURCES_ACTIVE_BINDING_IS_SET, isSet(labelBinding)); } context.putSourceValue(Constants.SOURCES_ACTIVE_BINDING_VALUE_DISPLAY, ci.getDisplayText()); context.addObservedValue(ci.getLabelUIAttribute().getCurrentValue()); } context.setSelectionProvider(getViewer()); }
From source file:org.dawb.common.ui.widgets.DoubleClickModifier.java
License:Open Source License
protected DoubleClickModifier(final ColumnViewer viewer) { viewer.getControl().addListener(SWT.MouseDown, new Listener() { @Override/*from w w w . jav a 2s . c o m*/ public void handleEvent(Event event) { setEnabled(false); } }); viewer.getControl().addListener(SWT.MouseDoubleClick, new Listener() { @Override public void handleEvent(Event event) { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); if (selection.toList().size() != 1) { return; } final ViewerCell cell = viewer.getCell(new Point(event.x, event.y)); setEnabled(true); viewer.editElement(selection.getFirstElement(), cell != null ? cell.getColumnIndex() : 0); } }); }
From source file:org.eclipse.rcptt.tesla.recording.core.swt.rap.SWTEventRecorder.java
License:Open Source License
private void processMouseUp(Widget widget, Event event, RecordedEvent toRecording) { if (widget instanceof Table || widget instanceof Tree) { Viewer viewer = TeslaSWTAccess.getViewer((Control) widget); if (viewer != null && viewer instanceof ColumnViewer) { ColumnViewer cview = (ColumnViewer) viewer; CellEditor[] editors = cview.getCellEditors(); // Collect click column ViewerCell cell = cview.getCell(new Point(event.x, event.y)); if (cell != null && editors != null) { int index = cell.getColumnIndex(); if (editors[index] != null && editors[index] instanceof CheckboxCellEditor) { recordCellAccess(widget, event, RecordCellAccessSource.MouseUp); return; }/*from w w w . j a v a2 s .c o m*/ } } Listener[] listenersUp = widget.getListeners(SWT.MouseUp); if ((listenersUp != null && hasNonPlatformListeners(listenersUp, SWT.MouseUp)) || mouseDownRecorded) { mouseDownRecorded = false; recordCellAccess(widget, event, RecordCellAccessSource.MouseUp); } } // Listener[] listenersDown = widget.getListeners(SWT.MouseDown); // if ((listenersDown != null && containsNonPlatform(listenersDown, // SWT.MouseDown))) { recordTextSetFocus(widget, event.button); // } if (isMacOS()) { if (widget instanceof Button) { if ((widget.getStyle() & SWT.CHECK) != 0) { FindResult result = getLocator().findElement(widget, false, false, true); if (result != null) { ControlUIElement e = new ControlUIElement(result.element, getRecorder()); e.check(((Button) widget).getSelection()); } } else if ((widget.getStyle() & SWT.RADIO) != 0) { FindResult result = getLocator().findElement(widget, false, false, true); if (result != null) { ControlUIElement e = new ControlUIElement(result.element, getRecorder()); e.clickAndWait(); } } } } // click on FilteredTree or Q7 SearchControl clear button if (widget instanceof Label && isSearchControlLabel((Label) widget) && lastEvents.checkType(widget, SWT.MouseDown)) { FindResult result = getLocator().findElement(widget, true, false, false); if (result != null) { ControlUIElement e = new ControlUIElement(result.element, getRecorder()); e.clickAndWait(); beforeTextState = ""; } } lastEvents.add(toRecording); }
From source file:org.eclipse.rcptt.tesla.recording.core.swt.SWTEventRecorder.java
License:Open Source License
private void processMouseUp(Widget widget, Event event, RecordedEvent toRecording) { if (widget instanceof Table || widget instanceof Tree) { Viewer viewer = TeslaSWTAccess.getViewer((Control) widget); if (viewer != null && viewer instanceof ColumnViewer) { ColumnViewer cview = (ColumnViewer) viewer; CellEditor[] editors = cview.getCellEditors(); // Collect click column ViewerCell cell = cview.getCell(new Point(event.x, event.y)); if (cell != null && editors != null) { int index = cell.getColumnIndex(); if (editors[index] != null && editors[index] instanceof CheckboxCellEditor) { recordCellAccess(widget, event, RecordCellAccessSource.MouseUp); return; }// ww w. ja v a 2 s.c om } } Listener[] listenersUp = widget.getListeners(SWT.MouseUp); if ((listenersUp != null && hasNonPlatformListeners(listenersUp, SWT.MouseUp)) || mouseDownRecorded) { mouseDownRecorded = false; recordCellAccess(widget, event, RecordCellAccessSource.MouseUp); } } // Listener[] listenersDown = widget.getListeners(SWT.MouseDown); // if ((listenersDown != null && containsNonPlatform(listenersDown, // SWT.MouseDown))) { recordTextSetFocus(widget, event.button); // } if (Platform.getOS().equals(Platform.OS_MACOSX)) { if (widget instanceof Button) { if ((widget.getStyle() & SWT.CHECK) != 0) { FindResult result = getLocator().findElement(widget, false, false, true); if (result != null) { ControlUIElement e = new ControlUIElement(result.element, getRecorder()); e.check(((Button) widget).getSelection()); } } else if ((widget.getStyle() & SWT.RADIO) != 0) { FindResult result = getLocator().findElement(widget, false, false, true); if (result != null) { ControlUIElement e = new ControlUIElement(result.element, getRecorder()); e.clickAndWait(); } } } } // click on FilteredTree or Q7 SearchControl clear button if (widget instanceof Label && isSearchControlLabel((Label) widget) && lastEvents.checkType(widget, SWT.MouseDown)) { FindResult result = getLocator().findElement(widget, true, false, false); if (result != null) { ControlUIElement e = new ControlUIElement(result.element, getRecorder()); e.clickAndWait(); beforeTextState = ""; } } lastEvents.add(toRecording); }