Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/virtuosotechnologies/lib/basiccommand/builder/ToolBarBuilderNode.java


1   /*
2   ================================================================================
3   
4     FILE:  ToolBarBuilderNode.java
5     
6     PROJECT:
7     
8       Virtuoso Utilities
9     
10    CONTENTS:
11    
12      A builder that creates a tool bar.
13    
14    PROGRAMMERS:
15    
16      Daniel Azuma (DA)  <dazuma@kagi.com>
17    
18    COPYRIGHT:
19    
20      Copyright (C) 2003  Daniel Azuma  (dazuma@kagi.com)
21      
22      This program is free software; you can redistribute it and/or
23      modify it under the terms of the GNU General Public License as
24      published by the Free Software Foundation; either version 2
25      of the License, or (at your option) any later version.
26      
27      This program is distributed in the hope that it will be useful,
28      but WITHOUT ANY WARRANTY; without even the implied warranty of
29      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30      GNU General Public License for more details.
31      
32      You should have received a copy of the GNU General Public
33      License along with this program; if not, write to
34        Free Software Foundation, Inc.
35        59 Temple Place, Suite 330
36        Boston, MA 02111-1307 USA
37  
38  ================================================================================
39  */
40  
41  
42  package com.virtuosotechnologies.lib.basiccommand.builder;
43  
44  
45  import javax.swing.JToolBar;
46  
47  import com.virtuosotechnologies.lib.command.CommandNode;
48  import com.virtuosotechnologies.lib.command.CommandNodeFlavor;
49  import com.virtuosotechnologies.lib.basiccommand.BasicCommandNode;
50  
51  
52  /**
53   * A builder that creates a tool bar.
54   */
55  public class ToolBarBuilderNode
56  extends AbstractAWTContainerBuilderNode
57  {
58    /**
59     * Constructor
60     */
61    public ToolBarBuilderNode(
62      CommandNode commandNode)
63    {
64      super(commandNode, null, END_POSITION);
65    }
66    
67    
68    /**
69     * Constructor
70     */
71    public ToolBarBuilderNode(
72      CommandNode commandNode,
73      JToolBar toolBar)
74    {
75      super(commandNode, null, END_POSITION, toolBar);
76    }
77    
78    
79    /**
80     * Override this method to create the initial element object.
81     */
82    protected Object createInitialElement()
83    {
84      return new JToolBar();
85    }
86    
87    
88    /**
89     * Create a child node
90     */
91    protected AbstractBuilderNode createChildNode(
92      CommandNode cn,
93      int index)
94    {
95      AbstractBuilderNode child = null;
96      CommandNodeFlavor flavor = cn.getFlavor();
97      if (flavor.equalsOrExtends(BasicCommandNode.SEPARATOR_FLAVOR))
98      {
99        child = new ToolBarSeparatorBuilderNode(cn, this, index);
100     }
101     else if (flavor.equalsOrExtends(BasicCommandNode.ACTIONITEM_FLAVOR))
102     {
103       child = new ToolBarItemBuilderNode(cn, this, index);
104     }
105     else if (flavor.equalsOrExtends(BasicCommandNode.APPEARANCECHANGING_TOGGLEITEM_FLAVOR))
106     {
107       child = new ToolBarToggleItemBuilderNode(cn, this, index);
108     }
109     else if (flavor.equalsOrExtends(BasicCommandNode.TOGGLEITEM_FLAVOR))
110     {
111       child = new ToolBarCheckBoxItemBuilderNode(cn, this, index);
112     }
113     else if (flavor.equalsOrExtends(BasicCommandNode.RADIOGROUP_FLAVOR))
114     {
115       child = new ToolBarRadioGroupBuilderNode(cn, this, index);
116     }
117     else if (flavor.equalsOrExtends(BasicCommandNode.GROUP_FLAVOR))
118     {
119       child = new ToolBarGroupBuilderNode(cn, this, index);
120     }
121     return child;
122   }
123   
124   
125   /**
126    * Get the built tool bar
127    */
128   public JToolBar getJToolBar()
129   {
130     return (JToolBar)getElement();
131   }
132 }