taskeditpart.java

来自「一个eclipse插件源代码。用于web开发」· Java 代码 · 共 152 行

JAVA
152
字号
/*
 * $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/gefmodule/edit/TaskEditPart.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 java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Vector;

import org.eclipse.draw2d.*;
import org.eclipse.gef.AccessibleEditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
import org.eclipse.gef.editparts.AbstractConnectionEditPart;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;

import com.webpump.ui.gefmodule.dialog.TaskDialog;
import com.webpump.ui.gefmodule.figure.FigureFactory;
import com.webpump.ui.gefmodule.model.Module;
import com.webpump.ui.gefmodule.model.Page;
import com.webpump.ui.gefmodule.model.Task;
import com.webpump.ui.perspective.MacroResource;
import com.webpump.ui.perspective.WebpumpIDEPlugin;

/**
 * Class for TaskEditPart
 * 
 * @author shi_l
 * @version 2.0.0 2004-5-30
 */
public class TaskEditPart extends AbstractConnectionEditPart implements PropertyChangeListener {

	AccessibleEditPart acc;

	public static final Color alive = new Color(Display.getDefault(), 0, 74, 168),
		dead = new Color(Display.getDefault(), 0, 0, 0);

	public void activate() {
		super.activate();
		getTask().addPropertyChangeListener(this);
	}

	public void activateFigure() {
		super.activateFigure();
		/*Once the figure has been added to the ConnectionLayer, start listening for its
		 * router to change.
		 */
		getFigure().addPropertyChangeListener(Connection.PROPERTY_CONNECTION_ROUTER, this);
	}

	/**
	 * Adds extra EditPolicies as required. 
	 */
	protected void createEditPolicies() {
		installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new TaskEndpointEditPolicy());
		//Note that the Connection is already added to the diagram and knows its Router.
		//		refreshBendpointEditPolicy();
		installEditPolicy(EditPolicy.CONNECTION_ROLE, new TaskEditPolicy());
	}

	/**
	 * Returns a newly created Figure to represent the connection.
	 *
	 * @return  The created Figure.
	 */
	protected IFigure createFigure() {
		if (getTask() == null)
			return null;
		Connection connx = FigureFactory.createNewBendableTask(getTask());
		return connx;
	}

	public void deactivate() {
		getTask().removePropertyChangeListener(this);
		super.deactivate();
	}

	public void deactivateFigure() {
		getFigure().removePropertyChangeListener(Connection.PROPERTY_CONNECTION_ROUTER, this);
		super.deactivateFigure();
	}

	public AccessibleEditPart getAccessibleEditPart() {
		if (acc == null)
			acc = new AccessibleGraphicalEditPart() {
			public void getName(AccessibleEvent e) {
				e.result = "Task";
			}
		};
		return acc;
	}

	/**
	 * Returns the model of this represented as a Wire.
	 * 
	 * @return  Model of this as <code>Wire</code>
	 */
	protected Task getTask() {
		return (Task) getModel();
	}

	/**
	 * Returns the Figure associated with this, which draws the
	 * Wire.
	 *
	 * @return  Figure of this.
	 */
	protected IFigure getTaskFigure() {
		return (PolylineConnection) getFigure();
	}

	/**
	 * Listens to changes in properties of the Wire (like the
	 * contents being carried), and reflects is in the visuals.
	 *
	 * @param event  Event notifying the change.
	 */
	public void propertyChange(PropertyChangeEvent event) {
		String property = event.getPropertyName();
		if ("PROPERTY_NAME".equals(property)) //$NON-NLS-1$
			refreshVisuals();
	}

	/**
	 * Refreshes the visual aspects of this, based upon the
	 * model (Wire). It changes the wire color depending on
	 * the state of Wire.
	 * 
	 */
	protected void refreshVisuals() {
		String name = ((Task) getModel()).getName();
		if (name == null || name == "") {//如果名称为空,去掉

⌨️ 快捷键说明

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