Search in sources :

Example 16 with ObjectsFolderTreeObject

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

the class TransactionCreateHandlerAction method selectionChanged.

@Override
public void selectionChanged(IAction action, ISelection selection) {
    try {
        boolean enable = false;
        super.selectionChanged(action, selection);
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
        if (treeObject instanceof TransactionTreeObject)
            enable = true;
        else if (treeObject instanceof ObjectsFolderTreeObject)
            enable = ((ObjectsFolderTreeObject) treeObject).folderType == ObjectsFolderTreeObject.FOLDER_TYPE_FUNCTIONS;
        action.setEnabled(enable);
    } catch (Exception e) {
    }
}
Also used : TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) IOException(java.io.IOException)

Example 17 with ObjectsFolderTreeObject

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

the class TreeDropAdapter method validateDrop.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ViewerDropAdapter#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData)
	 */
@Override
public boolean validateDrop(Object target, int operation, TransferData transferType) {
    if (TextTransfer.getInstance().isSupportedType(transferType)) {
        if (getCurrentOperation() == DND.DROP_MOVE) {
            Object targetObject = getCurrentTarget();
            Object sourceObject = getSelectedObject();
            if (targetObject != null && targetObject instanceof TreeObject) {
                TreeObject targetTreeObject = (TreeObject) targetObject;
                if (sourceObject != null && sourceObject instanceof TreeObject) {
                    TreeObject sourceTreeObject = (TreeObject) sourceObject;
                    boolean isFocus = sourceTreeObject.viewer.getControl().isFocusControl();
                    if (isFocus && (sourceObject == targetObject || targetTreeObject.isChildOf(sourceTreeObject))) {
                        return false;
                    }
                }
                if (targetObject instanceof DatabaseObjectTreeObject) {
                    try {
                        String xmlData = TextTransfer.getInstance().nativeToJava(transferType).toString();
                        List<Object> list = ConvertigoPlugin.clipboardManagerDND.read(xmlData);
                        DatabaseObject databaseObject = (DatabaseObject) list.get(0);
                        DatabaseObject targetDatabaseObject = ((DatabaseObjectTreeObject) target).getObject();
                        if (DatabaseObjectsManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
                            return true;
                        }
                        DatabaseObject parentDatabaseObject = targetDatabaseObject.getParent();
                        if (parentDatabaseObject != null && DatabaseObjectsManager.acceptDatabaseObjects(parentDatabaseObject, databaseObject)) {
                            return true;
                        }
                        return false;
                    } catch (Exception e) {
                        e.printStackTrace(System.out);
                    }
                }
            }
        }
        return true;
    }
    if (StepSourceTransfer.getInstance().isSupportedType(transferType)) {
        if (target instanceof TreeObject) {
            TreeObject targetTreeObject = (TreeObject) target;
            // Check for drop to a step which contains a stepSource definition
            // if (targetTreeObject.getObject() instanceof IStepSourceContainer) {
            Object ob = targetTreeObject.getObject();
            if (ob instanceof Step && ((Step) ob).canWorkOnSource() || ob instanceof IStepSourceContainer) {
                StepSource stepSource = StepSourceTransfer.getInstance().getStepSource();
                if (stepSource != null) {
                    Step targetStep = (Step) ((ob instanceof StepVariable) ? ((StepVariable) ob).getParent() : ob);
                    // Check for drop to a step in the same sequence
                    Long key = Long.valueOf(stepSource.getPriority());
                    Step sourceStep = targetStep.getSequence().loadedSteps.get(key);
                    if ((sourceStep != null) && (!targetStep.equals(sourceStep))) {
                        // Check for drop on a 'following' step
                        try {
                            List<TreeObject> siblings = new ArrayList<TreeObject>();
                            getNextSiblings(siblings, targetTreeObject.getProjectTreeObject(), sourceStep);
                            // System.out.println("siblings: "+siblings.toString());
                            return siblings.contains(targetTreeObject);
                        } catch (Exception e) {
                            e.printStackTrace(System.out);
                        }
                        ;
                    }
                }
            }
        }
    }
    if (PaletteSourceTransfer.getInstance().isSupportedType(transferType)) {
        if (target instanceof TreeObject) {
            TreeObject targetTreeObject = (TreeObject) target;
            PaletteSource paletteSource = PaletteSourceTransfer.getInstance().getPaletteSource();
            if (paletteSource != null) {
                try {
                    String xmlData = paletteSource.getXmlData();
                    List<Object> list = ConvertigoPlugin.clipboardManagerDND.read(xmlData);
                    DatabaseObject databaseObject = (DatabaseObject) list.get(0);
                    if (targetTreeObject instanceof ObjectsFolderTreeObject) {
                        ObjectsFolderTreeObject folderTreeObject = (ObjectsFolderTreeObject) targetTreeObject;
                        if (!ProjectExplorerView.folderAcceptMobileComponent(folderTreeObject.folderType, databaseObject)) {
                            return false;
                        }
                        // continue
                        targetTreeObject = folderTreeObject.getParent();
                    }
                    if (targetTreeObject instanceof DatabaseObjectTreeObject) {
                        DatabaseObject targetDatabaseObject = ((DatabaseObjectTreeObject) targetTreeObject).getObject();
                        if (targetDatabaseObject != null) {
                            if (!DatabaseObjectsManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
                                return false;
                            }
                            if (targetTreeObject instanceof MobileComponentTreeObject) {
                                if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
                                    return false;
                                }
                                if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.isTplCompatible(targetDatabaseObject, databaseObject)) {
                                    return false;
                                }
                            }
                            if (targetTreeObject instanceof NgxComponentTreeObject) {
                                if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
                                    return false;
                                }
                                if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.isTplCompatible(targetDatabaseObject, databaseObject)) {
                                    return false;
                                }
                            }
                            return true;
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace(System.out);
                }
            }
        }
    }
    if (MobileSourceTransfer.getInstance().isSupportedType(transferType)) {
        MobileSource mobileSource = MobileSourceTransfer.getInstance().getMobileSource();
        if (mobileSource != null) {
            if (target instanceof MobileUIComponentTreeObject) {
                MobileUIComponentTreeObject mcto = GenericUtils.cast(target);
                com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource mss = com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.valueOf(mobileSource.getJsonString());
                if (mss == null || !mss.isDroppableInto(mcto.getObject())) {
                    return false;
                }
                for (IPropertyDescriptor descriptor : mcto.getPropertyDescriptors()) {
                    if (descriptor instanceof MobileSmartSourcePropertyDescriptor) {
                        if (!((MobileSmartSourcePropertyDescriptor) descriptor).isReadOnly()) {
                            return true;
                        }
                    }
                }
            }
            if (target instanceof NgxUIComponentTreeObject) {
                NgxUIComponentTreeObject mcto = GenericUtils.cast(target);
                com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource mss = com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.valueOf(mobileSource.getJsonString());
                if (mss == null || !mss.isDroppableInto(mcto.getObject())) {
                    return false;
                }
                for (IPropertyDescriptor descriptor : mcto.getPropertyDescriptors()) {
                    if (descriptor instanceof NgxSmartSourcePropertyDescriptor) {
                        if (!((NgxSmartSourcePropertyDescriptor) descriptor).isReadOnly()) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) MobileSmartSourcePropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.MobileSmartSourcePropertyDescriptor) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) ArrayList(java.util.ArrayList) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) XMLElementStep(com.twinsoft.convertigo.beans.steps.XMLElementStep) Step(com.twinsoft.convertigo.beans.core.Step) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) NgxSmartSourcePropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.NgxSmartSourcePropertyDescriptor) IStepSourceContainer(com.twinsoft.convertigo.beans.core.IStepSourceContainer) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject) IOException(java.io.IOException) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) SAXException(org.xml.sax.SAXException) EngineException(com.twinsoft.convertigo.engine.EngineException) InvalidOperationException(com.twinsoft.convertigo.engine.InvalidOperationException) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) 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) IPropertyDescriptor(org.eclipse.ui.views.properties.IPropertyDescriptor)

