private void appendRow(ContactInfo info) { // System.out.println(str); final TreeItem item; String catalog = info.getCatalog(); if (catalog == "" || catalog.length() == 0) { catalog = "未分组"; } if (parentItem == null || parentItem.getText() == null || !parentItem.getText().equals(catalog)) { if (parentItem != null) { parentItem.setExpanded(true); parentItem.setText(parentItem.getText() + " (共" + parentItemChildrenCount + "人)"); } parentItem = new TreeItem(tree, SWT.NONE); parentItem.setText(catalog); parentItemChildrenCount = 0; } item = new TreeItem(parentItem, SWT.NONE); parentItemChildrenCount++; fillItem(item, info); }
private void fillTable() { results = ContactService.getInstance().getAll(); groupInfoList = new ArrayList<ContactGroupInfo>(); for (int i = 0; i < results.size(); i++) { ContactInfo info = results.get(i); String catalog = info.getCatalog(); ContactGroupInfo lastGroupInfo = null; if (groupInfoList.size() > 0) { lastGroupInfo = groupInfoList.get(groupInfoList.size() - 1); } if (lastGroupInfo != null && lastGroupInfo.getGroupName() != null && lastGroupInfo.getGroupName().equals(catalog)) { lastGroupInfo.setIndexEnd(i); } else { lastGroupInfo = new ContactGroupInfo(); lastGroupInfo.setGroupName(catalog); lastGroupInfo.setIndexStart(i); lastGroupInfo.setIndexEnd(i); groupInfoList.add(lastGroupInfo); } } }