com.scudata.ide.spl.etl.ExportFieldsDialog 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.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import com.scudata.common.MessageManager;
import com.scudata.common.StringUtils;
import com.scudata.ide.common.GM;
import com.scudata.ide.common.resources.IdeCommonMessage;
import com.scudata.ide.common.swing.JTableEx;
import com.scudata.ide.common.swing.VFlowLayout;
/**
* ?????ֶ?ʱ???????ֶ?????????ʽ?ĶԻ???
*
* @author Joancy
*
*/
public class ExportFieldsDialog extends JDialog implements IFieldDefineDialog{
private static final long serialVersionUID = 1L;
private static MessageManager mm = FuncMessage.get();
JPanel jPanel2 = new JPanel();
VFlowLayout vFlowLayout1 = new VFlowLayout();
JButton jBOK = new JButton();
JButton jBCancel = new JButton();
JScrollPane jScrollPane1 = new JScrollPane();
private final byte COL_INDEX = 0;
private final byte COL_EXP = 1;
private final byte COL_FIELD = 2;
JTableEx exportFields;
JPanel jPanel1 = new JPanel();
JButton jBAdd = new JButton();
JButton jBDel = new JButton();
private int m_option = JOptionPane.CANCEL_OPTION;
/**
* ???캯??
* @param owner ??????
* @param defineType ???峣??????
*/
public ExportFieldsDialog(Dialog owner,int defineType) {
super(owner);
try {
String colNames;
if( defineType == EtlConsts.INPUT_FIELDDEFINE_EXP_FIELD){
colNames = "ExportFieldsDialog.exportfields";
}else if(defineType == EtlConsts.INPUT_FIELDDEFINE_FIELD_EXP){
colNames = "ExportFieldsDialog.fieldExps";
}else{
colNames = "ExportFieldsDialog.renameFields";
}
exportFields = new JTableEx(mm.getMessage(colNames));
init();
rqInit();
setSize(450, 300);
resetText();
GM.setDialogDefaultButton(this, jBOK, jBCancel);
} catch (Exception ex) {
GM.showException(ex);
}
}
private void resetText() {
setTitle(mm.getMessage("ExportFieldsDialog.title"));
MessageManager icm = IdeCommonMessage.get();
jBOK.setText(icm.getMessage("button.ok"));
jBCancel.setText(icm.getMessage("button.cancel"));
jBAdd.setText(icm.getMessage("button.add"));
jBDel.setText(icm.getMessage("button.delete"));
}
/**
* ??ȡ???ڷ??صĶ???ѡ??
*/
public int getOption() {
return m_option;
}
/**
* ?????ֶζ????б?
* @param fields ?ֶζ????б?
*/
public void setFieldDefines(ArrayList fields) {
if(fields==null){
return;
}
for (int i = 0; i < fields.size(); i++) {
int row = exportFields.addRow();
FieldDefine fd = fields.get(i);
exportFields.data.setValueAt(fd.getOne(), row, COL_EXP);
exportFields.data.setValueAt(fd.getTwo(), row, COL_FIELD);
}
}
/**
* ??ȡ?༭?õ??ֶζ????б?
* @return ?ֶζ????б?
*/
public ArrayList getFieldDefines() {
exportFields.acceptText();
int rows = exportFields.getRowCount();
if(rows==0){
return null;
}
ArrayList fields = new ArrayList();
for (int i = 0; i < rows; i++) {
String name = (String) exportFields.data.getValueAt(i, COL_EXP);
if(!StringUtils.isValidString(name)){
continue;
}
FieldDefine fd = new FieldDefine();
fd.setOne(name);
fd.setTwo((String) exportFields.data.getValueAt(i, COL_FIELD));
fields.add(fd);
}
return fields;
}
private void rqInit() {
exportFields.setIndexCol(COL_INDEX);
exportFields.setRowHeight(20);
}
private void init() throws Exception {
setModal(true);
jPanel2.setLayout(vFlowLayout1);
jBOK.setMnemonic('O');
jBOK.setText("ȷ??(O)");
jBOK.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
exportFields.acceptText();
m_option = JOptionPane.OK_OPTION;
dispose();
}
});
jBCancel.setMnemonic('C');
jBCancel.setText("ȡ??(C)");
jBCancel.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
dispose();
}
});
jBAdd.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
exportFields.addRow();
}
});
jBDel.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
exportFields.deleteSelectedRows();
}
});
this.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
dispose();
}
});
jScrollPane1.getViewport().add(exportFields);
jBAdd.setMnemonic('A');
jBAdd.setText("????(A)");
jBDel.setMnemonic('D');
jBDel.setText("ɾ??(D)");
jPanel2.add(jBOK, null);
jPanel2.add(jBCancel, null);
jPanel2.add(jPanel1, null);
jPanel2.add(jBAdd, null);
jPanel2.add(jBDel, null);
this.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
this.getContentPane().add(jPanel2, BorderLayout.EAST);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy