@Override public void actionPerformed(final ActionEvent e) { if (e != null) { final Object source = e.getSource(); // find modified component int cp = 0; final int cs = panel.getComponentCount(); for (int c = 0; c < cs; ++c) if (panel.getComponent(c) == source) cp = c; if ((cp & 1) == 0) { // combo box with tags/attributes final BaseXCombo combo = (BaseXCombo) source; panel.remove(cp + 1); final Data data = gui.context.data(); final boolean selected = combo.getSelectedIndex() != 0; if (selected) { final String item = combo.getSelectedItem().toString(); final boolean att = item.startsWith("@"); final Names names = att ? data.atnindex : data.tagindex; final byte[] key = Token.token(att ? item.substring(1) : item); final StatsKey stat = names.stat(names.id(key)); switch (stat.kind) { case INT: addSlider(stat.min, stat.max, cp + 1, true); break; case DBL: addSlider(stat.min, stat.max, cp + 1, false); break; case CAT: addCombo(entries(stat.cats.keys()), cp + 1); break; case TEXT: addInput(cp + 1); break; case NONE: panel.add(new BaseXLabel(""), cp + 1); break; } } else { panel.add(new BaseXLabel(""), cp + 1); } while (cp + 2 < panel.getComponentCount()) { panel.remove(cp + 2); panel.remove(cp + 2); } if (selected) addKeys(data); panel.revalidate(); panel.repaint(); } } query(false); }
/** * Returns the path nodes that are the result of this step. * * @param nodes initial path nodes * @param data data reference * @return resulting path nodes, or {@code null} if nodes cannot be evaluated */ final ObjList<PathNode> nodes(final ObjList<PathNode> nodes, final Data data) { // skip steps with predicates or different namespaces if (preds.length != 0 || data.nspaces.globalNS() == null) return null; // check restrictions on node type int kind = -1, name = 0; if (test.type != null) { kind = ANode.kind(test.type); if (kind == Data.PI) return null; if (test.test == Name.NAME) { // element/attribute test (*:ln) final Names names = kind == Data.ATTR ? data.atnindex : data.tagindex; name = names.id(((NameTest) test).ln); } else if (test.test != null && test.test != Name.ALL) { // skip namespace and standard tests return null; } } // skip axes other than descendant, child, and attribute if (axis != Axis.ATTR && axis != Axis.CHILD && axis != Axis.DESC && axis != Axis.DESCORSELF && axis != Axis.SELF) return null; final ObjList<PathNode> tmp = new ObjList<PathNode>(); for (final PathNode n : nodes) { if (axis == Axis.SELF || axis == Axis.DESCORSELF) { if (kind == -1 || kind == n.kind && (name == 0 || name == n.name)) { if (!tmp.contains(n)) tmp.add(n); } } if (axis != Axis.SELF) add(n, tmp, name, kind); } return tmp; }