日期:2014-05-20 浏览次数:20811 次
private void fillData() { //创建一个列表ArrayList,里面保存的是String对象 List<String> items = new ArrayList<String>(); //创建Operator对象key,遍历ConditionUtil中的ipList集合( List<Operator> ipList = new ArrayList<Operator>();) for (Operator key : ConditionUtil.ipList) { //ConditionUtil.ipList中的每一个元素Operator对象key的getKey()值添加到列表items里面 items.add(key.getKey()); } //items.toArray(new String[0])这样就够了,toArray利用根据参数new String[0],创建String数据,(String[])这个强转是多余的,本来就是String[],不需要转换,也不能用强转转成别的数据 combo.setItems((String[]) items.toArray(new String[0])); //意思是combo选择第一个元素 combo.select(0); stacklayout.topControl = singleComp; // 代码不全还是怎么的,没看到getCondition()这方法 if (this.uc == null || this.uc.getCondition() == null) return; //group是个JText吧,把Text设置成UIname的值 group.setText(this.uc.getUiname()); if (this.uc.isUsed()) { for (Operator key : ConditionUtil.ipList) { if (this.uc.getCondition().getOperator().equals(key.getValue())) { combo.select(key.getOrder()); if (key.getValue().equals("in") || key.getValue().equals("out")) { stacklayout.topControl = scopComp; stackcomp.layout(); //就是把this.uc.getUivalue()的值,用","拆分成字符串数组.比如把"1,2,3,4,5" 拆成{"1","2","3","4","5"} String str[] = this.uc.getUivalue().split(","); value1.setText(str[0]); value2.setText(str[1]); } else { stacklayout.topControl = singleComp; stackcomp.layout(); value.setText(this.uc.getUivalue()); } break; } } } } //下面都是声明,没啥可说的 public class Condition { private String value; private String name; private String operator; } public class ConditionUtil { public static List<Operator> charList = new ArrayList<Operator>(); public static List<Operator> ipList = new ArrayList<Operator>(); public static List<Operator> numbList = new ArrayList<Operator>(); public static List<Operator> timeList = new ArrayList<Operator>(); } ublic class UiCondition { private Condition condition; private String judge; private boolean used; private String uiname; private String uivalue; public static String CHAR = "char"; public static String NUMB = "numb"; public static String IP = "ip"; public static String TIME = "time"; }