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

📄 changenamecommand.java

📁 对eclipse gef进行封装,可以生成图形化编辑器
💻 JAVA
字号:
/*******************************************************************************
 * $Header: /cvsroot/EOS6/work_dir/niegy/com.primeton.studio.gef.ui/src/com/primeton/studio/gef/ui/commands/ChangeNameCommand.java,v 1.3 2006/12/30 02:45:04 niegy Exp $
 * $Revision: 1.3 $
 * $Date: 2006/12/30 02:45:04 $
 *
 *==============================================================================
 *
 * Copyright (c) 2001-2006 Primeton Technologies, Ltd.
 * All rights reserved.
 * 
 * Created on 2006-11-21
 *******************************************************************************/


package com.primeton.studio.gef.ui.commands;

import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.gef.commands.Command;

import com.primeton.studio.gef.core.NodeElement;

/**
 * TODO 此处填写 class 信息
 *
 * @author niegy (mailto:niegy@primeton.com)
 */
/*
 * 修改历史
 * $Log: ChangeNameCommand.java,v $
 * Revision 1.3  2006/12/30 02:45:04  niegy
 * 重构代码
 *
 * Revision 1.2  2006/12/08 07:04:32  niegy
 * 重构代码
 *
 * Revision 1.1  2006/11/22 07:07:38  niegy
 * 增加table
 * 
 */
public class ChangeNameCommand extends Command {
	protected NodeElement element;
	protected String newName, oldName;

	public ChangeNameCommand(NodeElement elem, String newName) {
		super("Change Name");
		element = elem;
		oldName = elem.getName();
		this.newName = newName.trim();
	}
	
	public ChangeNameCommand(NodeElement elem, String newName,String commandName) {
		super(commandName);
		element = elem;
		oldName = elem.getName();
		this.newName = newName.trim();
	}

	public boolean canExecute() {
		return element != null;
	}

	public void execute() {
		element.setName(newName);
	}

	public void undo() {
		element.setName(oldName);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -