📄 reconnecttargetcommand.java
字号:
package com.example.commands;
import org.eclipse.gef.commands.Command;
import com.example.model.Connection;
import com.example.model.Diagram;
public class ReconnectTargetCommand extends Command {
private Connection connection;
private Diagram newTarget;
private Diagram oldTarget;
private Diagram source;
//setters
public void setConnection(Connection connection) {
this.connection = connection;
this.source=this.connection.getSource();
this.oldTarget=this.connection.getTarget();
}
public void setTarget(Diagram target) {
this.newTarget = target;
}
public void execute() {
oldTarget.removeOutput(connection);
newTarget.addOutput(connection);
connection.setTarget(newTarget);
}
public String getLabel() {
return "Reconnect Target";
}
public void redo() {
execute();
}
public void undo() {
newTarget.removeOutput(connection);
oldTarget.addOutput(connection);
connection.setSource(oldTarget);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -