diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/AbstractPresentation.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/AbstractPresentation.java index 8edd5acdcc85fd57d9ebd6d5f5204e44d4376d26..8614f364485a4a08effe3fe5cf4c90b2a827a570 100644 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/AbstractPresentation.java +++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/AbstractPresentation.java @@ -49,6 +49,7 @@ public abstract class AbstractPresentation implements IResultSetPresentation, IS public static final String RESULTS_CONTROL_CONTEXT_ID = "org.jkiss.dbeaver.ui.context.resultset.focused"; public static final StructuredSelection EMPTY_SELECTION = new StructuredSelection(); public static final String RESULT_SET_PRESENTATION_CONTEXT_MENU = "org.jkiss.dbeaver.ui.controls.resultset.conext.menu"; + public static final String DATA_VALUE_CONTROLLER = "org.jkiss.dbeaver.resultset.value-controller"; @NotNull protected IResultSetController controller; @@ -62,6 +63,11 @@ public abstract class AbstractPresentation implements IResultSetPresentation, IS return controller; } + @Override + public void applyChanges() { + // Do nothing + } + @Override public void createPresentation(@NotNull final IResultSetController controller, @NotNull Composite parent) { this.controller = controller; diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetPresentation.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetPresentation.java index 4cdf6af0e14e113bdf7bd569bbff36aaab0728eb..f7d8870cb04f6a33d94967e0b984f0dc1c1b8fa8 100644 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetPresentation.java +++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/IResultSetPresentation.java @@ -71,6 +71,8 @@ public interface IResultSetPresentation { void updateValueView(); + void applyChanges(); + /** * Called by controller to fill context menu. * Note: context menu invocation must be initiated by presentation, then it should call controller's diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java index f3006c9d19c887a3097d66937cfee0785def9ffe..200567cbf3f8ce55d0c148007d93245b0db36742 100644 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java +++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/ResultSetViewer.java @@ -2891,6 +2891,7 @@ public class ResultSetViewer extends Viewer */ private boolean applyChanges(@Nullable final DBRProgressMonitor monitor, @Nullable final ResultSetPersister.DataUpdateListener listener) { + //getActivePresentation(). try { final ResultSetPersister persister = createDataPersister(false); final ResultSetPersister.DataUpdateListener applyListener = success -> { diff --git a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/spreadsheet/SpreadsheetPresentation.java b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/spreadsheet/SpreadsheetPresentation.java index 5ee0581c0319e3bc79a33b3479a44a29210b60c5..f938de49bd4997fc48ee9e9ca1fe01cd05cf074b 100644 --- a/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/spreadsheet/SpreadsheetPresentation.java +++ b/plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/controls/resultset/spreadsheet/SpreadsheetPresentation.java @@ -139,6 +139,7 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe private boolean showCelIcons = true; private boolean colorizeDataTypes = true; private boolean rightJustifyNumbers = true; + private IValueEditor activeInlineEditor; public SpreadsheetPresentation() { findReplaceTarget = new SpreadsheetFindReplaceTarget(this); @@ -155,6 +156,22 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe return dataContainer == null ? null : dataContainer.getDataSource(); } + @Override + public void applyChanges() { + if (activeInlineEditor != null && activeInlineEditor.getControl() != null && !activeInlineEditor.getControl().isDisposed()) { + IValueController valueController = (IValueController) activeInlineEditor.getControl().getData(DATA_VALUE_CONTROLLER); + if (valueController != null) { + try { + Object value = activeInlineEditor.extractEditorValue(); + valueController.updateValue(value, true); + } catch (DBException e) { + DBUserInterface.getInstance().showError("Error extracting editor value", null, e); + } + } + spreadsheet.cancelInlineEditor(); + } + } + @Override public void createPresentation(@NotNull IResultSetController controller, @NotNull Composite parent) { super.createPresentation(controller, parent); @@ -820,6 +837,7 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe return null; } spreadsheet.cancelInlineEditor(); + activeInlineEditor = null; placeholder = new Composite(spreadsheet, SWT.NONE); placeholder.setFont(spreadsheet.getFont()); @@ -865,48 +883,50 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe } */ - final IValueEditor editor; try { - editor = valueController.getValueManager().createEditor(valueController); + activeInlineEditor = valueController.getValueManager().createEditor(valueController); } catch (Exception e) { DBUserInterface.getInstance().showError("Cannot edit value", null, e); return null; } - if (editor != null) { - editor.createControl(); + if (activeInlineEditor != null) { + activeInlineEditor.createControl(); + if (activeInlineEditor.getControl() != null) { + activeInlineEditor.getControl().setData(DATA_VALUE_CONTROLLER, valueController); + } } - if (editor instanceof IValueEditorStandalone) { - valueController.registerEditor((IValueEditorStandalone)editor); - Control editorControl = editor.getControl(); + if (activeInlineEditor instanceof IValueEditorStandalone) { + valueController.registerEditor((IValueEditorStandalone) activeInlineEditor); + Control editorControl = activeInlineEditor.getControl(); if (editorControl != null) { - editorControl.addDisposeListener(e -> valueController.unregisterEditor((IValueEditorStandalone)editor)); + editorControl.addDisposeListener(e -> valueController.unregisterEditor((IValueEditorStandalone) activeInlineEditor)); } // show dialog in separate job to avoid block new UIJob("Open separate editor") { @Override public IStatus runInUIThread(IProgressMonitor monitor) { - ((IValueEditorStandalone)editor).showValueEditor(); + ((IValueEditorStandalone) activeInlineEditor).showValueEditor(); return Status.OK_STATUS; } }.schedule(); //((IValueEditorStandalone)editor).showValueEditor(); } else { // Set editable value - if (editor != null) { + if (activeInlineEditor != null) { try { - editor.primeEditorValue(valueController.getValue()); + activeInlineEditor.primeEditorValue(valueController.getValue()); } catch (DBException e) { log.error(e); } - editor.setDirty(false); + activeInlineEditor.setDirty(false); } } if (inline) { - if (editor != null) { + if (activeInlineEditor != null) { spreadsheet.showCellEditor(placeholder); - return editor.getControl(); + return activeInlineEditor.getControl(); } else { // No editor was created so just drop placeholder placeholder.dispose();