argstable.java
来自「UCS (Ultra Corba Simulator) is one more 」· Java 代码 · 共 568 行 · 第 1/2 页
JAVA
568 行
}
return ret;
}
public void setMutilValueFlag(boolean flag) {
isMultiValue = flag;
}
public void setSelectedValue(String inValue) {
int len = selectBox.getItemCount();
for (int i = 0; i < len; i++) {
if (!inValue.equals(selectBox.getItemAt(i)))
continue;
selectBox.setSelectedIndex(i);
break;
}
}
public String getSelectedValue() {
return (String) selectBox.getSelectedItem();
}
public TableCellEditor getCellEditor(int row, int column) {
if (column == 1 && isMultiValue)
return cellEditor;
else
return txtCellEditor;
}
public TableCellRenderer getCellRenderer(int row, int column) {
return super.getCellRenderer(row, column);
}
public void update() {
}
public void itemStateChanged(ItemEvent e) {
// System.out.println("xxxxxxx itemStateChanged");
if (e.getStateChange() == 1) {
String selected = (String) e.getItem();
// any type
if (current instanceof CTBasic) {
CTBasic bt = (CTBasic) current;
if (bt.rdn.equalsIgnoreCase("any")) {
TypeBase n_sib;
IdlType tn = (IdlType) Warehouse.cname2node.get(selected);
if (tn == null) {
n_sib = new CTBasic();
n_sib.rdn = selected;
} else {
n_sib = tn.toType();
}
bt.t_any = n_sib;
MNQMutableTreeNode dMTN_sib = new MNQMutableTreeNode(n_sib);
bt.dmtn.removeAllChildren(true);
bt.dmtn.add(dMTN_sib);
n_sib.dmtn = dMTN_sib;
ArgsCellEditor.createTreeCellEditorComponent(dMTN_sib, tree);
MNQmainFrame.buildParaSibling(dMTN_sib, n_sib, tree);
((DefaultTreeModel) tree.getModel()).reload(bt.dmtn);
// expand the tree
// for (int i = 0; i < tree.getRowCount(); i++) {
// tree.expandRow(i);
// }
// expand the selected node
MNQmainFrame.expandNode(bt.dmtn, tree);
return;
}
return;
}
// CTExceptList
if (current instanceof CTExceptList) {
// System.out.println("--------set excetpin");
CTExceptList elt = (CTExceptList) current;
for (int i = 0; i < elt.memType.size(); i++) {
String tmp;
TypeBase dt = (TypeBase) elt.memType.get(i);
tmp = dt.toString();
if (selected.equalsIgnoreCase(tmp)) {
// one union subnode
TypeBase n_sib = (TypeBase) (elt.memType.get(i));
MNQMutableTreeNode dMTN_sib = new MNQMutableTreeNode(n_sib);
elt.dmtn.removeAllChildren(true);
elt.dmtn.add(dMTN_sib);
n_sib.dmtn = dMTN_sib;
ArgsCellEditor.createTreeCellEditorComponent(dMTN_sib, tree);
MNQmainFrame.buildParaSibling(dMTN_sib, n_sib, tree);
((DefaultTreeModel) tree.getModel()).reload(elt.dmtn);
// expand the tree
// for (int j = 0; j < tree.getRowCount();
// j++) {
// tree.expandRow(j);
// }
// expand the selected node
MNQmainFrame.expandNode(elt.dmtn, tree);
elt.selectedExcept = n_sib;
return;
}
}
elt.dmtn.removeAllChildren(true);
((DefaultTreeModel) tree.getModel()).reload(elt.dmtn);
elt.selectedExcept = null;
return;
}
// CTUnion
if (current instanceof CTUnion) {
CTUnion ut = (CTUnion) current;
// check
TypeBase udt = (TypeBase) ut.disType.get(0);
if (udt instanceof CTBasic) {
try {
if (udt.rdn.equalsIgnoreCase("char")) {
new Character(selected.charAt(0));
} else if (udt.rdn.equalsIgnoreCase("short")
|| udt.rdn.equalsIgnoreCase("unsigned short")
|| udt.rdn.equalsIgnoreCase("unsignedshort")) {
Short.valueOf(selected);
} else if (udt.rdn.equalsIgnoreCase("long")
|| udt.rdn.equalsIgnoreCase("unsigned long")
|| udt.rdn.equalsIgnoreCase("unsignedlong")) {
Integer.valueOf(selected);
} else if (udt.rdn.equalsIgnoreCase("long long")
|| udt.rdn.equalsIgnoreCase("longlong")
|| udt.rdn.equalsIgnoreCase("unsigned long long")
|| udt.rdn.equalsIgnoreCase("unsignedlonglong")) {
Long.valueOf(selected);
}
} catch (Exception ex) {
// output a messagebox.
JOptionPane
.showMessageDialog(
this,
"The input value for union switch is not valid, pls. set it again! Otherwise, first item will be used.",
"operation tip", 2);
selectBox.setSelectedIndex(0);
selected = (String) selectBox.getSelectedItem();
}
}
for (int i = 0; i < ut.disType.size(); i++) {
String tmp;
TypeBase dt = (TypeBase) ut.disType.get(i);
tmp = dt.toCaseLabel(dt.val);
if (selected.equalsIgnoreCase(tmp)) {
// one union subnode
TypeBase n_sib = (TypeBase) (ut.memType.get(i));
MNQMutableTreeNode dMTN_sib = new MNQMutableTreeNode(n_sib);
ut.dmtn.removeAllChildren(true);
ut.dmtn.add(dMTN_sib);
n_sib.dmtn = dMTN_sib;
ArgsCellEditor.createTreeCellEditorComponent(dMTN_sib, tree);
MNQmainFrame.buildParaSibling(dMTN_sib, n_sib, tree);
// ((DefaultTreeModel)tree.getModel()).reload();
// ((DefaultTreeModel)tree.getModel()).nodeChanged(ut.dmtn);
((DefaultTreeModel) tree.getModel()).reload(ut.dmtn);
// expand the tree
// for (int j = 0; j < tree.getRowCount();
// j++) {
// tree.expandRow(j);
// }
// expand the selected node
MNQmainFrame.expandNode(ut.dmtn, tree);
return;
}
}
for (int i = 0; i < ut.disType.size(); i++) {
String tmp;
TypeBase dt = (TypeBase) ut.disType.get(i);
tmp = dt.toCaseLabel(dt.val);
if (tmp.equalsIgnoreCase("default")) {
// one union subnode
TypeBase n_sib = (TypeBase) (ut.memType.get(i));
MNQMutableTreeNode dMTN_sib = new MNQMutableTreeNode(n_sib);
ut.dmtn.removeAllChildren(true);
ut.dmtn.add(dMTN_sib);
n_sib.dmtn = dMTN_sib;
ArgsCellEditor.createTreeCellEditorComponent(dMTN_sib, tree);
MNQmainFrame.buildParaSibling(dMTN_sib, n_sib, tree);
// ((DefaultTreeModel)tree.getModel()).reload();
// ((DefaultTreeModel)tree.getModel()).nodeChanged(ut.dmtn);
((DefaultTreeModel) tree.getModel()).reload(ut.dmtn);
// expand the tree
// for (int j = 0; j < tree.getRowCount();
// j++) {
// tree.expandRow(j);
// }
// expand the selected node
MNQmainFrame.expandNode(ut.dmtn, tree);
return;
}
}
ut.dmtn.removeAllChildren(true);
((DefaultTreeModel) tree.getModel()).reload(ut.dmtn);
return;
}
}
}
public void focusGained(FocusEvent arg0) {
// TODO Auto-generated method stub
}
public void focusLost(FocusEvent e) {
// TODO Auto-generated method stub
String selected = (String) selectBox.getSelectedItem();
if (selected == null) {
JOptionPane.showMessageDialog(this, "The value is invalid, pls. set it again.",
"operation tip", 2);
}
}
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
}
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
// if not caseTree, then return
if (tree != MNQmainFrame.caseTree)
return;
// if not right-click , then return
if (e.getButton() != MouseEvent.BUTTON3)
return;
boolean fRepExist = ReplaceUtil.fatherRepExist(current.dmtn);
String info = ReplaceUtil.displayRepInfo(current.dmtn);
String pinfo = MatchUtil.displayPatternInfo(current.dmtn);
MNQmainFrame.frame.popupMenu.removeAll();
if (!fRepExist) {
MNQmainFrame.frame.popupMenu.add(MNQmainFrame.frame.replaceParaMenuItem);
}
if (info != null) {
MNQmainFrame.frame.popupMenu.add(MNQmainFrame.frame.cancelReplaceMenuItem);
}
// if (current instanceof OpFlowNode) {
// MNQmainFrame.frame.popupMenu.add(MNQmainFrame.frame.delTestCaseMenuItem);
// } else {
// TypeBase t;
// if (current instanceof Args)
// t = ((Args) current).pt;
// else
// t = (TypeBase) current;
if (current instanceof CTBasic || current instanceof CTUnion || current instanceof CTEnum) {
MNQmainFrame.frame.popupMenu.add(MNQmainFrame.frame.setPatternMenuItem);
if (pinfo != null)
MNQmainFrame.frame.popupMenu.add(MNQmainFrame.frame.cancelPatternMenuItem);
}
MNQmainFrame.frame.popupMenu.add(MNQmainFrame.frame.autoAddMatchConMenuItem);
// }
// if (n instanceof Args || n instanceof TypeBase)
MNQmainFrame.frame.popupMenu.pack();
MNQmainFrame.frame.popupMenu.show(MNQmainFrame.caseTree, e.getX(), e.getY());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?