List of usage examples for org.eclipse.jface.viewers ViewerCell getBounds
public Rectangle getBounds()
From source file:au.gov.ga.earthsci.application.parts.layer.LayerTreeLabelProvider.java
License:Apache License
@Override public void update(ViewerCell cell) { super.update(cell); //ensure that the paint method is called too: Rectangle bounds = cell.getBounds(); getViewer().getControl().redraw(bounds.x, bounds.y, bounds.width, bounds.height, true); }
From source file:com.arm.cmsis.pack.ui.tree.ColumnAdvisor.java
License:Open Source License
public String getUrl(int x, int y) { Point pt = new Point(x, y); ViewerCell cell = getViewer().getCell(pt); if (cell != null) { int colIndex = cell.getColumnIndex(); Object element = cell.getElement(); if (getCellControlType(element, colIndex) == CellControlType.URL) { Rectangle cellBounds = cell.getBounds(); Image img = getImage(element, colIndex); if (img != null) { cellBounds.x += img.getBounds().width; }/*from w w w . j a va 2s . c om*/ if (cellBounds.contains(pt)) { return getUrl(element, colIndex); } } } return null; }
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;//from w ww .j a va2 s.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.netxforge.screens.editing.base.tables.FocusBlockOwnerDrawHighlighterForMultiselection.java
License:Open Source License
private void drawBorder(Event event, List<ViewerCell> block) { Rectangle allCellsRectangle = null; for (ViewerCell cell : block) { Rectangle rect = cell.getBounds(); if (allCellsRectangle == null) { allCellsRectangle = rect;//from ww w .jav a 2 s. co m } else { allCellsRectangle.add(rect); } } Color fg = event.gc.getForeground(); event.gc.setForeground(event.display.getSystemColor(SWT.COLOR_BLACK)); // Rectangle originalClipping = event.gc.getClipping(); // Adapt the clipping, as we draw outside the bounds of the cell. // allCellsRectangle.x = allCellsRectangle.x - 2; // allCellsRectangle.y = allCellsRectangle.y - 2; // allCellsRectangle.height = allCellsRectangle.height + 6; // allCellsRectangle.width = allCellsRectangle.width + 6; // event.gc.setClipping(allCellsRectangle); event.gc.drawRoundRectangle(allCellsRectangle.x, allCellsRectangle.y, allCellsRectangle.width - 1, allCellsRectangle.height - 1, 3, 3); // event.gc.setClipping(originalClipping); event.gc.setForeground(fg); }
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 void removeSelectionInformation(Event event, ViewerCell cell) { GC gc = event.gc;//from w w w. java 2s .c om gc.setBackground(getUnselectedCellBackgroundColor(cell)); gc.setForeground(getUnselectedCellForegroundColor(cell)); gc.fillRectangle(cell.getBounds()); event.detail &= ~SWT.SELECTED; }
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); }//w w w .j a v a2 s . com 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:de.instanttouch.ui.scaffolding.swt.viewer.lazy.SnakeLazyTableViewer.java
License:Open Source License
public String layoutText(ViewerCell viewerCell, SnakeType cell, TableViewerColumn viewerColumn) { String converted = ""; String text = cell.toString(); int columnWidth = viewerColumn.getColumn().getWidth(); // wrapping text if (text != null && text.length() > 0) { converted = wrapText(text, columnWidth); if (!viewerCell.getItem().isDisposed()) { viewerCell.setText(converted); viewerCell.getBounds().height = 100; }/*from w ww . j a v a 2 s . c o m*/ } return converted; }
From source file:eu.esdihumboldt.hale.ui.util.viewer.BrowserColumnViewerTip.java
License:Open Source License
/** * Show tooltip for the cell at the given position * // w w w .j a v a 2s . c o m * @param x the widget relative x ordinate * @param y the widget relative y ordinate */ protected void showToolTip(int x, int y) { ViewerCell cell = viewer.getCell(new Point(x, y)); if (toolCell != null && toolCell.equals(cell) && BrowserTip.toolTipVisible(toolShell)) { // tooltip already visible -> do nothing return; } toolCell = cell; BrowserTip.hideToolTip(toolShell); if (cell != null) { Object element = cell.getElement(); int col = cell.getColumnIndex(); /** * It would be very nice if we could get the column from the viewer * and the attached label provider, but the getViewerColumn method * is only package visible */ String text = cell.getText(); String tipText = getToolTip(element, col, text); if (tipText != null && !tipText.isEmpty() && tipText.length() >= tipCharThreshold) { Rectangle cellBounds = cell.getBounds(); // toolShell = tip.showToolTip(viewer.getControl(), x, y, tipText); toolShell = tip.showToolTip(viewer.getControl(), cellBounds.x, cellBounds.y + cellBounds.height, tipText, cellBounds, viewer.getControl()); } } }
From source file:hydrograph.ui.dataviewer.window.DebugDataViewer.java
License:Apache License
private void attachCellNavigator() { tableCursor = new TableCursor(gridViewTableViewer.getTable(), SWT.NONE); tableCursor.setBackground(DataViewerColors.COLOR_CELL_SELECTION); tableCursor.addControlListener(new ControlListener() { private Point previousCellSize; private boolean controlResized; @Override/*ww w . j ava2 s . c om*/ public void controlResized(ControlEvent e) { ViewerCell cell = gridViewTableViewer.getCell(getActualTableCursorLocation()); if (cell == null) { return; } Point currentCellSize = new Point(cell.getBounds().width, cell.getBounds().height); if (previousCellSize == null) { previousCellSize = new Point(currentCellSize.x, currentCellSize.y); } if (!controlResized) { controlResized = true; tableCursor.setSize(currentCellSize.x + 4, currentCellSize.y + 4); Point currentLocation = tableCursor.getLocation(); tableCursor.setLocation(currentLocation.x - 2, currentLocation.y - 2); previousCellSize = new Point(currentCellSize.x, currentCellSize.y); } else { controlResized = false; } } @Override public void controlMoved(ControlEvent e) { // Nothing to do } }); tableCursor.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.SHIFT) { selectionStartPoint = new Point(-1, -1); shiftKeyPressed = false; return; } if (e.keyCode == SWT.CTRL || e.keyCode == SWT.COMMAND) { ctrlKeyPressed = false; return; } if (!((e.stateMask & SWT.SHIFT) != 0)) { clearSelection(currentSelection, gridViewTableViewer); } } @Override public void keyPressed(KeyEvent e) { if ((e.keyCode == SWT.SHIFT) && shiftKeyPressed == false) { selectionStartPoint = getActualTableCursorLocation(); startCell = getCellId(selectionStartPoint, gridViewTableViewer); shiftKeyPressed = true; } if ((e.keyCode == SWT.CTRL || e.keyCode == SWT.COMMAND) && ctrlKeyPressed == false) { selectionStartPoint = getActualTableCursorLocation(); startCell = getCellId(selectionStartPoint, gridViewTableViewer); ctrlKeyPressed = true; } if (ctrlKeyPressed && !shiftKeyPressed) { if (e.keyCode == SWT.ARROW_RIGHT) { tableCursor.setSelection(gridViewTableViewer.getTable().indexOf(tableCursor.getRow()), gridViewTableViewer.getTable().getColumnCount() - 1); return; } if (e.keyCode == SWT.ARROW_LEFT) { tableCursor.setSelection(gridViewTableViewer.getTable().indexOf(tableCursor.getRow()), 0); return; } if (e.keyCode == SWT.ARROW_UP) { tableCursor.setSelection(0, tableCursor.getColumn()); return; } if (e.keyCode == SWT.ARROW_DOWN) { tableCursor.setSelection(gridViewTableViewer.getTable().getItemCount() - 1, tableCursor.getColumn()); return; } } if (shiftKeyPressed && ctrlKeyPressed) { if (e.keyCode == SWT.ARROW_RIGHT) { tableCursor.setSelection(gridViewTableViewer.getTable().indexOf(tableCursor.getRow()), gridViewTableViewer.getTable().getColumnCount() - 1); selectCellsOnArrowKeys(gridViewTableViewer, e); return; } if (e.keyCode == SWT.ARROW_LEFT) { tableCursor.setSelection(gridViewTableViewer.getTable().indexOf(tableCursor.getRow()), 0); selectCellsOnArrowKeys(gridViewTableViewer, e); return; } if (e.keyCode == SWT.ARROW_UP) { tableCursor.setSelection(0, tableCursor.getColumn()); selectCellsOnArrowKeys(gridViewTableViewer, e); return; } if (e.keyCode == SWT.ARROW_DOWN) { tableCursor.setSelection(gridViewTableViewer.getTable().getItemCount() - 1, tableCursor.getColumn()); selectCellsOnArrowKeys(gridViewTableViewer, e); return; } } if ((e.keyCode == SWT.ARROW_UP) || (e.keyCode == SWT.ARROW_DOWN) || (e.keyCode == SWT.ARROW_LEFT) || (e.keyCode == SWT.ARROW_RIGHT)) { selectCellsOnArrowKeys(gridViewTableViewer, e); } } private void selectCellsOnArrowKeys(final TableViewer tableViewer, KeyEvent e) { if ((e.stateMask & SWT.SHIFT) != 0) { Point selectionEndPoint = getActualTableCursorLocation(); List<Point> cellsToBeSelected = getCellRectangle(startCell, selectionEndPoint, tableViewer, true); if (cellsToBeSelected != null) { clearSelection(currentSelection, tableViewer); highlightCells(cellsToBeSelected, tableViewer); currentSelection.addAll(cellsToBeSelected); } } } }); }