private void initGui() { this.setLayout(new GridBagLayout()); this.setBorder( new TitledBorder(new EtchedBorder(), dsElement.getAttributeValue(Resources.get("NAME")))); // find all partition tables in this dataset List<Element> ptList = dsElement.getChildren(Resources.get("PARTITIONTABLE")); for (Element ptElement : ptList) { List<ArrayList<String>> ptTable = JDomUtils.ptElement2Table(ptElement); ptTableMap.put(ptElement.getAttributeValue(Resources.get("NAME")), ptTable); // default 0 ptCurrentIndex.put(ptElement.getAttributeValue(Resources.get("NAME")), 0); } // find the one has the same user and gui HashMap<String, String> conditions = new HashMap<String, String>(); List<Element> myContainers = JDomUtils.findChildElements(dsElement, Resources.get("CONTAINER"), conditions); Set<String> ftSet = this.getFlattenPTableName(); GridBagConstraints c = new GridBagConstraints(); c.gridy = 0; c.gridx = 0; c.anchor = GridBagConstraints.FIRST_LINE_START; for (Element container : myContainers) { if (JDomUtils.isElementHiden(container)) continue; // if container is empty, don't add it if (!this.isContainerEmpty(container)) { this.add(createContainerPanel(container, dsElement, ftSet, false), c); c.gridx = c.gridx + 1; } } }
private JPanel createContainerPanel( Element e, Element dsElement, Set<String> flattenTableSet, boolean clone) { // element is a container element boolean hasFlattenAttribute = false; List<ArrayList<String>> flattendata = null; String dsTableName = ""; JPanel containerPanel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.anchor = GridBagConstraints.FIRST_LINE_START; c.insets = new Insets(0, 5, 0, 5); int labelx = 0; int tfx = 1; int y = 0; containerPanel.setBorder( new TitledBorder(new EtchedBorder(), e.getAttributeValue(Resources.get("NAME")))); List<Element> childList = e.getChildren(); for (Element child : childList) { if (JDomUtils.isElementHiden(child)) continue; if (child.getName().equals(Resources.get("CONTAINER"))) { if (!this.isContainerEmpty(child)) { c.gridx = labelx; c.gridy = y; containerPanel.add(createContainerPanel(child, dsElement, flattenTableSet, false), c); y++; } } else { dsTableName = child.getAttributeValue(Resources.get("DSTABLE")); if (flattenTableSet.contains(dsTableName) && hasFlattenAttribute == false) { hasFlattenAttribute = true; Element ptElement = JDomUtils.searchElementWithCondition( dsElement, Resources.get("PARTITIONTABLE"), Resources.get("DSTABLE"), dsTableName); flattendata = JDomUtils.ptElement2Table(ptElement); } String oldLabelName = child.getAttributeValue(Resources.get("NAME")); String labelName = this.renameWithPartitionInfo(oldLabelName, ptTableMap); // check masked Element dsTableElement = JDomUtils.searchElement(dsElement, Resources.get("DSTABLE"), dsTableName); boolean colMasked = this.isDsColMasked(dsTableElement, oldLabelName); if (colMasked) continue; if (child.getName().equals(Resources.get("FILTER"))) { String ptName = child.getAttributeValue(Resources.get("PARTITIONTABLE")); if (!hasFlattenAttribute && ptName != null && !ptName.equals("")) { Element ptElement = JDomUtils.searchElement(dsElement, Resources.get("PARTITIONTABLE"), ptName); List<ArrayList<String>> data = JDomUtils.ptElement2Table(ptElement); PartitionedFilterDropDown pfo = new PartitionedFilterDropDown(data, child, this); c.gridx = labelx; c.gridy = y; if (!colMasked) { JLabel label = new JLabel(labelName); this.updateList.put(label, child); containerPanel.add(label, c); c.gridx = tfx; containerPanel.add(pfo, c); } } else { JLabel label = new JLabel(labelName); c.gridx = labelx; c.gridy = y; containerPanel.add(label, c); this.updateList.put(label, child); c.gridx = tfx; JTextField tf = new JTextField(5); containerPanel.add(tf, c); } y++; } else { JCheckBox cb = new JCheckBox(labelName); this.updateList.put(cb, child); c.gridx = labelx; c.gridy = y; containerPanel.add(cb, c); y++; } } } if (!clone && hasFlattenAttribute) { JPanel panel = new JPanel(new GridLayout(0, 1)); containerPanel.setBorder( new TitledBorder( new EtchedBorder(), dsTableName + "(" + flattendata.get(0).get(0) + ")")); panel.add(containerPanel); for (int i = 1; i < flattendata.size(); i++) { // get partitiontable name Element pt = JDomUtils.searchElementWithCondition( dsElement, Resources.get("PARTITIONTABLE"), Resources.get("DSTABLE"), dsTableName); this.ptCurrentIndex.put(pt.getAttributeValue(Resources.get("NAME")), i); JPanel clonePanel = this.createContainerPanel(e, dsElement, flattenTableSet, true); clonePanel.setBorder( new TitledBorder( new EtchedBorder(), dsTableName + "(" + flattendata.get(i).get(0) + ")")); panel.add(clonePanel); } return panel; } else return containerPanel; }