List of usage examples for org.eclipse.jface.viewers CellEditor getControl
public Control getControl()
From source file:at.medevit.elexis.gdt.ui.table.util.ColumnBuilder.java
License:Open Source License
/** * Makes the column cells editable using a custom cell editor. The given valueFormatter will be * responsible for formatting the value for the editor and converting it back to a new value. */// www.j ava2s . c om public ColumnBuilder makeEditable(CellEditor cellEditor, IValueFormatter valueFormatter) { if (cellEditor.getControl().getParent() != viewer.getTable()) throw new RuntimeException("Parent of cell editor needs to be the table!"); this.editor = cellEditor; this.editorFormat = valueFormatter; return this; }
From source file:cc.xuloo.rcputils.tables.ColumnBuilder.java
License:Open Source License
/** * Makes the column cells editable using a custom cell editor. The given * valueFormatter will be responsible for formatting the value for the * editor and converting it back to a new value. *//*from w w w.j av a 2 s. c o m*/ public ColumnBuilder makeEditable(CellEditor cellEditor, IValueFormatter valueFormatter) { if (cellEditor.getControl().getParent() != builder.getTable()) throw new RuntimeException("Parent of cell editor needs to be the table!"); this.editor = cellEditor; this.editorFormat = valueFormatter; return this; }
From source file:cn.cstv.wspscm.parts.LifelineCellEditorLocator.java
License:Open Source License
public void relocate(CellEditor celleditor) { // TODO Auto-generated method stub Text text = (Text) celleditor.getControl(); Point pref = text.computeSize(-1, -1); Rectangle rect = figure.getBounds().getCopy(); figure.translateToAbsolute(rect);// w w w. java2s .c om text.setBounds(rect.x + 5, rect.y + 5, pref.x + 5, pref.y + 5); }
From source file:cn.edu.pku.ogeditor.parts.ConnectionCellEditorLocator.java
License:Open Source License
public void relocate(CellEditor celleditor) { // TODO Auto-generated method stub Text text = (Text) celleditor.getControl(); Rectangle rect = figure.getBounds().getCopy(); figure.translateToAbsolute(rect);//from w w w.j a v a2 s. com text.setBounds(rect.x - 1, rect.y - 1, rect.width + 1, rect.height + 1); }
From source file:cn.edu.pku.ogeditor.parts.ShapeCellEditorLocator.java
License:Open Source License
public void relocate(CellEditor celleditor) { // TODO Auto-generated method stub Text text = (Text) celleditor.getControl(); //Point pref = text.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle rect = shapeFigure.getLabel().getTextBounds(); shapeFigure.getLabel().translateToAbsolute(rect); text.setBounds(rect.x - 1, rect.y - 1, rect.width + 1, rect.height + 1); }
From source file:com.aptana.theme.internal.TreeThemer.java
License:Open Source License
protected void addSelectionColorOverride() { if (controlIsDisposed()) { return;//from www . j ava 2s.c o m } super.addSelectionColorOverride(); final Tree tree = getTree(); selectionPaintListener = new Listener() { public void handleEvent(Event event) { if (!invasiveThemesEnabled()) { return; } GC gc = event.gc; Color oldBackground = gc.getBackground(); try { Rectangle clientArea = tree.getClientArea(); // FIX for busted drawing on some variants of Linux, notably OpenSuSE, where // setBackground on the tree doesn't behave. We color background behind items in // ControlThemer.addSelectionColorOverride() // This draws from bottom of the last item down to bottom of tree with background color if (!isWindows && !isMacOSX) { gc.setBackground(getBackground()); Rectangle itemBounds = new Rectangle(0, 0, 0, 0); if (tree.getItemCount() != 0) { TreeItem lastItem = tree.getItem(tree.getItemCount() - 1); lastItem = getLastItemRecursively(lastItem); itemBounds = lastItem.getBounds(); } int bottomY = itemBounds.y + itemBounds.height; // The +2 on width is for Linux, since clientArea begins at [-2,-2] and // without it we don't properly color full width Rectangle toColor = new Rectangle(clientArea.x, bottomY, clientArea.width + 2, clientArea.height - bottomY); gc.fillRectangle(toColor); } // FIX for TISTUD-426: http://jira.appcelerator.org/browse/TISTUD-426 // HACK to grab cell editors of tree views (specifically Variables view) and set their control's fg // explicitly! if (fTreeViewer != null) { CellEditor[] editors = fTreeViewer.getCellEditors(); if (editors != null) { for (CellEditor editor : editors) { if (editor == null) { continue; } Control c = editor.getControl(); if (c != null) { c.setForeground(getForeground()); } } } } // FIX For Windows, the selection color doesn't extend past bounds of the tree item, so here we // draw from right end of item to full width of tree, so selection bg color is full width of view if (!isWindows) { return; } TreeItem[] items = tree.getSelection(); if (items == null || items.length == 0) { return; } gc.setBackground(getSelection()); int clientWidth = clientArea.width + 2; int columns = tree.getColumnCount(); for (TreeItem item : items) { if (item != null) { Rectangle bounds; if (columns == 0) { bounds = item.getBounds(); } else { bounds = item.getBounds(columns - 1); } int x = bounds.x + bounds.width; if (x < clientWidth) { gc.fillRectangle(x, bounds.y, clientWidth - x, bounds.height); } } } } catch (Exception e) { // ignore } finally { gc.setBackground(oldBackground); // force foreground color. Otherwise on dark themes we get black FG (all the time on Win, on // non-focus for Mac) gc.setForeground(getForeground()); } } }; tree.addListener(SWT.Paint, selectionPaintListener); }
From source file:com.archimatetool.editor.propertysections.UserPropertiesSection.java
License:Open Source License
/** * Set some editing global Action Handlers to null when the cell editor is activated * And restore them when the cell editor is deactivated. *//* w w w. j a v a 2 s .c o m*/ private void hookCellEditorGlobalActionHandler(CellEditor cellEditor) { Listener listener = new Listener() { CellEditorGlobalActionHandler globalActionHandler; @Override public void handleEvent(Event event) { switch (event.type) { case SWT.Activate: globalActionHandler = new CellEditorGlobalActionHandler(); globalActionHandler.clearGlobalActions(); break; case SWT.Deactivate: if (globalActionHandler != null) { globalActionHandler.restoreGlobalActions(); } break; default: break; } } }; cellEditor.getControl().addListener(SWT.Activate, listener); cellEditor.getControl().addListener(SWT.Deactivate, listener); }
From source file:com.byterefinery.rmbench.util.keyboardsupport.TableViewerKeyBoardSupporter.java
License:Open Source License
/** * After the cell editors have been set on tableviewer, this method * should be called to start giving keyboard support. *///from ww w . j ava 2 s. co m public void startSupport() { tableViewer.getTable().addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.F2 && e.stateMask == SWT.NONE) { editColumnOrNextPossible(0); e.doit = false; } } }); tableViewer.getTable().addTraverseListener(new TraverseListener() { public void keyTraversed(TraverseEvent e) { if (e.detail == SWT.TRAVERSE_RETURN && e.stateMask == SWT.NONE) { editColumnOrNextPossible(0); e.detail = SWT.TRAVERSE_NONE; } } }); /* add table-textcelleditors key and traverse listeners */ CellEditor[] cellEditors = tableViewer.getCellEditors(); if (cellEditors != null) { for (int colIndex = 0; colIndex < cellEditors.length; colIndex++) { CellEditor cellEditor = cellEditors[colIndex]; if (cellEditor != null) { if (cellEditor.getControl() != null) { /*won't work with combo boxes, so we let it out.. at the moment cellEditor.getControl().addKeyListener( new CellEditorKeyListener(cellEditor, colIndex)); */ cellEditor.getControl() .addTraverseListener(new CellEditorTraverseListener(cellEditor, colIndex)); } } } } }
From source file:com.centurylink.mdw.plugin.launch.LoadTestLaunchTab.java
License:Apache License
protected void createTableViewer() { testCasesTableViewer = new TableViewer(testCasesTable); testCasesTableViewer.setUseHashlookup(true); testCasesTableViewer.setColumnProperties(testCasesColumnProps); CellEditor[] editors = new CellEditor[testCasesColumnSpecs.size()]; for (int i = 0; i < testCasesColumnSpecs.size(); i++) { ColumnSpec colSpec = testCasesColumnSpecs.get(i); CellEditor cellEditor = null; if (colSpec.type.equals(PropertyEditor.TYPE_TEXT)) { if (i == 1) cellEditor = new TextCellEditor(testCasesTable); else { // Text with digits only for 3rd column cellEditor = new TextCellEditor(testCasesTable); ((Text) cellEditor.getControl()).addVerifyListener(new VerifyListener() { public void verifyText(VerifyEvent e) { e.doit = "0123456789".indexOf(e.text) >= 0; }/*from w w w. j a v a2 s. co m*/ }); } } else if (colSpec.type.equals(PropertyEditor.TYPE_CHECKBOX)) { cellEditor = new CheckboxCellEditor(testCasesTable); } editors[i] = cellEditor; } testCasesTableViewer.setCellEditors(editors); testCasesTableViewer.setCellModifier(new TestCaseCellModifier()); testCasesTableViewer.setLabelProvider(new TestCaseLabelProvider()); testCasesTableViewer.setContentProvider(new TestCaseContentProvider()); }
From source file:com.clustercontrol.viewer.PropertySheetModifier.java
License:Open Source License
@Override public boolean canModify(Object element, String property) { if (PropertySheet.CLMN_VALUE.equals(property)) { if (element instanceof Property) { Property nodeProperty = (Property) element; if (nodeProperty.getModify() == PropertyDefineConstant.MODIFY_OK) { // ????????? CellEditor cellEditor = nodeProperty.getCellEditor(); if (cellEditor.getControl() == null || cellEditor.getControl().isDisposed()) { cellEditor.dispose(); cellEditor.create(m_viewer.getTree()); nodeProperty.initEditer(); }/*w ww . ja v a 2 s .c om*/ CellEditor[] editors = new CellEditor[] { null, cellEditor }; m_viewer.setCellEditors(editors); return true; } else { if (nodeProperty.getEditor().compareTo(PropertyDefineConstant.EDITOR_TEXTAREA) == 0) { // ????????? CellEditor cellEditor = nodeProperty.getCellEditor(); if (cellEditor.getControl() == null || cellEditor.getControl().isDisposed()) { cellEditor.dispose(); cellEditor.create(m_viewer.getTree()); nodeProperty.initEditer(); } CellEditor[] editors = new CellEditor[] { null, cellEditor }; m_viewer.setCellEditors(editors); return true; } } } } return false; }