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

📄 whileform.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.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
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.While;

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

	private JTextField condictionField;
	private JButton exitButton;
	
	public WhileForm(DefaultGraphCell cell, JGraph graph){
		this.cell = cell;
		this.graph = graph;
		
		if(FlowGraphConstants.getBpelWhile(cell.getAttributes()) == null){
			FlowGraphConstants.setBpelWhile(cell.getAttributes(), new While());
		}
		
		dialog = new JDialog(FlowManager.getInstance(), "While数据编辑窗口", true);
		
		condictionField = new JTextField(50);
		if(FlowGraphConstants.getBpelWhile(cell.getAttributes()) != null){
			condictionField.setText(((While)FlowGraphConstants.getBpelWhile(cell.getAttributes())).getCondiction());
		}
		
		exitButton = new JButton("关  闭");
		exitButton.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				saveData();
			}			
		});
		
		dialog.getContentPane().setLayout(new BorderLayout());
		JPanel panel = new JPanel(new BorderLayout());
		panel.setBorder(new TitledBorder(""));
		
		Box box = Box.createHorizontalBox();
		box.add(new JLabel("循环条件:"));
		box.add(condictionField);
		
		Box layoutBox = Box.createVerticalBox();
		JPanel controlPanel = new JPanel(new FlowLayout());
		controlPanel.add(exitButton);
		
		layoutBox.add(box);
		layoutBox.add(Box.createVerticalStrut(5));
		layoutBox.add(controlPanel);
		
		panel.add(layoutBox, 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
				if(saveData() == false)
					return;
			}

			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.getContentPane().add(panel, BorderLayout.CENTER);
		dialog.setSize(450, 100);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		dialog.setLocation((screenSize.width-450)/2, (screenSize.height-100)/2);
		dialog.setResizable(true);
		dialog.show();		
	}
	
	private boolean saveData(){
		if(condictionField.getText().length() <= 0){
			JOptionPane.showConfirmDialog(FlowManager.getInstance(),
					"循环条件不能为空!",
					"工作流操作提示",
					JOptionPane.CLOSED_OPTION);
			return false;
		}
		((While)FlowGraphConstants.getBpelWhile(cell.getAttributes())).setCondiction(condictionField.getText());
		dialog.dispose();
		return true;
	}
	
	public static void main(String[] args){
		AssignForm.configureUI();
		new WhileForm(new DefaultGraphCell(), new JGraph());
	}
}

⌨️ 快捷键说明

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