View Javadoc

1   package com.melloware.jukes.gui.view;
2   
3   import javax.swing.AbstractButton;
4   import javax.swing.JToolBar;
5   
6   import com.jgoodies.looks.BorderStyle;
7   import com.jgoodies.looks.HeaderStyle;
8   import com.jgoodies.looks.Options;
9   import com.jgoodies.looks.plastic.PlasticLookAndFeel;
10  import com.jgoodies.looks.windows.WindowsLookAndFeel;
11  import com.jgoodies.uif.action.ActionManager;
12  import com.jgoodies.uif.builder.ToolBarBuilder;
13  import com.jgoodies.uif.component.ToolBarButton;
14  import com.melloware.jukes.gui.tool.Actions;
15  
16  /**
17   * Builds the tool bar of the Jukes application.
18   * <p>
19   * Copyright (c) 1999-2007 Melloware, Inc. <http://www.melloware.com>
20   * @author Emil A. Lefkof III <info@melloware.com>
21   * @version 4.0
22   *
23   * @see MainFrame
24   * @see Actions
25   */
26  final class MainToolBarBuilder {
27  
28      /**
29       * Creates, configures, composes and returns the tool bar.
30       *
31       * @return the application's toolbar.
32       */
33      JToolBar build() {
34      	final ToolBarBuilder toolBar = new ToolBarBuilder("Main ToolBar");
35          toolBar.addGap(2);
36          toolBar.add(createToolBarButton(Actions.REFRESH_ID));
37          toolBar.add(createToolBarButton(Actions.TRACK_ADD_ID)); //AZ
38          toolBar.add(createToolBarButton(Actions.DISC_ADD_ID));
39          toolBar.add(createToolBarButton(Actions.DISC_FINDER_ID));
40          toolBar.add(createToolBarButton(Actions.DISC_REMOVER_ID));
41          toolBar.addSeparator();
42          toolBar.add(createToolBarButton(Actions.SEARCH_ID));
43          toolBar.add(createToolBarButton(Actions.PLAYLIST_SHOW_ID));
44          toolBar.add(createToolBarButton(Actions.DISCLIST_SHOW_ID)); //AZ
45          toolBar.add(createToolBarButton(Actions.FILTER_SHOW_ID));
46          toolBar.add(createToolBarButton(Actions.CATALOG_EXPORT_ID));
47          toolBar.add(createToolBarButton(Actions.TOOL_DIFFERENCE_ID));
48          toolBar.add(createToolBarButton(Actions.TOOL_CHECK_GENRES_ID));  //AZ 
49          toolBar.add(createToolBarButton(Actions.TOOL_LOCATION_ID));
50          toolBar.add(createToolBarButton(Actions.TOOL_BACKUP_ID));
51          toolBar.add(createToolBarButton(Actions.TOOL_MEMORY_ID));
52          toolBar.add(createToolBarButton(Actions.TOOL_STATISTICS_ID));
53          toolBar.addSeparator();
54          toolBar.addLargeGap();
55          toolBar.addLargeGap();
56          toolBar.addGlue();
57          toolBar.add(ActionManager.get(Actions.PREFERENCES_ID));
58          toolBar.add(ActionManager.get(Actions.HELP_CONTENTS_ID));
59          toolBar.addGap(2);
60          
61          JToolBar bar = toolBar.getToolBar();
62  //      Set a hint so that JGoodies Looks will detect it as being in the header.
63          bar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
64          // Unlike the default, use a separator border.
65          bar.putClientProperty(WindowsLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);
66          bar.putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);
67          return bar;
68      }
69      
70      /**
71       * Builds and returns the Tray Icon Menu.
72       */
73      public static JToolBar buildPlayerToolBar() {
74      	final ToolBarBuilder toolBar = new ToolBarBuilder("Player");
75  
76          toolBar.addGap(2);
77          toolBar.add(createToolBarButton(Actions.PLAYER_PLAY_ID));
78          toolBar.add(createToolBarButton(Actions.PLAYER_PAUSE_ID));
79          toolBar.add(createToolBarButton(Actions.PLAYER_STOP_ID));
80          toolBar.add(createToolBarButton(Actions.PLAYER_PREVIOUS_ID));
81          toolBar.add(createToolBarButton(Actions.PLAYER_NEXT_ID));
82          toolBar.addGap(2);
83          return toolBar.getToolBar();
84      }
85  
86      /**
87       * Creates and returns a button which is suitable for use in a tool bar.
88       */
89      private static AbstractButton createToolBarButton(String actionID) {
90          return new ToolBarButton(ActionManager.get(actionID));
91      }
92  
93  }