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

📄 task.java

📁 一个eclipse插件源代码。用于web开发
💻 JAVA
字号:
/*
 * $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/module/model/Task.java,v 1.1.1.1 2004/07/01 09:07:50 wang_j Exp $
 * $Revision: 1.1.1.1 $
 * $Date: 2004/07/01 09:07:50 $
 *
 * ====================================================================
 *
 * 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.module.model;

import java.io.PrintWriter;
import java.util.Hashtable;
import java.util.Vector;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Display;
import org.w3c.dom.Node;

import com.webpump.ui.base.data.BaseObject;
import com.webpump.ui.perspective.WebpumpIDEPlugin;

/**
 * Class for task object
 * 
 * @author shi_l
 * @version 2.0.0 2004-2-12
 */
public class Task extends BaseObject {
	/**The half width of the hotpoint*/
	final static int HOTHALFWIDTH = 3;

	/**The longest distance between the mouse and the line
	 * if want to show the hotpoint
	 */
	final static int MOUSEOFFSET = 3;

	/**The distance between the central of the Arrow and the end of the line*/
	final static int ARROWOFFSET = 5;

	/*The base properties that should be saved as XML*/
	/**The path of the task*/
	private String m_strPath;

	/**The name of the task*/
	private String m_strName;

	/**The base type of the task*/
	private String m_strBaseType;

	/**The name of the request page*/
	private String m_strReqPageName;

	/**The name of the response page*/
	private String m_strRspPageName;

	/**The start port*/
	private int m_nStartPort;

	/**The end port*/
	private int m_nEndPort;

	/**Whether the page has validate*/
	private boolean m_bValidate;

	/**The client of the task*/
	private String m_strClient;

	/**The forward name of the task*/
	private String m_strFwdName;

	/**The state of the task*/
	private String m_strState;

	/**The update time of the task*/
	private String m_strUpdateTime;

	/**The points of the task*/
	private Vector m_vPoints;

	/**The request page*/
	private Page m_objReqPage;

	/**The response page*/
	private Page m_objRspPage;

	/**The description*/
	private String m_strDescription;

	/**The mode*/
	private String m_strMode;
	
	private String m_strUILogicBean;

	/**The task info*/
	private Object[] m_objTaskInfo;

	/**
	 * constructor
	 */
	public Task() {
		m_strPath = "";
		m_strName = "";
		m_strBaseType = "";
		m_strReqPageName = "";
		m_strRspPageName = "";
		m_bValidate = false;
		m_strMode = "";
		m_strFwdName = "";
		m_strState = "new";
		m_strUpdateTime = "";
		m_strDescription = "";
		//m_strFunctionName = "";
		m_strUILogicBean = "";
		//m_strContent = null;
		m_nStartPort = 0;
		m_nEndPort = 0;
		m_vPoints = new Vector();
	}

	/**
	 * get description
	 * @return description String
	 */
	public String getDescription() {
		return m_strDescription;
	}

	/**
	 * set description
	 * @param strDescription
	 */
	public void setDescription(String strDescription) {
		m_strDescription = strDescription;
	}

	/**
	 * set start port
	 * @param port
	 */
	public void setStartPort(int port) {
		m_nStartPort = port;
	}

	/**
	 * get start port
	 * @return start port of the task int
	 */
	public int getStartPort() {
		return m_nStartPort;
	}

	/**
	 * set end port
	 * @param port
	 */
	public void setEndPort(int port) {
		m_nEndPort = port;
	}

	/**
	 * get end port
	 * @return end port of the task int
	 */
	public int getEndPort() {
		return m_nEndPort;
	}

	/**
	 * set path
	 * @param path
	 */
	public void setPath(String path) {
		m_strPath = path;
	}

	/**
	 * set name
	 * @param name
	 */
	public void setName(String name) {
		m_strName = name;
	}

	/**
	 * set base type
	 * @param baseType
	 */
	public void setBaseType(String baseType) {
		m_strBaseType = baseType;
	}

	/**
	 * set name of request page 
	 * @param reqName
	 */
	public void setReqPageName(String reqName) {
		m_strReqPageName = reqName;
	}

