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

📄 page.java

📁 一个eclipse插件源代码。用于web开发
💻 JAVA
字号:
/*
 * $Header: /home/cvs/WEBPUMP2.0/WebPumpIDE_Src/WebPumpIDE/src/com/webpump/ui/module/model/Page.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.core.runtime.CoreException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
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 org.w3c.dom.NodeList;

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

/**
 * Class for page object
 * 
 * @author shi_l
 * @version 2.0.0 2004-2-12
 */
public class Page extends BaseObject {

	/**The width of the page*/
	final public static int WIDTH = 100;

	/**The height of the page*/
	final public static int HEIGHT = 150;
	
	/**The height of the head*/
	final public static int HEAD_HEIGHT = 33;

	/**The longest distance between the mouse and the page
	 * if want to show the hotpoint
	 */
	final public static int EXTEND = 10;

	/**Half width of the hotpoint*/
	final public static int HOTHALFWIDTH = 3;

	/**The rect of the page*/
	private Rectangle m_objRect;

	/*The base properties that should be saved as XML*/
	/**The name of the page*/
	private String m_strPageName;

	/**The name of the package*/
	private String m_strPackageName;

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

	/**The scope of the page*/
	private String m_strScope;

	/**The error action of the page*/
	private String m_strErrorAction;

	/**The init action of the page*/
	private String m_strInitAction;

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

	/**Whether the page has security check*/
	private boolean m_bSecurityCheck;

	/**Whether the page has session check*/
	private boolean m_bSessionCheck;

	/**Whether the page has database connection*/
	private boolean m_bDBConnection;

	/**The datasource of the page*/
	private String m_strDataSource;

	/**Whether the page has URL access*/
	private boolean m_bUrlAccess;
	
	private boolean m_bGlobalForward;

	private String m_strValidateType;

	private String m_strDescription;

	private String m_strState;
	
	private String m_strFormType;
	
	private Vector m_vModuleForwardName;
	
	private Vector m_vModuleForwardAction;

	private Object[] pageInfo;
	
	/***/
	private boolean m_bMin;

	/**
	 * Constructor of the page that not specify of the position
	 */
	public Page() {
		//new a rect int (0, 0)
		m_objRect = new Rectangle(0, 0, WIDTH, HEIGHT);
		m_strPageName = "";
		m_strPackageName = "";
		m_strBaseType = "";
		m_strScope = "";
		m_strInitAction = null;
		m_strUpdateTime = "";
		m_strDataSource = "";
		m_strDescription = "";
		m_strDescription = "";
		m_bSecurityCheck = false;
		m_bSessionCheck = false;
		m_bDBConnection = false;
		m_bUrlAccess = true;
		m_strState = "";
		m_strValidateType = "Client";
		m_strFormType = "Static";
		m_bGlobalForward = false;
		m_vModuleForwardName = new Vector();
		m_vModuleForwardAction = new Vector();
		m_bMin = false;
	}

	/**
	 * Constructor of the page that specify the position
	 * @param x
	 * @param y
	 */
	public Page(int x, int y) {
		//new a rect int (x, y)
		m_objRect = new Rectangle(x, y, WIDTH, HEIGHT);
		m_strPageName = "";
		m_strPackageName = "";
		m_strBaseType = "";
		m_strScope = "";
		m_strUpdateTime = "";
		m_strDataSource = "";
		m_strDescription = "";
		m_bSecurityCheck = false;
		m_bSessionCheck = false;
		m_bDBConnection = false;
		m_bUrlAccess = true;
		m_strState = "";
		m_strValidateType = "Client";
		m_strFormType = "Static";
		m_bGlobalForward = false;
		m_vModuleForwardName = new Vector();
		m_vModuleForwardAction = new Vector();
		
		m_bMin = false;
	}

	public void setState(String strState) {
		m_strState = strState;
		firePropertyChanged("position", null, null);
	}

	public String getState() {
		return m_strState;
	}

	/**
	 * set page name
	 * @param name
	 */
	public void setPageName(String name) {
		m_strPageName = name;
		//fireStructureChanged(this, ModelChangedEvent.CHANGE);
	}

	/**
	 * set package name
	 * @param name
	 */
	public void setPackageName(String name) {
		m_strPackageName = name;
		//fireStructureChanged(this, ModelChangedEvent.CHANGE);
	}

	/**
	 * set base type
	 * @param baseType
	 */
	public void setBaseType(String baseType) {
		m_strBaseType = baseType;
		//fireStructureChanged(this, ModelChangedEvent.CHANGE);
	}

