📄 reconnectsourcecommand.java
字号:
/*
* Created on 2005-1-27
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.example.commands;
import org.eclipse.gef.commands.Command;
import com.example.model.Connection;
import com.example.model.Diagram;
import com.example.model.Node;
/**
* @author zhanghao
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ReconnectSourceCommand extends Command {
private Connection connection;
private Diagram newSource;
private Diagram oldSource;
private Diagram target;
//setters
public void setConnection(Connection connection) {
this.connection = connection;
this.target=this.connection.getTarget();
this.oldSource=this.connection.getSource();
}
public void setSource(Diagram source) {
this.newSource = source;
}
public void execute() {
oldSource.removeOutput(connection);
newSource.addOutput(connection);
connection.setSource(newSource);
}
public String getLabel() {
return "Reconnect Source";
}
public void redo() {
execute();
}
public void undo() {
newSource.removeOutput(connection);
oldSource.addOutput(connection);
connection.setSource(oldSource);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -