List of usage examples for org.eclipse.jface.viewers ViewerRow ABOVE
int ABOVE
To view the source code for org.eclipse.jface.viewers ViewerRow ABOVE.
Click Source Link
From source file:com.gorillalogic.monkeyconsole.tableview.MonkeyTalkTabularEditor.java
License:Open Source License
private static ViewerCell getNeighbor(ViewerCell currentCell, int directionMask, boolean sameLevel) { ViewerRow row;//from w w w . j av a 2s .c om if ((directionMask & ViewerCell.ABOVE) == ViewerCell.ABOVE) { row = currentCell.getViewerRow().getNeighbor(ViewerRow.ABOVE, sameLevel); } else if ((directionMask & ViewerCell.BELOW) == ViewerCell.BELOW) { row = currentCell.getViewerRow().getNeighbor(ViewerRow.BELOW, sameLevel); } else { row = currentCell.getViewerRow(); } if (row != null) { int columnIndex; columnIndex = getVisualIndex(row, currentCell.getColumnIndex()); int modifier = 0; if ((directionMask & ViewerCell.LEFT) == ViewerCell.LEFT) { modifier = -1; } else if ((directionMask & ViewerCell.RIGHT) == ViewerCell.RIGHT) { modifier = 1; } columnIndex += modifier; if (columnIndex >= 0 && columnIndex < row.getColumnCount()) { ViewerCell cell = getCellAtVisualIndex(row, columnIndex); if (cell != null) { while (cell != null && columnIndex < row.getColumnCount() - 1 && columnIndex > 0) { if (isVisible(cell)) { break; } columnIndex += modifier; cell = getCellAtVisualIndex(row, columnIndex); if (cell == null) { break; } } } return cell; } } return null; }
From source file:edu.ualberta.med.biobank.gui.common.widgets.nebula.tablecombo.TableComboViewerRow.java
License:Open Source License
/** * {@inheritDoc}//from w w w . j av a 2s.c o m */ @Override public ViewerRow getNeighbor(int direction, boolean sameLevel) { if (direction == ViewerRow.ABOVE) { return getRowAbove(); } else if (direction == ViewerRow.BELOW) { return getRowBelow(); } else { throw new IllegalArgumentException("Illegal value of direction argument."); //$NON-NLS-1$ } }
From source file:net.karlmartens.ui.viewer.GridChooserViewerRow.java
License:Apache License
@Override public ViewerRow getNeighbor(int direction, boolean sameLevel) { final GridChooserItem item; if (ViewerRow.ABOVE == direction) { item = getNeighbor(-1);/*from w w w . ja va 2s. co m*/ } else if (ViewerRow.BELOW == direction) { item = getNeighbor(1); } else { throw new IllegalArgumentException(); } if (item == null) return null; return new GridChooserViewerRow(item); }
From source file:net.karlmartens.ui.viewer.TableViewerRow.java
License:Apache License
@Override public ViewerRow getNeighbor(int direction, boolean sameLevel) { final TableItem item; if (ViewerRow.ABOVE == direction) { item = getNeighbor(-1);// w ww. j av a 2s . c om } else if (ViewerRow.BELOW == direction) { item = getNeighbor(1); } else { throw new IllegalArgumentException(); } if (item == null) return null; return new TableViewerRow(item); }
From source file:net.tourbook.ui.views.tourMarker.TourMarkerView.java
License:Open Source License
/** * Column: Distance delta km/mi//from ww w . java2 s .c o m */ private void defineColumn_Motion_DistanceDelta() { final ColumnDefinition colDef = TableColumnFactory.MOTION_DISTANCE_DELTA.createColumn(_columnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final TourMarker tourMarker = (TourMarker) cell.getElement(); final float markerDistance = tourMarker.getDistance(); if (markerDistance == -1) { cell.setText(UI.EMPTY_STRING); } else { float prevDistance = 0; final ViewerRow lastRow = cell.getViewerRow().getNeighbor(ViewerRow.ABOVE, false); if (null != lastRow) { final TourMarker element = (TourMarker) lastRow.getElement(); if (element instanceof TourMarker) { prevDistance = element.getDistance(); } prevDistance = prevDistance < 0 ? 0 : prevDistance; } cell.setText(_nf3.format( (markerDistance - prevDistance) / 1000 / net.tourbook.ui.UI.UNIT_VALUE_DISTANCE)); } } }); }
From source file:net.tourbook.ui.views.tourMarker.TourMarkerView.java
License:Open Source License
/** * Column: Time/*from w w w . j a v a 2 s . c om*/ */ private void defineColumn_Time_TimeDelta() { final ColumnDefinition colDef = TableColumnFactory.MARKER_TIME_DELTA.createColumn(_columnManager, _pc); colDef.setLabelProvider(new CellLabelProvider() { @Override public void update(final ViewerCell cell) { final ViewerRow lastRow = cell.getViewerRow().getNeighbor(ViewerRow.ABOVE, false); int lastTime = 0; if (null != lastRow) { final Object element = lastRow.getElement(); if (element instanceof TourMarker) { lastTime = ((TourMarker) element).getTime(); } } cell.setText(net.tourbook.common.UI .format_hh_mm_ss(((TourMarker) cell.getElement()).getTime() - lastTime)); final String text = ((TourMarker) cell.getElement()).getLabel(); /* * Show text in red/bold when the text ends with a !, this hidden feature was * introduced by helmling */ if (text.endsWith(UI.SYMBOL_EXCLAMATION_POINT)) { final Display display = Display.getCurrent(); if (null != display) { cell.setForeground(display.getSystemColor(SWT.COLOR_RED)); } cell.setFont(_boldFont); } } }); }
From source file:org.eclipse.linuxtools.dataviewers.findreplace.STFindReplaceDialog.java
License:Open Source License
/** * Returns the position of the specified search string, or <code>-1</code> if the string can * not be found when searching using the given options. * * @param findString the string to search for * @param startPosition the position at which to start the search * @param forwardSearch the direction of the search * @param caseSensitive should the search be case sensitive * @param wrapSearch should the search wrap to the start/end if arrived at the end/start * @param wholeWord does the search string represent a complete word * @param regExSearch if <code>true</code> findString represents a regular expression * @return the occurrence of the find string following the options or <code>-1</code> if nothing found * @since 3.0//w w w . j a va 2 s . c o m */ private ViewerCell findIndex(String findString, ViewerCell startPosition, boolean forwardSearch, boolean caseSensitive, boolean wrapSearch, boolean wholeWord, boolean regExSearch) { if (forwardSearch) { if (wrapSearch) { ViewerCell index = findAndSelect(startPosition, findString, true, caseSensitive, wholeWord, regExSearch, wrapSearch); if (index == null) { if (okToUse(getShell()) && !isIncrementalSearch()) getShell().getDisplay().beep(); index = findAndSelect(fTarget.getFirstCell(startPosition, ViewerRow.ABOVE), findString, true, caseSensitive, wholeWord, regExSearch, wrapSearch); } return index; } return findAndSelect(startPosition, findString, true, caseSensitive, wholeWord, regExSearch, wrapSearch); } // backward if (wrapSearch) { ViewerCell index = findAndSelect(startPosition, findString, false, caseSensitive, wholeWord, regExSearch, wrapSearch); if (index == null) { if (okToUse(getShell()) && !isIncrementalSearch()) getShell().getDisplay().beep(); index = findAndSelect(fTarget.getFirstCell(startPosition, ViewerRow.BELOW), findString, false, caseSensitive, wholeWord, regExSearch, wrapSearch); } return index; } return findAndSelect(startPosition, findString, false, caseSensitive, wholeWord, regExSearch, wrapSearch); }
From source file:org.eclipse.linuxtools.dataviewers.findreplace.STFindReplaceDialog.java
License:Open Source License
private void calcolateIndex(boolean forwardSearch) { if (forwardSearch) { if (findReplacePosition.getNeighbor(ViewerCell.RIGHT, true) != null) index = findReplacePosition.getNeighbor(ViewerCell.RIGHT, true); else {/*from w ww . j a v a2s. com*/ ViewerRow row = findReplacePosition.getViewerRow(); index = row.getNeighbor(ViewerRow.BELOW, true).getCell(0); } } else { if (findReplacePosition.getNeighbor(ViewerCell.LEFT, true) != null) index = findReplacePosition.getNeighbor(ViewerCell.LEFT, true); else { ViewerRow row = findReplacePosition.getViewerRow(); index = row.getNeighbor(ViewerRow.ABOVE, true).getCell(0); } } }
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 ww . jav a 2 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
public ViewerCell getFirstCell(ViewerCell start, int direction) { ViewerRow row = null;//w w w . ja v a 2 s .c om if (direction == ViewerRow.ABOVE) { if (scope && _viewer.getTable().getSelectionCount() > 0) row = new STTableViewerRow(_viewer.getTable().getSelection()[0]); else row = new STTableViewerRow(_viewer.getTable().getItem(0)); } else { if (scope && _viewer.getTable().getSelectionCount() > 0) row = new STTableViewerRow( _viewer.getTable().getSelection()[_viewer.getTable().getSelection().length - 1]); else row = new STTableViewerRow(_viewer.getTable().getItem(_viewer.getTable().getItemCount() - 1)); } return row.getCell(0); }