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

📄 modelnodeeditpolicy.java

📁 一个eclipse插件源代码。用于web开发
💻 JAVA
字号:
/*
 * $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/gefmodule/edit/ModelNodeEditPolicy.java,v 1.1.1.1 2004/07/01 09:07:47 wang_j Exp $
 * $Revision: 1.1.1.1 $
 * $Date: 2004/07/01 09:07:47 $
 *
 * ====================================================================
 *
 * The NanJing HopeRun(IT-FOREST) Software License, Version 2.0.0
 *
 * Copyright 2003-2004 by NanJing HopeRun(IT-FOREST) Information System Co., Ltd, CHINA and
 *                        IT Forest Corporation
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * HopeRun(IT-FOREST) Information System Co., Ltd, CHINA and IT Forest Corporation.
 * You shall not disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into with
 * HopeRun(IT-FOREST) Information System Co., Ltd, CHINA and IT Forest Corporation.
 */

package com.webpump.ui.gefmodule.edit;

import org.eclipse.draw2d.*;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.commands.Command;

import org.eclipse.gef.requests.CreateConnectionRequest;
import org.eclipse.gef.requests.ReconnectRequest;

import com.webpump.ui.gefmodule.command.ConnectionCommand;
import com.webpump.ui.gefmodule.figure.NodeFigure;
import com.webpump.ui.gefmodule.model.ModelSubpart;
import com.webpump.ui.gefmodule.model.Module;
import com.webpump.ui.gefmodule.model.Task;

/**
 * Class for ModelNodeEditPolicy
 * 
 * @author shi_l
 * @version 2.0.0 2004-5-30
 */
public class ModelNodeEditPolicy extends org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy {
	/*
	protected Connection createDummyConnection(Request req) {
		PolylineConnection conn = FigureFactory.createNewTask(null);
		return conn;
	}
	*/

	/**
	 * get connection complete command
	 * @param request CreateConnectionRequest
	 * @return command Command
	 */
	protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
		ConnectionCommand command = (ConnectionCommand) request.getStartCommand();
		command.setTarget(getModelSubpart());
		ConnectionAnchor ctor = getModelEditPart().getTargetConnectionAnchor(request);
		if (ctor == null)
			return null;
		command.setTargetTerminal(getModelEditPart().mapConnectionAnchorToTerminal(ctor));
		return command;
	}

	/**
	 * get connection create command
	 * @param request CreateConnectionRequest
	 * @return command Command
	 */
	protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
		ConnectionCommand command = new ConnectionCommand();
		command.setTask(new Task());
		command.setSource(getModelSubpart());
		ConnectionAnchor ctor = getModelEditPart().getSourceConnectionAnchor(request);
		command.setSourceTerminal(getModelEditPart().mapConnectionAnchorToTerminal(ctor));
		command.setModule((Module) getModelEditPart().getParent().getModel());
		request.setStartCommand(command);
		return command;
	}

	/**
	 * get model editpart
	 * @return host ModelEditPart
	 */
	protected ModelEditPart getModelEditPart() {
		return (ModelEditPart) getHost();
	}

	/**
	 * get model subpart
	 * @return model ModelSubpart
	 */
	protected ModelSubpart getModelSubpart() {
		return (ModelSubpart) getHost().getModel();
	}

	/**
	 * get reconnection target command
	 * @param request ReconnectRequest
	 * @return command Command
	 */
	protected Command getReconnectTargetCommand(ReconnectRequest request) {

		ConnectionCommand cmd = new ConnectionCommand();
		cmd.setTask((Task) request.getConnectionEditPart().getModel());

		ConnectionAnchor ctor = getModelEditPart().getTargetConnectionAnchor(request);
		cmd.setTarget(getModelSubpart());
		cmd.setTargetTerminal(getModelEditPart().mapConnectionAnchorToTerminal(ctor));
		return cmd;
	}

	/**
	 * get reconnection source command
	 * @param request ReconnectRequest
	 * @return command Command
	 */
	protected Command getReconnectSourceCommand(ReconnectRequest request) {
		ConnectionCommand cmd = new ConnectionCommand();
		cmd.setTask((Task) request.getConnectionEditPart().getModel());

		ConnectionAnchor ctor = getModelEditPart().getSourceConnectionAnchor(request);
		cmd.setSource(getModelSubpart());
		cmd.setSourceTerminal(getModelEditPart().mapConnectionAnchorToTerminal(ctor));
		return cmd;
	}

	/**
	 * get node figure
	 * @return host's figure
	 */
	protected NodeFigure getNodeFigure() {
		return (NodeFigure) ((GraphicalEditPart) getHost()).getFigure();
	}
}

⌨️ 快捷键说明

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