View Javadoc

1   package com.melloware.jukes.gui.tool;
2   
3   import java.awt.event.ActionEvent;
4   import java.beans.PropertyChangeEvent;
5   import java.beans.PropertyChangeListener;
6   import java.util.Locale;
7   import java.util.ResourceBundle;
8   
9   import javax.swing.AbstractAction;
10  
11  import org.apache.commons.logging.Log;
12  import org.apache.commons.logging.LogFactory;
13  
14  import com.jgoodies.uif.action.ActionManager;
15  import com.jgoodies.uifextras.help.HelpBroker;
16  import com.melloware.jukes.db.orm.Catalog;
17  import com.melloware.jukes.gui.Jukes;
18  
19  /**
20   * Provides all UI <code>Actions</code> and their IDs. Therefore it declares
21   * static fields for action ids and implementations of the <code>Action</code>
22   * interface. These actions are registered to the <code>ActionManager</code>.
23   * <p>
24   * This class demos three different styles to implement <code>Action</code>;
25   * they differ in readability, number of classes loaded, and the ability to
26   * write more or less large action bodies, while preserving good code
27   * formatting:
28   * <ol>
29   * <li>anonymous classes: This approach provides a literally compact way to
30   * write down a bunch of action implementations, which will work better, if you
31   * have tiny method bodys. In our demo, all method bodies just delegate to the
32   * application controller. Does not provide human readable name in case of an
33   * error and so, may be more difficult to debug. Requires a class for every
34   * action.
35   * <li>nested top-level classes: This approach requires a little bit more
36   * writing than the first approach. Writing larger method bodies does not affect
37   * the registering method. The extra class names help you find bugs. Requires a
38   * class for every action.
39   * <li>instances of a single dispatching class: This approach leads to good
40   * readability in the registering method and requires only one class to load for
41   * all actions. Works better with small action bodies. May lead to runtime
42   * errors, if you haven't defined a dispatch for an action ID.
43   * </ol>
44   * <p>
45   * Copyright (c) 1999-2007 Melloware, Inc. <http://www.melloware.com>
46   * @author Emil A. Lefkof III <info@melloware.com>
47   * @version 4.0
48   * @see ActionManager
49   * @see Action
50   * @see AbstractAction
51   * @see MainController
52   */
53  public final class Actions {
54  
55     private static final Log LOG = LogFactory.getLog(Actions.class);
56  
57     public static final String LANG_ENGLISH_ID = "language.english";
58     public static final String LANG_FRENCH_ID = "language.french";
59     public static final String LANG_GERMAN_ID = "language.german";
60     public static final String LANG_SPANISH_ID = "language.spanish";
61     public static final String LANG_PORTUGEUSE_ID = "language.portuguese";
62     public static final String LANG_NORWEGIAN_ID = "language.norwegian";
63     public static final String LANG_DUTCH_ID = "language.dutch";
64     public static final String LANG_ITALIAN_ID = "language.italian";
65     public static final String LANG_SWEDISH_ID = "language.swedish";
66     public static final String LANG_FINNISH_ID = "language.finnish";
67     public static final String LANG_RUSSIAN_ID = "language.russian";
68     public static final String LANG_UKRAINIAN_ID = "language.ukrainian";
69     public static final String LANG_CHINESE_ID = "language.chinese";
70     public static final String LANG_KOREAN_ID = "language.korean";
71     public static final String LANG_TAMIL_ID = "language.tamil";
72     public static final String LANG_TELEGU_ID = "language.telegu";
73     public static final String LANG_HINDHI_ID = "language.hindhi";
74     public static final String LANG_INDONESIAN_ID = "language.indonesian";
75     public static final String HELP_CONTENTS_ID = "openHelpContents";
76     public static final String HELP_TIP_OF_THE_DAY_ID = "openTipOfTheDay";
77     public static final String HELP_ABOUT_DIALOG_ID = "openAboutDialog";
78     public static final String HELP_FORUMS_ID = "help.forums";
79     public static final String HELP_DONATE_ID = "help.donate";
80     public static final String HELP_CONTACT_ID = "help.contact";
81     public static final String TITLECASE_ID = "titlecase";
82     public static final String FILE_RENAME_ID = "file.rename";
83     public static final String CATALOG_EXPORT_ID = "export.list";
84     public static final String DIRECTORY_ID = "directorychooser";
85     public static final String FILE_CHOOSER_ID = "filechooser";
86     public static final String COMMIT_ID = "commit";
87     public static final String ROLLBACK_ID = "rollback";
88     public static final String UNLOCK_ID = "unlock";
89     public static final String REFRESH_ID = "refresh";
90     public static final String PREFERENCES_ID = "preferences";
91     public static final String PREFERENCES_IMPORT_ID = "preferences.import";
92     public static final String PREFERENCES_EXPORT_ID = "preferences.export";
93     public static final String CONNECT_ID = "connect";
94     public static final String DELETE_ID = "delete";
95     public static final String DISC_WEB_ID = "disc.web";
96     public static final String DISC_COVER_ID = "disc.cover";
97     public static final String DISC_ADD_ID = "disc.add";
98     public static final String DISC_ADD_TITLECASE_ID = "disc.add.titlecase";
99     public static final String DISC_ADD_COMMENTS_ID = "disc.add.comments";
100    public static final String DISC_ADD_RESET_NUMBERS_ID = "disc.add.resettracks";
101    public static final String DISC_ADD_RESET_FROM_FILENAME_ID = "disc.add.resetfromfilename";
102    public static final String DISC_FINDER_ID = "disc.finder";
103    public static final String DISC_REMOVER_ID = "disc.remover";
104    public static final String APP_HIDE_ID = "application.hide";
105    public static final String APP_SHOW_ID = "application.show";
106    public static final String TOOL_STATISTICS_ID = "statistics";
107    public static final String TOOL_MEMORY_ID = "memory";
108    public static final String TOOL_DIFFERENCE_ID = "difference.tool";
109    public static final String TOOL_LOCATION_ID = "location.tool";
110    public static final String TOOL_BACKUP_ID = "backup.tool";
111    public static final String TRACK_PLAY_IMMEDIATE_ID = "play.immediate";
112    public static final String PLAYER_QUEUE_ID = "player.queue";
113    public static final String PLAYER_QUEUE_NEXT_ID = "player.queuenext";
114    public static final String PLAYER_PLAY_ID = "player.play";
115    public static final String PLAYER_PAUSE_ID = "player.pause";
116    public static final String PLAYER_STOP_ID = "player.stop";
117    public static final String PLAYER_PREVIOUS_ID = "player.previous";
118    public static final String PLAYER_NEXT_ID = "player.next";
119    public static final String FILTER_SHOW_ID = "filter.show";
120    public static final String FILTER_APPLY_ID = "filter.apply";
121    public static final String FILTER_CLEAR_ID = "filter.clear";
122    public static final String FILTER_CLOSE_ID = "filter.close";
123    public static final String PLAYLIST_CLOSE_ID = "playlist.close";
124    public static final String PLAYLIST_SHOW_ID = "playlist.show";
125    public static final String PLAYLIST_TOGGLE_ID = "playlist.toggle";
126    public static final String PLAYLIST_SHUFFLE_LIST_ID = "playlist.shufflelist";
127    public static final String PLAYLIST_SHUFFLE_CATALOG_ID = "playlist.shufflecatalog";
128    public static final String PLAYLIST_MOVEUP_ID = "playlist.moveup";
129    public static final String PLAYLIST_MOVEDOWN_ID = "playlist.movedown";
130    public static final String PLAYLIST_MOVEOVER_ID = "playlist.moveover";
131    public static final String PLAYLIST_REMOVE_TRACK_ID = "playlist.removetrack";
132    public static final String PLAYLIST_CLEAR_ID = "playlist.clear";
133    public static final String PLAYLIST_GOTO_ID = "playlist.goto";
134    public static final String PLAYLIST_SAVE_ID = "playlist.save";
135    public static final String PLAYLIST_LOAD_ID = "playlist.load";
136    public static final String SEARCH_ID = "search";
137    public static final String REPORT_CATALOG_ID = "report.catalog";
138    public static final String REPORT_NOCOVERART_ID = "report.nocoverart";
139    public static final String REPORT_BITRATE_ID = "report.bitrate";
140    public static final String EXIT_ID = "exit";
141 
142    /**
143     * Refers to the controller that is used to forward all action behavior to.
144     * @see #getController()
145     */
146    private final MainController controller;
147 
148    /**
149     * Initializes the actions used in this application. Registers all actions
150     * with the <code>ActionManager</code> and observes changes in the main
151     * module's selection and project to update the enablement of some actions.
152     * @param mainModule provides bound properties for the selection and project
153     * @param controller used to forward all action behavior
154     */
155    private Actions(MainModule mainModule, MainController controller) {
156       LOG.debug("Actions created.");
157       this.controller = controller;
158       // set the locale
159       ActionManager.setBundle(ResourceBundle.getBundle("Action", new Locale(MainModule.SETTINGS.getLocale()),
160                Jukes.class.getClassLoader()));
161       registerActions();
162       mainModule.addPropertyChangeListener(new ModuleChangeHandler());
163 
164       updateCatalogActionEnablement(null);
165    }
166 
167    /**
168     * Initializes the actions used in this application. Registers all actions
169     * with the <code>ActionManager</code> and observes changes in the main
170     * module's selection and project to update the enablement of some actions.
171     * @param mainModule provides bound properties for the selection and project
172     * @param controller used to forward all action behavior
173     */
174    public static void initializeFor(MainModule mainModule, MainController controller) {
175       new Actions(mainModule, controller);
176    }
177 
178    public MainController getController() {
179       return controller;
180    }
181 
182    /**
183     * Registers <code>Action</code>s at the <code>ActionManager</code>
184     * using three different styles for demoing purposes, see class comment.
185     */
186    private void registerActions() {
187       registerActionsViaAnonymousClasses();
188    }
189 
190    /**
191     * Registers actions in the <code>ActionManager</code> using a bunch of
192     * anonymous classes.
193     */
194    private void registerActionsViaAnonymousClasses() {
195       ActionManager.register(LANG_ENGLISH_ID, new AbstractAction() {
196          public void actionPerformed(ActionEvent event) {
197             getController().language(event, "en");
198          }
199       });
200       ActionManager.register(LANG_FRENCH_ID, new AbstractAction() {
201          public void actionPerformed(ActionEvent event) {
202             getController().language(event, "fr");
203          }
204       });
205       ActionManager.register(LANG_GERMAN_ID, new AbstractAction() {
206          public void actionPerformed(ActionEvent event) {
207             getController().language(event, "de");
208          }
209       });
210       ActionManager.register(LANG_SPANISH_ID, new AbstractAction() {
211          public void actionPerformed(ActionEvent event) {
212             getController().language(event, "es");
213          }
214       });
215       ActionManager.register(LANG_PORTUGEUSE_ID, new AbstractAction() {
216          public void actionPerformed(ActionEvent event) {
217             getController().language(event, "pt");
218          }
219       });
220       ActionManager.register(LANG_NORWEGIAN_ID, new AbstractAction() {
221          public void actionPerformed(ActionEvent event) {
222             getController().language(event, "no");
223          }
224       });
225       ActionManager.register(LANG_DUTCH_ID, new AbstractAction() {
226          public void actionPerformed(ActionEvent event) {
227             getController().language(event, "nl");
228          }
229       });
230       ActionManager.register(LANG_ITALIAN_ID, new AbstractAction() {
231          public void actionPerformed(ActionEvent event) {
232             getController().language(event, "it");
233          }
234       });
235       ActionManager.register(LANG_SWEDISH_ID, new AbstractAction() {
236          public void actionPerformed(ActionEvent event) {
237             getController().language(event, "sv");
238          }
239       });
240       ActionManager.register(LANG_FINNISH_ID, new AbstractAction() {
241          public void actionPerformed(ActionEvent event) {
242             getController().language(event, "fi");
243          }
244       });
245       ActionManager.register(LANG_RUSSIAN_ID, new AbstractAction() {
246          public void actionPerformed(ActionEvent event) {
247             getController().language(event, "ru");
248          }
249       });
250       ActionManager.register(LANG_UKRAINIAN_ID, new AbstractAction() {
251          public void actionPerformed(ActionEvent event) {
252             getController().language(event, "uk");
253          }
254       });
255       ActionManager.register(LANG_CHINESE_ID, new AbstractAction() {
256          public void actionPerformed(ActionEvent event) {
257             getController().language(event, "zh");
258          }
259       });
260       ActionManager.register(LANG_KOREAN_ID, new AbstractAction() {
261          public void actionPerformed(ActionEvent event) {
262             getController().language(event, "ko");
263          }
264       });
265       ActionManager.register(LANG_TAMIL_ID, new AbstractAction() {
266          public void actionPerformed(ActionEvent event) {
267             getController().language(event, "ta");
268          }
269       });
270       ActionManager.register(LANG_TELEGU_ID, new AbstractAction() {
271          public void actionPerformed(ActionEvent event) {
272             getController().language(event, "te");
273          }
274       });
275       ActionManager.register(LANG_HINDHI_ID, new AbstractAction() {
276          public void actionPerformed(ActionEvent event) {
277             getController().language(event, "hi");
278          }
279       });
280       ActionManager.register(LANG_INDONESIAN_ID, new AbstractAction() {
281          public void actionPerformed(ActionEvent event) {
282             getController().language(event, "in");
283          }
284       });
285       ActionManager.register(PREFERENCES_ID, new AbstractAction() {
286          public void actionPerformed(ActionEvent event) {
287             getController().preferences();
288          }
289       });
290       ActionManager.register(PREFERENCES_IMPORT_ID, new AbstractAction() {
291          public void actionPerformed(ActionEvent event) {
292             getController().preferencesImport(event);
293          }
294       });
295       ActionManager.register(PREFERENCES_EXPORT_ID, new AbstractAction() {
296          public void actionPerformed(ActionEvent event) {
297             getController().preferencesExport(event);
298          }
299       });
300       ActionManager.register(FILTER_APPLY_ID, new AbstractAction() {
301          public void actionPerformed(ActionEvent event) {
302             getController().filter(event);
303          }
304       });
305       ActionManager.register(PLAYLIST_TOGGLE_ID, new AbstractAction() {
306          public void actionPerformed(ActionEvent event) {
307             getController().playlistToggle(event);
308          }
309       });
310       ActionManager.register(PLAYLIST_SHUFFLE_LIST_ID, new AbstractAction() {
311          public void actionPerformed(ActionEvent event) {
312             getController().playlistShuffleList(event);
313          }
314       });
315       ActionManager.register(PLAYLIST_SHUFFLE_CATALOG_ID, new AbstractAction() {
316          public void actionPerformed(ActionEvent event) {
317             getController().playlistShuffleCatalog(event);
318          }
319       });
320       ActionManager.register(PLAYLIST_MOVEUP_ID, new AbstractAction() {
321          public void actionPerformed(ActionEvent event) {
322             getController().playlistMoveUp(event);
323          }
324       });
325       ActionManager.register(PLAYLIST_REMOVE_TRACK_ID, new AbstractAction() {
326          public void actionPerformed(ActionEvent event) {
327             getController().playlistRemoveTracks(event);
328          }
329       });
330       ActionManager.register(PLAYLIST_CLEAR_ID, new AbstractAction() {
331          public void actionPerformed(ActionEvent event) {
332             getController().playlistClear(event);
333          }
334       });
335       ActionManager.register(PLAYLIST_GOTO_ID, new AbstractAction() {
336          public void actionPerformed(ActionEvent event) {
337             getController().playlistGoto(event);
338          }
339       });
340       ActionManager.register(PLAYLIST_SAVE_ID, new AbstractAction() {
341          public void actionPerformed(ActionEvent event) {
342             getController().playlistSave(event);
343          }
344       });
345       ActionManager.register(PLAYLIST_LOAD_ID, new AbstractAction() {
346          public void actionPerformed(ActionEvent event) {
347             getController().playlistLoad(event);
348          }
349       });
350       ActionManager.register(PLAYLIST_MOVEDOWN_ID, new AbstractAction() {
351          public void actionPerformed(ActionEvent event) {
352             getController().playlistMoveDown(event);
353          }
354       });
355       ActionManager.register(PLAYLIST_MOVEOVER_ID, new AbstractAction() {
356          public void actionPerformed(ActionEvent event) {
357             getController().playlistMoveOver(event);
358          }
359       });
360       ActionManager.register(FILTER_SHOW_ID, new AbstractAction() {
361          public void actionPerformed(ActionEvent event) {
362             getController().filterDisplay(event);
363          }
364       });
365       ActionManager.register(FILTER_CLEAR_ID, new AbstractAction() {
366          public void actionPerformed(ActionEvent event) {
367             getController().filterClear(event);
368          }
369       });
370       ActionManager.register(SEARCH_ID, new AbstractAction() {
371          public void actionPerformed(ActionEvent event) {
372             getController().search(event);
373          }
374       });
375       ActionManager.register(TRACK_PLAY_IMMEDIATE_ID, new AbstractAction() {
376          public void actionPerformed(ActionEvent event) {
377             getController().playImmediately(event);
378          }
379       });
380       ActionManager.register(PLAYER_QUEUE_ID, new AbstractAction() {
381          public void actionPerformed(ActionEvent event) {
382             getController().queue(event);
383          }
384       });
385       ActionManager.register(PLAYER_QUEUE_NEXT_ID, new AbstractAction() {
386          public void actionPerformed(ActionEvent event) {
387             getController().queueNext(event);
388          }
389       });
390       ActionManager.register(PLAYER_PLAY_ID, new AbstractAction() {
391          public void actionPerformed(ActionEvent event) {
392             getController().playerPlay(event);
393          }
394       }).setEnabled(false);
395       ActionManager.register(PLAYER_PAUSE_ID, new AbstractAction() {
396          public void actionPerformed(ActionEvent event) {
397             getController().playerPause(event);
398          }
399       }).setEnabled(false);
400       ActionManager.register(PLAYER_STOP_ID, new AbstractAction() {
401          public void actionPerformed(ActionEvent event) {
402             getController().playerStop(event);
403          }
404       }).setEnabled(false);
405       ActionManager.register(PLAYER_NEXT_ID, new AbstractAction() {
406          public void actionPerformed(ActionEvent event) {
407             getController().playerNext(event);
408          }
409       }).setEnabled(false);
410       ActionManager.register(PLAYER_PREVIOUS_ID, new AbstractAction() {
411          public void actionPerformed(ActionEvent event) {
412             getController().playerPrevious(event);
413          }
414       }).setEnabled(false);
415       ActionManager.register(APP_SHOW_ID, new AbstractAction() {
416          public void actionPerformed(ActionEvent event) {
417             getController().showMainWindow();
418          }
419       }).setEnabled(false);
420       ActionManager.register(APP_HIDE_ID, new AbstractAction() {
421          public void actionPerformed(ActionEvent event) {
422             getController().hideMainWindow();
423          }
424       }).setEnabled(true);
425       ActionManager.register(EXIT_ID, new AbstractAction() {
426          public void actionPerformed(ActionEvent event) {
427             getController().aboutToExitApplication();
428          }
429       });
430       ActionManager.register(PLAYLIST_CLOSE_ID, new AbstractAction() {
431          public void actionPerformed(ActionEvent event) {
432             getController().playlistClose(event);
433          }
434       });
435       ActionManager.register(PLAYLIST_SHOW_ID, new AbstractAction() {
436          public void actionPerformed(ActionEvent event) {
437             getController().playlistDisplay(event);
438          }
439       });
440       ActionManager.register(FILTER_CLOSE_ID, new AbstractAction() {
441          public void actionPerformed(ActionEvent event) {
442             getController().filterClose(event);
443          }
444       });
445       ActionManager.register(TITLECASE_ID, new AbstractAction() {
446          public void actionPerformed(ActionEvent event) {
447             getController().titleCase(event);
448          }
449       });
450       ActionManager.register(FILE_RENAME_ID, new AbstractAction() {
451          public void actionPerformed(ActionEvent event) {
452             getController().fileRename(event);
453          }
454       });
455       ActionManager.register(DIRECTORY_ID, new AbstractAction() {
456          public void actionPerformed(ActionEvent event) {
457             getController().chooseDirectory(event);
458          }
459       });
460       ActionManager.register(FILE_CHOOSER_ID, new AbstractAction() {
461          public void actionPerformed(ActionEvent event) {
462             getController().chooseFile(event);
463          }
464       });
465       ActionManager.register(COMMIT_ID, new AbstractAction() {
466          public void actionPerformed(ActionEvent event) {
467             getController().commit(event);
468          }
469       });
470       ActionManager.register(ROLLBACK_ID, new AbstractAction() {
471          public void actionPerformed(ActionEvent event) {
472             getController().rollback(event);
473          }
474       });
475       ActionManager.register(UNLOCK_ID, new AbstractAction() {
476          public void actionPerformed(ActionEvent event) {
477             getController().unlock(event);
478          }
479       });
480       ActionManager.register(REFRESH_ID, new AbstractAction() {
481          public void actionPerformed(ActionEvent event) {
482             getController().refresh(event);
483          }
484       });
485       ActionManager.register(CONNECT_ID, new AbstractAction() {
486          public void actionPerformed(ActionEvent event) {
487             getController().connect(event);
488          }
489       });
490       ActionManager.register(DELETE_ID, new AbstractAction() {
491          public void actionPerformed(ActionEvent event) {
492             getController().delete(event);
493          }
494       });
495       ActionManager.register(TOOL_STATISTICS_ID, new AbstractAction() {
496          public void actionPerformed(ActionEvent event) {
497             getController().statistics(event);
498          }
499       });
500       ActionManager.register(TOOL_DIFFERENCE_ID, new AbstractAction() {
501          public void actionPerformed(ActionEvent event) {
502             getController().differenceTool(event);
503          }
504       });
505       ActionManager.register(TOOL_LOCATION_ID, new AbstractAction() {
506          public void actionPerformed(ActionEvent event) {
507             getController().locationTool(event);
508          }
509       });
510       ActionManager.register(TOOL_BACKUP_ID, new AbstractAction() {
511          public void actionPerformed(ActionEvent event) {
512             getController().backupTool(event);
513          }
514       });
515       ActionManager.register(CATALOG_EXPORT_ID, new AbstractAction() {
516          public void actionPerformed(ActionEvent event) {
517             getController().exportCatalog(event);
518          }
519       });
520       ActionManager.register(TOOL_MEMORY_ID, new AbstractAction() {
521          public void actionPerformed(ActionEvent event) {
522             getController().memory(event);
523          }
524       });
525       ActionManager.register(DISC_WEB_ID, new AbstractAction() {
526          public void actionPerformed(ActionEvent event) {
527             getController().discWebSearch(event);
528          }
529       });
530       ActionManager.register(DISC_COVER_ID, new AbstractAction() {
531          public void actionPerformed(ActionEvent event) {
532             getController().discCoverImage(event);
533          }
534       });
535       ActionManager.register(DISC_ADD_ID, new AbstractAction() {
536          public void actionPerformed(ActionEvent event) {
537             getController().discAdd(event);
538          }
539       });
540       ActionManager.register(DISC_ADD_TITLECASE_ID, new AbstractAction() {
541          public void actionPerformed(ActionEvent event) {
542             getController().discAddTitleCase(event);
543          }
544       });
545       ActionManager.register(DISC_ADD_COMMENTS_ID, new AbstractAction() {
546          public void actionPerformed(ActionEvent event) {
547             getController().discAddComments(event);
548          }
549       });
550       ActionManager.register(DISC_ADD_RESET_FROM_FILENAME_ID, new AbstractAction() {
551          public void actionPerformed(ActionEvent event) {
552             getController().discAddResetFromFilename(event);
553          }
554       });
555       ActionManager.register(DISC_ADD_RESET_NUMBERS_ID, new AbstractAction() {
556          public void actionPerformed(ActionEvent event) {
557             getController().discAddResetTrackNumbers(event);
558          }
559       });
560       ActionManager.register(DISC_FINDER_ID, new AbstractAction() {
561          public void actionPerformed(ActionEvent event) {
562             getController().discFinder(event);
563          }
564       });
565       ActionManager.register(DISC_REMOVER_ID, new AbstractAction() {
566          public void actionPerformed(ActionEvent event) {
567             getController().discRemover(event);
568          }
569       });
570       ActionManager.register(REPORT_CATALOG_ID, new AbstractAction() {
571          public void actionPerformed(ActionEvent event) {
572             getController().reportCatalog(event);
573          }
574       });
575       ActionManager.register(REPORT_NOCOVERART_ID, new AbstractAction() {
576          public void actionPerformed(ActionEvent event) {
577             getController().reportNoCoverArt(event);
578          }
579       });
580       ActionManager.register(REPORT_BITRATE_ID, new AbstractAction() {
581          public void actionPerformed(ActionEvent event) {
582             getController().reportBitrate(event);
583          }
584       });
585       ActionManager.register(HELP_CONTACT_ID, new AbstractAction() {
586          public void actionPerformed(ActionEvent event) {
587             getController().contactUs(event);
588          }
589       });
590       ActionManager.register(HELP_CONTENTS_ID, new AbstractAction() {
591          public void actionPerformed(ActionEvent event) {
592             HelpBroker.openDefault();
593          }
594       });
595       ActionManager.register(HELP_TIP_OF_THE_DAY_ID, new AbstractAction() {
596          public void actionPerformed(ActionEvent event) {
597             getController().openTipOfTheDayDialog();
598          }
599       });
600       ActionManager.register(HELP_ABOUT_DIALOG_ID, new AbstractAction() {
601          public void actionPerformed(ActionEvent event) {
602             getController().helpAbout();
603          }
604       });
605       ActionManager.register(HELP_DONATE_ID, new AbstractAction() {
606          public void actionPerformed(ActionEvent event) {
607             getController().donate();
608          }
609       });
610       ActionManager.register(HELP_FORUMS_ID, new AbstractAction() {
611          public void actionPerformed(ActionEvent event) {
612             getController().forums();
613          }
614       });
615    }
616 
617    /**
618     * Updates the enablement of actions that are related to the catalog state.
619     * @param project the current catalog
620     */
621    private void updateCatalogActionEnablement(Catalog catalog) {
622       boolean enabled = catalog != null;
623       ActionManager.get(Actions.REFRESH_ID).setEnabled(enabled);
624       ActionManager.get(Actions.DISC_ADD_ID).setEnabled(enabled);
625       ActionManager.get(Actions.DISC_FINDER_ID).setEnabled(enabled);
626       ActionManager.get(Actions.DISC_REMOVER_ID).setEnabled(enabled);
627       ActionManager.get(Actions.TOOL_DIFFERENCE_ID).setEnabled(enabled);
628       ActionManager.get(Actions.TOOL_STATISTICS_ID).setEnabled(enabled);
629       ActionManager.get(Actions.DISC_WEB_ID).setEnabled(enabled);
630       ActionManager.get(Actions.CATALOG_EXPORT_ID).setEnabled(enabled);
631       ActionManager.get(Actions.SEARCH_ID).setEnabled(enabled);
632       ActionManager.get(Actions.TOOL_LOCATION_ID).setEnabled(enabled);
633       ActionManager.get(Actions.TOOL_BACKUP_ID).setEnabled(enabled);
634    }
635 
636    // Listens to changes in the navigation selection and update enablements.
637    private class ModuleChangeHandler implements PropertyChangeListener {
638 
639       /**
640        * The selection in the navigation tree has changed. Updates the add and
641        * delete actions.
642        * @param evt describes the property change
643        */
644       public void propertyChange(PropertyChangeEvent evt) {
645          String propertyName = evt.getPropertyName();
646          if (MainModule.PROPERTYNAME_CATALOG.equals(propertyName)) {
647             updateCatalogActionEnablement((Catalog) evt.getNewValue());
648          }
649       }
650    }
651 
652 }