	/**
	 * set name of response page
	 * @param rspName
	 */
	public void setRspPageName(String rspName) {
		m_strRspPageName = rspName;
	}

	/**
	 * set validate
	 * @param validate
	 */
	public void setValidate(boolean validate) {
		m_bValidate = validate;
	}

	/**
	 * set points
	 * @param points
	 */
	public void setPoints(Vector points) {
		m_vPoints.removeAllElements();
		for (int i = 0; i < points.size(); i++) {
			Point point =
				new Point(((Point) points.get(i)).x, ((Point) points.get(i)).y);
			m_vPoints.add(point);
		}
		firePropertyChanged("position", null, null);
	}

	/**
	 * set mode
	 * @param mode
	 */
	public void setMode(String mode) {
		m_strMode = mode;
	}

	/**
	 * set forward name
	 * @param fwdName
	 */
	public void setFwdName(String fwdName) {
		m_strFwdName = fwdName;
	}

	/**
	 * set state
	 * @param state
	 */
	public void setState(String strState) {
		m_strState = strState;
		firePropertyChanged("position", null, null);
	}

	/**
	 * set update time
	 * @param updateTime
	 */
	public void setUpdateTime(String updateTime) {
		m_strUpdateTime = updateTime;
	}

	/**
	 * set request page
	 * @param page
	 */
	public void setReqPage(Page page) {
		m_objReqPage = page;
		m_strReqPageName = page.getPageName();
	}

	/**
	 * add a point
	 * @param point
	 */
	public void addPoint(Point point) {
		m_vPoints.add(point);
	}

	/**
	 * set response page
	 * @param page
	 */
	public void setRspPage(Page page) {
		m_objRspPage = page;
		m_strRspPageName = page.getPageName();
	}

	/**
	 * get path
	 * @return path String
	 */
	public String getPath() {
		return m_strPath;
	}

	/**
	 * get name
	 * @return name String
	 */
	public String getName() {
		return m_strName;
	}

	/**
	 * get base type
	 * @return base type String
	 */
	public String getBasetype() {
		return m_strBaseType;
	}

	/**
	 * get name of request page
	 * @return name of request page String
	 */
	public String getReqPageName() {
		return m_strReqPageName;
	}

	/**
	 * get name of response page
	 * @return name of response page
	 */
	public String getRspPageName() {
		return m_strRspPageName;
	}

	/**
	 * get validate
	 * @return validate boolean
	 */
	public boolean getValidate() {
		return m_bValidate;
	}

	/**
	 * get mode
	 * @return mode String
	 */
	public String getMode() {
		return m_strMode;
	}

	/**
	 * get forward name
	 * @return forward name String
	 */
	public String getFwdName() {
		return m_strFwdName;
	}

	/**
	 * get state
	 * @return state String
	 */
	public String getState() {
		return m_strState;
	}

	/**
	 * get update time
	 * @return update time String
	 */
	public String getUpdateTime() {
		return m_strUpdateTime;
	}

	/**
	 * get request page
	 * @return request page Page
	 */
	public Page getReqPage() {
		return m_objReqPage;
	}

	/**
	 * get response page
	 * @return response page Page
	 */
	public Page getRspPage() {
		return m_objRspPage;
	}

	/**
	 * get points
	 * @return points Vector
	 */
	public Vector getPoints() {
		return m_vPoints;
	}

	/**
	 * get task info
	 * @return task info Object[]
	 */
	public Object[] getTaskInfo() {
		Object[] newInfo = new Object[22];
		newInfo[1] = m_strState;
		newInfo[2] = new Boolean(m_bValidate);
		newInfo[3] = new Integer(m_nEndPort);
		newInfo[4] = new Integer(m_nStartPort);
		newInfo[5] = m_objReqPage;
		newInfo[6] = m_objRspPage;
		newInfo[7] = m_objTaskInfo;
		newInfo[8] = m_strBaseType;
		newInfo[9] = m_strClient;
		newInfo[11] = m_strDescription;
		newInfo[13] = m_strFwdName;
		newInfo[14] = m_strMode;
		newInfo[15] = m_strName;
		newInfo[16] = m_strPath;
		newInfo[17] = m_strReqPageName;
		newInfo[18] = m_strRspPageName;
		newInfo[19] = m_strUpdateTime;
		newInfo[20] = m_vPoints;
		newInfo[21] = m_strUILogicBean;
		return newInfo;
	}

