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

📄 blankform.java

📁 JGraph扩展应用。自定义Renderer,自定义视图View实现自定义工作流控件
💻 JAVA
字号:
/**
 * 
 */
package flow.graph.gui.graph.lua.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

import org.jgraph.JGraph;
import org.jgraph.graph.DefaultGraphCell;

import flow.graph.app.FlowManager;
import flow.graph.gui.graph.FlowGraphConstants;
import flow.graph.gui.graph.lua.code.LuaInvokeParse;
import flow.graph.gui.graph.lua.gui.function.FunctionTree;
import flow.graph.gui.graph.lua.xml.ActionTemplate;
import flow.graph.gui.syntax.JHightLightLineTextPane;

/**
 * @author Administrator
 *
 */
public class BlankForm {
	private DefaultGraphCell cell;
	private JGraph graph;
	private JDialog dialog;

	private JHightLightLineTextPane actionArea;

	public BlankForm(final DefaultGraphCell cell, JGraph graph){
		this.cell = cell;
		this.graph = graph;
		
		if(FlowGraphConstants.getActionTemplate(cell.getAttributes()) == null){
			FlowGraphConstants.setActionTemplate(cell.getAttributes(), new ActionTemplate());
		}		
		
		dialog = new JDialog(FlowManager.getInstance(), "参数配置", true);
		actionArea = new JHightLightLineTextPane();
		JPanel actionPanel = new JPanel(new BorderLayout());
		actionPanel.setPreferredSize(new Dimension(250, 110));
		//actionPanel.setBorder(new TitledBorder("代码"));
		//actionPanel.add(new JScrollPane(actionArea), BorderLayout.CENTER);
		actionPanel.add(actionArea, BorderLayout.WEST);
		actionPanel.add(actionArea.scrollPane, BorderLayout.CENTER);
		actionPanel.add(actionArea.staturBar, BorderLayout.SOUTH);
		
		JButton exitButton = new JButton("关  闭");
		exitButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				saveData();
			}			
		});
		JPanel exitPanel = new JPanel(new FlowLayout());
		exitPanel.add(exitButton);
		
		///////////////////////////////////////////////////////////
		//初始化actionArea
		if(FlowGraphConstants.getActionTemplate(cell.getAttributes()) != null){
			ActionTemplate action = (ActionTemplate)FlowGraphConstants.getActionTemplate(cell.getAttributes());
			//actionArea.setText(action.getAction().length()<=0?TemplateConstants.ACTION_TEMPLATE:action.getAction());
			actionArea.setText(action.getAction());
		}
		Box actionBox = Box.createHorizontalBox();
		JPanel tipsPanel = new JPanel(new BorderLayout());
		tipsPanel.setBorder(new TitledBorder("函数参考"));
		tipsPanel.setPreferredSize(new Dimension(1, 100));
		tipsPanel.add(new FunctionTree(graph).getTree(), BorderLayout.CENTER);
		actionBox.add(actionPanel);
		actionBox.add(tipsPanel);
		
		JPanel codePanel = new JPanel(new BorderLayout());
		codePanel.setBorder(new TitledBorder("代码"));
		codePanel.add(actionBox, BorderLayout.CENTER);
				
		dialog.getContentPane().add(codePanel, BorderLayout.CENTER);
		dialog.getContentPane().add(exitPanel, BorderLayout.SOUTH);
		dialog.setSize(800, 500);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		dialog.setLocation((screenSize.width-800)/2, (screenSize.height-500)/2);
		dialog.setResizable(false);
		dialog.addWindowListener(new WindowListener(){

			public void windowOpened(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}

			public void windowClosing(WindowEvent e) {
				// TODO Auto-generated method stub
				saveData();
			}

			public void windowClosed(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}

			public void windowIconified(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}

			public void windowDeiconified(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}

			public void windowActivated(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}

			public void windowDeactivated(WindowEvent e) {
				// TODO Auto-generated method stub
				
			}
		});
		dialog.show();		
	}
	
	private void saveData(){
		if(FlowGraphConstants.getActionTemplate(cell.getAttributes()) != null){
			((ActionTemplate)FlowGraphConstants.getActionTemplate(cell.getAttributes())).setAction(actionArea.getText());
		}
		//Vector v = GraphTemplateCell.getParameters(cell);
		//System.out.println("-===================ddddddddddd=======================-");
		//for(int i=0;i<v.size();i++){
		//	System.out.println(v.get(i).toString());
		//}
		/*
		LuaInvokeParse parse = new LuaInvokeParse(cell);
		System.out.println(parse.getDiscriptionCode());
		System.out.println(parse.getDefineCode());
		System.out.println(parse.getExecuteCode());
		*/
		dialog.dispose();
	}
}

⌨️ 快捷键说明

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