List of usage examples for org.eclipse.jface.viewers ViewerRow getItem
public abstract Widget getItem();
From source file:com.gorillalogic.monkeyconsole.tableview.MonkeyTalkTabularEditor.java
License:Open Source License
private static int getVisualIndex(ViewerRow row, int creationIndex) { TableItem item = (TableItem) row.getItem(); int[] order = item.getParent().getColumnOrder(); for (int i = 0; i < order.length; i++) { if (order[i] == creationIndex) { return i; }//from w w w . j av a 2 s . co m } return creationIndex; }
From source file:com.gorillalogic.monkeyconsole.tableview.MonkeyTalkTabularEditor.java
License:Open Source License
private static int getCreationIndex(ViewerRow row, int visualIndex) { TableItem item = (TableItem) row.getItem(); if (item != null && !item.isDisposed() /* * && hasColumns() && isValidOrderIndex * (visualIndex) */) { return item.getParent().getColumnOrder()[visualIndex]; }/* w w w . j av a 2s . co m*/ return visualIndex; }
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 .ja v a 2 s . 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:org.eclipse.andmore.android.emulator.core.emulationui.AbstractEmuLabelProvider.java
License:Apache License
/** * @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell) *///from w ww .j av a2 s . 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:org.eclipse.e4mf.common.ui.viewer.ColumnViewerInformationControlToolTipSupport.java
License:Open Source License
protected boolean shouldCreateToolTip(Event event) { ViewerCell cell = getToolTipArea(event); if (cell != null && !cell.equals(currentCell)) { control.setToolTipText(""); currentCell = cell;// w w w .j a va 2 s.c o m ViewerRow row = cell.getViewerRow(); if (row != null) { Object element = row.getItem().getData(); CellLabelProvider labelProvider = viewer.getLabelProvider(cell.getColumnIndex()); text = labelProvider.getToolTipText(element); boolean useNative = labelProvider.useNativeToolTip(element); if (useNative || text == null) { control.setToolTipText(text); } else { foregroundColor = labelProvider.getToolTipForegroundColor(element); backgroundColor = labelProvider.getToolTipBackgroundColor(element); font = labelProvider.getToolTipFont(element); return text != null; } } } else { currentCell = cell; } return false; }
From source file:org.eclipse.linuxtools.dataviewers.findreplace.STTableFindReplaceTarget.java
License:Open Source License
private ViewerCell findAndSelect(ViewerCell cell, String findString, boolean searchForward, boolean direction, boolean caseSensitive, boolean wholeWord, boolean wrapSearch, boolean regExSearch) { if (cell == null) return null; int dirCell = ViewerCell.RIGHT; if (!searchForward) dirCell = ViewerCell.LEFT;/*from w w w. j ava2 s . c o m*/ Table table = _viewer.getTable(); if (!scope || table.isSelected(table.indexOf((TableItem) cell.getItem()))) { ViewerCell cellFound = searchInRow(cell.getViewerRow(), cell.getColumnIndex(), findString, searchForward, caseSensitive, wholeWord, dirCell, regExSearch); if (cellFound != null) return cellFound; } dirCell = ViewerCell.RIGHT; int dirRow = 0; if (searchForward) dirRow = ViewerRow.BELOW; else dirRow = ViewerRow.ABOVE; ViewerRow row = cell.getViewerRow(); if (table.getSelectionCount() == 0) { while (row.getNeighbor(dirRow, true) != null) { row = row.getNeighbor(dirRow, true); cell = searchInRow(row, 0, findString, searchForward, caseSensitive, wholeWord, dirCell, regExSearch); if (cell != null) return cell; } } else { while (row.getNeighbor(dirRow, true) != null) { row = row.getNeighbor(dirRow, true); if (!scope || table.isSelected(table.indexOf((TableItem) row.getItem()))) { cell = searchInRow(row, 0, findString, searchForward, caseSensitive, wholeWord, dirCell, regExSearch); if (cell != null) return cell; } } } return null; }
From source file:org.eclipse.linuxtools.dataviewers.findreplace.STTableFindReplaceTarget.java
License:Open Source License
private ViewerCell searchInRow(ViewerRow row, int index, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord, int dirCell, boolean regExSearch) { Pattern pattern = null;//from w w w .j a v a 2s .c o m if (regExSearch) { pattern = Pattern.compile(findString); } ISTDataViewersField[] fields = getAllFields(); ViewerCell cell = row.getCell(index); do { String text = ""; ISTDataViewersField field = fields[cell.getColumnIndex()]; if (field.getSpecialDrawer(cell.getElement()) != null) { ISpecialDrawerListener hfield = (ISpecialDrawerListener) field; text = hfield.getValue(cell.getElement()).trim(); } else text = cell.getText().trim(); boolean ok = false; if (regExSearch) { Matcher matcher = pattern.matcher(text); ok = matcher.find(); } else { if (wholeWord) { if (caseSensitive) ok = text.equals(findString); else ok = text.equalsIgnoreCase(findString); } else { ok = text.contains(findString); if (ok && caseSensitive) { text.indexOf(findString); } } } if (ok) { _viewer.reveal(cell.getElement()); if (((TableViewer) _viewer).getTable().getSelectionCount() > 0) { TableViewer tv = (TableViewer) _viewer; Table table = tv.getTable(); table.deselect(table.indexOf((TableItem) row.getItem())); } return cell; } cell = cell.getNeighbor(dirCell, true); } while (cell != null); return null; }
From source file:org.eclipse.linuxtools.dataviewers.findreplace.STTreeFindReplaceTarget.java
License:Open Source License
private ViewerCell searchInRow(ViewerRow row, int index, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord, int dirCell, boolean regExSearch) { Pattern pattern = null;// ww w. j a va 2s . c om if (regExSearch) { pattern = Pattern.compile(findString); } ISTDataViewersField[] fields = getAllFields(); ViewerCell cell = row.getCell(index); do { String text = ""; ISTDataViewersField field = fields[cell.getColumnIndex()]; if (field.getSpecialDrawer(cell.getElement()) != null) { ISpecialDrawerListener hfield = (ISpecialDrawerListener) field; text = hfield.getValue(cell.getElement()).trim(); } else text = cell.getText().trim(); boolean ok = false; if (regExSearch) { Matcher matcher = pattern.matcher(text); ok = matcher.find(); } else { if (wholeWord) { if (caseSensitive) ok = text.equals(findString); else ok = text.equalsIgnoreCase(findString); } else { ok = text.contains(findString); if (ok && caseSensitive) { text.indexOf(findString); } } } if (ok) { _viewer.reveal(cell.getElement()); if (fSelections != null && fSelections.indexOf(row.getItem()) != -1) _viewer.getTree().deselectAll(); return cell; } cell = cell.getNeighbor(dirCell, true); } while (cell != null); return null; }
From source file:org.eclipse.nebula.jface.galleryviewer.GalleryTreeViewer.java
License:Open Source License
/** * Create a new ViewerRow at rowIndex//from w w w . j av a2 s .c om * * @param parent * @param style * @param rowIndex * @return ViewerRow */ private ViewerRow createNewRowPart(ViewerRow parent, int style, int rowIndex) { if (parent == null) { if (rowIndex >= 0) { return getViewerRowFromItem(new GalleryItem(gallery, style, rowIndex)); } return getViewerRowFromItem(new GalleryItem(gallery, style)); } if (rowIndex >= 0) { return getViewerRowFromItem(new GalleryItem((GalleryItem) parent.getItem(), SWT.NONE, rowIndex)); } return getViewerRowFromItem(new GalleryItem((GalleryItem) parent.getItem(), SWT.NONE)); }
From source file:org.eclipse.nebula.jface.gridviewer.GridTreeViewer.java
License:Open Source License
/** * Create a new ViewerRow at rowIndex/*from ww w . java 2s .co m*/ * * @param parent * the parent row * @param style * the style bits to use for the new row * @param rowIndex * the index at which the new row should be created under the parent * @return ViewerRow * the new row */ private ViewerRow createNewRowPart(ViewerRow parent, int style, int rowIndex) { if (parent == null) { if (rowIndex >= 0) { return getViewerRowFromItem(new GridItem(grid, style, rowIndex)); } return getViewerRowFromItem(new GridItem(grid, style)); } if (rowIndex >= 0) { return getViewerRowFromItem(new GridItem((GridItem) parent.getItem(), SWT.NONE, rowIndex)); } return getViewerRowFromItem(new GridItem((GridItem) parent.getItem(), SWT.NONE)); }