📄 modelform.java
字号:
JOptionPane.CLOSED_OPTION);
return;
}
}
((FunctionTipsTableModel)functionTipsTable.getModel()).addRow(functionTipsName.getText(), functionTipsParameter.getText(), functionTipsDiscription.getText());
FunctionTips functionTips = new FunctionTips(functionTipsName.getText(), functionTipsParameter.getText(), functionTipsDiscription.getText());
((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).addFunctionTips(functionTips);
functionTipsName.setText("");
functionTipsParameter.setText("");
functionTipsDiscription.setText("");
}
});
functionTipsModifyButton = new JButton("修改");
functionTipsModifyButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(functionTipsRowID != -1){
if(functionTipsName.getText().length() <= 0){
//提示不能为空
JOptionPane.showConfirmDialog(FlowManager.getInstance(),
"函数名称不能为空!",
"工作流操作提示",
JOptionPane.CLOSED_OPTION);
functionTipsName.setFocusable(true);
return;
}
for(int i=0;i<((FunctionTipsTableModel)functionTipsTable.getModel()).getRowCount();i++){
if(i == functionTipsRowID)
continue;
if(((FunctionTipsTableModel)functionTipsTable.getModel()).getValueAt(i, 0).toString().equalsIgnoreCase(functionTipsName.getText())){
JOptionPane.showConfirmDialog(FlowManager.getInstance(),
"函数 "+functionTipsName.getText()+" 已经存在!",
"工作流操作提示",
JOptionPane.CLOSED_OPTION);
return;
}
}
if(FlowGraphConstants.getBpelFunctions(cell.getAttributes()) != null){
for(int i=0;i<((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).getFunctionTips().size();i++){
FunctionTips functionTips = ((FunctionTips)((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).getFunctionTips().get(i));
if(functionTips.getName().equals(((FunctionTipsTableModel)functionTipsTable.getModel()).getValueAt(functionTipsRowID, 0))){
((FunctionTips)((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).getFunctionTips().get(i)).setName(functionTipsName.getText());
((FunctionTips)((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).getFunctionTips().get(i)).setParameter(functionTipsParameter.getText());
((FunctionTips)((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).getFunctionTips().get(i)).setDiscription(functionTipsDiscription.getText());
}
}
}
((FunctionTipsTableModel)functionTipsTable.getModel()).setValueAt(functionTipsName.getText(), functionTipsRowID, 0);
((FunctionTipsTableModel)functionTipsTable.getModel()).setValueAt(functionTipsParameter.getText(), functionTipsRowID, 1);
((FunctionTipsTableModel)functionTipsTable.getModel()).setValueAt(functionTipsDiscription.getText(), functionTipsRowID, 2);
functionTipsName.setText("");
functionTipsParameter.setText("");
functionTipsDiscription.setText("") ;
}
functionTipsRowID = -1;
}
});
functionTipsTable = new FunctionTipsTable(cell);
functionTipsTable.setDragEnabled(false);
functionTipsTable.addMouseListener(new MouseListener(){
public void mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
int rowID = functionTipsTable.rowAtPoint(e.getPoint());
functionTipsRowID = rowID;
//System.out.println("rowID="+rowID);
int columnID = functionTipsTable.columnAtPoint(e.getPoint());
functionTipsName.setText(((FunctionTipsTableModel)functionTipsTable.getModel()).getValueAt(rowID, 0).toString());
functionTipsParameter.setText(((FunctionTipsTableModel)functionTipsTable.getModel()).getValueAt(rowID, 1).toString());
functionTipsDiscription.setText(((FunctionTipsTableModel)functionTipsTable.getModel()).getValueAt(rowID, 2).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
}
});
functionTipsDeleteButton = new JButton("删 除");
functionTipsDeleteButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(functionTipsRowID != -1){
if(FlowGraphConstants.getBpelFunctions(cell.getAttributes()) != null){
for(int i=0;i<((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).getFunctionTips().size();i++){
FunctionTips functionTips = ((FunctionTips)((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).getFunctionTips().get(i));
if(functionTips.getName().equals(((FunctionTipsTableModel)functionTipsTable.getModel()).getValueAt(functionTipsRowID, 0))){
((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).getFunctionTips().remove(i);
}
}
}
((FunctionTipsTableModel)functionTipsTable.getModel()).removeRow(functionTipsRowID);
functionTipsName.setText("");
functionTipsParameter.setText("");
functionTipsDiscription.setText("");
}
functionTipsRowID = -1;
}
});
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
closeButton = new JButton("关 闭");
closeButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
//System.out.println(((Functions)FlowGraphConstants.getBpelFunctions(cell.getAttributes())).toString());
saveData();
}
});
JPanel functionTitlePanel = new JPanel(new BorderLayout());
functionTitlePanel.setBorder(new TitledBorder("自定义函数"));
Box funcationLayoutBox = Box.createVerticalBox();
Box funcationAddBox1 = Box.createHorizontalBox();
funcationAddBox1.add(new JLabel("函数名称:"));
funcationAddBox1.add(functionName);
funcationAddBox1.add(Box.createHorizontalStrut(2));
funcationAddBox1.add(new JLabel("参数列表:"));
funcationAddBox1.add(functionParameter);
funcationAddBox1.add(Box.createHorizontalStrut(5));
funcationAddBox1.add(functionAddButton);
funcationAddBox1.add(Box.createHorizontalStrut(2));
funcationAddBox1.add(functionModifyButton);
Box funcationAddBox2 = Box.createHorizontalBox();
funcationAddBox2.add(new JLabel("函数说明:"));
funcationAddBox2.add(functionDiscription);
funcationLayoutBox.add(funcationAddBox1);
funcationLayoutBox.add(Box.createVerticalStrut(2));
funcationLayoutBox.add(funcationAddBox2);
funcationLayoutBox.add(Box.createVerticalStrut(2));
JPanel controlPanel = new JPanel(new FlowLayout());
controlPanel.add(functionDeleteButton);
controlPanel.add(functionDetailButton);
funcationLayoutBox.add(new JScrollPane(functionTable));
funcationLayoutBox.add(Box.createVerticalStrut(2));
funcationLayoutBox.add(controlPanel);
functionTitlePanel.add(funcationLayoutBox, BorderLayout.CENTER);
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
JPanel functionTipsTitlePanel = new JPanel(new BorderLayout());
functionTipsTitlePanel.setBorder(new TitledBorder("定义函数说明库"));
Box funcationTipsLayoutBox = Box.createVerticalBox();
Box funcationTipsAddBox1 = Box.createHorizontalBox();
funcationTipsAddBox1.add(new JLabel("函数名称:"));
funcationTipsAddBox1.add(functionTipsName);
funcationTipsAddBox1.add(Box.createHorizontalStrut(5));
funcationTipsAddBox1.add(new JLabel("参数列表:"));
funcationTipsAddBox1.add(functionTipsParameter);
funcationTipsAddBox1.add(Box.createHorizontalStrut(5));
funcationTipsAddBox1.add(functionTipsAddButton);
funcationTipsAddBox1.add(Box.createHorizontalStrut(5));
funcationTipsAddBox1.add(functionTipsModifyButton);
Box funcationTipsAddBox2 = Box.createHorizontalBox();
funcationTipsAddBox2.add(new JLabel("函数说明:"));
funcationTipsAddBox2.add(functionTipsDiscription);
funcationTipsLayoutBox.add(funcationTipsAddBox1);
funcationTipsLayoutBox.add(Box.createVerticalStrut(2));
funcationTipsLayoutBox.add(funcationTipsAddBox2);
funcationTipsLayoutBox.add(Box.createVerticalStrut(2));
JPanel controlTipsPanel = new JPanel(new FlowLayout());
controlTipsPanel.add(functionTipsDeleteButton);
funcationTipsLayoutBox.add(new JScrollPane(functionTipsTable));
funcationTipsLayoutBox.add(Box.createVerticalStrut(2));
funcationTipsLayoutBox.add(controlTipsPanel);
functionTipsTitlePanel.add(funcationTipsLayoutBox, BorderLayout.CENTER);
/////////////////////////////////////////////////
dialog.getContentPane().setLayout(new BorderLayout());
Box rootLayout = Box.createVerticalBox();
rootLayout.add(functionTitlePanel);
rootLayout.add(Box.createVerticalStrut(5));
rootLayout.add(functionTipsTitlePanel);
JPanel exitPanel = new JPanel(new FlowLayout());
exitPanel.add(closeButton);
rootLayout.add(exitPanel);
//rootLayout.add(assignTitlePanel);
dialog.setSize(600, 550);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
dialog.setLocation((screenSize.width-600)/2, (screenSize.height-550)/2);
dialog.setResizable(true);
dialog.add(rootLayout, 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();
}
public static 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);
}
}
private void saveData(){
System.out.println(new LuaFunctionParse(cell).getCode());
dialog.dispose();
}
public static void main(String[] args){
AssignForm.configureUI();
ModelForm form = new ModelForm(new DefaultGraphCell("哈哈"), new JGraph());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -