View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   package org.directdemocracyportal.democracy.web.views;
6   
7   import org.directdemocracyportal.democracy.web.ApplicationMessageHolder;
8   import org.directdemocracyportal.democracy.web.BeanLocator;
9   import org.directdemocracyportal.democracy.web.ImageConstants;
10  import org.directdemocracyportal.democracy.web.ApplicationMessageHolder.MessageConstans;
11  import org.directdemocracyportal.democracy.web.action.ShowGovernmentsAction;
12  import org.directdemocracyportal.democracy.web.action.ShowMembersAction;
13  import org.directdemocracyportal.democracy.web.action.ShowPoliticalPartiesAction;
14  
15  import thinwire.ui.Button;
16  import thinwire.ui.Label;
17  import thinwire.ui.Panel;
18  import thinwire.ui.AlignTextComponent.AlignX;
19  import thinwire.ui.layout.TableLayout;
20  import thinwire.ui.style.Background;
21  import thinwire.ui.style.Color;
22  
23  /***
24   * The Class ExplorerPanel.
25   */
26  public class ExplorerPanel extends Panel
27  {
28  
29      /***
30       * Instantiates a new explorer panel.
31       */
32      public ExplorerPanel() {
33          setLayout(new TableLayout(new double[][] { { 0 }, // Column Widths
34                  { 10, 130, 10, 130, 10, 130 } }, // Row Heights
35                  1, // Margin around edge of container
36                  5)); // Spacing between cells
37  
38          getStyle().getBackground().setColor(Color.valueOf("rgb(0,51,153)"));
39  
40          Label memberBanner = new Label();
41          memberBanner.getStyle().getFont().setColor(Color.WHITE);
42          memberBanner.setAlignX(AlignX.CENTER);
43          memberBanner.setText(ApplicationMessageHolder
44                  .getMessage(MessageConstans.GROUPS));
45          memberBanner.getStyle().getBackground().setPosition(
46                  Background.Position.CENTER);
47          memberBanner.setLimit("0,0");
48          getChildren().add(memberBanner);
49  
50          Button memberButton = new Button();
51          memberButton.getStyle().getBackground().setColor(
52                  Color.valueOf("rgb(0,51,153)"));
53          memberButton.setImage(ImageConstants.GROUP_HOME_IMAGE);
54          memberButton.setSize(ImageConstants.IMAGE_SIZE,
55                  ImageConstants.IMAGE_SIZE);
56          memberButton.setLimit("0,+1,c,c");
57          memberButton.setUserObject(new ShowMembersAction());
58          memberButton.addActionListener(ACTION_CLICK, BeanLocator
59                  .getApplicationActionListener());
60          getChildren().add(memberButton);
61  
62          Label partyBanner = new Label();
63          partyBanner.getStyle().getFont().setColor(Color.WHITE);
64          partyBanner.setAlignX(AlignX.CENTER);
65          partyBanner.setText(ApplicationMessageHolder
66                  .getMessage(MessageConstans.POLITICAL_PARTIES));
67          partyBanner.getStyle().getBackground().setPosition(
68                  Background.Position.CENTER);
69          partyBanner.setLimit("0,+1");
70          getChildren().add(partyBanner);
71  
72          Button partyButton = new Button();
73          partyButton.getStyle().getBackground().setColor(
74                  Color.valueOf("rgb(0,51,153)"));
75          partyButton.setImage(ImageConstants.POLITICAL_PARTY_IMAGE);
76          partyButton.setSize(ImageConstants.IMAGE_SIZE,
77                  ImageConstants.IMAGE_SIZE);
78          partyButton.setLimit("0,+1,c,c");
79          partyButton.setUserObject(new ShowPoliticalPartiesAction());
80          partyButton.addActionListener(ACTION_CLICK, BeanLocator
81                  .getApplicationActionListener());
82          getChildren().add(partyButton);
83  
84          Label governmentBanner = new Label();
85          governmentBanner.getStyle().getFont().setColor(Color.WHITE);
86          governmentBanner.setAlignX(AlignX.CENTER);
87          governmentBanner.setText(ApplicationMessageHolder
88                  .getMessage(MessageConstans.GOVERNMENTS));
89          governmentBanner.getStyle().getBackground().setPosition(
90                  Background.Position.CENTER);
91          governmentBanner.setLimit("0,+1");
92          getChildren().add(governmentBanner);
93  
94          Button governmentButton = new Button();
95          governmentButton.getStyle().getBackground().setColor(
96                  Color.valueOf("rgb(0,51,153)"));
97          governmentButton.setImage(ImageConstants.GOVERNMENT_IMAGE);
98          governmentButton.setSize(ImageConstants.IMAGE_SIZE,
99                  ImageConstants.IMAGE_SIZE);
100         governmentButton.setLimit("0,+1,c,c");
101         governmentButton.setUserObject(new ShowGovernmentsAction());
102         governmentButton.addActionListener(ACTION_CLICK, BeanLocator
103                 .getApplicationActionListener());
104         getChildren().add(governmentButton);
105 
106     }
107 }