1 /********************************************** 2 * Copyright (C) 2011 Lukas Laag 3 * This file is part of svgreal. 4 * 5 * svgreal is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * 10 * svgreal is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with svgreal. If not, see http://www.gnu.org/licenses/ 17 **********************************************/ 18 package org.vectomatic.svg.edit.client.command.dnd; 19 20 import java.util.List; 21 22 import org.vectomatic.svg.edit.client.command.DndCommandFactory.DropGesture; 23 import org.vectomatic.svg.edit.client.model.svg.SVGElementModel; 24 25 import com.extjs.gxt.ui.client.event.DNDEvent; 26 27 /** 28 * Interface for classes which interpret drag and drop input 29 * @author laaglu 30 */ 31 public interface IDndHandler { 32 /** 33 * Determines the feasibility of creating a command using the 34 * specified source elements as drag sources. 35 * @param event 36 * The drag and drop event 37 * @param sourceElements 38 * The elements being dragged 39 * @return 40 * True if the drag and drop operation can proceed, false if 41 * it should be completely blocked. 42 */ 43 public boolean isValidSource(DNDEvent event, List<SVGElementModel> sourceElements); 44 /** 45 * Determines if dropping on the specified target will result 46 * in a successful command creation. 47 * @param sourceElements 48 * The elements being dragged 49 * @param target 50 * The hovered target 51 * @return 52 * True if the target is authorized, false otherwise 53 */ 54 public boolean isValidTarget(List<SVGElementModel> sourceElements, SVGElementModel target); 55 /** 56 * Creates the commands which represent the drag and drop operation 57 * @param sourceElements 58 * The drag source elements 59 * @param target 60 * The drop target elements 61 * @param dropGesture 62 * The drop gesture 63 */ 64 public void createCommands(List<SVGElementModel> sourceElements, SVGElementModel target, DropGesture dropGesture); 65 /** 66 * Returns the DOM attribute value which trigger the display 67 * of the proper icons in the drag ghost using a CSS rule 68 * @return a DOM attribute value 69 */ 70 public String getOperationCssAttr(); 71 /** 72 * Returns the text which appears in the ghost during a 73 * drag and drop operation 74 * @param sourceElements 75 * The elements being dragged 76 * @return 77 */ 78 public String getMessage(List<SVGElementModel> sourceElements); 79 /** 80 * Returns the key code associated with this handler 81 * @return 82 */ 83 public int getKeyCode(); 84 }