	/**
	 * set task info
	 * @param newInfo
	 */
	public void setTaskInfo(Object[] newInfo) {

		Object[] objOldArray = getTaskInfo();
		m_strState = (String) newInfo[1];
		m_bValidate = ((Boolean) newInfo[2]).booleanValue();
		m_nEndPort = ((Integer) newInfo[3]).intValue();
		m_nStartPort = ((Integer) newInfo[4]).intValue();
		m_objReqPage = (Page) newInfo[5];
		m_objRspPage = (Page) newInfo[6];
		m_objTaskInfo = (Object[]) newInfo[7];
		m_strBaseType = ((String) newInfo[8]);
		m_strClient = ((String) newInfo[9]);
		m_strDescription = ((String) newInfo[11]);
		m_strFwdName = ((String) newInfo[13]);
		m_strMode = ((String) newInfo[14]);
		m_strName = ((String) newInfo[15]);
		m_strPath = ((String) newInfo[16]);
		m_strReqPageName = ((String) newInfo[17]);
		m_strRspPageName = ((String) newInfo[18]);
		m_strUpdateTime = ((String) newInfo[19]);
		m_vPoints = (Vector) newInfo[20];
		m_strUILogicBean = (String)newInfo[21];
		setState("false");
		firePropertyChanged("TaskInfo", objOldArray, newInfo);
	}

	/**
	 * restore property
	 * @param name
	 * @param oldValue
	 * @param newValue
	 */
	public void restoreProperty(
		String name,
		Object oldValue,
		Object newValue) {
		Object[] newInfo = (Object[]) newValue;
		m_strState = (String) newInfo[1];
		m_bValidate = ((Boolean) newInfo[2]).booleanValue();
		m_nEndPort = ((Integer) newInfo[3]).intValue();
		m_nStartPort = ((Integer) newInfo[4]).intValue();
		m_objReqPage = (Page) newInfo[5];
		m_objRspPage = (Page) newInfo[6];
		m_objTaskInfo = (Object[]) newInfo[7];
		m_strBaseType = ((String) newInfo[8]);
		m_strClient = ((String) newInfo[9]);
		m_strDescription = ((String) newInfo[11]);
		m_strFwdName = ((String) newInfo[13]);
		m_strMode = ((String) newInfo[14]);
		m_strName = ((String) newInfo[15]);
		m_strPath = ((String) newInfo[16]);
		m_strReqPageName = ((String) newInfo[17]);
		m_strRspPageName = ((String) newInfo[18]);
		m_strUpdateTime = ((String) newInfo[19]);
		m_vPoints = (Vector) newInfo[20];
		m_strUILogicBean = (String)newInfo[21];
		setState("false");
		((Model) getModel()).getResource().getCanvas().redraw();
		firePropertyChanged("TaskInfo", oldValue, newValue);
	}

	/**
	 * draw line
	 * @param gc
	 * @param display
	 */
	private void drawLine(GC gc, Display display) {
		Color oldForeColor = gc.getForeground();
		int oldStyle = gc.getLineStyle();
		gc.setXORMode(false);
		//保存设置

		gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
		gc.setLineStyle(SWT.LINE_SOLID);
		Resource.drawPolyline(gc, m_vPoints);
		//画线

		gc.setForeground(oldForeColor);
		gc.setLineStyle(oldStyle);
		//恢复设置
	}

	/**
	 * draw arrow
	 * @param gc
	 * @param display
	 */
	private void drawArrow(GC gc, Display display) {
		Color oldBackColor = gc.getBackground();
		//保存设置

		gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
		gc.setXORMode(false);
		if (((Point) m_vPoints.get(m_vPoints.size() - 1)).y
			== ((Point) m_vPoints.get(m_vPoints.size() - 2)).y) {
			//

⌨️ 快捷键说明

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