List of usage examples for org.eclipse.jface.viewers ViewerCell BELOW
int BELOW
To view the source code for org.eclipse.jface.viewers ViewerCell BELOW.
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 ww .j a v a 2s . c o m 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: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/* w ww . ja v a 2s . c o m*/ 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;/*w w w . j a v a 2s. c o 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.netxforge.screens.editing.base.tables.SWTFocusBlockManager.java
License:Open Source License
/** * Handle mouse dragging./* w w w .ja v a 2s . co m*/ * * @param event */ private void handleCellDragging(Event event) { // in the new position, look if we are the focus cell, // if not, add to our cell blow only if we are the below neighbour... ViewerCell cell = viewer.getCell(new Point(event.x, event.y)); if (cell != null) { if (!lastInFocusBlock(cell)) { // if we are not the last cell, but we are in the block, we // should get the position // to remove other cells.. if (inFocusBlock(cell)) { cleanFocusBlock(cell, event); // System.out.println("Dragging....removing cell in column:" // + cell.getVisualIndex() + " size of block = " // + focusBlock.size()); } else { // we can add it now. // do this for the last cell, not last focus cell. ViewerCell belowNeighborCell = lastCellInBlock().getNeighbor(ViewerCell.BELOW, false); if (cell.equals(belowNeighborCell)) { addCellToBlock(cell, event); // System.out.println("Dragging....Adding cell in column:" // + cell.getVisualIndex() + " size of block = " // + focusBlock.size()); } } } else { // last cell in the block do nothing... } } }
From source file:org.bonitasoft.studio.contract.ui.property.AddRowOnEnterCellNavigationStrategy.java
License:Open Source License
protected ViewerCell addNewRow(final ViewerCell currentSelectedCell, final Event event) { if (isContractInputNameColumn(currentSelectedCell)) { ViewerCell nextCell = currentSelectedCell.getNeighbor(ViewerCell.BELOW, false); if (nextCell == null) { setCancelEvent(true);/*ww w . j a v a 2 s. c om*/ controller.add(viewer); nextCell = currentSelectedCell.getNeighbor(ViewerCell.BELOW, false); updateSelection(nextCell); return nextCell; } } return null; }