1   /*
2    * Created on Sep 8, 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.DraggableLabel;
22  import org.cafesip.gwtcomp.client.ui.DroppableList;
23  import org.cafesip.gwtcomp.client.ui.TitleBar;
24  import org.cafesip.gwtcomp.client.utils.HTMLHelper;
25  
26  import com.google.gwt.core.client.GWT;
27  import com.google.gwt.user.client.ui.FlowPanel;
28  import com.google.gwt.user.client.ui.HTML;
29  import com.google.gwt.user.client.ui.HasHorizontalAlignment;
30  import com.google.gwt.user.client.ui.HasVerticalAlignment;
31  import com.google.gwt.user.client.ui.HorizontalPanel;
32  import com.google.gwt.user.client.ui.VerticalPanel;
33  
34  /**
35   * @author Amit Chatterjee
36   *
37   */
38  public class DraggableSample extends FlowPanel
39  {
40      private static final String WORLD = "world";
41      private static final String COUNTRY = "country";
42      public DraggableSample()
43      {
44          setWidth("100%");
45          init();
46      }
47      
48  
49      private void init()
50      {
51          TitleBar titleBar = new TitleBar("Drag and Drop Widgets", null, 1);
52          add(titleBar);
53          titleBar.setWidth("100%");
54  
55          HorizontalPanel hp = new HorizontalPanel();
56          add(hp);
57          hp.setSpacing(5);
58          hp.setBorderWidth(1);
59          hp.setSize("100%", "100%");
60          
61          VerticalPanel vp = new VerticalPanel();
62          vp.setSpacing(5);
63          vp.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
64          vp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
65          
66          hp.add(vp);
67          vp.setWidth("100%");
68                 
69          HTML label1 = new HTML(HTMLHelper.bold("Drag items into the basket"), false);
70          vp.add(label1);
71  
72          DraggableLabel us = new DraggableLabel(GWT
73                  .getModuleBaseURL() + "icons/us.png", "USA", "us", COUNTRY);
74          vp.add(us);   
75          
76          DraggableLabel ca = new DraggableLabel(GWT
77                  .getModuleBaseURL() + "icons/ca.png", "Canada", "ca", COUNTRY);
78          vp.add(ca);
79          
80          DraggableLabel in = new DraggableLabel(GWT
81                  .getModuleBaseURL() + "icons/in.png", "India", "in", COUNTRY);
82          vp.add(in);
83          
84          DraggableLabel fr = new DraggableLabel(GWT
85                  .getModuleBaseURL() + "icons/fr.png", "France", "fr", COUNTRY);
86          vp.add(fr);
87                          
88          vp.add(new HTML(HTMLHelper.hr("black")));
89          
90          HTML label2 = new HTML(HTMLHelper.bold("Try dragging the items below"), false);
91          vp.add(label2);
92          
93          DraggableLabel un = new DraggableLabel(GWT
94                  .getModuleBaseURL() + "icons/html.png", "UN", "un", WORLD);
95          vp.add(un);
96          
97          DraggableLabel eu = new DraggableLabel(GWT
98                  .getModuleBaseURL() + "icons/europeanunion.png", "EU", "eu", WORLD);
99          vp.add(eu);
100         
101         DroppableList list = new DroppableList("list", COUNTRY);
102         hp.add(list);
103         list.addItem("France");
104 
105     }
106 }