/** * Reads the stored toolbars' status from plugin-persinstence.xml, and sets the toolbars * accordingly. */ private void getPersistedStatus() { PluginServices ps = PluginServices.getPluginServices(this); XMLEntity xml = ps.getPersistentXML(); XMLEntity child = null; for (int i = xml.getChildrenCount() - 1; i >= 0; i--) { if (xml.getChild(i).getName().equals("Toolbars")) child = xml.getChild(i).getChild(0); } if (child != null) { SelectableToolBar[] toolBars = PluginServices.getMainFrame().getToolbars(); for (int i = toolBars.length - 1; i >= 0; i--) { if (child.contains(toolBars[i].getName())) toolBars[i].setAndamiVisibility( child.getStringProperty(toolBars[i].getName()).equals("visible")); } } }
/** * Save the status of the provided toolbar. * * @param toolbarName The toolbar name whose status wants to be saved. * @param visible Whether or not the toolbar is visible. */ private void persistStatus(String toolbarName, boolean visible) { PluginServices ps = PluginServices.getPluginServices(this); XMLEntity xml = ps.getPersistentXML(); XMLEntity child = null; for (int i = xml.getChildrenCount() - 1; i >= 0; i--) { if (xml.getChild(i).getName().equals("Toolbars")) child = xml.getChild(i).getChild(0); } if (child == null) { XMLEntity toolbars = new XMLEntity(); toolbars.setName("Toolbars"); child = new XMLEntity(); toolbars.addChild(child); xml.addChild(toolbars); } if (visible) { child.putProperty(toolbarName, "visible"); } else { child.putProperty(toolbarName, "hidden"); } ps.setPersistentXML(xml); }