⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 componentsetconstraintcommand.java

📁 基于eclipse的工具开发代码
💻 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 + -