View Javadoc
1   package fr.ifremer.reefdb.ui.swing.content;
2   
3   /*
4    * #%L
5    * Reef DB :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2014 - 2015 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  import fr.ifremer.quadrige3.ui.swing.content.AbstractMainUIHandler;
27  import fr.ifremer.reefdb.config.ReefDbConfiguration;
28  import fr.ifremer.reefdb.ui.swing.ReefDbApplication;
29  import fr.ifremer.reefdb.ui.swing.ReefDbUIContext;
30  import fr.ifremer.reefdb.ui.swing.util.ReefDbUIs;
31  import jaxx.runtime.SwingUtil;
32  import org.apache.commons.logging.Log;
33  import org.apache.commons.logging.LogFactory;
34  
35  import java.net.URL;
36  
37  /**
38   * <p>ReefDbMainUIHandler class.</p>
39   *
40   * @since 0.1
41   */
42  public class ReefDbMainUIHandler extends AbstractMainUIHandler<ReefDbUIContext, ReefDbMainUI> {
43  
44      /**
45       * Logger.
46       */
47      private static final Log LOG = LogFactory.getLog(ReefDbMainUIHandler.class);
48  
49      @Override
50      public ReefDbUIContext getContext() {
51          return (ReefDbUIContext) super.getContext();
52      }
53  
54      @Override
55      public ReefDbConfiguration getConfig() {
56          return (ReefDbConfiguration) super.getConfig();
57      }
58  
59      //------------------------------------------------------------------------//
60      //-- AbstractReefDbUIHandler methods                                     --//
61      //------------------------------------------------------------------------//
62      /** {@inheritDoc} */
63      @Override
64      public void beforeInit(ReefDbMainUI ui) {
65          super.beforeInit(ui);
66  
67          // override context value
68          ui.setContextValue(getContext());
69          ui.createModel();
70          ui.setContextValue(SwingUtil.createActionIcon("observation"));
71      }
72  
73      /** {@inheritDoc} */
74      @Override
75      public void afterInit(ReefDbMainUI ui) {
76  
77          super.afterInit(ui);
78  
79          ui.getMenuFile().add(ui.getMenuFileExit());
80  
81          // Don't add language menu until translation is done (Mantis #48927)
82  //        ui.getMenuHelp().add(ui.getMenuChangeLocale());
83  
84      }
85  
86      /**
87       * <p>reloadUI.</p>
88       */
89      public void reloadUI() {
90  
91          //close ui
92          onCloseUI();
93  
94          // restart ui
95          ReefDbApplication.reloadUI(getContext());
96      }
97  
98      /**
99       * <p>gotoSite.</p>
100      */
101     public void gotoSite() {
102         ReefDbConfiguration config = getConfig();
103 
104         URL siteURL = config.getSiteUrl();
105 
106         if (LOG.isDebugEnabled()) {
107             LOG.debug("goto " + siteURL);
108         }
109         ReefDbUIs.openLink(siteURL);
110     }
111 
112     /**
113      * <p>showHelp.</p>
114      */
115     public void showHelp() {
116         getContext().showHelp(ui, ui.getBroker(), null);
117     }
118 
119 
120 }