List of usage examples for org.eclipse.jface.viewers ViewerCell getColumnIndex
public int getColumnIndex()
From source file:com.netxforge.screens.editing.base.tables.AbstractFocusBlockActionHandler.java
License:Open Source License
private boolean isPrepared(ViewerCell focusCell) { if (editingDomain == null | featureMap == null | featureMap.getColumnFeatureMap().isEmpty()) { return false; }/*from www. j ava 2 s. com*/ if (focusCell != null && focusCell.getElement() instanceof EObject) { // Make sure the feature is a feature for the focus object. EStructuralFeature feature = mapColumnToFeature(focusCell.getColumnIndex()); EObject element = (EObject) focusCell.getElement(); if (element.eClass().getEAllStructuralFeatures().contains(feature)) { return true; } } return false; }
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.TreeViewerFocusBlockManager.java
License:Open Source License
public ViewerCell getFocusCell() { ViewerCell cell = super.getFocusCell(); Tree t = (Tree) getViewer().getControl(); // It is possible that the selection has changed under the hood if (cell != null) { if (t.getSelection().length == 1 && t.getSelection()[0] != cell.getItem()) { OpenTreeViewer v = (OpenTreeViewer) this.getViewer(); setFocusCell(v.getViewerRowFromItemExposed(t.getSelection()[0]).getCell(cell.getColumnIndex())); }//from w w w .j a v a 2 s . c o m } return super.getFocusCell(); }
From source file:com.nextep.designer.sqlclient.ui.jface.SQLResultLabelProvider.java
License:Open Source License
@Override public void update(ViewerCell cell) { final Object elt = cell.getElement(); final int colIndex = cell.getColumnIndex(); final String text = getColumnText(elt, colIndex); cell.setText(text);/*from www. j a v a 2s .c om*/ final Image img = getColumnImage(elt, colIndex); cell.setImage(img); final Color background = getBackground(elt, colIndex); cell.setBackground(background); }
From source file:com.peergreen.eclipse.osgi.preferences.provider.column.ActionsColumnLabelProvider.java
License:Apache License
@Override public void update(ViewerCell cell) { PeergreenServerEntry serverEntry = (PeergreenServerEntry) cell.getElement(); TableItem item = (TableItem) cell.getItem(); composite = new Composite((Composite) cell.getViewerRow().getControl(), SWT.BORDER_DASH); composite.setLayout(new FillLayout()); // Download button if assembly not installed if (serverEntry.isDownloadable()) { Button downloadButton = new Button(composite, SWT.NONE); downloadButton.setText("Download..."); downloadButton.setToolTipText("Download this version"); }/* w w w .ja v a 2s . com*/ // Remove button if assembly is installed if (!serverEntry.isDownloadable() && (serversConfiguration.getDefaultEntry() != null && !serversConfiguration.getDefaultEntry().equals(serverEntry))) { Button removeButton = new Button(composite, SWT.NONE); removeButton.setText("Remove"); removeButton.setToolTipText("Remove this assembly"); removeButton .addSelectionListener(new RemoveEntryListener(serversConfiguration, serverEntry, tableViewer)); } // Update button if assembly has a new version available if (serverEntry.isUpdatable()) { Button updateButton = new Button(composite, SWT.NONE); updateButton.setText("Update..."); updateButton.setToolTipText("Update this assembly to a newer version"); } // Create editor TableEditor editor = new TableEditor(item.getParent()); editor.grabHorizontal = true; editor.grabVertical = true; editor.setEditor(composite, item, cell.getColumnIndex()); editor.layout(); }
From source file:com.peergreen.eclipse.osgi.preferences.provider.column.RadioButtonColumnLabelProvider.java
License:Apache License
@Override public void update(ViewerCell cell) { final PeergreenServerEntry serverEntry = (PeergreenServerEntry) cell.getElement(); TableItem item = (TableItem) cell.getItem(); TableEditor editor = new TableEditor(item.getParent()); Button radioButton = new Button((Composite) cell.getViewerRow().getControl(), SWT.RADIO); // It's the default selection if (serversConfiguration.getDefaultEntry() != null && serversConfiguration.getDefaultEntry().equals(serverEntry)) { radioButton.setSelection(true);/*w w w .j a va 2 s . c o m*/ } // Downloadable so not ready, greyed radioButton.setEnabled(!serverEntry.isDownloadable()); radioButton.addSelectionListener( new RadioButtonSelectionListener(serversConfiguration, serverEntry, tableViewer, radioButton)); radioButton.pack(); editor.minimumWidth = radioButton.getSize().x; editor.horizontalAlignment = SWT.CENTER; editor.setEditor(radioButton, item, cell.getColumnIndex()); editor.layout(); }
From source file:com.questoid.sqlitebrowser.view.SqliteBrowserView.java
License:Open Source License
private void createDataGui(final TabFolder tabFolder, final String[] tableNames) { final TabItem browseDataTabItem = new TabItem(tabFolder, SWT.NULL); browseDataTabItem.setText("Browse Data"); final Composite dataComposite = new Composite(tabFolder, SWT.NONE); dataComposite.setLayout(new GridLayout(4, false)); ////from w ww . j ava 2 s . co m Label label = null; label = new Label(dataComposite, SWT.LEFT); label.setText("Table: "); label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER)); final Combo guiTableCombo = new Combo(dataComposite, SWT.READ_ONLY); guiTableCombo.setItems(tableNames); guiTableCombo.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER)); final Button refreshBtn = new Button(dataComposite, SWT.PUSH); refreshBtn.setText("refresh"); refreshBtn.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER)); label = new Label(dataComposite, SWT.LEFT); label.setText(" "); // Blank label to grab horizontal space label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); // final Table guiTable = new Table(dataComposite, SWT.SINGLE | SWT.FULL_SELECTION); final TableViewer guiTableViewer = new TableViewer(guiTable); guiTableViewer.setLabelProvider(new DataLabelProvider()); guiTableViewer.setContentProvider(new DataContentProvider()); // guiTableCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { loadTableData(dbFile, guiTableViewer, guiTableCombo.getText()); } }); // refresh button refreshBtn.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(final SelectionEvent e) { pullFile(); // pull file from device. loadTableData(dbFile, guiTableViewer, guiTableCombo.getText()); } @Override public void widgetDefaultSelected(final SelectionEvent e) { // System.out.println("SqliteBrowserView.createDataGui(...).new SelectionListener() {...}.widgetDefaultSelected()"); } }); // cell double click listener. guiTable.addListener(SWT.MouseDoubleClick, new Listener() { @Override public void handleEvent(final Event event) { final Point pt = new Point(event.x, event.y); final ViewerCell cell = guiTableViewer.getCell(pt); final int column = cell.getColumnIndex(); final DataRow row = (DataRow) cell.getElement(); final Object cellData = row.getValueAt(column); handleCellData(cellData); } }); guiTableCombo.select(0); browseDataTabItem.setControl(dataComposite); loadTableData(dbFile, guiTableViewer, guiTableCombo.getText()); // Load first selected item on start }
From source file:com.rcpcompany.uibindings.extests.viewerBindings.ViewerItemMoveTest.java
License:Open Source License
/** * Checks the operation of the move command with focus on the resulting selection and focus *///w w w .j av a 2 s .c o m @Test public void testOp() { try { final ICommandService cs = (ICommandService) myView.getSite().getService(ICommandService.class); final IHandlerService hs = (IHandlerService) myView.getSite().getService(IHandlerService.class); final ParameterizedCommand command = cs.deserialize(myCommandId); assertTrue(what + " is defined", command.getCommand().isDefined()); final Country country = myShop.getCountries().get(myRow); // LogUtils.debug(country, "" + country.getName()); postMouse(myTableViewer.getTable(), myColumn + myViewerBinding.getFirstTableColumnOffset(), myRow); yield(); assertTrue(what + " is not handled", command.getCommand().isHandled()); assertTrue(what + " is not defined", command.getCommand().isDefined()); ViewerCell viewerCell = myTableViewer.getColumnViewerEditor().getFocusCell(); assertEquals(what + " index wrong", myColumn + myViewerBinding.getFirstTableColumnOffset(), viewerCell.getColumnIndex()); assertEquals(what + " element wrong", country, viewerCell.getElement()); assertEquals(what + " item wrong", myTableViewer.getTable().getItem(myRow), viewerCell.getViewerRow().getItem()); assertEquals(what + " row element", country, viewerCell.getViewerRow().getElement()); assertEquals(4, myShop.getCountries().size()); hs.executeCommand(command, null); assertEquals(4, myShop.getCountries().size()); // Seq of items final List<Country> myResultList = new ArrayList<Country>(); for (int i = 0; i < mySeq.length(); i++) { final String s = mySeq.substring(i, i + 1); for (final Country c : myShop.getCountries()) { if (c.getName().equals(s)) { myResultList.add(c); break; } } } assertArrayEquals(myResultList.toArray(), myShop.getCountries().toArray()); // Selection final TableItem[] tableItems = myTable.getSelection(); assertEquals(1, tableItems.length); assertEquals(country, tableItems[0].getData()); // ISelection final ISelection selection = myTableViewer.getSelection(); assertTrue(selection instanceof IStructuredSelection); final IStructuredSelection ss = (IStructuredSelection) selection; assertEquals(1, ss.toArray().length); assertEquals(country, ss.getFirstElement()); // Viewer cell // Focus cell viewerCell = myTableViewer.getColumnViewerEditor().getFocusCell(); assertEquals(myColumn + myViewerBinding.getFirstTableColumnOffset(), viewerCell.getColumnIndex()); assertEquals(country, viewerCell.getElement()); assertEquals(myTableViewer.getTable().getItem(myNewRow), viewerCell.getViewerRow().getItem()); assertEquals(country, viewerCell.getViewerRow().getElement()); } catch (final Exception ex) { fail(ex.getMessage()); } }
From source file:com.rcpcompany.uibindings.internal.CellEditorActivationStrategy.java
License:Open Source License
@Override protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) { final ViewerCell viewerCell = (ViewerCell) event.getSource(); final IColumnBindingCellInformation cell = myViewerBinding.getCell( viewerCell.getColumnIndex() - myViewerBinding.getFirstTableColumnOffset(), viewerCell.getItem().getData()); return IManager.Factory.getManager().isEditorActivationEvent(event, cell); }
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); }// www.j a v a2 s. c o m 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); } }