List of usage examples for org.eclipse.jface.viewers ICellModifier canModify
public boolean canModify(Object element, String property);
From source file:net.rim.ejde.internal.ui.editors.locale.ResourceCellEditorUIFactory.java
License:Open Source License
private ICellEditorListener createCommentListener(final IResourceCellEditor commentEditor, final ResourceElement element) { final ICellModifier commentModifier = new ResourceCommentModifier(_table.getShell(), commentEditor); return new ICellEditorListener() { public void applyEditorValue() { if (commentModifier.canModify(element, null)) { Object value = commentEditor.getValue(); commentModifier.modify(element, null, value); }//ww w.j a va2 s . co m } public void cancelEditor() { } public void editorValueChanged(boolean oldValidState, boolean newValidState) { } }; }
From source file:net.rim.ejde.internal.ui.editors.locale.ResourceCellEditorUIFactory.java
License:Open Source License
private ICellEditorListener createKeyListener(final IResourceCellEditor keyEditor, final ResourceElement element) { final ICellModifier keyModifier = new ResourceKeyModifier(_table.getShell(), keyEditor); return new ICellEditorListener() { public void applyEditorValue() { if (keyModifier.canModify(element, ResourceEditorPage.KEY_COLUMN_ID)) { Object value = keyEditor.getValue(); keyModifier.modify(element, ResourceEditorPage.KEY_COLUMN_ID, value); }// w ww. j av a2 s . com } public void cancelEditor() { } public void editorValueChanged(boolean oldValidState, boolean newValidState) { } }; }
From source file:net.rim.ejde.internal.ui.editors.locale.ResourceCellEditorUIFactory.java
License:Open Source License
private ICellEditorListener createValueListener(final IResourceCellEditor valueEditor, final ResourceElement element) { final ICellModifier valueModifier = new ResourceValueModifier(_table.getShell(), valueEditor); return new ICellEditorListener() { public void applyEditorValue() { if (valueModifier.canModify(element, ResourceEditorPage.VALUE_COLUMN_ID)) { Object value = valueEditor.getValue(); valueModifier.modify(element, ResourceEditorPage.VALUE_COLUMN_ID, value); ResourceEditorOptionsDialog.updateVersioningAfterResourceElementEdited(element); }//w ww . j av a2s . c o m } public void cancelEditor() { } public void editorValueChanged(boolean oldValidState, boolean newValidState) { } }; }
From source file:org.eclipse.bpel.ui.details.providers.TableProvider.java
License:Open Source License
public boolean canModify(Object element, String property) { // delegate to the appropriate cell modifier. ICellModifier cm = (ICellModifier) propertyToCellModifier.get(property); if (cm != null) return cm.canModify(element, property); // no cell modifier found. return false; }
From source file:org.eclipse.debug.internal.ui.views.memory.renderings.AsyncTableRenderingViewer.java
License:Open Source License
/** * Activate cell editor and pre-fill it with initial value. * If initialValue is null, use cell content as initial value * @param initialValue the initial value for the cell editor *//*from w w w .j a va 2s . com*/ private void activateCellEditor(String initialValue) { final int col = fTableCursor.getColumn(); final int row = indexOf(fSelectionKey); if (row < 0) return; // do not allow user to edit address column if (col == 0 || col > getNumCol()) { return; } ICellModifier cellModifier = null; cellModifier = getCellModifier(); TableItem tableItem = getTable().getItem(row); Object element = tableItem.getData(); if (element != null) { Object property = getColumnProperties()[col]; Object value = cellModifier.getValue(element, (String) property); boolean canEdit = cellModifier.canModify(element, (String) property); if (!canEdit) return; CellEditor editor = getCellEditors()[col]; if (editor != null) { // The control that will be the editor must be a child of the // Table Control control = editor.getControl(); Object cellValue = null; if (initialValue != null) { cellValue = initialValue; } else { cellValue = value; } editor.setValue(cellValue); fCursorEditor.horizontalAlignment = SWT.LEFT; fCursorEditor.grabHorizontal = true; // Open the editor editor in selected column of the selected // row. fCursorEditor.setEditor(control, tableItem, col); // Assign focus to the editor control editor.setFocus(); if (initialValue != null && control instanceof Text) { ((Text) control).clearSelection(); } control.setFont(JFaceResources.getFont(IInternalDebugUIConstants.FONT_NAME)); // add listeners for the editor control addListeners(control); fCellEditorListener = new CellEditorListener(row, col, editor); editor.addListener(fCellEditorListener); // move cursor below editor control fTableCursor.moveBelow(control); } } }
From source file:org.eclipse.debug.ui.memory.AbstractTableRendering.java
License:Open Source License
/** * Activate cell editor and pre-fill it with initial value. * If initialValue is null, use cell content as initial value * @param initialValue the initial value to edit *///from w w w .j a v a 2s.co m private void activateCellEditor(String initialValue) { int col = fTableCursor.getColumn(); int row = findAddressIndex(fSelectedAddress); if (row < 0) return; // do not allow user to edit address column if (col == 0 || col > getNumCol()) { return; } ICellModifier cellModifier = null; if (fTableViewer == null) { return; } cellModifier = fTableViewer.getCellModifier(); TableItem tableItem = fTableViewer.getTable().getItem(row); Object element = tableItem.getData(); Object property = fTableViewer.getColumnProperties()[col]; Object value = cellModifier.getValue(element, (String) property); // The cell modifier canModify function always returns false if the edit action // is not invoked from here. This is to prevent data to be modified when // the table cursor loses focus from a cell. By default, data will // be changed in a table when the cell loses focus. This is to workaround // this default behavior and only change data when the cell editor // is activated. ((TableRenderingCellModifier) cellModifier).setEditActionInvoked(true); boolean canEdit = cellModifier.canModify(element, (String) property); ((TableRenderingCellModifier) cellModifier).setEditActionInvoked(false); if (!canEdit) return; // activate based on current cursor position TextCellEditor selectedEditor = (TextCellEditor) fTableViewer.getCellEditors()[col]; if (fTableViewer != null && selectedEditor != null) { // The control that will be the editor must be a child of the Table Text text = (Text) selectedEditor.getControl(); String cellValue = null; if (initialValue != null) { cellValue = initialValue; } else { cellValue = ((String) value); } text.setText(cellValue); fCursorEditor.horizontalAlignment = SWT.LEFT; fCursorEditor.grabHorizontal = true; // Open the text editor in selected column of the selected row. fCursorEditor.setEditor(text, tableItem, col); // Assign focus to the text control selectedEditor.setFocus(); if (initialValue != null) { text.clearSelection(); } text.setFont(JFaceResources.getFont(IInternalDebugUIConstants.FONT_NAME)); // add listeners for the text control addListeners(text); // move cursor below text control fTableCursor.moveBelow(text); } }
From source file:org.eclipse.epf.authoring.ui.celleditors.ProcessCheckBoxCellEditor.java
License:Open Source License
public Image getImage(TreeItem item, String columnproperty) { final ICellModifier modifier = getCellModifier(); Object element = item.getData(); if (element == null) return null; // if (columnproperty == IBSItemProvider.COL_IS_ONGOING // || columnproperty == IBSItemProvider.COL_IS_REPEATABLE // || columnproperty == IBSItemProvider.COL_IS_EVENT_DRIVEN) { // if (!(TngUtil.unwrap(element) instanceof WorkBreakdownElement)) { // return null; // }//w w w . ja v a 2s .c om // } Object value = modifier.getValue(element, columnproperty); if (value == null || !(value instanceof Boolean)) return null; boolean canModify = modifier.canModify(element, columnproperty); if (((Boolean) value).booleanValue()) { return canModify ? checkImage : disableCheckImage; } else { return canModify ? uncheckImage : disableUncheckImage; } }
From source file:org.eclipse.epf.authoring.ui.celleditors.ProcessCheckBoxCellEditor.java
License:Open Source License
public void modify(TreeItem item, String columnproperty) { final ICellModifier modifier = getCellModifier(); if (!modifier.canModify(item.getData(), columnproperty)) return;//from w w w . jav a 2 s . c om modifier.modify(item, columnproperty, new Boolean(!((Boolean) modifier.getValue(item.getData(), columnproperty)).booleanValue())); }
From source file:org.eclipse.mdht.uml.common.ui.util.AdapterFactoryCellModifier.java
License:Open Source License
public boolean canModify(Object element, String property) { // Get the adapter from the factory. ICellModifier cellModifier = (ICellModifier) adapterFactory.adapt(element, ICellModifierClass); // Now we could check that the adapter implements interface ICellModifier. if (cellModifier != null) { // And delegate the call. return cellModifier.canModify(element, property); }//from ww w . j a v a 2s . co m return false; }
From source file:org.eclipsetrader.ui.internal.markets.TimeScheduleEditorTest.java
License:Open Source License
public void testEditOpenTime() throws Exception { TimeScheduleEditor editor = new TimeScheduleEditor(shell); editor.setSchedule(new MarketTime[] { new MarketTime(getTime(9, 0), getTime(16, 0)), }); MarketTimeElement element = (MarketTimeElement) editor.getViewer().getTable().getItem(0).getData(); ICellModifier cellModifier = editor.getViewer().getCellModifier(); assertTrue(cellModifier.canModify(element, "0")); assertEquals(element.getOpenTime(), cellModifier.getValue(element, "0")); cellModifier.modify(element, "0", getTime(10, 30)); assertEquals(getTime(10, 30), element.getOpenTime()); }