001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.gwt.client.dnd; 029 030import com.google.common.base.Optional; 031import com.google.gwt.dom.client.Element; 032 033/** 034 * Interface defining all methods used by drag and drop on a draggable element.<p> 035 * 036 * @since 8.0.0 037 */ 038public interface I_CmsDraggable { 039 040 /** 041 * Gets an optional pair of integers which are to be used as an "offset delta" for the drag and drop process.<p> 042 * 043 * @return an optional array containing exactly 2 entries [x,y] 044 */ 045 Optional<int[]> getCursorOffsetDelta(); 046 047 /** 048 * Creates the drag helper element and attaches it into the DOM.<p> 049 * 050 * @param target the drop target 051 * 052 * @return the drag helper element 053 */ 054 Element getDragHelper(I_CmsDropTarget target); 055 056 /** 057 * Returns the draggable element.<p> 058 * 059 * @return the element 060 */ 061 Element getElement(); 062 063 /** 064 * Returns the draggable id.<p> 065 * 066 * @return the id 067 */ 068 String getId(); 069 070 /** 071 * Returns the parent drop target or <code>null</code> if there is none.<p> 072 * 073 * @return the parent drop target 074 */ 075 I_CmsDropTarget getParentTarget(); 076 077 /** 078 * Creates the drag placeholder element.<p> 079 * 080 * @param target the drop target 081 * 082 * @return the drag placeholder element 083 */ 084 Element getPlaceholder(I_CmsDropTarget target); 085 086 /** 087 * Executed on drag cancel.<p> 088 */ 089 void onDragCancel(); 090 091 /** 092 * Executed on drop.<p> 093 * 094 * @param target the drop target 095 */ 096 void onDrop(I_CmsDropTarget target); 097 098 /** 099 * Executed on drag start.<p> 100 * 101 * @param target the current drop target 102 */ 103 void onStartDrag(I_CmsDropTarget target); 104}