View Javadoc

1   package com.melloware.jukes.gui.view.editor;
2   
3   import javax.swing.Icon;
4   import javax.swing.JComponent;
5   import javax.swing.JLabel;
6   import javax.swing.JScrollPane;
7   import javax.swing.JToolBar;
8   
9   import org.apache.commons.logging.Log;
10  import org.apache.commons.logging.LogFactory;
11  
12  import com.jgoodies.forms.builder.PanelBuilder;
13  import com.jgoodies.forms.factories.Borders;
14  import com.jgoodies.forms.layout.CellConstraints;
15  import com.jgoodies.forms.layout.FormLayout;
16  import com.jgoodies.uif.action.ActionManager;
17  import com.jgoodies.uifextras.panel.GradientBackgroundPanel;
18  import com.l2fprod.common.swing.JTaskPane;
19  import com.l2fprod.common.swing.JTaskPaneGroup;
20  import com.melloware.jukes.db.orm.Catalog;
21  import com.melloware.jukes.gui.tool.Actions;
22  import com.melloware.jukes.gui.tool.Resources;
23  
24  /**
25   * This panel is displayed after a successful application startup to welcome
26   * the user. It provides access to actions that are most useful at the
27   * application start.
28   * <p>
29   * Copyright (c) 1999-2007 Melloware, Inc. <http://www.melloware.com>
30   * @author Emil A. Lefkof III <info@melloware.com>
31   * @version 4.0
32   */
33  public final class WelcomePanel
34      extends GradientBackgroundPanel
35      implements Editor {
36  
37      private static final Log LOG = LogFactory.getLog(WelcomePanel.class);
38  
39      /**
40       * Constructs a <code>WelcomePanel</code>.
41       */
42      public WelcomePanel() {
43          super(false);
44          add(buildForeground());
45          LOG.debug("Welcome Panel created.");
46      }
47  
48      public Class getDomainClass() {
49          return Catalog.class;
50      }
51  
52      /* (non-Javadoc)
53       * @see com.melloware.jukes.gui.view.editor.Editor#getHeaderToolBar()
54       */
55      public JToolBar getHeaderToolBar() {
56          return null;
57      }
58  
59      // Implementing the Editor Interface ************************************
60  
61      public Icon getIcon() {
62          return null;
63      }
64  
65      public Object getModel() {
66          return null;
67      }
68  
69      public String getTitle() {
70          return Resources.getString("application.name");
71      }
72  
73      public JToolBar getToolBar() {
74          return null;
75      }
76  
77      public void setModel(Object m) {
78          // Nothing to do in this welcome panel.
79      }
80  
81      // Building *************************************************************
82  
83      public void activate() {
84          // Nothing to do in this welcome panel.
85      }
86  
87      public void deactivate() {
88          // Nothing to do in this welcome panel.
89      }
90  
91      /**
92       * Builds and answers the foreground.
93       */
94      private JComponent buildForeground() {
95          final JLabel selectLbl = new JLabel(Resources.getString("label.Selectoptions"));
96  
97          JTaskPane taskPane = new JTaskPane();
98          JScrollPane scroll = new JScrollPane(taskPane);
99          scroll.setBorder(null);
100 
101         // "Catalog" GROUP
102         JTaskPaneGroup catalogGroup = new JTaskPaneGroup();
103         catalogGroup.setTitle(Resources.getString("menu.catalog"));
104         catalogGroup.setToolTipText(Resources.getString("label.Catalogbasedtasks"));
105         catalogGroup.setSpecial(true);
106         catalogGroup.setIcon(Resources.NAVIGATOR_ICON);
107         catalogGroup.add(ActionManager.get(Actions.DISC_FINDER_ID));
108         catalogGroup.add(ActionManager.get(Actions.DISC_ADD_ID));
109         catalogGroup.add(ActionManager.get(Actions.DISC_REMOVER_ID));
110         catalogGroup.add(ActionManager.get(Actions.SEARCH_ID));
111         catalogGroup.add(ActionManager.get(Actions.PREFERENCES_ID));
112         taskPane.add(catalogGroup);
113 
114         // "See Also" GROUP
115         JTaskPaneGroup alsoGroup = new JTaskPaneGroup();
116         alsoGroup.setTitle(Resources.getString("label.seealso"));
117         alsoGroup.setToolTipText(Resources.getString("label.Othertasks"));
118         alsoGroup.setSpecial(true);
119         alsoGroup.setIcon(Resources.getIcon("help.icon"));
120         alsoGroup.add(ActionManager.get(Actions.HELP_CONTENTS_ID));
121         alsoGroup.add(ActionManager.get(Actions.HELP_ABOUT_DIALOG_ID));
122         alsoGroup.add(ActionManager.get(Actions.HELP_CONTACT_ID));
123         alsoGroup.add(ActionManager.get(Actions.HELP_FORUMS_ID));
124         alsoGroup.add(ActionManager.get(Actions.HELP_DONATE_ID));
125         taskPane.add(alsoGroup);
126 
127         // add spacer for visibilty
128         taskPane.add(new JLabel());
129 
130         FormLayout layout = new FormLayout("9dlu, left:pref:grow", "b:pref, c:pref, t:pref, 9dlu, pref, 6dlu, pref");
131         PanelBuilder builder = new PanelBuilder(layout);
132         builder.getPanel().setOpaque(false);
133         builder.setBorder(Borders.DLU14_BORDER);
134 
135         CellConstraints cc = new CellConstraints();
136 
137         builder.add(selectLbl, cc.xyw(1, 3, 2));
138         builder.add(scroll, cc.xyw(1, 5, 2));
139 
140         return builder.getPanel();
141     }
142 
143 }