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.DISC_ADD_ID));
38          toolBar.add(createToolBarButton(Actions.DISC_FINDER_ID));
39          toolBar.add(createToolBarButton(Actions.DISC_REMOVER_ID));
40          toolBar.addSeparator();
41          toolBar.add(createToolBarButton(Actions.SEARCH_ID));
42          toolBar.add(createToolBarButton(Actions.PLAYLIST_SHOW_ID));
43          toolBar.add(createToolBarButton(Actions.FILTER_SHOW_ID));
44          toolBar.add(createToolBarButton(Actions.CATALOG_EXPORT_ID));
45          toolBar.add(createToolBarButton(Actions.TOOL_DIFFERENCE_ID));
46          toolBar.add(createToolBarButton(Actions.TOOL_LOCATION_ID));
47          toolBar.add(createToolBarButton(Actions.TOOL_BACKUP_ID));
48          toolBar.add(createToolBarButton(Actions.TOOL_MEMORY_ID));
49          toolBar.add(createToolBarButton(Actions.TOOL_STATISTICS_ID));
50          toolBar.addSeparator();
51          toolBar.addLargeGap();
52          toolBar.addLargeGap();
53          toolBar.addGlue();
54          toolBar.add(ActionManager.get(Actions.PREFERENCES_ID));
55          toolBar.add(ActionManager.get(Actions.HELP_CONTENTS_ID));
56          toolBar.addGap(2);
57          
58          JToolBar bar = toolBar.getToolBar();
59  //      Set a hint so that JGoodies Looks will detect it as being in the header.
60          bar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
61          // Unlike the default, use a separator border.
62          bar.putClientProperty(WindowsLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);
63          bar.putClientProperty(PlasticLookAndFeel.BORDER_STYLE_KEY, BorderStyle.SEPARATOR);
64          return bar;
65      }
66      
67      /**
68       * Builds and returns the Tray Icon Menu.
69       */
70      public static JToolBar buildPlayerToolBar() {
71      	final ToolBarBuilder toolBar = new ToolBarBuilder("Player");
72  
73          toolBar.addGap(2);
74          toolBar.add(createToolBarButton(Actions.PLAYER_PLAY_ID));
75          toolBar.add(createToolBarButton(Actions.PLAYER_PAUSE_ID));
76          toolBar.add(createToolBarButton(Actions.PLAYER_STOP_ID));
77          toolBar.add(createToolBarButton(Actions.PLAYER_PREVIOUS_ID));
78          toolBar.add(createToolBarButton(Actions.PLAYER_NEXT_ID));
79          toolBar.addGap(2);
80          return toolBar.getToolBar();
81      }
82  
83      /**
84       * Creates and returns a button which is suitable for use in a tool bar.
85       */
86      private static AbstractButton createToolBarButton(String actionID) {
87          return new ToolBarButton(ActionManager.get(actionID));
88      }
89  
90  }