1 /*
2 * Copyright 2006-2016 The JGUIraffe Team.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License")
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package net.sf.jguiraffe.gui.platform.swing.builder.components;
17
18 import org.apache.commons.configuration.tree.ConfigurationNode;
19
20 /**
21 * <p>
22 * An internally used helper class for formatting the nodes of a tree view.
23 * </p>
24 * <p>
25 * The main task of this class is to return a string representation for the node
26 * of a tree. Nodes are represented by {@code ConfigurationNode} objects
27 * (although the Swing model operates on untyped objects internally). The
28 * default format is just the name of the node.
29 * </p>
30 *
31 * @author Oliver Heger
32 * @version $Id: $
33 */
34 class SwingTreeNodeFormatter
35 {
36 /**
37 * Returns the text to be displayed for the passed in tree node. This
38 * implementation expects that the passed in node is a
39 * {@code ConfigurationNode} and returns its name.
40 *
41 * @param node the tree node
42 * @return the text representation for this node
43 */
44 public String textForNode(Object node)
45 {
46 return ((ConfigurationNode) node).getName();
47 }
48 }