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

📄 diagramxylayouteditpolicy.java

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


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

import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.requests.CreateRequest;

import com.primeton.studio.gef.core.Node;
import com.primeton.studio.gef.core.Diagram;
import com.primeton.studio.gef.core.NodeElement;
import com.primeton.studio.gef.core.TNodeType;
import com.primeton.studio.gef.ui.commands.NodeCreateCommand;

/**
 * TODO 此处填写 class 信息
 *
 * @author niegy (mailto:niegy@primeton.com)
 */
/*
 * 修改历史
 * $Log: DiagramXYLayoutEditPolicy.java,v $
 * Revision 1.2  2006/12/30 02:45:03  niegy
 * 重构代码
 *
 * Revision 1.1  2006/12/05 05:18:59  niegy
 * 修改模型,增加连线的扩展点
 * 
 */
public class DiagramXYLayoutEditPolicy extends NodeXYLayoutEditPolicy {

	private String pluginId;
	/**
	 * @param node
	 */
	public DiagramXYLayoutEditPolicy(Node node,String id) {
		super(node);
		// TODO Auto-generated constructor stub
		pluginId = id;
	}

    protected Command getCreateCommand(CreateRequest request) {
        Object childClass = request.getNewObject();
        if(((NodeElement)childClass).getNodeType().equals(TNodeType.CHILD_LITERAL) &&
        		model instanceof Diagram)
        	return null;
        
        if(((NodeElement)childClass).getNodeType().equals(TNodeType.COMMON_LITERAL) &&
        		!(model instanceof Diagram))
        	return null;
        
        
        boolean isAttri = ((NodeElement)childClass).getNodeType().equals(TNodeType.ATTRICOLUMN_LITERAL);
        boolean isOper = ((NodeElement)childClass).getNodeType().equals(TNodeType.OPERATIONCOLUMN_LITERAL);
       
        if(isAttri || isOper){
        	if(model instanceof Diagram)
        		return null;
        	else if(model instanceof NodeElement && !((NodeElement)model).getNodeType().equals(TNodeType.TABLE_LITERAL)){
        		return null;
        	}
        }

        
        Rectangle constraint = (Rectangle) getConstraintFor(request);

        if (childClass instanceof NodeElement){
        // return a command that can add a Shape to a ShapesDiagram 
           return new NodeCreateCommand(model, request, constraint,pluginId,true);
        }
        return null;
    }
}

⌨️ 快捷键说明

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