@Override public void delete() { getSettingsClient().deleteSettings(name); modified = false; } }
/** * Deletes screen settings associated with this screen. */ protected void deleteSettings() { settings.delete(); }
protected Settings getSettingsImpl(String id) { return new SettingsImpl(id); }
@Override public void applySettings(Settings settings) { super.applySettings(settings); String visible = settings.get(hintBox.getId()).attributeValue("visible"); if (visible != null) hintBox.setVisible(Boolean.parseBoolean(visible)); } }
log.trace("Saving settings for {} : {}", name, component); Element e = settings.get(name); boolean modified = ((HasSettings) component).saveSettings(e); settings.setModified(modified); settings.commit();
SettingsImpl settings = new SettingsImpl(window.getId()); String name = ValuePathHelper.format(ArrayUtils.subarray(strings, 1, strings.length)); Element e = settings.get(name).element("defaultFilter"); if (e != null) { String defIdStr = e.attributeValue("id");
@Override public void commit() { if (modified && root != null) { String xml = Dom4j.writeDocument(root.getDocument(), true); getSettingsClient().setSetting(name, xml); modified = false; } }
protected void checkLoaded() { if (root == null) { // use cache String xml = getSettingsClient().getSetting(name); if (StringUtils.isBlank(xml)) { root = DocumentHelper.createDocument().addElement("settings"); } else { root = Dom4j.readDocument(xml).getRootElement(); } } }
@Override public Element get() { checkLoaded(); Element e = root.element("window"); if (e == null) { e = root.addElement("window"); } return e; }
public void closeHint() { hintBox.setVisible(false); getSettings().get(hintBox.getId()).addAttribute("visible", "false"); }
@Override public Element get(final String componentId) { checkLoaded(); Element componentsRoot = root.element("components"); if (componentsRoot == null) { componentsRoot = root.addElement("components"); } for (Element e : componentsRoot.elements()) { if (componentId.equals(e.attributeValue("name"))) { return e; } } Element e = componentsRoot.addElement("component"); e.addAttribute("name", componentId); return e; }
@Override public void applySettings(Settings settings) { super.applySettings(settings); if (settings.get().attribute(LAST_SELECTED_JMX_CONNECTION_ID) != null) { UUID lastJmxConnectionId = UUID.fromString( settings.get().attributeValue(LAST_SELECTED_JMX_CONNECTION_ID)); if (jmxInstancesDs.containsItem(lastJmxConnectionId)) { jmxConnectionField.setValue(jmxInstancesDs.getItem(lastJmxConnectionId)); } } if (settings.get().attribute(LAST_SELECTED_LOG_FILE_NAME) != null) { String lastFileName = settings.get().attributeValue(LAST_SELECTED_LOG_FILE_NAME); @SuppressWarnings("unchecked") List<String> logFileNamesList = logFileNameField.getOptionsList(); if (logFileNamesList.contains(lastFileName)) { logFileNameField.setValue(lastFileName); showLogTail(); } } }
@Override public void saveSettings() { String lastFileName = logFileNameField.getValue(); getSettings().get().addAttribute(LAST_SELECTED_LOG_FILE_NAME, lastFileName); if (!getSelectedConnection().equals(localJmxInstance)) { String lastJmxConnectionId = String.valueOf(getSelectedConnection().getId()); getSettings().get().addAttribute(LAST_SELECTED_JMX_CONNECTION_ID, lastJmxConnectionId); } else { getSettings().get().addAttribute(LAST_SELECTED_JMX_CONNECTION_ID, null); } super.saveSettings(); } }
/** * Apply settings for screen. * * @param screen screen * @param settings settings */ public void applySettings(Screen screen, Settings settings) { checkNotNullArgument(screen); checkNotNullArgument(settings); walkComponents( screen.getWindow(), (component, name) -> { if (component.getId() != null && component instanceof HasSettings) { log.trace("Applying settings for {} : {} ", name, component); Element e = settings.get(name); ((HasSettings) component).applySettings(e); if (component instanceof HasPresentations && e.attributeValue("presentation") != null) { String def = e.attributeValue("presentation"); if (!StringUtils.isEmpty(def)) { UUID defaultId = UUID.fromString(def); ((HasPresentations) component).applyPresentationAsDefault(defaultId); } } } } ); }
if (settingsComponent.getId() != null && settingsComponent instanceof HasSettings) { Element e = settings.get(name); ((HasSettings) settingsComponent).applySettings(e);
if (settingsComponent.getId() != null && settingsComponent instanceof HasSettings) { Element e = settings.get(name); ((HasSettings) settingsComponent).applySettings(e);