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

📄 functionbodyform.java

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

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.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
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.cell.bpel.Function;
import flow.graph.gui.graph.cell.bpel.Functions;
import flow.graph.gui.syntax.JHightLightLineTextPane;

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

	private JHightLightLineTextPane functionBody;
	
	public FunctionBodyForm(DefaultGraphCell cell, JGraph graph, String name){
		this.cell = cell;
		this.graph = graph;
		this.name = name;
		String params = "";
		dialog = new JDialog(FlowManager.getInstance(), "定义函数体窗口", true);
		
		functionBody = new JHightLightLineTextPane();
		if(FlowGraphConstants.getBpelFunctions(cell.getAttributes()) != null){
			for(int i=0;i<((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).getFunctions().size();i++){
				Function function = ((Function)((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).getFunctions().get(i));
				if(function.getName().equals(name)){
					functionBody.setText(function.getBody());
					params = function.getParameter();
				}
			}
		}
		
		JPanel textPanel = new JPanel(new BorderLayout());
		textPanel.setBorder(new TitledBorder("定义函数:"+name));
		textPanel.add(new JLabel("<html><B><font color=\"blue\">function</font></B> <B><font color=\"red\">"+name+"</font></B>("+params+")"+"</html>"));

		JPanel bodyPanel = new JPanel(new BorderLayout());
		bodyPanel.setBorder(new TitledBorder(""));
		bodyPanel.add(functionBody, BorderLayout.WEST);
		bodyPanel.add(functionBody.scrollPane, BorderLayout.CENTER);
		bodyPanel.add(functionBody.staturBar, BorderLayout.SOUTH);
		
		JPanel controlPanel = new JPanel(new FlowLayout());
		JButton closeButton = new JButton("关  闭");
		closeButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				saveData();
			}
		});
		controlPanel.add(closeButton);
		//layoutBox.add(Box.createVerticalStrut(2));
		//layoutBox.add(controlPanel);
		JPanel layoutPanel = new JPanel(new BorderLayout());
		layoutPanel.add(textPanel, BorderLayout.NORTH);
		layoutPanel.add(bodyPanel, BorderLayout.CENTER);
		layoutPanel.add(controlPanel, BorderLayout.SOUTH);
		
		dialog.getContentPane().setLayout(new BorderLayout());
		dialog.getContentPane().add(layoutPanel, BorderLayout.CENTER);
		dialog.setSize(550, 500);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		dialog.setLocation((screenSize.width-550)/2, (screenSize.height-500)/2);
		dialog.setResizable(false);
		
		dialog.add(layoutPanel, BorderLayout.CENTER);
		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.getBpelFunctions(cell.getAttributes()) != null){
			for(int i=0;i<((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).getFunctions().size();i++){
				Function function = ((Function)((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).getFunctions().get(i));
				if(function.getName().equals(name)){
					((Function)((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).getFunctions().get(i)).setBody(functionBody.getText());
				}
			}
		}
		dialog.dispose();
	}
	
	public static void main(String[] args){
		AssignForm.configureUI();
		new FunctionBodyForm(new DefaultGraphCell(), new JGraph(), "哈哈哈");
	}
}

⌨️ 快捷键说明

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