MiscWidgetsSample.java
001 /*
002  * Created on Aug 19, 2007
003  
004  * Copyright 2005 CafeSip.org 
005  *
006  * Licensed under the Apache License, Version 2.0 (the "License"); 
007  * you may not use this file except in compliance with the License. 
008  * You may obtain a copy of the License at 
009  *
010  *  http://www.apache.org/licenses/LICENSE-2.0 
011  *
012  * Unless required by applicable law or agreed to in writing, software 
013  * distributed under the License is distributed on an "AS IS" BASIS, 
014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
015  * See the License for the specific language governing permissions and 
016  * limitations under the License.
017  *
018  */
019 package org.cafesip.gwtcomp.examples.client;
020 
021 import org.cafesip.gwtcomp.client.ui.MessageBar;
022 import org.cafesip.gwtcomp.client.ui.TitleBar;
023 import org.cafesip.gwtcomp.client.ui.Toolbar;
024 import org.cafesip.gwtcomp.client.ui.ToolbarPanel;
025 
026 import com.google.gwt.user.client.Window;
027 import com.google.gwt.user.client.ui.Button;
028 import com.google.gwt.user.client.ui.ClickListener;
029 import com.google.gwt.user.client.ui.FlowPanel;
030 import com.google.gwt.user.client.ui.Image;
031 import com.google.gwt.user.client.ui.TextBox;
032 import com.google.gwt.user.client.ui.Widget;
033 
034 /**
035  @author Amit Chatterjee
036  
037  */
038 public class MiscWidgetsSample extends FlowPanel
039 {
040     /**
041      * A constructor for this class.
042      
043      
044      */
045     public MiscWidgetsSample()
046     {
047         super();
048         setWidth("100%");
049 
050         init();
051     }
052 
053     protected void init()
054     {
055         initTitleBar();
056 
057         initToolbar();
058 
059         initMessageBars();
060     }
061 
062     private void initToolbar()
063     {
064         ToolbarPanel tool = new ToolbarPanel();
065         add(tool);
066 
067         final Toolbar tb1 = new Toolbar();
068         Image cancel = new Image("gwtcomp-icons/cancel.png");
069         cancel.setTitle("Cancel the operation");
070         cancel.addClickListener(new ClickListener()
071         {
072 
073             public void onClick(Widget sender)
074             {
075                 Window.alert("Cancel clicked");
076 
077             }
078         });
079         tb1.addWidget(cancel);
080 
081         tb1.addWidget(new Image("gwtcomp-icons/edit.png"));
082         tool.addToolbar(tb1);
083         final Toolbar tb2 = new Toolbar();
084         tb2.addWidget(new Image("gwtcomp-icons/help.png"));
085         tool.addToolbar(tb2);
086         final Toolbar tb3 = new Toolbar();
087         tb3.addWidget(new Image("gwtcomp-icons/folder.png"));
088         TextBox tb = new TextBox();
089         tb.setMaxLength(5);
090         tb.setVisibleLength(5);
091         tb3.addWidget(tb);
092         Button find = new Button("Go");
093         find.addClickListener(new ClickListener()
094         {
095 
096             public void onClick(Widget sender)
097             {
098                 Window.alert("Go Listener!");
099 
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 }