📄 componentsetconstraintcommand.java
字号:
package com.cownew.uidesigner.commands;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.RequestConstants;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import com.cownew.uidesigner.model.Component;
public class ComponentSetConstraintCommand extends Command
{
private final Rectangle newEditorBounds;
private Rectangle oldTermBounds;
private final ChangeBoundsRequest request;
private final Component component;
public ComponentSetConstraintCommand(Component component,
ChangeBoundsRequest req, Rectangle newBounds)
{
if (component == null || req == null || newBounds == null)
{
throw new IllegalArgumentException();
}
this.component = component;
this.request = req;
this.newEditorBounds = newBounds.getCopy();
}
public String getLabel()
{
return "move / resize";
}
public boolean canExecute()
{
Object type = request.getType();
return (RequestConstants.REQ_MOVE.equals(type)
|| RequestConstants.REQ_MOVE_CHILDREN.equals(type)
|| RequestConstants.REQ_RESIZE.equals(type)
|| RequestConstants.REQ_RESIZE_CHILDREN.equals(type)
|| RequestConstants.REQ_ALIGN_CHILDREN.equals(type));
}
public void execute()
{
oldTermBounds = component.getBounds();
component.setBounds(newEditorBounds);
}
public void redo()
{
component.setBounds(newEditorBounds);
}
public void undo()
{
component.setBounds(oldTermBounds);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -