src/core/net/sf/basedb/util/overview/node/ExtractNameGenerator.java

Code
Comments
Other
Rev Date Author Line
5651 08 Jun 11 nicklas 1 /**
5651 08 Jun 11 nicklas 2   $Id$
5651 08 Jun 11 nicklas 3
5651 08 Jun 11 nicklas 4   Copyright (C) 2009 Nicklas Nordborg
5651 08 Jun 11 nicklas 5
5651 08 Jun 11 nicklas 6   This file is part of BASE - BioArray Software Environment.
5651 08 Jun 11 nicklas 7   Available at http://base.thep.lu.se/
5651 08 Jun 11 nicklas 8
5651 08 Jun 11 nicklas 9   BASE is free software; you can redistribute it and/or
5651 08 Jun 11 nicklas 10   modify it under the terms of the GNU General Public License
5651 08 Jun 11 nicklas 11   as published by the Free Software Foundation; either version 3
5651 08 Jun 11 nicklas 12   of the License, or (at your option) any later version.
5651 08 Jun 11 nicklas 13
5651 08 Jun 11 nicklas 14   BASE is distributed in the hope that it will be useful,
5651 08 Jun 11 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
5651 08 Jun 11 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5651 08 Jun 11 nicklas 17   GNU General Public License for more details.
5651 08 Jun 11 nicklas 18
5651 08 Jun 11 nicklas 19   You should have received a copy of the GNU General Public License
5651 08 Jun 11 nicklas 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
5651 08 Jun 11 nicklas 21 */
5651 08 Jun 11 nicklas 22 package net.sf.basedb.util.overview.node;
5651 08 Jun 11 nicklas 23
5651 08 Jun 11 nicklas 24 import net.sf.basedb.core.Tag;
5651 08 Jun 11 nicklas 25 import net.sf.basedb.core.Extract;
5651 08 Jun 11 nicklas 26 import net.sf.basedb.util.overview.Node;
5651 08 Jun 11 nicklas 27
5651 08 Jun 11 nicklas 28 /**
5651 08 Jun 11 nicklas 29   Name generator implementation for {@link Extract}
5651 08 Jun 11 nicklas 30   items. The implementation use the {@link NameableNameGenerator}
5651 08 Jun 11 nicklas 31   but prefixes the node title with the name of the tag (if present).
5651 08 Jun 11 nicklas 32   Eg. <code>cy3: My labeled extract</code>.
5651 08 Jun 11 nicklas 33   
5651 08 Jun 11 nicklas 34   @author Nicklas
5651 08 Jun 11 nicklas 35   @version 2.10
5651 08 Jun 11 nicklas 36   @base.modified $Date$
5651 08 Jun 11 nicklas 37 */
5651 08 Jun 11 nicklas 38 public class ExtractNameGenerator
5651 08 Jun 11 nicklas 39   extends NameableNameGenerator<Extract>
5651 08 Jun 11 nicklas 40 {
5651 08 Jun 11 nicklas 41
5651 08 Jun 11 nicklas 42   /**
5651 08 Jun 11 nicklas 43     Create a new name generator.
5651 08 Jun 11 nicklas 44     @param namePrefix The prefix to use in node names
5651 08 Jun 11 nicklas 45     @param titlePrefix The prefix to use in node titles
5651 08 Jun 11 nicklas 46   */
5651 08 Jun 11 nicklas 47   public ExtractNameGenerator(String namePrefix, String titlePrefix)
5651 08 Jun 11 nicklas 48   {
5651 08 Jun 11 nicklas 49     super(namePrefix, titlePrefix);
5651 08 Jun 11 nicklas 50   }
5651 08 Jun 11 nicklas 51   
5651 08 Jun 11 nicklas 52   /*
5651 08 Jun 11 nicklas 53     From the NameableNameGenerator class
5651 08 Jun 11 nicklas 54     ------------------------------------
5651 08 Jun 11 nicklas 55   */
5651 08 Jun 11 nicklas 56   /**
5651 08 Jun 11 nicklas 57     The base of the title is generated by the superclass. This
5651 08 Jun 11 nicklas 58     implementation just prefixes the title with the name of the tag.
5651 08 Jun 11 nicklas 59   */
5651 08 Jun 11 nicklas 60   @Override
5651 08 Jun 11 nicklas 61   public String getNodeTitle(Extract item, Node parentNode)
5651 08 Jun 11 nicklas 62   {
5651 08 Jun 11 nicklas 63     String title = super.getNodeTitle(item, parentNode);
5651 08 Jun 11 nicklas 64     try
5651 08 Jun 11 nicklas 65     {
5651 08 Jun 11 nicklas 66       Tag tag = item.getTag();
5748 19 Sep 11 nicklas 67       if (tag != null && parentNode.getNodeType() == Node.Type.FOLDER) 
5748 19 Sep 11 nicklas 68       {
5748 19 Sep 11 nicklas 69         title = tag.getName() + ": " + title;
5748 19 Sep 11 nicklas 70       }
5651 08 Jun 11 nicklas 71     }
5651 08 Jun 11 nicklas 72     catch (RuntimeException ex)
5651 08 Jun 11 nicklas 73     {}
5651 08 Jun 11 nicklas 74     return title;
5651 08 Jun 11 nicklas 75   }
5651 08 Jun 11 nicklas 76
5651 08 Jun 11 nicklas 77 }