List of usage examples for org.eclipse.jface.viewers ViewerCell getColumnIndex
public int getColumnIndex()
From source file:org.eclipse.nebula.jface.gridviewer.GridViewerEditor.java
License:Open Source License
/** * {@inheritDoc}/*from ww w . j a va2 s . co m*/ */ 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()); }
From source file:org.eclipse.nebula.widgets.richtext.RichTextCellLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { columnIndex = cell.getColumnIndex(); super.update(cell); }
From source file:org.eclipse.papyrus.infra.gmfdiag.dnd.preferences.DropStrategyLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); if (element instanceof DropStrategy) { DropStrategy strategy = (DropStrategy) element; if (cell.getColumnIndex() == DropStrategyEditor.LABEL_COLUMN) { cell.setImage(strategy.getImage()); int foreground; if (DropStrategyManager.instance.isActive(strategy)) { foreground = SWT.COLOR_BLACK; } else { foreground = SWT.COLOR_GRAY; }// w w w . ja va2 s . c o m cell.setForeground(Display.getCurrent().getSystemColor(foreground)); cell.setText(strategy.getLabel()); } } }
From source file:org.eclipse.papyrus.uml.diagram.dnd.strategy.instancespecification.ui.ClassifierPropertiesLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); int columnIndex = cell.getColumnIndex(); StyledString styledText = getStyledText(element, columnIndex); cell.setText(styledText.getString()); cell.setStyleRanges(styledText.getStyleRanges()); cell.setImage(getImage(element, columnIndex)); }
From source file:org.eclipse.ptp.internal.rm.jaxb.control.ui.providers.ViewerDataCellLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { int index = cell.getColumnIndex(); Object element = cell.getElement(); Color color = getBackground(element, index); if (color != null) { cell.setBackground(color);//from ww w . j a v a 2 s . c om } color = getForeground(element, index); if (color != null) { cell.setForeground(color); } else { /* * If foreground color is not specified, then we use the edit status of the * cell to determine the color. We save the default foreground color to use * when the cell is editable. */ if (foregroundColor == null) { foregroundColor = cell.getForeground(); } if (!canEdit(element)) { cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY)); } else { cell.setForeground(foregroundColor); } } Font font = getFont(element, index); if (font != null) { cell.setFont(font); } Image img = getColumnImage(element, index); if (img != null) { cell.setImage(img); } cell.setText(getColumnText(element, index)); }
From source file:org.eclipse.ptp.rm.jaxb.control.ui.providers.ViewerDataCellLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { int index = cell.getColumnIndex(); Object element = cell.getElement(); Color color = getBackground(element, index); if (color != null) { cell.setBackground(color);/*from w w w . j av a 2s .com*/ } color = getForeground(element, index); if (color != null) { cell.setBackground(color); } Font font = getFont(element, index); if (font != null) { cell.setFont(font); } Image img = getColumnImage(element, index); if (img != null) { cell.setImage(img); } cell.setText(getColumnText(element, index)); }
From source file:org.eclipse.rcptt.tesla.recording.core.swt.JFaceRecordingProcessor.java
License:Open Source License
public void activateCellEditor(CellEditor cellEditor, ColumnViewerEditorActivationEvent activationEvent) { if (cellEditor == null) return;/*from www .ja v a 2 s .c om*/ if (checkCellEditorOP()) { return; } if (activeCellEditors.contains(cellEditor)) { return; } boolean checkbox = cellEditor instanceof CheckboxCellEditor; Control control = cellEditor.getControl(); lastCellEditorControl = null; if (control == null && !checkbox) { return; } Composite parent = null; if (checkbox) { parent = getCheckboxCellEditorSource(activationEvent); } else { parent = control.getParent(); } if (parent == null) { return; } activeCellEditors.add(cellEditor); // Control[] children = parent.getChildren(); if (parent instanceof Tree || parent instanceof Table) { String[][] selection = Viewers.getMultiPathSelection(getPlayer().wrap(parent)); ControlEditor editor = TeslaSWTAccess.getControlEditor(parent); int column = -1; if (activationEvent.getSource() instanceof ViewerCell) { ViewerCell cell = (ViewerCell) activationEvent.getSource(); column = cell.getColumnIndex(); Widget item = cell.getItem(); if (item instanceof TreeItem) { selection = new String[][] { Viewers.getPathByTreeItem((TreeItem) item) }; } else if (item instanceof TableItem) { selection = new String[][] { Viewers.getPathByTableItem((TableItem) item) }; } } else { if (editor instanceof TreeEditor) { column = ((TreeEditor) editor).getColumn(); } else if (editor instanceof TableEditor) { column = ((TableEditor) editor).getColumn(); } } FindResult result = getLocator().findElement(parent, true, false, false); if (result != null && (result.realElement.isTable() || result.realElement.isTree())) { ViewerUIElement e = new ViewerUIElement(result.element, getRecorder()); if (!checkbox) { e.setMultiSelection(selection); e.activateCellEditor(column); } else { CheckboxCellEditor checkboxCellEditor = (CheckboxCellEditor) cellEditor; int row = -1; if (parent instanceof Tree) { Tree tree = (Tree) parent; if (tree.getSelectionCount() > 0) row = tree.indexOf(tree.getSelection()[0]); } else if (parent instanceof Table) { Table table = (Table) parent; row = table.getSelectionIndex(); } if (row != -1 && checkboxCellEditor.getValue() != null) { ItemUIElement item = e.item(column, row); CheckItem checkItem = ProtocolFactory.eINSTANCE.createCheckItem(); checkItem.setElement(item.getElement()); checkItem.setState((Boolean) checkboxCellEditor.getValue()); getRecorder().safeExecuteCommand(checkItem); } } } } else { List<ICellEditsProcessor> processors = TeslaRecorder.getInstance() .getProcessors(ICellEditsProcessor.class); for (ICellEditsProcessor p : processors) if (p.activateCellEdit(cellEditor, activationEvent)) break; } }
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 . jav a2 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 (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.rap.SWTWidgetLocator.java
License:Open Source License
public int getColumnFromCellEditor(Object cellEditorObj, ControlEditor editor, CellEditor cellEditor) { if (editor instanceof TreeEditor) { int col = ((TreeEditor) editor).getColumn(); if (col != -1) { return col; }/* w ww . j a va 2 s . c o m*/ } else if (editor instanceof TableEditor) { int col = ((TableEditor) editor).getColumn(); if (col != -1) { return col; } } ColumnViewerEditor cve = null; if (cellEditorObj instanceof ColumnViewerEditor) { cve = (ColumnViewerEditor) cellEditorObj; } if (cve == null) { cve = getColumnViewerEditor(cellEditor); } if (cve != null) { ViewerCell cell = cve.getFocusCell(); if (cell != null) { return cell.getColumnIndex(); } } return -1; }
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; }// w w w . j a v a2 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); }