KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > scenario > util > isac > gui > tree > ScenarioTreeLabelProvider


1 /*
2 * CLIF is a Load Injection Framework
3 * Copyright (C) 2004 France Telecom R&D
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * CLIF
20 *
21 * Contact: clif@objectweb.org
22 */

23 package org.objectweb.clif.scenario.util.isac.gui.tree;
24
25
26 import org.apache.log4j.Category;
27 import org.eclipse.jface.viewers.LabelProvider;
28 import org.eclipse.swt.graphics.Image;
29 import org.objectweb.clif.scenario.util.isac.gui.Icons;
30 import org.objectweb.clif.scenario.util.isac.util.tree.ScenarioNode;
31 import org.objectweb.clif.scenario.util.isac.util.tree.TreeManager;
32
33 /**
34  * This class is the an extension of the LabelProvider class, which permit to print label
35  * for tree nodes.
36  * This class will be used for Scenario trees (containig ScenarioNode objects)
37  *
38  * @author JC Meillaud
39  * @author A Peyrard
40  */

41 public class ScenarioTreeLabelProvider extends LabelProvider {
42     static Category cat = Category.getInstance(ScenarioTreeLabelProvider.class.getName());
43     
44     /**
45      * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
46      */

47     public String JavaDoc getText(Object JavaDoc element) {
48         cat.debug("-> getText") ;
49         TreeManager instance = TreeManager.getTreeManager(null);
50         String JavaDoc label = instance.getNodeLabel((ScenarioNode) element);
51         cat.debug("getText ->") ;
52         return label ;
53     }
54     
55     
56     /**
57      * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
58      */

59     public Image getImage(Object JavaDoc element) {
60         cat.debug("-> getImage") ;
61         try {
62             TreeManager instance = TreeManager.getTreeManager(null);
63             String JavaDoc nodeType = instance.getNodeType((ScenarioNode) element);
64             return Icons.getImageRegistry().get(nodeType);
65         }
66         catch (Exception JavaDoc e) {
67             e.printStackTrace(System.out) ;
68         }
69         return null ;
70     }
71 }
72
Popular Tags