📄 diagramgraphicalnodeeditpolicy.java
字号:
package com.example.policies;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy;
import org.eclipse.gef.requests.CreateConnectionRequest;
import org.eclipse.gef.requests.ReconnectRequest;
import com.example.commands.CreateConnectionCommand;
import com.example.commands.ReconnectSourceCommand;
import com.example.commands.ReconnectTargetCommand;
import com.example.model.Connection;
import com.example.model.Diagram;
public class DiagramGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
CreateConnectionCommand command = (CreateConnectionCommand) request.getStartCommand();
command.setTarget((Diagram) getHost().getModel());
return command;
}
protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
CreateConnectionCommand command = new CreateConnectionCommand();
command.setSource((Diagram) getHost().getModel());
request.setStartCommand(command);
return command;
}
protected Command getReconnectSourceCommand(ReconnectRequest request) {
ReconnectSourceCommand cmd = new ReconnectSourceCommand();
cmd.setConnection((Connection)request.getConnectionEditPart().getModel());
cmd.setSource((Diagram)getHost().getModel());
return cmd;
}
protected Command getReconnectTargetCommand(ReconnectRequest request) {
ReconnectTargetCommand cmd = new ReconnectTargetCommand();
cmd.setConnection((Connection)request.getConnectionEditPart().getModel());
cmd.setTarget((Diagram)getHost().getModel());
return cmd;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -