List of usage examples for org.eclipse.jface.viewers ViewerCell getControl
public Control getControl()
From source file:com.ibm.etools.mft.conversion.esb.editor.parameter.GlobalOptionsEditor.java
License:Open Source License
@Override public void doubleClick(DoubleClickEvent event) { if (event.getSelection().isEmpty()) { return;//from w w w .j a v a 2s . c om } Object o = ((IStructuredSelection) event.getSelection()).getFirstElement(); TableViewer viewer = (o instanceof PrimitiveConverter) ? primtiveConverterViewer : ((o instanceof BindingConverter) ? bindingConverterViewer : null); if (viewer != null) { boolean showUsage = false; Control c = null; if (viewer == primtiveConverterViewer) { ViewerCell vc = primitiveHighlighter.getFocusCell(); int index = vc.getColumnIndex(); if (index == 2) showUsage = true;// only show usage dialog for 3rd column else if (index == 3)// 4th column is being acted on, get the // (...) control c = vc.getControl(); } else if (viewer == bindingConverterViewer) { ViewerCell vc = bindingHighlighter.getFocusCell(); int index = vc.getColumnIndex(); if (index == 2) showUsage = true;// only show usage dialog for 3rd column else if (index == 3) // 4th column is being acted on, get the // (...) control c = vc.getControl(); } if (showUsage) {// usage dialog will come up if cell column 3 is // double-clicked or ENTER is pressed on it Converter converter = (Converter) o; String message = null; String desc = (o instanceof PrimitiveConverter) ? WESBConversionMessages.GlobalOptionsEditor_primitiveConvertersDescription : ((o instanceof BindingConverter) ? WESBConversionMessages.GlobalOptionsEditor_bindingConvertersDescription : ""); //$NON-NLS-2$ //$NON-NLS-1$ String title = (o instanceof PrimitiveConverter) ? WESBConversionMessages.GlobalOptionsEditor_MPUsage_Title : ((o instanceof BindingConverter) ? WESBConversionMessages.GlobalOptionsEditor_BindingUsage_Title : ""); //$NON-NLS-2$ //$NON-NLS-1$ String heading = WESBConversionMessages.GlobalOptionsEditor_UsageHeading; message = WESBConversionMessages.GlobalOptionsEditor_UsageMessage; UsageDialog d = new UsageDialog(heading, title, desc, NLS.bind(message, (o instanceof PrimitiveConverter) ? WESBConversionMessages.GlobalOptionsEditor_MP : ((o instanceof BindingConverter) ? WESBConversionMessages.GlobalOptionsEditor_binding : ""), //$NON-NLS-1$ ((ITableLabelProvider) viewer //$NON-NLS-2$ .getLabelProvider()).getColumnText(converter, 0)), converter.getUsages()); d.open(); } // if else if (null != c) { c.setFocus();// 4th column is being acted on, so show the (...) // button } } }
From source file:com.motorola.studio.android.emulator.core.emulationui.AbstractEmuLabelProvider.java
License:Apache License
/** * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell) *///from w w w .j a v a2s . c o m @Override public void update(ViewerCell cell) { // The instance column index is set with the current cell column index, as the logic // contained in this class depends on this information. Then after the cell is // updated according to the standard procedure, the column index field is reset so that // it does not interfere with subsequent updates. columnIndex = cell.getColumnIndex(); super.update(cell); columnIndex = firstColumnIndex; // Checks if the cell needs to be highlighted. This will be true if the values of // alternativeColorHost and alternativeColorBeanId are different from null and -1 if ((alternativeColorHost != null) && (alternativeColorBeanId != -1)) { Object element = cell.getElement(); // Only leaf nodes can be highlighted if (element instanceof EmuViewerLeafNode) { // The next lines are used to check if the current element is the one to be // highlighted. For that, the host and bean id needs to be compared to the // alternativeColorHost and alternativeColorBeanId instance field values EmuViewerLeafNode node = (EmuViewerLeafNode) element; long beanId = node.getBeanId(); EmuViewerRootNode root = (EmuViewerRootNode) node.getParent().getParent(); String host = root.getEmulatorIdentifier(); if ((beanId == alternativeColorBeanId) && (host.equals(alternativeColorHost))) { // Highlighting the node cell.setBackground(alternativeColor); // Putting the node at the visible part of the tree ViewerRow highlightedRow = cell.getViewerRow(); TreeItem highlightedItem = (TreeItem) highlightedRow.getItem(); Tree tree = (Tree) cell.getControl(); tree.showItem(highlightedItem); } } } }
From source file:com.netxforge.screens.editing.base.tables.FocusBlockOwnerDrawHighlighterForMultiselection.java
License:Open Source License
private void markFocusedBlock(Event event, List<ViewerCell> block) { // iterate through the cell, and draw a rectangle. for (ViewerCell cell : block) { Color background = (cell.getControl().isFocusControl()) ? getSelectedCellBackgroundColor(cell) : getSelectedCellBackgroundColorNoFocus(cell); Color foreground = (cell.getControl().isFocusControl()) ? getSelectedCellForegroundColor(cell) : getSelectedCellForegroundColorNoFocus(cell); if (foreground != null || background != null || onlyTextHighlighting(cell)) { GC gc = event.gc;// w ww.j a v a2s. c o m if (background == null) { background = cell.getItem().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION); } if (foreground == null) { foreground = cell.getItem().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT); } gc.setBackground(background); gc.setForeground(foreground); if (onlyTextHighlighting(cell)) { Rectangle area = event.getBounds(); Rectangle rect = cell.getTextBounds(); if (rect != null) { area.x = rect.x; } gc.fillRectangle(area); } else { gc.fillRectangle(event.getBounds()); } } } drawBorder(event, block); event.detail &= ~SWT.SELECTED; }
From source file:com.netxforge.screens.editing.base.tables.FocusBlockOwnerDrawHighlighterForMultiselection.java
License:Open Source License
/** * The color to use when rendering the background of the selected cell when * the control has the input focus//from w ww. jav a 2s .c o m * * @param cell * the cell which is colored * @return the color or <code>null</code> to use the default */ protected Color getSelectedCellBackgroundColor(ViewerCell cell) { return cell.getControl().getDisplay().getSystemColor(SWT.COLOR_WHITE); }
From source file:com.netxforge.screens.editing.base.tables.FocusBlockOwnerDrawHighlighterForMultiselection.java
License:Open Source License
/** * The color to use when rendering the foreground (=text) of the selected * cell when the control has the input focus * //from w w w . j a va 2 s .c o m * @param cell * the cell which is colored * @return the color or <code>null</code> to use the default */ protected Color getSelectedCellForegroundColor(ViewerCell cell) { return cell.getControl().getDisplay().getSystemColor(SWT.COLOR_BLACK); }
From source file:com.netxforge.screens.editing.base.tables.FocusBlockOwnerDrawHighlighterForMultiselection.java
License:Open Source License
private void redrawCell(ViewerCell redrawCell) { Rectangle rect = redrawCell.getBounds(); int x = redrawCell.getColumnIndex() == 0 ? 0 : rect.x; int width = redrawCell.getColumnIndex() == 0 ? rect.x + rect.width : rect.width; // int y = (rect.y + 1); // System.out.println("redraw viewercell horizontal from " + x + " to " // + (x + width)); // System.out.println("redraw viewercell vertical from " + y + " to " // + (y + rect.height)); // 1 is a fix for Linux-GTK redrawCell.getControl().redraw(x, rect.y - 1, width, rect.height + 1, true); }
From source file:com.netxforge.screens.editing.base.tables.FocusBlockOwnerDrawHighlighterForMultiselection.java
License:Open Source License
private Color getUnselectedCellForegroundColor(ViewerCell cell) { return cell.getControl().getDisplay().getSystemColor(SWT.COLOR_BLACK); }
From source file:com.netxforge.screens.editing.base.tables.FocusBlockOwnerDrawHighlighterForMultiselection.java
License:Open Source License
private Color getUnselectedCellBackgroundColor(ViewerCell cell) { return cell.getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION); }
From source file:com.rcpcompany.uibindings.internal.FocusCellUIPainterHighlighter.java
License:Open Source License
@Override protected void focusCellChanged(ViewerCell newCell, ViewerCell oldCell) { super.focusCellChanged(newCell, oldCell); // Redraw new area if (newCell != null) { final Rectangle rect = newCell.getBounds(); final int x = newCell.getColumnIndex() == 0 ? 0 : rect.x; final int width = newCell.getColumnIndex() == 0 ? rect.x + rect.width : rect.width; // 1 is a fix for Linux-GTK newCell.getControl().redraw(x, rect.y - 1, width, rect.height + 1, true); }//from w w w . j a v a2 s. c om if (oldCell != null) { final Rectangle rect = oldCell.getBounds(); final int x = oldCell.getColumnIndex() == 0 ? 0 : rect.x; final int width = oldCell.getColumnIndex() == 0 ? rect.x + rect.width : rect.width; // 1 is a fix for Linux-GTK oldCell.getControl().redraw(x, rect.y - 1, width, rect.height + 1, true); } }
From source file:eu.esdihumboldt.hale.ui.templates.webtemplates.LinkLabels.java
License:Open Source License
@Override public void update(ViewerCell cell) { StyledString text = new StyledString("Info", linkStyler); cell.setText(text.getString());// w ww .j a va 2 s. c om cell.setStyleRanges(text.getStyleRanges()); cell.getControl().setCursor(cursor); super.update(cell); }