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

📄 extendsform.java

📁 JGraph扩展应用。自定义Renderer,自定义视图View实现自定义工作流控件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		
		inputTable.addMouseListener(new MouseListener(){

			public void mouseClicked(MouseEvent e) {
				// TODO Auto-generated method stub
				inputRowID = inputTable.rowAtPoint(e.getPoint());
				int columnID = inputTable.columnAtPoint(e.getPoint());
				inputName.setText(((InputParameterTableModel)inputTable.getModel()).getValueAt(inputRowID, 0).toString());
				inputType.setSelectedItem(((InputParameterTableModel)inputTable.getModel()).getValueAt(inputRowID, 1).toString());
				inputFlag.setSelected(((Boolean)((InputParameterTableModel)inputTable.getModel()).getValueAt(inputRowID, 2)).booleanValue());
				inputSource.setSelectedItem(((InputParameterTableModel)inputTable.getModel()).getValueAt(inputRowID, 3).toString());
				inputValue.setText(((InputParameterTableModel)inputTable.getModel()).getValueAt(inputRowID, 4).toString());
				inputDiscription.setText(((InputParameterTableModel)inputTable.getModel()).getValueAt(inputRowID, 5).toString());
			}

			public void mousePressed(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}

			public void mouseReleased(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}

			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}

			public void mouseExited(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}});
		inputModifyButton.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				if(inputRowID != -1){
					if(inputName.getText().length() <= 0){
						JOptionPane.showConfirmDialog(FlowManager.getInstance(),
								"变量名称不能为空!",
								"工作流操作提示",
								JOptionPane.CLOSED_OPTION);
						inputName.requestFocus();
						return;
					}
					if(inputType.getSelectedIndex() == 0){
						JOptionPane.showConfirmDialog(FlowManager.getInstance(),
								"请选择数据类型!",
								"工作流操作提示",
								JOptionPane.CLOSED_OPTION);
						inputType.requestFocus();
						return;
					}
					if(inputFlag.isSelected() == true){
						if(inputSource.getSelectedIndex() <= 0){
							JOptionPane.showConfirmDialog(FlowManager.getInstance(),
									"请选择数据来源!",
									"工作流操作提示",
									JOptionPane.CLOSED_OPTION);
							inputSource.requestFocus();
							return;
						}
					}
					
					//////////////////////////
					//判断变量名是否已经存在
					for(int i=0;i<((InputParameterTableModel)inputTable.getModel()).getRowCount();i++){
						if(i == inputRowID)
							continue;
						if(((InputParameterTableModel)inputTable.getModel()).getValueAt(i, 0).toString().equalsIgnoreCase(inputName.getText())){
							JOptionPane.showConfirmDialog(FlowManager.getInstance(),
									"变量"+inputName.getText()+" 已经存在!",
									"工作流操作提示",
									JOptionPane.CLOSED_OPTION);
							inputName.requestFocus();
							return;
						}
					}
					String name = ((InputParameterTableModel)inputTable.getModel()).getValueAt(inputRowID, 0).toString();
					int index = ((InputParameters)FlowGraphConstants.getInputTemplate(cell.getAttributes())).getExistsParameter(name);
					if(index >= 0){
						((InputParameter)((InputParameters)FlowGraphConstants.getInputTemplate(cell.getAttributes())).getParameters().get(index)).setName(inputName.getText());
						((InputParameter)((InputParameters)FlowGraphConstants.getInputTemplate(cell.getAttributes())).getParameters().get(index)).setType(inputType.getSelectedItem().toString());
						((InputParameter)((InputParameters)FlowGraphConstants.getInputTemplate(cell.getAttributes())).getParameters().get(index)).setFlag(inputFlag.isSelected());
						((InputParameter)((InputParameters)FlowGraphConstants.getInputTemplate(cell.getAttributes())).getParameters().get(index)).setSource(inputSource.getSelectedItem().toString());
						((InputParameter)((InputParameters)FlowGraphConstants.getInputTemplate(cell.getAttributes())).getParameters().get(index)).setValue(inputValue.getText());
						((InputParameter)((InputParameters)FlowGraphConstants.getInputTemplate(cell.getAttributes())).getParameters().get(index)).setDiscription(inputDiscription.getText());
					}
					
					((InputParameterTableModel)inputTable.getModel()).setValueAt(inputName.getText(), inputRowID, 0);
					((InputParameterTableModel)inputTable.getModel()).setValueAt(inputType.getSelectedItem().toString(), inputRowID, 1);
					((InputParameterTableModel)inputTable.getModel()).setValueAt(inputFlag.isSelected(), inputRowID, 2);
					((InputParameterTableModel)inputTable.getModel()).setValueAt(inputSource.getSelectedItem().toString(), inputRowID, 3);
					((InputParameterTableModel)inputTable.getModel()).setValueAt(inputValue.getText(), inputRowID, 4);
					((InputParameterTableModel)inputTable.getModel()).setValueAt(inputDiscription.getText(), inputRowID, 5);
					inputName.setText("");
					inputType.setSelectedIndex(0);
					inputFlag.setSelected(false);
					inputSource.setSelectedIndex(0);
					inputValue.setText("");
					inputDiscription.setText("");					
				}
				inputRowID = -1;
			}});
		inputDeleteButton.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				if(inputRowID != -1){
					((InputParameterTableModel)inputTable.getModel()).removeRow(inputRowID);
					int index = ((InputParameters)FlowGraphConstants.getInputTemplate(cell.getAttributes())).getExistsParameter(inputName.getText());
					if(index >= 0){
						((InputParameters)FlowGraphConstants.getInputTemplate(cell.getAttributes())).getParameters().remove(index);
					}
					inputName.setText("");
					inputType.setSelectedIndex(0);
					inputFlag.setSelected(false);
					inputSource.setSelectedIndex(0);
					inputValue.setText("");
					inputDiscription.setText("");					
				}
				inputRowID = -1;
			}});
		
		
		///////////////////////////////////
		
		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);
				
		Box listLayout = Box.createVerticalBox();
		listLayout.add(inputTitledPanel);
		listLayout.add(codePanel);
		dialog.getContentPane().add(listLayout, BorderLayout.CENTER);
		dialog.getContentPane().add(exitPanel, BorderLayout.SOUTH);
		
		dialog.setSize(700, 650);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		dialog.setLocation((screenSize.width-700)/2, (screenSize.height-650)/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());
		}
		inputType.setPopupVisible(false);
		inputSource.setPopupVisible(false);
		dialog.dispose();
		LuaExtendsParse parse = new LuaExtendsParse(cell);
		System.out.println(parse.getDiscriptionCode());
		System.out.println(parse.getExecuteCode());
	}
	
	public static void main(String[] args){
		CaseForm.setLookAndFeel();
		DefaultGraphCell cell = new DefaultGraphCell();
		cell.addPort();
		new ExtendsForm(cell, new JGraph());
	}
}

⌨️ 快捷键说明

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