Example 18 with ObjectsFolderTreeObject

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

the class CreateSheetAction method selectionChanged.

public void selectionChanged(IAction action, ISelection selection) {
    try {
        boolean enable = true;
        super.selectionChanged(action, selection);
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
        if (treeObject instanceof ObjectsFolderTreeObject) {
            enable = ((ObjectsFolderTreeObject) treeObject).folderType == ObjectsFolderTreeObject.FOLDER_TYPE_SHEETS;
        } else if (treeObject instanceof DatabaseObjectTreeObject) {
            DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
            ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
            enable = actionModel.isEnabled;
        }
        action.setEnabled(enable);
    } catch (Exception e) {
    }
}
Also used : DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) ActionModel(com.twinsoft.convertigo.engine.studio.ActionModel)

Example 19 with ObjectsFolderTreeObject

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

the class CreateVariableAction method selectionChanged.

public void selectionChanged(IAction action, ISelection selection) {
    try {
        boolean enable = true;
        super.selectionChanged(action, selection);
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
        if (treeObject instanceof ObjectsFolderTreeObject) {
            ObjectsFolderTreeObject ofto = (ObjectsFolderTreeObject) treeObject;
            enable = ofto.folderType == ObjectsFolderTreeObject.FOLDER_TYPE_VARIABLES;
            treeObject = ofto.getParent();
        }
        if (enable && treeObject instanceof DatabaseObjectTreeObject) {
            DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
            ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
            enable = actionModel.isEnabled;
        }
        action.setEnabled(enable);
    } catch (Exception e) {
    }
}
Also used : DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) ActionModel(com.twinsoft.convertigo.engine.studio.ActionModel)

Example 20 with ObjectsFolderTreeObject

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

the class CreateMobileUIComponentAction method selectionChanged.

public void selectionChanged(IAction action, ISelection selection) {
    try {
        boolean enable = true;
        super.selectionChanged(action, selection);
        IStructuredSelection structuredSelection = (IStructuredSelection) selection;
        TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
        if (treeObject instanceof ObjectsFolderTreeObject) {
            ObjectsFolderTreeObject oft = (ObjectsFolderTreeObject) treeObject;
            if (oft.folderType == ObjectsFolderTreeObject.FOLDER_TYPE_PAGES) {
                enable = false;
            } else {
                TreeParent treeParent = oft.getParent();
                enable = treeParent != null && treeParent instanceof MobileComponentTreeObject;
            }
        } else if (treeObject instanceof DatabaseObjectTreeObject) {
            DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
            ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
            enable = actionModel.isEnabled;
        }
        action.setEnabled(enable);
    } catch (Exception e) {
    }
}
Also used : DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject) ActionModel(com.twinsoft.convertigo.engine.studio.ActionModel)

Aggregations

ObjectsFolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject)21 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)19 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)18 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)14 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 ActionModel (com.twinsoft.convertigo.engine.studio.ActionModel)11 EngineException (com.twinsoft.convertigo.engine.EngineException)5 IOException (java.io.IOException)5 Shell (org.eclipse.swt.widgets.Shell)5 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)4 PropertyTableRowTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject)4 WizardDialog (org.eclipse.jface.wizard.WizardDialog)4 Cursor (org.eclipse.swt.graphics.Cursor)4 Display (org.eclipse.swt.widgets.Display)4 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)3 IPropertyTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)3 MobileUIComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject)3 NgxComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject)3 NgxUIComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject)3 PropertyTableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)3