	/**
	 * set scope
	 * @param scope
	 */
	public void setScope(String scope) {
		m_strScope = scope;
		//fireStructureChanged(this, ModelChangedEvent.CHANGE);
	}

	/**
	 * set erroraction
	 * @param errorAction
	 */
	public void setErrorAction(String errorAction) {
		m_strErrorAction = errorAction;
		//fireStructureChanged(this, ModelChangedEvent.CHANGE);
	}

	/**
	 * set initaction
	 * @param initAction
	 */
	public void setInitAction(String initAction) {
		m_strInitAction = initAction;
		//fireStructureChanged(this, ModelChangedEvent.CHANGE);
	}

	/**
	 * set update time
	 * @param updateTime
	 */
	public void setUpdateTime(String updateTime) {
		m_strUpdateTime = updateTime;
		//fireStructureChanged(this, ModelChangedEvent.CHANGE);
	}

	/**
	 * set security check
	 * @param secCheck
	 */
	public void setSecCheck(boolean secCheck) {
		m_bSecurityCheck = secCheck;
		//fireStructureChanged(this, ModelChangedEvent.CHANGE);
	}

	/**
	 * set session check
	 * @param sesCheck
	 */
	public void setSesCheck(boolean sesCheck) {
		m_bSessionCheck = sesCheck;
		//fireStructureChanged(this, ModelChangedEvent.CHANGE);
	}

	/**
	 * set dbconnection
	 * @param dbCon
	 */
	public void setDBCon(boolean dbCon) {
		m_bDBConnection = dbCon;
		//fireStructureChanged(this, ModelChangedEvent.CHANGE);
	}

	/**
	 * set data source
	 * @param dataSource
	 */
	public void setDataSource(String dataSource) {
		m_strDataSource = dataSource;
		//fireStructureChanged(this, ModelChangedEvent.CHANGE);
	}

	/**
	 * set position of the page
	 * @param x
	 * @param y
	 */
	public void setPosition(int x, int y) {
		m_objRect.x = x;
		m_objRect.y = y;
		firePropertyChanged("position", null, null);
	}

	/**
	 * set url access
	 * @param urlAccess
	 */
	public void setUrlAccess(boolean urlAccess) {
		m_bUrlAccess = urlAccess;
		//fireStructureChanged(this, ModelChangedEvent.CHANGE);
	}

	/**
	 * get page name
	 * @return pagename String
	 */
	public String getPageName() {
		return m_strPageName;
	}

	/**
	 * get package name of the page
	 * @return package name String
	 */
	public String getPackageName() {
		return m_strPackageName;
	}

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

	/**
	 * get scope
	 * @return scope String
	 */
	public String getScope() {
		return m_strScope;
	}

	/**
	 * get error action
	 * @return error action String
	 */
	public String getErrorAction() {
		return m_strErrorAction;
	}

	/**
	 * get init action
	 * @return init action String
	 */
	public String getInitAction() {
		return m_strInitAction;
	}

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

	/**
	 * get security check
	 * @return security check String
	 */
	public boolean getSecCheck() {
		return m_bSecurityCheck;
	}

	/**
	 * get session check
	 * @return session check String
	 */
	public boolean getSesCheck() {
		return m_bSessionCheck;
	}

	/**
	 * get dbconnection
	 * @return dbconnection String
	 */
	public boolean getDBCon() {
		return m_bDBConnection;
	}

	/**
	 * get data source
	 * @return data source String
	 */
	public String getDataSource() {
		return m_strDataSource;
	}

	/**
	 * get rect
	 * @return rect Rectangle
	 */
	public Rectangle getRect() {
		return m_objRect;
	}

	/**
	 * get url access
	 * @return url access boolean
	 */
	public boolean getUrlAccess() {
		return m_bUrlAccess;
	}

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

	/**
	 * @return
	 */
	public String getValidateType() {
		return m_strValidateType;
	}

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

	/**
	 * set rect
	 * @param rect
	 */
	public void setRect(Rectangle rect) {
		m_objRect = rect;
	}

