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

📄 businessnode.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.UIManager;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

import flow.graph.app.FlowManager;
import flow.graph.db.SQLiteConnection;
import flow.graph.db.bean.DataBaseNode;
import flow.graph.db.bean.NodeBean;
import flow.graph.gui.graph.GraphManager;

/**
* @author matt
*
*/
//public class BusinessNode implements ServerTreeViewSelectionListener, IconItem, TreePathable, IconListView.Activateable,Deleteable {
public class BusinessNode implements ServerTreeViewSelectionListener, IconItem, TreePathable, IconListView.Activateable,Deleteable {
	private ServiceNode serviceNode;
	private NodeBean nodeBean;
	private GraphManager manager;
	private HilighterCodePrinter codePrinter;
	
	static ImageIcon icon = null;
	static {
		try { icon = new ImageIcon(ServiceNode.class.getResource("images/new_bus.gif")); } catch (Exception e) { e.printStackTrace(); }
	}
	
	public BusinessNode(NodeBean bean,ServiceNode service) {
		nodeBean = bean;
		serviceNode = service;
		//System.out.println(bean.getT_graph());
		//manager = new GraphManager(null);
		//System.out.println("*************************");
		if(manager == null){
			manager = new GraphManager();
			manager.readGraphString(this);
			//System.out.println("*************************");
		}
		if(codePrinter == null){
			codePrinter = new HilighterCodePrinter();
		}
	}
	
	public String toString() {
		return nodeBean.getT_desc();
	}
	
	public boolean equals(Object o) {
		if (o instanceof BusinessNode){
			BusinessNode bn = (BusinessNode)o;
			if(bn.getNodeBean().getT_id() == nodeBean.getT_id())
				return true;
			else
				return false;
		}
		else
			return false;
	}
	
	/* (non-Javadoc)
	 * @see com.safmq.manager.ServerTreeViewSelectionListener#doSelection()
	 */
	public void doSelection(JTree tree, DefaultMutableTreeNode node) {
		//System.out.println("BusinessNode select...");
		//FlowManager.getInstance().setControlView(new UserEditor(this));
				
		//System.out.println(nodeBean.getT_graph());
		manager.setFocusable(true);
		//System.out.println(nodeBean.getT_graph());
		//System.out.println("length . ="+manager.getGraph().getRoots().length);
		if(manager.getGraph().getRoots().length <= 0)
			manager.graphInit();
		//FlowManager.getInstance().setControlView(manager);
		GraphTabPanel tab = new GraphTabPanel(manager, codePrinter);
		FlowManager.getInstance().setControlView(tab);
		tab.requestFocus();
		//manager.requestFocus();
		//setNodeChildren(tree, node);
		//System.out.println("node="+node);
		//setPath(new TreePath(node.getPath()));
	}

	/**
	 * 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() {
		System.out.println("Business activate...1");
		if (getPath() != null) {
			System.out.println("Business activate...2");
			FlowManager.getInstance().getTreeView().activatePath(getPath());
			System.out.println(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() {
		int res = JOptionPane.showConfirmDialog(FlowManager.getInstance(),
				"确定要删除节点 \""+toString()+"\"?\n",
				"系统删除操作提示",
				JOptionPane.YES_NO_OPTION);
		if (res == JOptionPane.YES_OPTION) {
			FlowManager.getInstance().deleteBusinessNode(this);
		}
		return true;
	}

	public boolean updateGraph() {
		Connection con = SQLiteConnection.getConnection();
		if(con == null){
			int res = JOptionPane.showConfirmDialog(FlowManager.getInstance(),
					"Connect data base \""+SQLiteConnection.SQLite_DATABASE+"\" failed!",
					"System Infomation",
					JOptionPane.CLOSED_OPTION);	
			return false;
		}
		else{
			try {
				DataBaseNode.updateNodeProgram(con, nodeBean);
				//System.out.println
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				int res = JOptionPane.showConfirmDialog(FlowManager.getInstance(),
						"DataBase error: \""+e.getMessage()+"!",
						"DataBase Error",
						JOptionPane.CLOSED_OPTION);	
				return false;
			}
		}
		return true;
	}
	
	/**
	 * @see com.safmq.manager.Deleteable#getDescription()
	 */
	public String getDescription() {
		return "节点 "+nodeBean.getT_desc();
	}
	
	/**
	 * @return
	 */
	public NodeBean getNodeBean() {
		return nodeBean;
	}

	/**
	 * @return
	 */
	public ServiceNode getServiceNode() {
		return serviceNode;
	}

}

⌨️ 快捷键说明

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