/* DatabaseTreeNode.java * * created: October 2006 * * This file is part of Artemis * * Copyright(C) 2006 Genome Research Limited * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or(at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ package uk.ac.sanger.artemis.components.database; import java.awt.Frame; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.UnsupportedFlavorException; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.tree.DefaultMutableTreeNode; import org.gmod.schema.organism.Organism; import org.gmod.schema.organism.OrganismProp; import org.gmod.schema.sequence.Feature; import uk.ac.sanger.artemis.Options; import uk.ac.sanger.artemis.components.Splash; import uk.ac.sanger.artemis.util.DatabaseDocument; import java.io.File; import java.io.FileOutputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import java.io.IOException; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Set; /** * File node for local file tree manager */ public class DatabaseTreeNode extends DefaultMutableTreeNode implements Transferable, Serializable { private static final long serialVersionUID = 1L; public static final DataFlavor DATABASETREENODE = new DataFlavor(DatabaseTreeNode.class, "Work Package"); public static final DataFlavor STRING_DATA_FLAVOUR = new DataFlavor(String.class, "text/plain"); private static final DataFlavor flavors[] = { DATABASETREENODE, DataFlavor.stringFlavor }; private String featureId; private String featureType; // e.g. chromosome, mitochondrial_chromosome private transient Organism organism; private String organismCommonName; private boolean isLeaf = false; private String userName; private static transient DatabaseDocument dbDoc; private boolean explored = false; protected DatabaseTreeNode(final String name) { super(name); } private DatabaseTreeNode(final String name, final boolean isLeaf) { super(name); this.isLeaf = isLeaf; } /** * Top node constructor * @param name * @param isLeaf * @param organism * @param userName * @param dbDoc */ protected DatabaseTreeNode(final String name, final boolean isLeaf, final Organism organism, final String userName, final DatabaseDocument dbDoc) { super(name); this.isLeaf = isLeaf; this.organism = organism; this.userName = userName; this.dbDoc = dbDoc; setOrganismCommonName(); } /** * Leaf constructor * @param name * @param organism * @param featureId * @param userName */ private DatabaseTreeNode(final String name, final Organism organism, final String featureId, final String featureType, final String userName) { super(name); this.organism = organism; this.featureId = featureId; this.featureType = featureType; this.userName = userName; if(getOrganism() != null) setOrganismCommonName(); } public String getOrganismCommonName() { return organismCommonName; } private void setOrganismCommonName() { this.organismCommonName = getOrganism().getCommonName(); if(organismCommonName == null || organismCommonName.equals("")) organismCommonName = getOrganism().getGenus() + "." + getOrganism().getSpecies(); } /** * Use the OrganismProps to set the translation table and * determine in this is a read only entry. * @param op * @return */ public static boolean setOrganismProps(Set op, final boolean isMitochondrial) { Splash splash = getSplash(); boolean readOnly = false; final Iterator it = op.iterator(); while (it.hasNext()) { OrganismProp organismProp = it.next(); if(splash != null) { if( (isMitochondrial && organismProp.getCvTerm().getName().equals("mitochondrialTranslationTable")) || (!isMitochondrial && organismProp.getCvTerm().getName().equals("translationTable"))) splash.setTranslationTable(organismProp.getValue()); } if(organismProp.getCvTerm().getName().equals("frozen") && organismProp.getValue().equals("yes")) readOnly = true; } return readOnly; } private static Splash getSplash() { Frame[] frames = JFrame.getFrames(); for(int i=0;i sequenceList = dbDoc.getResidueFeatures(new Integer(getOrganism().getOrganismId())); Hashtable sequenceNode = new Hashtable(); for(int i=0;i