提交 b60aea8c 编写于 作者: J jurgen

Value controller refactoring

上级 3cb23fac
......@@ -45,10 +45,7 @@ import org.jkiss.dbeaver.model.struct.DBSDataType;
import org.jkiss.dbeaver.model.struct.DBSTypedObject;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.data.IValueController;
import org.jkiss.dbeaver.ui.data.IValueEditor;
import org.jkiss.dbeaver.ui.data.IValueEditorStandalone;
import org.jkiss.dbeaver.ui.data.IValueManager;
import org.jkiss.dbeaver.ui.data.*;
import org.jkiss.dbeaver.ui.data.registry.DataManagerRegistry;
import org.jkiss.utils.ArrayUtils;
import org.jkiss.utils.CommonUtils;
......@@ -322,7 +319,7 @@ public class SQLQueryParameterBindDialog extends StatusDialog {
}
}
private class ParameterValueController implements IValueController {
private class ParameterValueController implements IValueController, IMultiController {
private final SQLQueryParameter parameter;
private final Composite placeholder;
......
......@@ -189,15 +189,6 @@ public class ResultSetValueController implements IAttributeController, IRowContr
return null;
}
@Override
public void closeInlineEditor()
{
}
@Override
public void nextInlineEditor(boolean next) {
}
@Override
public void showMessage(String message, boolean error)
{
......
......@@ -90,6 +90,7 @@ import org.jkiss.dbeaver.ui.controls.lightgrid.GridPos;
import org.jkiss.dbeaver.ui.controls.lightgrid.IGridContentProvider;
import org.jkiss.dbeaver.ui.controls.lightgrid.IGridLabelProvider;
import org.jkiss.dbeaver.ui.controls.resultset.*;
import org.jkiss.dbeaver.ui.data.IMultiController;
import org.jkiss.dbeaver.ui.data.IValueController;
import org.jkiss.dbeaver.ui.data.IValueEditor;
import org.jkiss.dbeaver.ui.data.IValueEditorStandalone;
......@@ -1441,7 +1442,7 @@ public class SpreadsheetPresentation extends AbstractPresentation implements IRe
/////////////////////////////
// Value controller
public class SpreadsheetValueController extends ResultSetValueController {
public class SpreadsheetValueController extends ResultSetValueController implements IMultiController {
public SpreadsheetValueController(@NotNull IResultSetController controller, @NotNull DBDAttributeBinding binding, @NotNull ResultSetRow row, @NotNull EditType editType, @Nullable Composite inlinePlaceholder) {
super(controller, binding, row, editType, inlinePlaceholder);
......
......@@ -203,10 +203,8 @@ abstract class ViewValuePanel extends Composite {
{
try {
Object newValue = valueViewer.extractEditorValue();
//previewController.closeInlineEditor();
previewController.updateValue(newValue);
} catch (DBException e) {
previewController.closeInlineEditor();
UIUtils.showErrorDialog(null, "Value save", "Can't save edited value", e);
}
}
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.ui.data;
/**
* Multi-value controller.
* Supports value editors switch.
*/
public interface IMultiController
{
/**
* Closes current value editor.
* This action may initiated by editor control (e.g. on Enter or Esc key)
*/
void closeInlineEditor();
/**
* Closes current editor and activated next cell editor
* @param next true for next and false for previous cell
*/
void nextInlineEditor(boolean next);
}
......@@ -115,18 +115,6 @@ public interface IValueController
@Nullable
IContributionManager getEditBar();
/**
* Closes current value editor.
* This action may initiated by editor control (e.g. on Enter or Esc key)
*/
void closeInlineEditor();
/**
* Closes current editor and activated next cell editor
* @param next true for next and false for previous cell
*/
void nextInlineEditor(boolean next);
/**
* Show error/warning message in grid control.
* @param message error message
......
......@@ -26,6 +26,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.data.IMultiController;
import org.jkiss.dbeaver.ui.data.IValueController;
import org.jkiss.dbeaver.ui.data.IValueEditor;
......@@ -82,8 +83,7 @@ public abstract class BaseValueEditor<T extends Control> implements IValueEditor
}
});
// if (!UIUtils.isInDialog(inlineControl)) { // In dialog it also should handle all standard stuff because we have params dialog
{
if (valueController instanceof IMultiController) { // In dialog it also should handle all standard stuff because we have params dialog
inlineControl.addTraverseListener(new TraverseListener() {
@Override
public void keyTraversed(TraverseEvent e) {
......@@ -92,12 +92,12 @@ public abstract class BaseValueEditor<T extends Control> implements IValueEditor
e.doit = false;
e.detail = SWT.TRAVERSE_NONE;
} else if (e.detail == SWT.TRAVERSE_ESCAPE) {
valueController.closeInlineEditor();
((IMultiController) valueController).closeInlineEditor();
e.doit = false;
e.detail = SWT.TRAVERSE_NONE;
} else if (e.detail == SWT.TRAVERSE_TAB_NEXT || e.detail == SWT.TRAVERSE_TAB_PREVIOUS) {
saveValue();
valueController.nextInlineEditor(e.detail == SWT.TRAVERSE_TAB_NEXT);
((IMultiController) valueController).nextInlineEditor(e.detail == SWT.TRAVERSE_TAB_NEXT);
e.doit = false;
e.detail = SWT.TRAVERSE_NONE;
}
......@@ -136,10 +136,10 @@ public abstract class BaseValueEditor<T extends Control> implements IValueEditor
{
try {
Object newValue = extractEditorValue();
valueController.closeInlineEditor();
((IMultiController) valueController).closeInlineEditor();
valueController.updateValue(newValue);
} catch (DBException e) {
valueController.closeInlineEditor();
((IMultiController) valueController).closeInlineEditor();
UIUtils.showErrorDialog(null, "Value save", "Can't save edited value", e);
}
}
......
......@@ -348,18 +348,6 @@ public class ComplexObjectEditor extends TreeViewer {
return null;
}
@Override
public void closeInlineEditor()
{
disposeOldEditor();
}
@Override
public void nextInlineEditor(boolean next)
{
}
@Override
public void showMessage(String message, boolean error)
{
......
......@@ -195,16 +195,6 @@ public abstract class ValueViewDialog extends Dialog implements IValueEditorStan
return null;
}
@Override
public void closeInlineEditor()
{
}
@Override
public void nextInlineEditor(boolean next)
{
}
@Override
public void showMessage(String message, boolean error)
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册