Search in sources :

Example 1 with IOrderableTreeObject

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IOrderableTreeObject in project convertigo by convertigo.

the class TreeDropAdapter method dragOver.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ViewerDropAdapter#dragOver(org.eclipse.swt.dnd.DropTargetEvent)
	 */
@Override
public void dragOver(DropTargetEvent event) {
    super.dragOver(event);
    // Overrides feedback: by default is DND.FEEDBACK_SELECT
    feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND;
    boolean shouldFeedBack = true;
    if (PaletteSourceTransfer.getInstance().isSupportedType(event.currentDataType)) {
        shouldFeedBack = false;
    }
    // Handles feedback for objects that can be ordered
    if (shouldFeedBack && getCurrentOperation() == DND.DROP_MOVE) {
        Object targetObject = getCurrentTarget();
        Object sourceObject = getSelectedObject();
        if ((sourceObject != null) && (targetObject != null)) {
            // Source and target objects must be different
            if (!sourceObject.equals(targetObject)) {
                if ((sourceObject instanceof TreeObject) && (targetObject instanceof TreeObject)) {
                    // Source and target objects can be ordered
                    if ((sourceObject instanceof IOrderableTreeObject) && (targetObject instanceof IOrderableTreeObject)) {
                        // Source and target objects must have the same parent
                        if (((TreeObject) sourceObject).getParent().equals(((TreeObject) targetObject).getParent())) {
                            boolean srcInherited = false;
                            if (sourceObject instanceof DatabaseObjectTreeObject)
                                srcInherited = ((DatabaseObjectTreeObject) sourceObject).isInherited;
                            else if (sourceObject instanceof IPropertyTreeObject)
                                srcInherited = ((IPropertyTreeObject) sourceObject).isInherited();
                            // Source object musn't be inherited
                            if (!srcInherited) {
                                int currentLocation = getCurrentLocation();
                                switch(currentLocation) {
                                    case LOCATION_BEFORE:
                                        feedback = DND.FEEDBACK_INSERT_BEFORE;
                                        break;
                                    case LOCATION_AFTER:
                                        feedback = DND.FEEDBACK_INSERT_AFTER;
                                        break;
                                    case LOCATION_ON:
                                    default:
                                        feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND;
                                        break;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // Set feedback
    event.feedback = feedback;
}
Also used : IOrderableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IOrderableTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) IOrderableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IOrderableTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject) PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) IOrderableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IOrderableTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)

Aggregations

DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)1 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)1 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)1 FolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject)1 IOrderableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IOrderableTreeObject)1 IPropertyTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)1 MobileComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject)1 MobileUIComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject)1 NgxComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject)1 NgxUIComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject)1 ObjectsFolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject)1 PropertyTableRowTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject)1 PropertyTableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)1 ScreenClassTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject)1 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)1