View Javadoc
1   package fr.ifremer.dali.ui.swing.content.welcome;
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.ui.swing.DaliUIContext;
27  import fr.ifremer.dali.ui.swing.util.AbstractDaliUIHandler;
28  import jaxx.runtime.SwingUtil;
29  
30  import javax.swing.ImageIcon;
31  import javax.swing.SwingConstants;
32  import java.awt.Color;
33  import java.awt.Dimension;
34  import java.awt.Font;
35  
36  /**
37   * Controller for Welcome scereen.
38   */
39  public class WelcomeUIHandler extends AbstractDaliUIHandler<DaliUIContext, WelcomeUI> {
40  
41      /**
42       * Button font.
43       */
44      private static final Font BUTTON_FONT = new Font("", Font.BOLD, 40);
45  
46      /** {@inheritDoc} */
47      @Override
48      public void beforeInit(final WelcomeUI ui) {
49          super.beforeInit(ui);
50  
51          // Ajout du model pour la page d acceuil
52          ui.setContextValue(getContext());
53  
54          ui.setContextValue(SwingUtil.createActionIcon("home"));
55      }
56  
57      /** {@inheritDoc} */
58      @Override
59      public void afterInit(final WelcomeUI ui) {
60          initUI(ui);
61  
62          // Change font on title
63          getUI().getObservationButton().setEnabled(getContext().isAuthenticated());
64          getUI().getObservationButton().setFont(BUTTON_FONT);
65          ImageIcon image = getResourceImage("saisie", "jpg");
66          if (image != null) {
67  
68              // Add image on label
69              getUI().getObservationButton().setIcon(image);
70              getUI().getObservationButton().setPreferredSize(new Dimension(image.getIconWidth(), image.getIconHeight()));
71  
72              getUI().getObservationButton().setHorizontalTextPosition(SwingConstants.CENTER);
73              getUI().getObservationButton().setForeground(Color.WHITE);
74          }
75  
76          getUI().getExtractionButton().setEnabled(getContext().isAuthenticated());
77          getUI().getExtractionButton().setFont(BUTTON_FONT);
78          image = getResourceImage("extraction","jpg");
79          if (image != null) {
80  
81              // Add image on label
82              getUI().getExtractionButton().setIcon(image);
83              getUI().getExtractionButton().setPreferredSize(new Dimension(image.getIconWidth(), image.getIconHeight()));
84  
85              getUI().getExtractionButton().setHorizontalTextPosition(SwingConstants.CENTER);
86              getUI().getExtractionButton().setForeground(Color.WHITE);
87          }
88  
89      }
90  
91  }