/** * {@inheritDoc} After the error is handled by its underlying {@link IEditErrorHandler}, the * configured error style will be applied to the editor control. */ @Override public void displayError(ICellEditor cellEditor, Exception e) { super.displayError(cellEditor, e); if (!this.errorStylingActive) { Control editorControl = cellEditor.getEditorControl(); // store the current rendering information to be able to reset again originalBgColor = editorControl.getBackground(); originalFgColor = editorControl.getForeground(); originalFont = editorControl.getFont(); // set the rendering information out of the error style editorControl.setBackground( this.errorStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR)); editorControl.setForeground( this.errorStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR)); editorControl.setFont(this.errorStyle.getAttributeValue(CellStyleAttributes.FONT)); if (decorationProvider != null) { decorationProvider.showDecoration(); } this.errorStylingActive = true; } }
/** * {@inheritDoc} After the error remove is handled by its underlying {@link IEditErrorHandler}, * the original style will be applied to the editor control. */ @Override public void removeError(ICellEditor cellEditor) { super.removeError(cellEditor); if (this.errorStylingActive) { Control editorControl = cellEditor.getEditorControl(); // reset the rendering information to normal editorControl.setBackground(originalBgColor); editorControl.setForeground(originalFgColor); editorControl.setFont(originalFont); // ensure to reset the stored original values so possible // dynamic rendering aspects are also covered originalBgColor = null; originalFgColor = null; originalFont = null; if (decorationProvider != null) { decorationProvider.hideDecoration(); } this.errorStylingActive = false; } }
@Inject @Optional private void whenSectionIsRemoved( @UIEventTopic(RobotModelEvents.ROBOT_SUITE_SECTION_REMOVED) final RobotSuiteFile file) { if (file == fileModel && dataProvider.getInput() != null) { final ICellEditor activeCellEditor = table.getActiveCellEditor(); if (activeCellEditor != null && !activeCellEditor.isClosed()) { activeCellEditor.close(); } dataProvider.setInput(getSection()); selectionLayerAccessor.clear(); table.refresh(); setDirty(); } }
// From Nebula EditController (with minor tweaks) private static boolean supportMultiEdit( List<ILayerCell> cells, ICellEditor cellEditor, IConfigRegistry configRegistry) { for (ILayerCell cell : cells) { if (!(cellEditor.supportMultiEdit(configRegistry, cell.getConfigLabels().getLabels()))) { return false; } } return true; }
// From Nebula EditController (with minor tweaks) protected ExecutionStatusKind editCell( ILayerCell cell, Composite parent, Object initialCanonicalValue, IConfigRegistry configRegistry) { ExecutionStatusKind result = ExecutionStatusKind.FAIL_ROLLBACK; try { Rectangle cellBounds = cell.getBounds(); ILayer layer = cell.getLayer(); int columnPosition = cell.getColumnPosition(); int rowPosition = cell.getRowPosition(); List<String> configLabels = cell.getConfigLabels().getLabels(); ICellEditor cellEditor = (ICellEditor) configRegistry.getConfigAttribute( EditConfigAttributes.CELL_EDITOR, DisplayMode.EDIT, configLabels); // Try to open an in-line editor before falling back to a dialog if (cellEditor.openInline(configRegistry, configLabels)) { MyInlineEditHandler editHandler = new MyInlineEditHandler(layer, columnPosition, rowPosition); Rectangle editorBounds = layer .getLayerPainter() .adjustCellBounds( columnPosition, rowPosition, new Rectangle(cellBounds.x, cellBounds.y, cellBounds.width, cellBounds.height)); cellEditor.activateCell( parent, initialCanonicalValue, EditModeEnum.INLINE, editHandler, cell, configRegistry); Control editorControl = cellEditor.getEditorControl(); if ((editorControl != null) && (!(editorControl.isDisposed()))) { editorControl.setBounds(editorBounds); cellEditor.addEditorControlListeners(); ActiveCellEditorRegistry.registerActiveCellEditor(cellEditor); } // Command succeeded but should not appear on the undo stack because we haven't completed an // edit (only activated the cell editor), // unless the cell editor is like the CheckBoxCellEditor that commits upon activation result = editHandler.isCommitted() ? ExecutionStatusKind.OK_COMPLETE : ExecutionStatusKind.OK_ROLLBACK; } else { // The dialog case List<ILayerCell> cells = new ArrayList<ILayerCell>(1); cells.add(cell); result = editCells(cells, parent, initialCanonicalValue, configRegistry); } } catch (OperationCanceledException e) { // OK. The user cancelled a dialog or some such result = ExecutionStatusKind.FAIL_ROLLBACK; } catch (Exception e) { Activator.log.error("Uncaught exception in table cell editor activation.", e); // $NON-NLS-1$ } return result; }