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

📄 node.java

📁 JGraph扩展应用。自定义Renderer,自定义视图View实现自定义工作流控件
💻 JAVA
字号:
/*
Copyright 2005 Matthew J. Battey

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in writing, software distributed
	under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
	CONDITIONS OF ANY KIND, either express or implied. See the License for the
	specific language governing permissions and limitations under the License.

This software implements a Java application to manage a SAFMQ server.
		
Created on May 13, 2005
*/
package flow.graph.gui.tree;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

import flow.graph.app.WorkFlow;
import flow.graph.db.SQLiteConnection;
import flow.graph.db.bean.DataBaseNode;
import flow.graph.db.bean.DataBaseService;
import flow.graph.db.bean.NodeBean;
import flow.graph.db.bean.ServiceBean;

/**
* @author matt
*
*/
public class Node implements TreeViewSelectionListener, IconItem, TreePathable, IconListView.Activateable,Deleteable {
	NodeBean nodebean;
	ServiceBean servicebean;
	AbstractTreeNode absNode;
	
	static ImageIcon icon = null;
	static {
		try {
			icon = new ImageIcon(Node.class.getResource("images/node.gif"));
		} catch (Exception e) {
		}
	}
	
	public Node(NodeBean node, ServiceBean service, AbstractTreeNode abs) {
		this.nodebean = node;
		this.servicebean = service;
		absNode = abs;
	}
	
	public ServiceBean getServiceBean(){
		return servicebean;
	}
	
	public NodeBean getNodeBean(){
		return nodebean;
	}
	
	public AbstractTreeNode getAbs(){
		return absNode;
	}
	
	public String toString() {
		return nodebean.getT_desc();		
	}
	
	public boolean equals(Object o) {
		return o == this || ((o instanceof Node));	
	}
	
	/* (non-Javadoc)
	 * @see com.safmq.manager.ServerTreeViewSelectionListener#doSelection()
	 */
	public void doSelection(JTree tree, DefaultMutableTreeNode node) {
		//Manager.getInstance().setControlView(new UserEditor(this));
	}

	/**
	 * Provides the User icon for the list of SAFMQ users
	 * 
	 * @see com.safmq.manager.IconItem#getIcon()
	 */
	public Icon getIcon() {
		return icon;
	}
	
	/**
	 * @see com.safmq.manager.IconListView.Activateable#activate()
	 */
	public void activate() {
		if (getPath() != null) {
			WorkFlow.getInstance().getTreeView().activatePath(getPath());	
		}
	}

	TreePath treePath = null;
	/**
	 * @see com.safmq.manager.TreePathable#getPath()
	 */
	public TreePath getPath() {
		return treePath;
	}

	/**
	 * @see com.safmq.manager.TreePathable#setPath(javax.swing.tree.TreePath)
	 */
	public void setPath(TreePath path) {
		treePath = path;
	}
	
	/**
	 * @see com.safmq.manager.Deleteable#delete()
	 */
	public boolean delete() {
		Connection con = SQLiteConnection.getConnection();
		if(con == null){
			int res = JOptionPane.showConfirmDialog(WorkFlow.getInstance(),
					"Connect data base \""+SQLiteConnection.SQLite_DATABASE+"\" failed!",
					"System Infomation",
					JOptionPane.CLOSED_OPTION);	
			return false;
		}
		else{
			try {
				if(DataBaseNode.deleteNode(con, nodebean.getT_id()) > 0){	
				}
				else{
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				System.out.println("2.5............");
				int res = JOptionPane.showConfirmDialog(WorkFlow.getInstance(),
						"DataBase error: \""+e.getMessage()+"!",
						"DataBase Error",
						JOptionPane.CLOSED_OPTION);	
				return false;
			}
		}
		return true;
	}
	
	/**
	 * @see com.safmq.manager.Deleteable#getDescription()
	 */
	public String getDescription() {
		return "Node \""+nodebean.getT_desc()+"\"";
	}
	
	public void handleNetworkError() {
		//con = null;	
	}
	
}

⌨️ 快捷键说明

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