MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / LaunchSet

Class LaunchSet

src/org/opensourcephysics/tools/Launcher.java:3031–3249  ·  view source on GitHub ↗

A class to save and load a set of launch tabs and Launcher static fields.

Source from the content-addressed store, hash-verified

3029 * A class to save and load a set of launch tabs and Launcher static fields.
3030 */
3031 public class LaunchSet implements XML.ObjectLoader {
3032 private Launcher launcher;
3033 private String name;
3034 boolean failedToLoad = false;
3035 @SuppressWarnings("javadoc")
3036 public boolean showHiddenNodes = true;
3037
3038 /**
3039 * Constructor LaunchSet
3040 */
3041 public LaunchSet() {
3042 launcher = Launcher.this;
3043 }
3044
3045 protected LaunchSet(Launcher launcher, String path) {
3046 this.launcher = launcher;
3047 name = XML.getName(XML.forwardSlash(path));
3048 }
3049
3050 @Override
3051 public void saveObject(XMLControl control, Object obj) {
3052 LaunchSet tabset = (LaunchSet) obj;
3053 Launcher launcher = tabset.launcher;
3054 control.setValue("classpath", classPath); //$NON-NLS-1$
3055 control.setValue("title", launcher.title); //$NON-NLS-1$
3056 // save dimensions and split pane divider location
3057 Dimension dim = launcher.getSize();
3058 control.setValue("width", dim.width); //$NON-NLS-1$
3059 control.setValue("height", dim.height); //$NON-NLS-1$
3060 control.setValue("divider", launcher.divider); //$NON-NLS-1$
3061 control.setValue("look_and_feel", launcher.lookAndFeel); //$NON-NLS-1$
3062 control.setValue("editor_enabled", launcher.editorEnabled); //$NON-NLS-1$
3063 if (saveState) {
3064 // save currently selected node
3065 LaunchNode node = launcher.getSelectedNode();
3066 control.setValue("selected_node", node.getPathString()); //$NON-NLS-1$
3067 // save array of expanded node collections (one for each tab)
3068 int n = launcher.tabbedPane.getTabCount();
3069 Collection<?>[] expansions = new Collection[n];
3070 for (int i = 0; i < n; i++) {
3071 LaunchPanel tab = launcher.getTab(i);
3072 expansions[i] = tab.getExpandedNodes();
3073 }
3074 control.setValue("expanded", expansions); //$NON-NLS-1$
3075 }
3076 // save collection of tab root nodes
3077 Collection<Object> nodes = new ArrayList<Object>();
3078 for (int i = 0; i < launcher.tabs.size(); i++) {
3079 LaunchNode root = ((LaunchPanel) launcher.tabs.get(i)).getRootNode();
3080 if (root.isHiddenInLauncher() && !tabset.showHiddenNodes) {
3081 continue;
3082 }
3083 // initialize selfContained, previewing and saveHiddenNodes properties
3084 root.parentSelfContained = false;
3085 root.previewing = false;
3086 root.saveHiddenNodes = tabset.showHiddenNodes;
3087 if (launcher.selfContained) {
3088 // save tab root

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected