001 /*
002 * Created on Sep 8, 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.DraggableLabel;
022 import org.cafesip.gwtcomp.client.ui.DroppableList;
023 import org.cafesip.gwtcomp.client.ui.TitleBar;
024 import org.cafesip.gwtcomp.client.utils.HTMLHelper;
025
026 import com.google.gwt.user.client.ui.FlowPanel;
027 import com.google.gwt.user.client.ui.HTML;
028 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
029 import com.google.gwt.user.client.ui.HasVerticalAlignment;
030 import com.google.gwt.user.client.ui.HorizontalPanel;
031 import com.google.gwt.user.client.ui.Tree;
032 import com.google.gwt.user.client.ui.VerticalPanel;
033
034 /**
035 * @author Amit Chatterjee
036 *
037 */
038 public class DraggableSample extends FlowPanel
039 {
040 private static final String WORLD = "world";
041 private static final String COUNTRY = "country";
042 private Tree tree;
043
044 public DraggableSample()
045 {
046 setWidth("100%");
047 init();
048 }
049
050
051 private void init()
052 {
053 TitleBar titleBar = new TitleBar("Drag and Drop Widgets", null, 1);
054 add(titleBar);
055 titleBar.setWidth("100%");
056
057 HorizontalPanel hp = new HorizontalPanel();
058 add(hp);
059 hp.setSpacing(5);
060 hp.setBorderWidth(1);
061 hp.setSize("100%", "100%");
062
063 VerticalPanel vp = new VerticalPanel();
064 vp.setSpacing(5);
065 vp.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
066 vp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
067
068 hp.add(vp);
069 vp.setWidth("100%");
070
071 HTML label1 = new HTML(HTMLHelper.bold("Drag items into the basket"), false);
072 vp.add(label1);
073
074 DraggableLabel us = new DraggableLabel("icons/us.png", "USA", "us", COUNTRY);
075 vp.add(us);
076
077 DraggableLabel ca = new DraggableLabel("icons/ca.png", "Canada", "ca", COUNTRY);
078 vp.add(ca);
079
080 DraggableLabel in = new DraggableLabel("icons/in.png", "India", "in", COUNTRY);
081 vp.add(in);
082
083 DraggableLabel fr = new DraggableLabel("icons/fr.png", "France", "fr", COUNTRY);
084 vp.add(fr);
085
086 vp.add(new HTML(HTMLHelper.hr("black")));
087
088 HTML label2 = new HTML(HTMLHelper.bold("Try dragging the items below"), false);
089 vp.add(label2);
090
091 DraggableLabel un = new DraggableLabel("icons/html.png", "UN", "un", WORLD);
092 vp.add(un);
093
094 DraggableLabel eu = new DraggableLabel("icons/europeanunion.png", "EU", "eu", WORLD);
095 vp.add(eu);
096
097 DroppableList list = new DroppableList("list", COUNTRY);
098 hp.add(list);
099 list.addItem("France");
100
101 }
102
103 }
|