boolean openForEditing) { Object o = node.getUserObject(); Experiment experiment; if (o instanceof SocietyComponent) { SocietyComponent sc = (SocietyComponent) o; String name = "Experiment for " + sc.getSocietyName(); experiment = new Experiment(experimentNames.generateName(name), new SocietyComponent[] {sc}, new ImpactComponent[0], new Metric[0]); } else if (o instanceof Impact) { ImpactComponent impact = (ImpactComponent) o; String name = "Experiment for " + impact.getImpactName(); experiment = new Experiment(experimentNames.generateName(name), new SocietyComponent[0], new ImpactComponent[] {impact}, new Metric[0]); } else if (o instanceof Metric) { Metric metric = (Metric) o; String name = "Experiment for " + metric.getName(); experiment = new Experiment(experimentNames.generateName(name), new SocietyComponent[0], new ImpactComponent[0], new Metric[] {metric}); } else if (o instanceof Experiment) { experiment = (Experiment) o; } else if (o instanceof String) { experiment = new Experiment(experimentNames.generateName(), getSocietyComponents(node), getImpacts(node), getMetrics(node)); } else { return; } if (o instanceof Experiment) {  } else { if (o instanceof String) {  DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(experiment); model.insertNodeInto(newNode, node, 0);  workspace.setSelection(newNode); } else {  DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(experiment, false); DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) node.getParent(); model.insertNodeInto(newNode, parentNode, parentNode.getIndex(node) + 1);  workspace.setSelection(newNode); } experimentNames.add(experiment.getExperimentName()); experiment.addModificationListener(myModificationListener); } csmart.runExperimentBuilder(experiment, false, openForEditing);
boolean openForEditing) { Object o = node.getUserObject(); Experiment experiment; if (o instanceof SocietyComponent) { SocietyComponent sc = (SocietyComponent) o; String name = "Experiment for " + sc.getSocietyName(); experiment = new Experiment(experimentNames.generateName(name), new SocietyComponent[] {sc}, new ImpactComponent[0], new Metric[0]); } else if (o instanceof ImpactComponent) { ImpactComponent impact = (ImpactComponent) o; String name = "Experiment for " + impact.getImpactName(); experiment = new Experiment(experimentNames.generateName(name), new SocietyComponent[0], new ImpactComponent[] {impact}, new Metric[0]); } else if (o instanceof Metric) { Metric metric = (Metric) o; String name = "Experiment for " + metric.getName(); experiment = new Experiment(experimentNames.generateName(name), new SocietyComponent[0], new ImpactComponent[0], new Metric[] {metric}); } else if (o instanceof Experiment) { experiment = (Experiment) o; } else if (o instanceof String) { experiment = new Experiment(experimentNames.generateName(), getSocietyComponents(node), getImpacts(node), getMetrics(node)); } else { return;
    private void startExperimentBuilder(DefaultMutableTreeNode node,					boolean openForEditing) {        Object o = node.getUserObject();        Experiment experiment;        if (o instanceof SocietyComponent) {            SocietyComponent sc = (SocietyComponent) o;            String name = "Experiment for " + sc.getSocietyName();            experiment = new Experiment(experimentNames.generateName(name),                                        new SocietyComponent[] {sc},                                        new ImpactComponent[0],                                        new Metric[0]);        } else if (o instanceof Impact) {            ImpactComponent impact = (ImpactComponent) o;            String name = "Experiment for " + impact.getImpactName();            experiment = new Experiment(experimentNames.generateName(name),                                        new SocietyComponent[0],                                        new ImpactComponent[] {impact},                                        new Metric[0]);        } else if (o instanceof Metric) {            Metric metric = (Metric) o;            String name = "Experiment for " + metric.getName();            experiment = new Experiment(experimentNames.generateName(name),                                        new SocietyComponent[0],                                        new ImpactComponent[0],                                        new Metric[] {metric});        } else if (o instanceof Experiment) {            experiment = (Experiment) o;        } else if (o instanceof String) {            experiment = new Experiment(experimentNames.generateName(),                                        getSocietyComponents(node),                                        getImpacts(node),                                        getMetrics(node));        } else {            return;        }        if (o instanceof Experiment) {            //Experiment already in tree        } else {            if (o instanceof String) {                // Add experiment under the given node                DefaultMutableTreeNode newNode = 		  new DefaultMutableTreeNode(experiment);                model.insertNodeInto(newNode, node, 0);		// make the new node be the selected node		workspace.setSelection(newNode);            } else {                // Add experiment as sibling of given node                DefaultMutableTreeNode newNode =                    new DefaultMutableTreeNode(experiment, false);                DefaultMutableTreeNode parentNode =                    (DefaultMutableTreeNode) node.getParent();                model.insertNodeInto(newNode, parentNode, parentNode.getIndex(node) + 1);		// make the new node be the selected node		workspace.setSelection(newNode);            }            experimentNames.add(experiment.getExperimentName());	    experiment.addModificationListener(myModificationListener);        }        csmart.runExperimentBuilder(experiment, false, openForEditing);    }