public void reload(DatasetConfigTreeNode editingNode, DatasetConfigTreeNode parentNode) { int start, finish; String parentClassName = (parentNode.getUserObject().getClass()).getName(); String childClassName = (editingNode.getUserObject().getClass()).getName(); start = childClassName.lastIndexOf(".") + 1; finish = childClassName.length(); String childName = childClassName.substring(start, finish); if (parentClassName.equals("org.ensembl.mart.lib.config.DatasetConfig")) { if (childClassName.equals("org.ensembl.mart.lib.config.FilterPage")) { config = (DatasetConfig) parentNode.getUserObject(); config.addFilterPage((FilterPage) editingNode.getUserObject()); // config.removeAttributePage(); } else if (childClassName.equals("org.ensembl.mart.lib.config.AttributePage")) { config = (DatasetConfig) parentNode.getUserObject(); config.addAttributePage((AttributePage) editingNode.getUserObject()); } else if (childClassName.equals("org.ensembl.mart.lib.config.Importable")) { config = (DatasetConfig) parentNode.getUserObject(); config.addImportable((Importable) editingNode.getUserObject()); } else if (childClassName.equals("org.ensembl.mart.lib.config.Exportable")) { config = (DatasetConfig) parentNode.getUserObject(); config.addExportable((Exportable) editingNode.getUserObject()); } } else if (parentClassName.equals("org.ensembl.mart.lib.config.FilterPage")) { if (childClassName.equals("org.ensembl.mart.lib.config.FilterGroup")) { FilterPage fp = (FilterPage) parentNode.getUserObject(); fp.addFilterGroup((FilterGroup) editingNode.getUserObject()); } } else if (parentClassName.equals("org.ensembl.mart.lib.config.FilterGroup")) { if (childClassName.equals("org.ensembl.mart.lib.config.FilterCollection")) { FilterGroup fg = (FilterGroup) parentNode.getUserObject(); fg.addFilterCollection((FilterCollection) editingNode.getUserObject()); } } else if (parentClassName.equals("org.ensembl.mart.lib.config.FilterCollection")) { if (childClassName.equals("org.ensembl.mart.lib.config.FilterDescription")) { FilterCollection fc = (FilterCollection) parentNode.getUserObject(); fc.addFilterDescription((FilterDescription) editingNode.getUserObject()); } } else if (parentClassName.equals("org.ensembl.mart.lib.config.FilterDescription")) { if (childClassName.equals("org.ensembl.mart.lib.config.Option")) { FilterDescription fd = (FilterDescription) parentNode.getUserObject(); fd.addOption((Option) editingNode.getUserObject()); } else if (childClassName.equals("org.ensembl.mart.lib.config.SpecificFilterContent")) { FilterDescription ad = (FilterDescription) parentNode.getUserObject(); ad.addSpecificFilterContent((SpecificFilterContent) editingNode.getUserObject()); } } else if (parentClassName.equals("org.ensembl.mart.lib.config.Option")) { if (childClassName.equals("org.ensembl.mart.lib.config.SpecificOptionContent")) { Option ad = (Option) parentNode.getUserObject(); ad.addSpecificOptionContent((SpecificOptionContent) editingNode.getUserObject()); } else if (childClassName.equals("org.ensembl.mart.lib.config.PushAction")) { Option op = (Option) parentNode.getUserObject(); op.addPushAction((PushAction) editingNode.getUserObject()); } else if (childClassName.equals("org.ensembl.mart.lib.config.Option")) { Option op = (Option) parentNode.getUserObject(); op.addOption((Option) editingNode.getUserObject()); } } else if (parentClassName.equals("org.ensembl.mart.lib.config.PushAction")) { if (childClassName.equals("org.ensembl.mart.lib.config.Option")) { PushAction pa = (PushAction) parentNode.getUserObject(); pa.addOption((Option) editingNode.getUserObject()); } } else if (parentClassName.equals("org.ensembl.mart.lib.config.AttributePage")) { if (childClassName.equals("org.ensembl.mart.lib.config.AttributeGroup")) { AttributePage ap = (AttributePage) parentNode.getUserObject(); ap.addAttributeGroup((AttributeGroup) editingNode.getUserObject()); } } else if (parentClassName.equals("org.ensembl.mart.lib.config.AttributeGroup")) { if (childClassName.equals("org.ensembl.mart.lib.config.AttributeCollection")) { AttributeGroup ag = (AttributeGroup) parentNode.getUserObject(); ag.addAttributeCollection((AttributeCollection) editingNode.getUserObject()); } } else if (parentClassName.equals("org.ensembl.mart.lib.config.AttributeCollection")) { if (childClassName.equals("org.ensembl.mart.lib.config.AttributeDescription")) { AttributeCollection ac = (AttributeCollection) parentNode.getUserObject(); ac.addAttributeDescription((AttributeDescription) editingNode.getUserObject()); } else if (childClassName.equals("org.ensembl.mart.lib.config.AttributeList")) { AttributeCollection ac = (AttributeCollection) parentNode.getUserObject(); ac.addAttributeList((AttributeList) editingNode.getUserObject()); } } else if (parentClassName.equals("org.ensembl.mart.lib.config.AttributeDescription")) { if (childClassName.equals("org.ensembl.mart.lib.config.SpecificAttributeContent")) { AttributeDescription ad = (AttributeDescription) parentNode.getUserObject(); ad.addSpecificAttributeContent((SpecificAttributeContent) editingNode.getUserObject()); } } else if (parentClassName.equals("org.ensembl.mart.lib.config.SpecificFilterContent")) { if (childClassName.equals("org.ensembl.mart.lib.config.Option")) { SpecificFilterContent fd = (SpecificFilterContent) parentNode.getUserObject(); System.out.println( "TREE MODEL -- ADDING DYN OPTION " + ((Option) editingNode.getUserObject()).getInternalName()); fd.addOption((Option) editingNode.getUserObject()); } } super.reload(parentNode); }
public String insertNodeInto( DatasetConfigTreeNode editingNode, DatasetConfigTreeNode parentNode, int index) { int start, finish; Object child = editingNode.getUserObject(); Object parent = parentNode.getUserObject(); BaseNamedConfigurationObject parentObj = (BaseNamedConfigurationObject) parent; BaseNamedConfigurationObject childObj = (BaseNamedConfigurationObject) child; if (parentObj.getHidden() != null && parentObj.getHidden().equals("true")) { childObj.setHidden("true"); Enumeration children = editingNode.breadthFirstEnumeration(); DatasetConfigTreeNode childNode = null; while (children.hasMoreElements()) { childNode = (DatasetConfigTreeNode) children.nextElement(); BaseNamedConfigurationObject ch = (BaseNamedConfigurationObject) childNode.getUserObject(); ch.setHidden("true"); } } String childClassName = (editingNode.getUserObject().getClass()).getName(); start = childClassName.lastIndexOf(".") + 1; finish = childClassName.length(); String childName = childClassName.substring(start, finish); // index is a Node index. objectIndex may be different int objIndex = index - DatasetConfigTreeNode.getHeterogenousOffset(parent, child); if (parent instanceof org.ensembl.mart.lib.config.DatasetConfig) { if (child instanceof org.ensembl.mart.lib.config.FilterPage) { config = (DatasetConfig) parentNode.getUserObject(); config.insertFilterPage(objIndex, (FilterPage) editingNode.getUserObject()); } else if (child instanceof org.ensembl.mart.lib.config.AttributePage) { config = (DatasetConfig) parentNode.getUserObject(); config.insertAttributePage(objIndex, (AttributePage) editingNode.getUserObject()); } else if (child instanceof org.ensembl.mart.lib.config.Importable) { config = (DatasetConfig) parentNode.getUserObject(); config.insertImportable(objIndex, (Importable) editingNode.getUserObject()); } else if (child instanceof org.ensembl.mart.lib.config.Exportable) { config = (DatasetConfig) parentNode.getUserObject(); config.insertExportable(objIndex, (Exportable) editingNode.getUserObject()); } else { String error_string = "Error: " + childName + " cannot be inserted in a DatasetConfig."; return error_string; } } else if (parent instanceof org.ensembl.mart.lib.config.FilterPage) { if (child instanceof org.ensembl.mart.lib.config.FilterGroup) { FilterPage fp = (FilterPage) parentNode.getUserObject(); fp.insertFilterGroup(objIndex, (FilterGroup) editingNode.getUserObject()); } else { String error_string = "Error: " + childName + " cannot be inserted in a FilterPage."; return error_string; } } else if (parent instanceof org.ensembl.mart.lib.config.FilterGroup) { if (child instanceof org.ensembl.mart.lib.config.FilterCollection) { FilterGroup fg = (FilterGroup) parentNode.getUserObject(); fg.insertFilterCollection(objIndex, (FilterCollection) editingNode.getUserObject()); } else { String error_string = "Error: " + childName + " cannot be inserted in a FilterGroup."; return error_string; } } else if (parent instanceof org.ensembl.mart.lib.config.FilterCollection) { if (child instanceof org.ensembl.mart.lib.config.FilterDescription) { FilterCollection fc = (FilterCollection) parentNode.getUserObject(); fc.insertFilterDescription(objIndex, (FilterDescription) editingNode.getUserObject()); } else if (child instanceof org.ensembl.mart.lib.config.Option) { FilterCollection fc = (FilterCollection) parentNode.getUserObject(); FilterDescription fdConvert = new FilterDescription((Option) editingNode.getUserObject()); fc.insertFilterDescription(objIndex, fdConvert); editingNode.setUserObject(fdConvert); } else if (child instanceof org.ensembl.mart.lib.config.AttributeDescription) { FilterCollection fc = (FilterCollection) parentNode.getUserObject(); // FilterDescription fdConvert = new FilterDescription((AttributeDescription) // editingNode.getUserObject()); AttributeDescription ad = (AttributeDescription) editingNode.getUserObject(); FilterDescription fdConvert = null; try { fdConvert = new FilterDescription( ad.getInternalName(), ad.getField(), "text", "=", "=", ad.getDisplayName(), ad.getTableConstraint(), ad.getKey(), ad.getDescription(), "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""); } catch (ConfigurationException e) { // guaranteed internal name for atts } fc.insertFilterDescription(objIndex, fdConvert); editingNode.setUserObject(fdConvert); } else { String error_string = "Error: " + childName + " cannot be inserted in a FilterCollection."; return error_string; } } else if (parent instanceof org.ensembl.mart.lib.config.FilterDescription) { if (child instanceof org.ensembl.mart.lib.config.SpecificFilterContent) { FilterDescription ad = (FilterDescription) parentNode.getUserObject(); ad.insertSpecificFilterContent( objIndex, (SpecificFilterContent) editingNode.getUserObject()); } else if (child instanceof org.ensembl.mart.lib.config.FilterDescription) { FilterDescription fd = (FilterDescription) parentNode.getUserObject(); Option opConvert = new Option((FilterDescription) editingNode.getUserObject()); fd.insertOption(objIndex, opConvert); editingNode.setUserObject(opConvert); } else if (child instanceof org.ensembl.mart.lib.config.Option) { FilterDescription fd = (FilterDescription) parentNode.getUserObject(); fd.insertOption(objIndex, (Option) editingNode.getUserObject()); } else if (child instanceof org.ensembl.mart.lib.config.PushAction) { FilterDescription fd = (FilterDescription) parentNode.getUserObject(); // fd.insertPushAction(objIndex, (PushAction) editingNode.getUserObject()); } else { String error_string = "Error: " + childName + " cannot be inserted in a FilterDescription."; return error_string; } } else if (parent instanceof org.ensembl.mart.lib.config.Option) { if (child instanceof org.ensembl.mart.lib.config.SpecificOptionContent) { Option ad = (Option) parentNode.getUserObject(); ad.insertSpecificOptionContent( objIndex, (SpecificOptionContent) editingNode.getUserObject()); } else if (child instanceof org.ensembl.mart.lib.config.PushAction) { Option op = (Option) parentNode.getUserObject(); op.insertPushAction(objIndex, (PushAction) editingNode.getUserObject()); } else if (child instanceof org.ensembl.mart.lib.config.Option) { Option op = (Option) parentNode.getUserObject(); op.insertOption(objIndex, (Option) editingNode.getUserObject()); } } else if (parent instanceof org.ensembl.mart.lib.config.PushAction) { if (child instanceof org.ensembl.mart.lib.config.Option) { PushAction pa = (PushAction) parentNode.getUserObject(); pa.insertOption(objIndex, (Option) editingNode.getUserObject()); } } else if (parent instanceof org.ensembl.mart.lib.config.AttributePage) { if (child instanceof org.ensembl.mart.lib.config.AttributeGroup) { AttributePage ap = (AttributePage) parentNode.getUserObject(); ap.insertAttributeGroup(objIndex, (AttributeGroup) editingNode.getUserObject()); } else { String error_string = "Error: " + childName + " cannot be inserted in an AttributePage."; return error_string; } } else if (parent instanceof org.ensembl.mart.lib.config.AttributeGroup) { if (child instanceof org.ensembl.mart.lib.config.AttributeCollection) { AttributeGroup ag = (AttributeGroup) parentNode.getUserObject(); ag.insertAttributeCollection(objIndex, (AttributeCollection) editingNode.getUserObject()); } else { String error_string = "Error: " + childName + " cannot be inserted in an AttributeGroup."; return error_string; } } else if (parent instanceof org.ensembl.mart.lib.config.AttributeCollection) { if (child instanceof org.ensembl.mart.lib.config.AttributeDescription) { AttributeCollection ac = (AttributeCollection) parentNode.getUserObject(); ac.insertAttributeDescription(objIndex, (AttributeDescription) editingNode.getUserObject()); } else if (child instanceof org.ensembl.mart.lib.config.AttributeList) { AttributeCollection ac = (AttributeCollection) parentNode.getUserObject(); ac.insertAttributeList(objIndex, (AttributeList) editingNode.getUserObject()); } else { String error_string = "Error: " + childName + " cannot be inserted in an AttributeCollection."; return error_string; } } else if (parent instanceof org.ensembl.mart.lib.config.AttributeDescription) { if (child instanceof org.ensembl.mart.lib.config.SpecificAttributeContent) { AttributeDescription ad = (AttributeDescription) parentNode.getUserObject(); ad.insertSpecificAttributeContent( objIndex, (SpecificAttributeContent) editingNode.getUserObject()); } else { String error_string = "Error: " + childName + " cannot be inserted in a FilterDescription."; return error_string; } } else if (parent instanceof org.ensembl.mart.lib.config.SpecificFilterContent) { if (child instanceof org.ensembl.mart.lib.config.Option) { SpecificFilterContent fd = (SpecificFilterContent) parentNode.getUserObject(); System.out.println( "TREE MODEL 2 -- ADDING DYN OPTION " + ((Option) editingNode.getUserObject()).getInternalName()); fd.insertOption(objIndex, (Option) editingNode.getUserObject()); } else { String error_string = "Error: " + childName + " cannot be inserted in an DynamicFilterContent."; return error_string; } } else if (parent instanceof org.ensembl.mart.lib.config.SpecificAttributeContent) { String error_string = "Error: " + childName + " cannot be inserted in an DynamicAttributeContent."; return error_string; } else if (parent instanceof org.ensembl.mart.lib.config.SpecificOptionContent) { String error_string = "Error: " + childName + " cannot be inserted in an DynamicOptionContent."; return error_string; } super.insertNodeInto(editingNode, parentNode, index); return "success"; }