com.scudata.ide.spl.etl.DialogFuncEdit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of esproc Show documentation
Show all versions of esproc Show documentation
SPL(Structured Process Language) A programming language specially for structured data computing.
package com.scudata.ide.spl.etl;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.scudata.common.MessageManager;
import com.scudata.common.StringUtils;
import com.scudata.ide.common.*;
import com.scudata.ide.common.swing.*;
import com.scudata.ide.spl.resources.*;
/**
* SPL????????????
* ????༭??
* @author Joancy
*
*/
public class DialogFuncEdit extends JDialog {
private static final long serialVersionUID = 1L;
private int m_option = JOptionPane.CLOSED_OPTION;
private static MessageManager mm = FuncMessage.get();
JLabel lbUrl = new JLabel("Help");
JButton okbtn = new JButton();
JButton cancelbtn = new JButton();
ParamInputPanel propPanel;
JLabel lbCellNames = new JLabel("??ѡ??Ԫ??");
JComboBoxEx jCBCellNames = new JComboBoxEx();
JLabel lbFuncNames = new JLabel("??ѡ??????");
JComboBoxEx jCBElementNames = new JComboBoxEx();
transient HashMap cellNames = null;
transient ObjectElement oe;
/**
* ???캯??
* @param cellNames ÿ??֧?ָ????????ĵ?Ԫ?????ָ?????????Ԫ?ص?ӳ??
* @param currentOe ??ǰ?༭?ĺ???????Ԫ??
*/
public DialogFuncEdit(HashMap cellNames,ObjectElement currentOe) {
super(GV.appFrame, "?????༭", true);
try {
this.cellNames = cellNames;
this.oe = currentOe;
init();
rqInit();
setSize(640, 480);
resetText();
GM.setDialogDefaultButton(this, okbtn, cancelbtn);
} catch (Exception ex) {
GM.showException(ex);
}
}
private void resetText() {
setTitle(mm.getMessage("DialogFuncEdit.title"));
lbCellNames.setText(mm.getMessage("DialogFuncEdit.selectcell"));
lbFuncNames.setText(mm.getMessage("DialogFuncEdit.selectfunc"));
}
private void init() {
lbUrl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
lbUrl.setFont(new java.awt.Font("Comic Sans MS", 2, 13));
lbUrl.setForeground(Color.blue);
lbUrl.setBorder(null);
okbtn.setText(ChartMessage.get().getMessage("button.ok")); // "ȷ??(O)" );
okbtn.setPreferredSize(new Dimension(70, 25));
okbtn.setMargin(new Insets(2, 10, 2, 10));
okbtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
okbtn_actionPerformed(e);
}
});
cancelbtn.setText(ChartMessage.get().getMessage("button.cancel")); // "ȡ??(C)"
cancelbtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
cancelbtn_actionPerformed(e);
}
});
cancelbtn.setPreferredSize(new Dimension(70, 25));
cancelbtn.setMargin(new Insets(2, 10, 2, 10));
okbtn.setMnemonic('O');
cancelbtn.setMnemonic('C');
JPanel panel = new JPanel(new GridBagLayout());
panel.add(lbUrl,GM.getGBC(1, 1,true));
panel.add(new JLabel(" "),GM.getGBC(1, 2));
panel.add(okbtn,GM.getGBC(1, 3));
panel.add(cancelbtn,GM.getGBC(1, 4));
Container pane = this.getContentPane();
pane.setLayout(new BorderLayout());
pane.add(panel, BorderLayout.SOUTH);
JPanel cmdPanel = new JPanel();
cmdPanel.setLayout(new GridBagLayout());
cmdPanel.add(lbCellNames, GM.getGBC(1, 1));
cmdPanel.add(jCBCellNames, GM.getGBC(1, 2, true));
cmdPanel.add(lbFuncNames, GM.getGBC(1, 3));
GridBagConstraints gbc = GM.getGBC(1, 4, true);
cmdPanel.add(jCBElementNames, gbc);
pane.add(cmdPanel, BorderLayout.NORTH);
propPanel = new ParamInputPanel(this);
pane.add(propPanel);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
closeDialog();
}
});
}
private boolean isInludeType(byte[] allType, byte current){
for(int i=0;i getAncestorNames(){
ArrayList ans = new ArrayList();
String currentName = (String) jCBCellNames.x_getSelectedItem();
if (cellNames != null && !cellNames.isEmpty()) {
while (StringUtils.isValidString(currentName)) {
ans.add(currentName);
ObjectElement tmp = cellNames.get(currentName);
currentName = tmp.getCellName();
}
}
return ans;
}
/**
* ??ӳ????н????е?Ԫ????????г?????????????????cellTypes?????ƹ???Ϊ?????б?
* @param cellTypes ??Ԫ??????
* @return ?????????б?
*/
public JComboBoxEx getCellNameDropdownBox(byte[] cellTypes){
Vector scodes = new Vector(),sdisps = new Vector();
if (cellNames != null) {
ArrayList names = new ArrayList();
Iterator it = cellNames.keySet().iterator();
ArrayList ans = getAncestorNames();
while (it.hasNext()) {
String name = it.next();
if(ans.contains(name)){//Ҫ?г??????????Ӳ??ܰ?????ǰ???ӵ????ȸ????Ƕ????
continue;
}
names.add(name);
}
Collections.sort(names);
// GM.sort(names, true);
scodes.add("");
sdisps.add("");
for (String name : names) {
ObjectElement cellOE = cellNames.get(name);
byte cellType = cellOE.getReturnType();
if(isInludeType(cellTypes,cellType)){
scodes.add(name);
sdisps.add(cellTitle(name));
}
}
}
JComboBoxEx combo = new JComboBoxEx();
combo.x_setData(scodes, sdisps);
return combo;
}
private void refreshCellNames(){
String cellName = (String) jCBCellNames.x_getSelectedItem();
byte cellType = EtlConsts.TYPE_EMPTY;
if (StringUtils.isValidString(cellName)) {
ObjectElement cellOE = cellNames.get(cellName);
cellType = cellOE.getReturnType();
}
ArrayList elements = ElementLib
.getElementInfos(cellType);
Vector names = new Vector();
Vector titles = new Vector();
String codeItem = null;
for (int i = 0; i < elements.size(); i++) {
ElementInfo ei = elements.get(i);
if (codeItem == null) {
codeItem = ei.getName();
}
names.add(ei.getName());
titles.add(ei.getTitle());
}
jCBElementNames.x_setData(names, titles);
}
private String cellTitle(String name){
ObjectElement oe = cellNames.get(name);
String oeType = EtlConsts.getTypeDesc(oe.getReturnType());
return name+"("+oeType+")";
}
private void rqInit() {
if (oe == null) {
ArrayList names = new ArrayList();
Iterator it = cellNames.keySet().iterator();
while (it.hasNext()) {
String name = it.next();
names.add(name);
}
Collections.sort(names);
// GM.sort(names, true);
Vector vNames = new Vector();
Vector vTitles = new Vector();
vNames.add("");
vTitles.add("");
for (String name : names) {
vNames.add(name);
vTitles.add(cellTitle(name));
}
jCBCellNames.x_setData(vNames, vTitles);
jCBCellNames.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
refreshCellNames();
}
});
jCBElementNames.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String elementName = (String) jCBElementNames
.x_getSelectedItem();
if (elementName == null) {
return;
}
ElementInfo ei = ElementLib.getElementInfo(elementName);
oe = ei.newInstance();
dispDetail();
}
});
jCBCellNames.x_setSelectedCodeItem("");
refreshCellNames();
Object dispItem = jCBElementNames.getItemAt(0);
jCBElementNames.x_setSelectedCodeItem(dispItem);
} else {
//?????ж??????????Ϊͬ???͵ĸ???
Vector vNames = new Vector();
Vector vTitles = new Vector();
Iterator it = cellNames.keySet().iterator();
while (it.hasNext()) {
String name = it.next();
ObjectElement tmp = cellNames.get(name);
if(oe.getParentType()==tmp.getReturnType()){
vNames.add(name);
}
}
Collections.sort(vNames);
// GM.sort(vNames, true);
for (String name : vNames) {
vTitles.add(cellTitle(name));
}
jCBCellNames.x_setData(vNames, vTitles);
jCBCellNames.x_setSelectedCodeItem(oe.getCellName());
String elementName = oe.getElementName();
ElementInfo ei = ElementLib.getElementInfo(elementName);
Vector names = new Vector();
Vector titles = new Vector();
names.add(ei.getName());
titles.add(ei.getTitle());
jCBElementNames.x_setData(names, titles);
jCBElementNames.x_setSelectedCodeItem(elementName);
jCBElementNames.setEnabled(false);
dispDetail();
}
lbUrl.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
int b = e.getButton();
if (b != MouseEvent.BUTTON1) {
return;
}
if (GM.getOperationSytem() == GC.OS_WINDOWS) {
try {
Runtime.getRuntime().exec(
"cmd /C start " + lbUrl.getText());
} catch (Exception x) {
GM.showException(x);
}
}
}
});
}
/**
* ??ȡ???ڷ??صĶ???ѡ??
* @return ѡ??
*/
public int getOption() {
return m_option;
}
/**
* ??ȡ??ǰ?༭????????Ԫ??
* @return ????????Ԫ??
*/
public ObjectElement getObjectElement() {
String cellName = (String) jCBCellNames.x_getSelectedItem();
oe.setCellName(cellName);
return oe;
}
/**
* ????ǰ?ĺ???????Ԫ????????ʾ?????????
*/
public void dispDetail() {
String funcTitle = (String) jCBElementNames.getSelectedItem();
byte type = oe.getParentType();
String stype = EtlConsts.getTypeDesc(type);
String funcDesc = oe.getFuncDesc();
propPanel.setParamInfoList(stype,funcTitle, funcDesc,oe.getParamInfoList());
lbUrl.setText(oe.getHelpUrl());
}
private void closeDialog() {
GM.setWindowDimension(this);
dispose();
}
void okbtn_actionPerformed(ActionEvent e) {
propPanel.getParamTable().acceptText();
m_option = JOptionPane.OK_OPTION;
ParamInfoList pil = propPanel.getParamInfoList();
try{
pil.check();
oe.setParamInfoList(pil.getAllParams());
closeDialog();
}catch(Exception x){
GM.showException(x);
}
}
void cancelbtn_actionPerformed(ActionEvent e) {
m_option = JOptionPane.CANCEL_OPTION;
closeDialog();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy