1   /*
2    * Created on Aug 19, 2007
3    * 
4    * Copyright 2005 CafeSip.org 
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License"); 
7    * you may not use this file except in compliance with the License. 
8    * You may obtain a copy of the License at 
9    *
10   *	http://www.apache.org/licenses/LICENSE-2.0 
11   *
12   * Unless required by applicable law or agreed to in writing, software 
13   * distributed under the License is distributed on an "AS IS" BASIS, 
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
15   * See the License for the specific language governing permissions and 
16   * limitations under the License.
17   *
18   */
19  package org.cafesip.gwtcomp.examples.client;
20  
21  import org.cafesip.gwtcomp.client.ui.MessageBar;
22  import org.cafesip.gwtcomp.client.ui.TitleBar;
23  import org.cafesip.gwtcomp.client.ui.Toolbar;
24  import org.cafesip.gwtcomp.client.ui.ToolbarPanel;
25  
26  import com.google.gwt.event.dom.client.ClickEvent;
27  import com.google.gwt.event.dom.client.ClickHandler;
28  import com.google.gwt.user.client.Window;
29  import com.google.gwt.user.client.ui.Button;
30  import com.google.gwt.user.client.ui.FlowPanel;
31  import com.google.gwt.user.client.ui.Image;
32  import com.google.gwt.user.client.ui.TextBox;
33  
34  /**
35   * @author Amit Chatterjee
36   * 
37   */
38  public class MiscWidgetsSample extends FlowPanel
39  {
40      /**
41       * A constructor for this class.
42       * 
43       * 
44       */
45      public MiscWidgetsSample()
46      {
47          super();
48          setWidth("100%");
49  
50          init();
51      }
52  
53      protected void init()
54      {
55          initTitleBar();
56  
57          initToolbar();
58  
59          initMessageBars();
60      }
61  
62      private void initToolbar()
63      {
64          ToolbarPanel tool = new ToolbarPanel();
65          add(tool);
66  
67          final Toolbar tb1 = new Toolbar();
68          Image cancel = new Image("gwtcomp-icons/cancel.png");
69          cancel.setTitle("Cancel the operation");
70          
71          cancel.addClickHandler(new ClickHandler() {
72  
73              public void onClick(ClickEvent event)
74              {
75                  Window.alert("Cancel clicked");
76                  
77              }});
78          
79          tb1.addWidget(cancel);
80  
81          tb1.addWidget(new Image("gwtcomp-icons/edit.png"));
82          tool.addToolbar(tb1);
83          final Toolbar tb2 = new Toolbar();
84          tb2.addWidget(new Image("gwtcomp-icons/help.png"));
85          tool.addToolbar(tb2);
86          final Toolbar tb3 = new Toolbar();
87          tb3.addWidget(new Image("gwtcomp-icons/folder.png"));
88          TextBox tb = new TextBox();
89          tb.setMaxLength(5);
90          tb.setVisibleLength(5);
91          tb3.addWidget(tb);
92          Button find = new Button("Go");
93          find.setStyleName("gwtcomp-Examples-Button");
94          
95          find.addClickHandler(new ClickHandler() {
96  
97              public void onClick(ClickEvent event)
98              {
99                  Window.alert("Go Listener!");
100                 
101             }});
102 
103         tb3.addWidget(find);
104         tool.addToolbar(tb3);
105     }
106 
107     private void initTitleBar()
108     {
109         TitleBar titleBar = new TitleBar();
110         add(titleBar);
111         titleBar.setHelpUrl("http://www.cafesip.org");
112         titleBar.setText("Example Title Bar");
113     }
114 
115     private void initMessageBars()
116     {
117         MessageBar infoMessageBar = new MessageBar();
118         add(infoMessageBar);
119         infoMessageBar.setMessage("This is an informational message");
120         infoMessageBar.setAudioEnabled(true);
121         infoMessageBar.setWidth("100%");
122 
123         final MessageBar warnMessageBar = new MessageBar();
124         add(warnMessageBar);
125         warnMessageBar.setAudioEnabled(true);
126         warnMessageBar.setWidth("100%");
127         warnMessageBar.setSeverity(MessageBar.SEVERITY_WARNING);
128         warnMessageBar.setText("This is a warning message");
129 
130         final MessageBar errMessageBar = new MessageBar();
131         add(errMessageBar);
132         errMessageBar.setAudioEnabled(true);
133         errMessageBar.setWidth("100%");
134         errMessageBar.setMessage("This is an error message",
135                 MessageBar.SEVERITY_ERROR);
136     }
137 
138 }