flowmanager.java

来自「JGraph扩展应用。自定义Renderer,自定义视图View实现自定义工作流」· Java 代码 · 共 622 行 · 第 1/2 页

JAVA
622
字号
		sb1.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				System.out.println("sb1");
			}});
		toolBar.add(sb1);

		toolBar.addSeparator();
		SelectButton sb2 = new SelectButton("", new ImageIcon(FlowManager.class.getResource("images/cut.gif")));
		sb2.setToolTipText("cut");
		sb2.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				System.out.println("sb2");
			}});
		toolBar.add(sb2);

		SelectButton sb3 = new SelectButton("", new ImageIcon(FlowManager.class.getResource("images/find.gif")));
		sb3.setToolTipText("cut");
		sb3.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				System.out.println("sb3");
			}});
		toolBar.add(sb3);

		SelectButton sb4 = new SelectButton("AAA", new ImageIcon(FlowManager.class.getResource("images/save.gif")));
		sb4.setToolTipText("cut");
		sb4.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				System.out.println("sb4");
			}});
		toolBar.add(sb4);
		
		SelectButton sb5 = new SelectButton("", new ImageIcon(FlowManager.class.getResource("images/print.gif")));
		sb5.setToolTipText("cut");
		sb5.addActionListener(new ActionListener(){

			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				System.out.println("sb5");
			}});
		toolBar.add(sb5);

		JButtonGroup bg = new JButtonGroup();
		bg.add(sb1);
		bg.add(sb2);
		bg.add(sb3);
		bg.add(sb4);
		bg.add(sb5);

		this.getContentPane().setLayout(new BorderLayout());
		this.getContentPane().add(toolBar, BorderLayout.NORTH);
	}

	private void createToolBar(ServerTreeView tv){
		JToolBar toolbar = new JToolBar("流程图工具栏");
		//toolbar.setBorderPainted(true);
		toolbar.setFloatable(false);
		toolbar.setLayout(new FlowLayout(FlowLayout.LEFT));
		tv.toolNewServiceAction.setEnabled(false);
		tv.toolNewServiceAction.setToolTipText("新业务");
		tv.toolModifyServiceAction.setEnabled(false);
		tv.toolModifyServiceAction.setToolTipText("修改业务");
		tv.toolNewNodeAction.setEnabled(false);
		tv.toolNewNodeAction.setToolTipText("新节点");
		tv.toolModifyNodeAction.setEnabled(false);
		tv.toolModifyNodeAction.setToolTipText("修改节点");
		toolbar.add(tv.toolNewServiceAction);
		toolbar.add(tv.toolModifyServiceAction);
		toolbar.addSeparator();
		toolbar.add(tv.toolNewNodeAction);
		toolbar.add(tv.toolModifyNodeAction);
		toolbar.addSeparator();
		//toolbar.add(tv.toolDeleteAction);
		toolbar.addSeparator();
		SimpleButton toolExit = new SimpleButton(new ImageIcon(ServerTreeView.class.getResource("images/exit.gif")));
		toolExit.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e)	{
				if (JOptionPane.showConfirmDialog(FlowManager.getInstance(), "要保存所做的更改吗?", "系统正在退出...", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
					System.out.println("System.exit by ask yes.");
				}
				else{
					System.out.println("System.exit by ask no.");
				}
				System.exit(0);
			} 
		});
		toolExit.setToolTipText("退出");
		toolbar.add(toolExit);
		
		getContentPane().add(toolbar, BorderLayout.NORTH);
	}
	
	
	public static synchronized FlowManager getInstance() {	
		//if (theManager == null)
		//	theManager = new FlowManager();		
		return theManager;
	}
	
	public void addNewService() {
		String name = JOptionPane.showInputDialog(FlowManager.getInstance(),
				"请输入新业务名称",
				"新建业务",
				JOptionPane.QUESTION_MESSAGE);
		if (name != null && name.length() > 0) {
			startNode.addService(name);
			treeView.refreshRoot();
		}
	}
	
	/*
	public void addNewNode() {
		String name = JOptionPane.showInputDialog(FlowManager.getInstance(),
				"请输入新节点名称",
				"新建节点",
				JOptionPane.QUESTION_MESSAGE);
		if (name != null && name.length() > 0) {
			startNode.addNode(startNode.getServiceBean().getT_id(), name);
			treeView.refreshRoot();
		}
	}*/
	
	public void deleteServiceNode(ServiceNode s) {
		treeView.deleteServiceNode(s);
		treeView.refreshRoot();
	}
	
	public void deleteBusinessNode(BusinessNode s) {
		treeView.deleteBusinessNode(s);
		treeView.refreshRoot();
	}
	
	/**
	 * Provides access to the tree view pane.
	 * 
	 * @return the pane representing the tree view
	 */
	public ServerTreeView getTreeView() {
		return treeView;
	}

	public void setControlView(Component c) {
		//controlView.setViewportView(c);
		controlView.removeAll();
		controlView.add(c);
		controlView.validate();
		controlView.updateUI();
	}
	
	public void handleNetworkError(ServiceNode svr) {
		JOptionPane.showMessageDialog(this,"An error occurred communicating with safmq://"+svr.getName(),
														"Network Error",JOptionPane.ERROR_MESSAGE);
		startNode.handleNetworkError(svr);
		treeView.resetChildren(svr, "Connection Closed by Server");
	}
	
	public void handleNetworkError(String msg, ServiceNode svr) {
		JOptionPane.showMessageDialog(this,msg,"Network Error",JOptionPane.ERROR_MESSAGE);
		startNode.handleNetworkError(svr);
		treeView.resetChildren(svr, "Connection Closed by Server");
	}
	
	public void storeList() {
		//servers.store();	
	}
	
	public void run() {
		//startNode.load();
	}

	public void configureUI(){
		/*
		Settings settings = Settings.createDefault();
        Options.setDefaultIconSize(new Dimension(18, 18));

        Options.setUseNarrowButtons(settings.isUseNarrowButtons());

        // Global options
        Options.setTabIconsEnabled(settings.isTabIconsEnabled());
        UIManager.put(Options.POPUP_DROP_SHADOW_ENABLED_KEY,
                settings.isPopupDropShadowEnabled());

        // Swing Settings
        LookAndFeel selectedLaf = settings.getSelectedLookAndFeel();
        if (selectedLaf instanceof PlasticLookAndFeel) {
            PlasticLookAndFeel.setPlasticTheme(settings.getSelectedTheme());
            PlasticLookAndFeel.setTabStyle(settings.getPlasticTabStyle());
            PlasticLookAndFeel.setHighContrastFocusColorsEnabled(settings.isPlasticHighContrastFocusEnabled());
        } else if (selectedLaf.getClass() == MetalLookAndFeel.class) {
            MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
        }

        // Work around caching in MetalRadioButtonUI
        JRadioButton radio = new JRadioButton();
        radio.getUI().uninstallUI(radio);
        JCheckBox checkBox = new JCheckBox();
        checkBox.getUI().uninstallUI(checkBox);

        try {
            UIManager.setLookAndFeel(selectedLaf );
        } catch (Exception e) {
            System.out.println("Can't change L&F: " + e);
        }
        */

		try {
			//UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
			//UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticLookAndFeel");
			//UIManager.setLookAndFeel("com.jgoodies.looks.windows.WindowsLookAndFeel");
			//UIManager.setLookAndFeel( new com.nilo.plaf.nimrod.NimRODLookAndFeel());

			com.nilo.plaf.nimrod.NimRODTheme nt = new com.nilo.plaf.nimrod.NimRODTheme();
			//System.out.println("nt="+nt.getOpacity());
			nt.setOpacity(100);
			//nt.setPrimary(Color.LIGHT_GRAY);
			//nt.setPrimary1( new Color(10,10,10));
			//nt.setPrimary2( new Color(20,20,20));
			//nt.setPrimary3( new Color(30,30,30));

			com.nilo.plaf.nimrod.NimRODLookAndFeel NimRODLF = new com.nilo.plaf.nimrod.NimRODLookAndFeel();
			NimRODLF.setCurrentTheme( nt);
			UIManager.setLookAndFeel( NimRODLF);


			//com.nilo.plaf.nimrod.NimRODLookAndFeel nf = new com.nilo.plaf.nimrod.NimRODLookAndFeel();
			//com.nilo.plaf.nimrod.NimRODTheme nt = new com.nilo.plaf.nimrod.NimRODTheme();
			//com.nilo.plaf.nimrod.NimRODLookAndFeel.setCurrentTheme( nt);

			//UIManager.setLookAndFeel( nf);
			
	         //UIManager.setLookAndFeel("org.fife.plaf.Office2003.Office2003LookAndFeel");
	         //UIManager.setLookAndFeel("org.fife.plaf.OfficeXP.OfficeXPLookAndFeel");
	         //UIManager.setLookAndFeel("org.fife.plaf.VisualStudio2005.VisualStudio2005LookAndFeel");
			
			//UIManager.setLookAndFeel(ch.randelshofer.quaqua.QuaquaManager.getLookAndFeelClassName());
		} catch (UnsupportedLookAndFeelException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	private void onWindowClosing(final JFrame frame){
		frame.addWindowListener(new WindowListener(){

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

			public void windowClosing(WindowEvent e) {
				// TODO Auto-generated method stub
				if (JOptionPane.showConfirmDialog(frame, "要保存所做的更改吗?", "系统正在退出...", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION){
					System.out.println("System.exit by ask yes.");
				}
				else{
					System.out.println("System.exit by ask no.");
				}
			}

			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
				
			}});
	}

	public static void main(String args[]) {
		/*
		try {
			UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
			JFrame.setDefaultLookAndFeelDecorated(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
		*/
		//FlowManager.getInstance();
		//System.out.println("args0="+args[0]);
		//System.out.println("args1="+args[1]);
		if(args.length > 0)
			new FlowManager(args[0]);
		else
			new FlowManager("workflow.db");
	}
}

⌨️ 快捷键说明

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