📄 workflow.java
字号:
/**
*
*/
package flow.graph.app;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.net.URL;
import flow.graph.gui.tree.ServiceList;
import flow.graph.gui.tree.ServiceTreeView;
import flow.graph.gui.tree.*;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSplitPane;
import javax.swing.JToolBar;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
import com.jgoodies.looks.Options;
import com.jgoodies.looks.demo.Settings;
import com.jgoodies.looks.plastic.PlasticLookAndFeel;
import com.jgoodies.uif_lite.panel.SimpleInternalFrame;
/**
* @author Administrator
*
*/
public class WorkFlow extends JFrame implements Runnable{
StartList services;
ServiceTreeView treeView;
JPanel controlView = new JPanel();
private static WorkFlow theManager = null;
public WorkFlow() {
super("WorkFlow Manager");
configureUI();
services = new StartList();
treeView = new ServiceTreeView(services);
JMenuBar bar = new JMenuBar();
JMenu file = new JMenu("文件(F)");
file.setMnemonic(KeyEvent.VK_F);
file.add(treeView.getNewServiceAction());
file.add(treeView.getModifyServiceAction());
file.addSeparator();
file.add(treeView.getNewNodeAction());
file.add(treeView.getModifyNodeAction());
file.addSeparator();
file.add(treeView.getDeleteAction());
file.addSeparator();
file.add(new SimpleAction("Exit", new Integer(KeyEvent.VK_X), true) {
public void actionPerformed(ActionEvent e){ WorkFlow.getInstance().hide(); }
});
bar.add(file);
this.setJMenuBar(bar);
controlView.setLayout(new GridLayout());
controlView.setMinimumSize(new Dimension(50,50));
controlView.setPreferredSize(new Dimension(400,400));
//SimpleInternalFrame sif = new SimpleInternalFrame("业务列表");
SimpleInternalFrame sif = new SimpleInternalFrame("");
sif.setPreferredSize(new Dimension(200, 100));
sif.add(treeView);
JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sif, controlView);
sp.setOpaque(true);
this.setLayout(new BorderLayout());
getContentPane().add(sp, BorderLayout.CENTER);
//setContentPane(sp);
createToolBar(treeView);
this.pack();
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
private Action createButton(String gif){
String url = "images/"+gif;
//System.out.println(url);
ImageIcon cutIcon = new ImageIcon(WorkFlow.class.getResource(url));
Action cutundo = new AbstractAction("", cutIcon) {
public void actionPerformed(ActionEvent e) {
//
}
};
return cutundo;
}
private void createToolBar(ServiceTreeView tv){
JToolBar toolbar = new JToolBar();
toolbar.setBorderPainted(true);
toolbar.setFloatable(true);
ImageIcon newIcon = new ImageIcon(WorkFlow.class.getResource("images/new.gif"));
Action newaction = new AbstractAction("", newIcon) {
public void actionPerformed(ActionEvent e) {
//WorkFlow.getInstance().hide();
String name = JOptionPane.showInputDialog(WorkFlow.getInstance(),
"请输入新节点名称",
"新建节点",
JOptionPane.QUESTION_MESSAGE);
System.out.println("name="+name);
}
};
toolbar.add(newaction);
//toolbar.add(createButton("about.gif"));
toolbar.add(createButton("copy.gif"));
toolbar.add(createButton("cut.gif"));
toolbar.addSeparator();
toolbar.add(createButton("next.gif"));
toolbar.add(createButton("prev.gif"));
toolbar.addSeparator();
toolbar.add(createButton("find.gif"));
toolbar.add(createButton("help.gif"));
toolbar.add(createButton("new.gif"));
toolbar.addSeparator();
toolbar.add(createButton("print.gif"));
toolbar.add(createButton("saveall.gif"));
toolbar.add(createButton("save.gif"));
toolbar.add(createButton("tips.gif"));
toolbar.add(createButton("text.gif"));
toolbar.add(createButton("undo.gif"));
toolbar.addSeparator();
ImageIcon exitIcon = new ImageIcon(WorkFlow.class.getResource("images/tips.gif"));
Action exitundo = new AbstractAction("", exitIcon) {
public void actionPerformed(ActionEvent e) {
//WorkFlow.getInstance().hide();
System.exit(0);
}
};
toolbar.add(exitundo);
/*
toolbar.add(createButton("next.gif"));
toolbar.add(createButton("flow/graph/app/images/prev.gif"));
toolbar.add(createButton("flow/graph/app/images/find.gif"));
toolbar.add(createButton("flow/graph/app/images/help.gif"));
toolbar.add(createButton("flow/graph/app/images/new.gif"));
toolbar.add(createButton("flow/graph/app/images/print.gif"));
toolbar.add(createButton("flow/graph/app/images/saveall.gif"));
toolbar.add(createButton("flow/graph/app/images/save.gif"));
toolbar.add(createButton("flow/graph/app/images/tips.gif"));
toolbar.add(createButton("flow/graph/app/images/text.gif"));
toolbar.add(createButton("flow/graph/app/images/undo.gif"));
*/
/*
//toolbar.add(new SimpleAction("New", ));
toolbar.add(treeView.getNewUserAction());
toolbar.add(treeView.getNewGroupAction());
toolbar.addSeparator();
toolbar.add(treeView.getDeleteAction());
toolbar.addSeparator();
*/
/*
JButton button = new JButton(readImageIcon("new.gif"));
button.setToolTipText("new");
button.setFocusable(false);
toolbar.add(button);
*/
getContentPane().add(toolbar, BorderLayout.NORTH);
}
protected ImageIcon readImageIcon(String filename) {
URL url = WorkFlow.class.getResource("images/" + filename);
return new ImageIcon(url);
}
public static synchronized WorkFlow getInstance() {
if (theManager == null)
theManager = new WorkFlow();
return theManager;
}
public void handleNetworkError(ServiceList svr) {
JOptionPane.showMessageDialog(this,"An error occurred communicating with safmq://"+svr.toString(),
"Network Error",JOptionPane.ERROR_MESSAGE);
services.handleNetworkError(svr);
treeView.resetChildren(svr, "Connection Closed by Server");
}
public void handleNetworkError(String msg, ServiceList svr) {
JOptionPane.showMessageDialog(this,msg,"Network Error",JOptionPane.ERROR_MESSAGE);
services.handleNetworkError(svr);
treeView.resetChildren(svr, "Connection Closed by Server");
}
public void storeList() {
//servers.store();
}
public void run() {
//services.load();
}
public StartList getStartList(){
return services;
}
public ServiceTreeView getTreeView() {
return treeView;
}
public void setControlView(Component c) {
//controlView.setViewportView(c);
controlView.removeAll();
controlView.add(c);
controlView.validate();
}
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.setCurrentTheme(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);
}
}
public static void main(String args[]) {
WorkFlow.getInstance().run();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -