public static boolean setProjectionDefault(Object flavor, String tableName, ValMap map) { if (ProfileManager.transportsLoaded()) { String xpath = ProfileManager.transportsSelector + flavorSelector(flavor); Element element = selectElement(ProfileManager.transports, xpath); if (element != null && notNullOrEmpty(tableName)) { Element el = ProfileManager.transports.createElement("PROJECTION"); try { BidiMultiMap projection = (BidiMultiMap) map.get("projection"); xmlSerialize(projection, el, null); el.setAttribute("version", "" + map.get("version")); el.setAttribute("table", tableName); } catch (Exception e) { Log.e(TAG, "setDefaultProjection", e); return false; } NodeList nodes = evaluateXPath(element, "." + projectionSelector(tableName)); if (nodes != null && nodes.getLength() > 0) { Node node = nodes.item(0); node.getParentNode().replaceChild(el, node); } else element.appendChild(el); ProfileManager.saveTransports(); return true; } } return false; }
@SuppressWarnings("unchecked") private void updateModel(boolean refresh, boolean save, boolean keepSelection, Object... params) { String function = param(getFunction(), 0, params); if (ProfileManager.transportsLoaded()) { if (refresh) { blockDirty( new Job<Void>() { public void perform(Void t, Object[] params) throws Exception { DefaultComboBoxModel model = (DefaultComboBoxModel) comboBoxes[0].getModel(); model.removeAllElements(); NodeList nodes = evaluateXPath(ProfileManager.transports, selector + "/FUNCTION"); for (int i = 0; i < nodes.getLength(); i++) { Element element = (Element) nodes.item(i); model.addElement(element.getAttribute("name")); } comboBoxes[0].setModel(model); } }); } if (save) ProfileManager.saveTransports(); } if (!refresh) return; if (!keepSelection) function = getFunction(); setFunction(function); }