1 package fr.ifremer.dali.ui.swing.content;
2
3 /*
4 * #%L
5 * Dali :: 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.dali.config.DaliConfiguration;
27 import fr.ifremer.dali.ui.swing.DaliUIContext;
28 import fr.ifremer.quadrige3.ui.swing.ApplicationUIUtil;
29 import fr.ifremer.quadrige3.ui.swing.content.AbstractMainUIHandler;
30 import org.apache.commons.logging.Log;
31 import org.apache.commons.logging.LogFactory;
32
33 import java.net.URL;
34
35 /**
36 * <p>DaliMainUIHandler class.</p>
37 *
38 * @since 0.1
39 */
40 public class DaliMainUIHandler extends AbstractMainUIHandler<DaliUIContext, DaliMainUI> {
41
42 /**
43 * Logger.
44 */
45 private static final Log LOG = LogFactory.getLog(DaliMainUIHandler.class);
46
47 @Override
48 public DaliUIContext getContext() {
49 return (DaliUIContext) super.getContext();
50 }
51
52 @Override
53 public DaliConfiguration getConfig() {
54 return getContext().getConfiguration();
55 }
56
57 @Override
58 public void beforeInit(DaliMainUI ui) {
59 super.beforeInit(ui);
60
61 // override context value
62 ui.setContextValue(getContext());
63 ui.createModel();
64 }
65
66 /**
67 * {@inheritDoc}
68 */
69 @Override
70 public void afterInit(DaliMainUI ui) {
71
72 super.afterInit(ui);
73
74 ui.getMenuFile().add(ui.getMenuFileExit());
75
76 ui.getMenuHelp().add(ui.getMenuChangeLocale());
77
78 }
79
80 //------------------------------------------------------------------------//
81 //-- Public methods --//
82 //------------------------------------------------------------------------//
83
84 /**
85 * <p>reloadUI.</p>
86 */
87 // public void reloadUI() {
88 //
89 // //close ui
90 // onCloseUI();
91 //
92 // // restart ui
93 // DaliApplication.reloadUI(getContext());
94 // }
95
96 /**
97 * <p>gotoSite.</p>
98 */
99 public void gotoSite() {
100
101 URL siteURL = getConfig().getSiteUrl();
102
103 if (LOG.isDebugEnabled()) {
104 LOG.debug("goto " + siteURL);
105 }
106 ApplicationUIUtil.openLink(siteURL);
107 }
108
109 /**
110 * <p>showHelp.</p>
111 */
112 public void showHelp() {
113 getContext().showHelp(ui, ui.getBroker(), null);
114 }
115
116 }