List of usage examples for org.eclipse.jface.viewers ViewerCell getColumnIndex
public int getColumnIndex()
From source file:com.kdmanalytics.toif.ui.views.FindingStyledLabelProvider.java
License:Open Source License
public void update(final ViewerCell cell) { final IFindingEntry entry = (IFindingEntry) cell.getElement(); int index = cell.getColumnIndex(); String text = getColumnText(entry, index); if (text == null) { text = ""; }/*w w w . ja va 2s . c om*/ final StyledString styledString = new StyledString(text); Boolean citing = entry.getCiting(); if (citing != null) { if (citing) { cell.setForeground(FOREGROUND_RED); cell.setBackground(RED); } else { cell.setForeground(FOREGROUND_GREEN); cell.setBackground(GREEN); } } else { cell.setForeground(FOREGROUND_BLACK); cell.setBackground(WHITE); } cell.setText(styledString.toString()); cell.setStyleRanges(styledString.getStyleRanges()); cell.setImage(getImage(entry, cell.getColumnIndex())); }
From source file:com.logcat.offline.view.ddmuilib.logcat.LogCatMessageLabelProvider.java
License:Apache License
@Override public void update(ViewerCell cell) { Object element = cell.getElement(); if (!(element instanceof LogCatMessageWrapper)) { return;//from w w w. j a v a 2 s .co m } LogCatMessage m = ((LogCatMessageWrapper) element).getLogCatMessage(); String text = getCellText(m, cell.getColumnIndex()); cell.setText(text); cell.setFont(mLogFont); cell.setForeground(getForegroundColor(m)); cell.setBackground(getBackgroundColor((LogCatMessageWrapper) element)); }
From source file:com.maccasoft.composer.internal.TextEditingSupport.java
License:Open Source License
@Override protected CellEditor getCellEditor(Object element) { if (cellEditor == null) { cellEditor = new TextCellEditor((Composite) getViewer().getControl(), SWT.CENTER) { @Override/*www . j av a 2s . com*/ protected void keyReleaseOccured(KeyEvent e) { if (e.keyCode == SWT.ARROW_UP) { fireApplyEditorValue(); deactivate(); ViewerCell cell = getViewer().getColumnViewerEditor().getFocusCell(); if (cell != null) { final ViewerCell nextCell = cell.getNeighbor(ViewerCell.ABOVE, false); if (nextCell != null) { getViewer().getControl().getDisplay().asyncExec(new Runnable() { @Override public void run() { GridTableViewer viewer = (GridTableViewer) getViewer(); Grid grid = (Grid) viewer.getControl(); if (!grid.isDisposed()) { viewer.editElement(nextCell.getElement(), nextCell.getColumnIndex()); } } }); } } e.doit = false; } else if (e.keyCode == SWT.ARROW_DOWN) { fireApplyEditorValue(); deactivate(); ViewerCell cell = getViewer().getColumnViewerEditor().getFocusCell(); if (cell != null) { final ViewerCell nextCell = cell.getNeighbor(ViewerCell.BELOW, false); if (nextCell != null) { getViewer().getControl().getDisplay().asyncExec(new Runnable() { @Override public void run() { GridTableViewer viewer = (GridTableViewer) getViewer(); Grid grid = (Grid) viewer.getControl(); if (!grid.isDisposed()) { viewer.editElement(nextCell.getElement(), nextCell.getColumnIndex()); } } }); } } e.doit = false; } super.keyReleaseOccured(e); } }; } return cellEditor; }
From source file:com.maccasoft.composer.NoteKeyListener.java
License:Open Source License
@Override public void keyPressed(KeyEvent e) { IStructuredSelection selection = viewer.getStructuredSelection(); if (selection.isEmpty()) { return;/*from w ww. ja v a 2 s. co m*/ } SongRow model = (SongRow) selection.getFirstElement(); final ViewerCell cell = viewer.getColumnViewerEditor().getFocusCell(); int channel = cell.getColumnIndex() / 4; int columnIndex = cell.getColumnIndex() % 4; if (columnIndex == 0) { String s = noteMap.get(e.character); if (s != null) { model.setNote(channel, s + String.valueOf(getOctave())); if ("".equals(model.getInstrument(channel))) { model.setInstrument(channel, getInstrument()); } viewer.update(model, null); final ViewerCell nextCell = cell.getNeighbor(ViewerCell.BELOW, false); if (nextCell != null) { final Event event1 = new Event(); event1.type = SWT.KeyDown; event1.keyCode = SWT.ARROW_DOWN; event1.widget = e.widget; final Event event2 = new Event(); event2.type = SWT.KeyUp; event2.keyCode = SWT.ARROW_DOWN; event2.widget = e.widget; final Display display = e.display; display.asyncExec(new Runnable() { @Override public void run() { if (event1.widget.isDisposed()) { return; } display.post(event1); display.post(event2); } }); } e.doit = false; return; } } if (e.character == SWT.DEL) { if ((e.stateMask & SWT.MOD2) != 0) { removeEntryAndShiftUp(channel, model); viewer.refresh(); e.doit = false; return; } switch (columnIndex) { case 0: model.setNote(channel, ""); break; case 1: model.setInstrument(channel, ""); break; case 2: model.setFx1(channel, ""); break; case 3: model.setFx2(channel, ""); break; } viewer.update(model, null); e.doit = false; return; } if (e.keyCode == SWT.INSERT) { insertBlankAndShiftDown(channel, model); viewer.refresh(); e.doit = false; return; } if (e.character >= 0x20 && e.character <= 0x7F) { e.doit = false; return; } }
From source file:com.mentor.nucleus.bp.ui.sem.pages.SEMEditorPage.java
License:Open Source License
private void createColumnForEvent(StateMachineEvent_c event) { TableViewerColumn column = new TableViewerColumn(fTableViewer, SWT.CENTER); column.setLabelProvider(new CellLabelProvider() { @Override// w w w . ja v a2s. co m public void update(ViewerCell cell) { ITableLabelProvider provider = (ITableLabelProvider) fTableViewer.getLabelProvider(); cell.setText(provider.getColumnText(cell.getElement(), cell.getColumnIndex())); cell.setImage(provider.getColumnImage(cell.getElement(), cell.getColumnIndex())); } }); column.setEditingSupport(new SEMEditingSupport(fTableViewer, column.getColumn())); column.getColumn().setData(event); column.getColumn().setText(event.Get_name()); column.getColumn().pack(); }
From source file:com.mentor.nucleus.bp.ui.sem.viewers.SEMFocusCellHighlighter.java
License:Open Source License
private void removeSelectionInformation(Event event, ViewerCell cell) { GC gc = event.gc;// www .j a va 2s . c o m gc.setBackground(cell.getViewerRow().getBackground(cell.getColumnIndex())); gc.setForeground(cell.getViewerRow().getForeground(cell.getColumnIndex())); gc.fillRectangle(cell.getBounds()); // This is a workaround for an SWT-Bug on WinXP bug 169517 gc.drawText(" ", cell.getBounds().x, cell.getBounds().y, false); //$NON-NLS-1$ event.detail &= ~SWT.SELECTED; }
From source file:com.mercatis.lighthouse3.ui.event.providers.EventTable.java
License:Apache License
public void addSelectedColumnAsFilterCriteria() { ViewerCell cell = (ViewerCell) tableViewer.getCell(lastMousePosition); int columnIndex = cell.getColumnIndex(); ColumnType columnType = (ColumnType) tableViewer.getTable().getColumn(columnIndex).getData(); Event event = (Event) ((StructuredSelection) tableViewer.getSelection()).getFirstElement(); List<Object> values = new LinkedList<Object>(); int propertyIndex = EventTableUIElementsConstants.transformColumnNameToFilterPropertyIndex(columnType); switch (propertyIndex) { case EventFilterModel.UDF: for (Entry<String, Object> entry : event.getUdfs().entrySet()) { values.add(new Tuple<String, Object>(entry.getKey(), entry.getValue())); }//from www. j av a 2 s.co m values.addAll(eventFilterModel.getValuesFor(propertyIndex)); break; case EventFilterModel.DATE: values.add(new Tuple<Date, Object>(event.getDateOfOccurrence(), null)); break; case EventFilterModel.TRANSACTION_ID: for (String transActionId : event.getTransactionIds()) { values.add((Object) transActionId); } values.addAll(eventFilterModel.getValuesFor(propertyIndex)); break; default: values.add(cell.getText()); values.addAll(eventFilterModel.getValuesFor(propertyIndex)); } eventFilterModel.setValuesFor(values, propertyIndex); }
From source file:com.microsoft.tfs.client.common.ui.framework.celleditor.accessibility.CellEditorAccessibility.java
License:Open Source License
public static final Point getFocusCellIndex(final TableViewer viewer) { try {// w ww .j a va 2 s . c o m if (viewer.getColumnViewerEditor() != null) { final ViewerCell focusCell = viewer.getColumnViewerEditor().getFocusCell(); if (focusCell != null) { final int x = focusCell.getColumnIndex(); final int y = viewer.getTable().indexOf((TableItem) focusCell.getItem()); return new Point(x, y); } } } catch (final Exception e) { log.warn("Could not determine cell index", e); //$NON-NLS-1$ } return new Point(-1, -1); }
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) *//* w w w . j a v a 2s. c om*/ @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.netxstudio.callflow.screens.CallFlowsTreeLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { // Service Flow object // 0 = index//ww w. j av a 2s. co m // 1 = Name // 2 = empty (Perhaps the first element). // 3 = empty (Perhaps the last element) // 4 = Protocol. // Service Flow Relationship object. // 0 = empty // 1 = empty // 2 = NodeType A // 3 = NodeType B // 4 = Protocol // // We potentially support multiple columns, override as needed. binding // to features should return a reasonable default. Object element = cell.getElement(); int columnIndex = cell.getColumnIndex(); switch (columnIndex) { case 0: { updateColumn0(cell, element); } break; case 1: { updateColumn1(cell, element); } break; case 2: { updateColumn2(cell, element); } break; case 3: { updateColumn3(cell, element); } break; case 4: { updateColumn4(cell, element); } break; case 5: { updateColumn5(cell, element); } break; case 6: { updateColumn6(cell, element); } break; case 7: { updateColumn7(cell, element); } break; default: { super.update(cell); } } }