	/**
	 * set page info
	 * @param newInfo
	 */
	public void setPageInfo(Object[] newInfo) {
		Object[] oldInfo = getPageInfo();
		m_objRect =
			new Rectangle(
				((Rectangle) newInfo[0]).x,
				((Rectangle) newInfo[0]).y,
		        ((Rectangle) newInfo[0]).width,
				((Rectangle) newInfo[0]).height);
		m_strPageName = (String) newInfo[1];
		m_strPackageName = (String) newInfo[2];
		m_strBaseType = (String) newInfo[3];
		m_strScope = (String) newInfo[4];
		m_strErrorAction = (String) newInfo[5];
		m_strInitAction = (String) newInfo[6];
		m_strUpdateTime = (String) newInfo[7];
		m_strDataSource = (String) newInfo[8];
		m_strDescription = (String) newInfo[9];
		m_strFormType = (String) newInfo[10];
		m_bSessionCheck = ((Boolean) newInfo[11]).booleanValue();
		m_bSecurityCheck = ((Boolean) newInfo[12]).booleanValue();
		m_bDBConnection = ((Boolean) newInfo[13]).booleanValue();
		m_bUrlAccess = ((Boolean) newInfo[14]).booleanValue();
		m_strValidateType = (String) newInfo[15];
		m_bGlobalForward = ((Boolean) newInfo[16]).booleanValue();
		m_vModuleForwardName = (Vector) newInfo[17];
		m_vModuleForwardAction = (Vector) newInfo[18];		
		setState("false");
		//通知改动
		firePropertyChanged("pageInfo", oldInfo, newInfo);

	}

	/**
	 * get page info
	 * @return page info Object[]
	 */
	public Object[] getPageInfo() {
		Object[] newInfo = new Object[19];
		newInfo[0] = new Rectangle(m_objRect.x, m_objRect.y, m_objRect.width, m_objRect.height);
		newInfo[1] = m_strPageName;
		newInfo[2] = m_strPackageName;
		newInfo[3] = m_strBaseType;
		newInfo[4] = m_strScope;
		newInfo[5] = m_strErrorAction;
		newInfo[6] = m_strInitAction;
		newInfo[7] = m_strUpdateTime;
		newInfo[8] = m_strDataSource;
		newInfo[9] = m_strDescription;
		newInfo[10] = m_strFormType;
		newInfo[11] = new Boolean(m_bSessionCheck);
		newInfo[12] = new Boolean(m_bSecurityCheck);
		newInfo[13] = new Boolean(m_bDBConnection);
		newInfo[14] = new Boolean(m_bUrlAccess);
		newInfo[15] = m_strValidateType;
		newInfo[16] = new Boolean(m_bGlobalForward);
		newInfo[17] = m_vModuleForwardName;
		newInfo[18] = m_vModuleForwardAction;
		
		return newInfo;
	}

	/**
	 * restore properties
	 * @param name
	 * @param oldValue
	 * @param newValue
	 */
	public void restoreProperty(String name, Object oldValue, Object newValue)
		throws CoreException {
		Object[] oldInfo = (Object[]) newValue;
		m_objRect =
			new Rectangle(
				((Rectangle) oldInfo[0]).x,
				((Rectangle) oldInfo[0]).y,
				((Rectangle) oldInfo[0]).width,
				((Rectangle) oldInfo[0]).height);
		m_strPageName = (String) oldInfo[1];
		m_strPackageName = (String) oldInfo[2];
		m_strBaseType = (String) oldInfo[3];
		m_strScope = (String) oldInfo[4];
		m_strErrorAction = (String) oldInfo[5];
		m_strInitAction = (String) oldInfo[6];
		m_strUpdateTime = (String) oldInfo[7];
		m_strDataSource = (String) oldInfo[8];
		m_strDescription = (String) oldInfo[9];
		m_strFormType = (String) oldInfo[10];
		m_bSessionCheck = ((Boolean) oldInfo[11]).booleanValue();
		m_bSecurityCheck = ((Boolean) oldInfo[12]).booleanValue();
		m_bDBConnection = ((Boolean) oldInfo[13]).booleanValue();
		m_bUrlAccess = ((Boolean) oldInfo[14]).booleanValue();
		m_strValidateType = (String) oldInfo[15];
		m_bGlobalForward = ((Boolean) oldInfo[16]).booleanValue();
		m_vModuleForwardName = (Vector) oldInfo[17];
		m_vModuleForwardAction = (Vector) oldInfo[18];
		((Model) getModel()).getResource().getCanvas().redraw();
		setState("false");
		firePropertyChanged("pageInfo", oldValue, newValue);
	}

	/**
	 * Draw rect of the page
	 * @param gc
	 * @param display
	 */
	private void drawRect(GC gc, Display display) {
		//保存配置
		Color oldForeColor = gc.getForeground();
		Color oldBackColor = gc.getBackground();

		gc.setXORMode(false);
		gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
		if (m_strBaseType.toLowerCase().equals("error")) {
			//代牦页面显示黄色
			gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
		} else {
			//基本页面显示灰色
			gc.setBackground(display.getSystemColor(SWT.COLOR_GRAY));
		}
		//绘制矩形
		gc.fillRectangle(m_objRect);
		//绘制实边

⌨️ 快捷键说明

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