reconnectsourcecommand.java
来自「GEF初学者可以用来对照的小例子」· Java 代码 · 共 61 行
JAVA
61 行
/*
* 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 + =
减小字号Ctrl + -
显示快捷键?