Java tutorial
/* * Copyright 2011 Google Inc. All Rights Reserved. * * 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. */ package it.alexabbi.aproject.client.ui.second; import java.util.logging.Logger; import com.google.gwt.core.client.GWT; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.DragOverEvent; import com.google.gwt.event.dom.client.DragOverHandler; import com.google.gwt.event.dom.client.DragStartEvent; import com.google.gwt.event.dom.client.DragStartHandler; import com.google.gwt.event.dom.client.DropEvent; import com.google.gwt.event.dom.client.DropHandler; import com.google.gwt.storage.client.Storage; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Widget; /** * Sample implementation of {@link SecondPage}. */ public class SecondPageImpl extends Composite implements SecondPage { interface Binder extends UiBinder<Widget, SecondPageImpl> { } private static final Binder binder = GWT.create(Binder.class); private final static Logger logger = Logger.getLogger("SecondPageImpl"); private Presenter listener; private ClickHandler settingsHandler; @UiField HTMLPanel pannello; @UiField HTMLPanel pannello2; public SecondPageImpl() { logger.info("SecondPageImpl"); initWidget(binder.createAndBindUi(this)); Storage storage = Storage.getLocalStorageIfSupported(); if (storage != null) { storage.setItem("a", "pippo"); } final String valore = storage.getItem("a"); final Label label = new Label(); label.setText("DRAG ME"); label.getElement().setDraggable("TRUE"); pannello.add(label); label.addDragStartHandler(new DragStartHandler() { @Override public void onDragStart(DragStartEvent event) { event.setData("prova", "DROPPATO"); //event.getDataTransfer().setDragImage(label, 10, 10); } }); final Label label2 = new Label(); label2.setText("DROP HERE"); pannello2.add(label2); label2.addDragOverHandler(new DragOverHandler() { @Override public void onDragOver(DragOverEvent event) { //label2.getElement().setTitle("cicco"); } }); label2.addDropHandler(new DropHandler() { @Override public void onDrop(DropEvent event) { // TODO Auto-generated method stub event.preventDefault(); String data = event.getData("prova"); label2.setText(data); } }); } @Override public void setPresenter(Presenter listener) { this.listener = listener; } }