提交 785fb378 编写于 作者: S Serge Rider

ERD editor enhancement

上级 a5c9f4d7
......@@ -22,9 +22,11 @@ package org.jkiss.dbeaver.ext.erd.directedit;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.editpolicies.DirectEditPolicy;
import org.eclipse.gef.tools.CellEditorLocator;
import org.eclipse.gef.tools.DirectEditManager;
import org.eclipse.jface.viewers.ICellEditorValidator;
......@@ -170,11 +172,17 @@ public class ExtendedDirectEditManager extends DirectEditManager {
getCellEditor().getControl().setVisible(false);
if (isDirty()) {
CommandStack stack = getEditPart().getViewer().getEditDomain().getCommandStack();
Command command = getEditPart().getCommand(getDirectEditRequest());
if (command != null && command.canExecute())
EditPolicy editPolicy = getEditPart().getEditPolicy(EditPolicy.DIRECT_EDIT_ROLE);
Command command;
if (editPolicy != null) {
command = editPolicy.getCommand(getDirectEditRequest());
} else {
command = getEditPart().getCommand(getDirectEditRequest());
}
if (command != null && command.canExecute()) {
stack.execute(command);
}
}
} finally {
bringDown();
committing = false;
......
......@@ -26,6 +26,7 @@ import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
import org.eclipse.gef.RequestConstants;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.requests.DirectEditRequest;
import org.eclipse.gef.tools.DirectEditManager;
import org.jkiss.dbeaver.ext.erd.directedit.ExtendedDirectEditManager;
......@@ -69,6 +70,7 @@ public class NotePart extends NodePart
//installEditPolicy(EditPolicy.CONTAINER_ROLE, new EntityContainerEditPolicy());
//installEditPolicy(EditPolicy.COMPONENT_ROLE, new NoteEditPolicy());
installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new NoteDirectEditPolicy());
//installEditPolicy(EditPolicy.COMPONENT_ROLE, new NoteDirectEditPolicy());
//installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new ResizableEditPolicy());
}
......@@ -87,6 +89,14 @@ public class NotePart extends NodePart
}
}
@Override
public Command getCommand(Request request) {
if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
performDirectEdit();
}
return null;
}
private boolean directEditHitTest(Point requestLoc) {
NoteFigure figure = (NoteFigure) getFigure();
figure.translateToRelative(requestLoc);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册