Search in sources :

Example 1 with DatabaseObjectTreeObject

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

the class ClipboardAction method paste.

public void paste(String source, Shell shell, ProjectExplorerView explorerView, TreeObject selectedTreeObject, boolean isDND) throws ConvertigoException, IOException, ParserConfigurationException, SAXException, CoreException {
    if ((explorerView != null) && (selectedTreeObject != null)) {
        TreeObject targetTreeObject = null;
        Object targetObject = null;
        if (selectedTreeObject instanceof FolderTreeObject) {
            if (selectedTreeObject.getParent() instanceof IDesignTreeObject) {
                selectedTreeObject = selectedTreeObject.getParent();
            }
        }
        if (selectedTreeObject instanceof IPropertyTreeObject) {
            targetTreeObject = selectedTreeObject;
            targetObject = selectedTreeObject;
        } else if (selectedTreeObject instanceof IDesignTreeObject) {
            targetTreeObject = selectedTreeObject;
            targetObject = selectedTreeObject;
            if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_DOCUMENT) {
                targetTreeObject = ((IDesignTreeObject) selectedTreeObject).getTreeObjectOwner();
                targetObject = (DatabaseObject) targetTreeObject.getObject();
            }
        } else {
            // case of folder, retrieve owner object
            targetTreeObject = explorerView.getFirstSelectedDatabaseObjectTreeObject(selectedTreeObject);
            targetObject = (DatabaseObject) targetTreeObject.getObject();
            // i.e. without having to select the parent database object.
            if (clipboardManager.objectsType == ProjectExplorerView.getTreeObjectType(new TreePath(targetTreeObject))) {
                // it must be different from the currently selected object.
                if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_SCREEN_CLASS) {
                    CustomDialog customDialog = new CustomDialog(shell, "Paste a Screenclass", "Do you want to paste the Screenclass as a sibling or as an inherited ScreenClass?", 500, 150, new ButtonSpec("As a sibling", true), new ButtonSpec("As an iherited", false), new ButtonSpec(IDialogConstants.CANCEL_LABEL, false));
                    int response = customDialog.open();
                    if (response == 0)
                        targetObject = ((DatabaseObject) targetObject).getParent();
                    else if (response == 2)
                        return;
                } else if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STATEMENT_WITH_EXPRESSIONS) {
                    if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_FUNCTION) {
                        targetObject = ((DatabaseObject) targetObject).getParent();
                    } else {
                        CustomDialog customDialog = new CustomDialog(shell, "Paste a statement", "Do you want to paste the statement as a sibling or a child statement?", 500, 150, new ButtonSpec("As a sibling", true), new ButtonSpec("As a child", false), new ButtonSpec(IDialogConstants.CANCEL_LABEL, false));
                        int response = customDialog.open();
                        if (response == 0) {
                            targetObject = ((DatabaseObject) targetObject).getParent();
                        } else if (response == 2) {
                            return;
                        }
                    }
                } else if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_MOBILE_UICOMPONENT) {
                    if (!clipboardManager.isCut) {
                        CustomDialog customDialog = new CustomDialog(shell, "Paste a Component", "Do you want to paste the Component as a sibling or as a child component?", 500, 150, new ButtonSpec("As a sibling", true), new ButtonSpec("As a child", false), new ButtonSpec(IDialogConstants.CANCEL_LABEL, false));
                        int response = customDialog.open();
                        if (response == 0) {
                            targetObject = ((DatabaseObject) targetObject).getParent();
                        } else if (response == 2) {
                            return;
                        }
                    }
                } else if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP_WITH_EXPRESSIONS || clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP) {
                    targetObject = pasteStep(shell, source, (DatabaseObject) targetObject);
                    if (targetObject == null)
                        return;
                } else if (isDND && clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_SEQUENCE) {
                // Do not change target to parent
                } else {
                    targetObject = ((DatabaseObject) targetObject).getParent();
                }
                targetTreeObject = explorerView.findTreeObjectByUserObject(((DatabaseObject) targetObject));
            } else {
                if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP_WITH_EXPRESSIONS || clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_STEP) {
                    targetObject = pasteStep(shell, source, (DatabaseObject) targetObject);
                    if (targetObject == null)
                        return;
                }
            }
        }
        if (clipboardManager.isCut) {
            TreeParent targetTreeParent = null;
            String targetPath = targetTreeObject.getPath();
            if (targetTreeObject instanceof DatabaseObjectTreeObject) {
                targetTreeParent = ((DatabaseObjectTreeObject) targetTreeObject).getOwnerDatabaseObjectTreeObject();
            } else if (targetTreeObject instanceof IPropertyTreeObject) {
                targetTreeParent = ((IPropertyTreeObject) targetTreeObject).getTreeObjectOwner();
            } else if (targetTreeObject instanceof IDesignTreeObject) {
                targetTreeParent = ((IDesignTreeObject) targetTreeObject).getTreeObjectOwner();
            }
            for (int i = 0; i < clipboardManager.objects.length; i++) {
                // Cut & paste
                clipboardManager.cutAndPaste(clipboardManager.objects[i], targetTreeObject);
                // Updating the tree
                // Report 4.5: fix #401
                // explorerView.reloadTreeObject(clipboardManager.parentTreeNodeOfCutObjects[i]);
                TreeObject parentTreeNodeOfCutObjects = clipboardManager.parentTreeNodeOfCutObjects[i];
                parentTreeNodeOfCutObjects.getProjectTreeObject().hasBeenModified(true);
                if (!(parentTreeNodeOfCutObjects instanceof IDesignTreeObject)) {
                    explorerView.reloadTreeObject(parentTreeNodeOfCutObjects);
                }
            }
            if (targetTreeObject != null) {
                if (targetTreeObject.getParent() == null)
                    targetTreeObject = explorerView.findTreeObjectByPath(targetTreeParent, targetPath);
                if (targetTreeObject != null)
                    // Report 4.5: fix #401
                    targetTreeObject.getProjectTreeObject().hasBeenModified(true);
            }
            clipboardManager.reset();
        } else if (source != null) {
            // Paste
            clipboardManager.paste(source, targetObject, true);
            // Case of project copy
            if (clipboardManager.objectsType == ProjectExplorerView.TREE_OBJECT_TYPE_DBO_PROJECT) {
                Object[] pastedObjects = clipboardManager.pastedObjects;
                for (int i = 0; i < pastedObjects.length; i++) {
                    Object object = pastedObjects[i];
                    if ((object != null) && (object instanceof Project)) {
                        Project project = (Project) object;
                        String oldName = project.getName();
                        try {
                            Project importedProject = importProjectTempArchive(oldName, explorerView);
                            if (importedProject != null) {
                                String newName = importedProject.getName();
                                explorerView.importProjectTreeObject(newName, true, oldName);
                            } else
                                throw new EngineException("Unable to import project temporary archive");
                        } catch (Exception e) {
                            throw new EngineException("Unable to paste project", e);
                        }
                    }
                }
            }
        }
        // Updating the tree
        if (targetTreeObject != null) {
            TreeObject treeObjectToReload = targetTreeObject;
            TreeObject treeObjectToSelect = targetTreeObject;
            if (targetTreeObject instanceof IPropertyTreeObject) {
                treeObjectToSelect = ((IPropertyTreeObject) targetTreeObject).getTreeObjectOwner();
                treeObjectToReload = treeObjectToSelect;
                if (treeObjectToReload instanceof DatabaseObjectTreeObject) {
                    treeObjectToReload = treeObjectToReload.getParent();
                    if (treeObjectToReload instanceof FolderTreeObject)
                        treeObjectToReload = treeObjectToReload.getParent();
                }
            }
            if (targetTreeObject instanceof IDesignTreeObject) {
                treeObjectToSelect = ((IDesignTreeObject) targetTreeObject).getTreeObjectOwner();
                treeObjectToReload = treeObjectToSelect;
                if (treeObjectToReload instanceof DatabaseObjectTreeObject) {
                    treeObjectToReload = treeObjectToReload.getParent();
                    if (treeObjectToReload instanceof FolderTreeObject)
                        treeObjectToReload = treeObjectToReload.getParent();
                }
            }
            if (treeObjectToReload != null) {
                // explorerView.reloadTreeObject(targetTreeObject);
                // explorerView.setSelectedTreeObject(targetTreeObject);
                explorerView.objectChanged(new CompositeEvent(treeObjectToReload.getObject(), treeObjectToSelect.getPath()));
            }
        }
    }
}
Also used : DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) EngineException(com.twinsoft.convertigo.engine.EngineException) CoreException(org.eclipse.core.runtime.CoreException) ConvertigoException(com.twinsoft.convertigo.engine.ConvertigoException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) EngineException(com.twinsoft.convertigo.engine.EngineException) Project(com.twinsoft.convertigo.beans.core.Project) TreePath(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreePath) CustomDialog(com.twinsoft.convertigo.eclipse.dialogs.CustomDialog) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) ButtonSpec(com.twinsoft.convertigo.eclipse.dialogs.ButtonSpec) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)

Example 2 with DatabaseObjectTreeObject

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

the class DatabaseObjectIncreasePriorityAction method increasePriority.

private void increasePriority(TreeObject treeObject) throws EngineException {
    int count = counter;
    if (treeObject instanceof DatabaseObjectTreeObject) {
        DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
        DatabaseObject parent = databaseObject.getParent();
        if (parent != null && parent instanceof IContainerOrdered) {
            IContainerOrdered containerOrdered = (IContainerOrdered) parent;
            while (count-- > 0) {
                containerOrdered.increasePriority(databaseObject);
            }
            if (parent.hasChanged) {
                TreeParent parentTreeObject = null;
                TreeParent treeParent = treeObject.getParent();
                if (treeParent instanceof FolderTreeObject) {
                    parentTreeObject = treeObject.getParent().getParent();
                } else {
                    parentTreeObject = treeParent;
                }
                if (!treeNodesToUpdate.contains(parentTreeObject)) {
                    treeNodesToUpdate.add(parentTreeObject);
                }
            }
        }
    } else {
        DatabaseObjectTreeObject databaseObjectTreeObject = null;
        if (treeObject instanceof PropertyTableRowTreeObject) {
            PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) treeObject.getParent();
            while (count-- > 0) {
                if ((treeObject = propertyTableTreeObject.moveRow((PropertyTableRowTreeObject) treeObject, true)) != null) {
                    databaseObjectTreeObject = (DatabaseObjectTreeObject) propertyTableTreeObject.getParent();
                }
            }
        } else if (treeObject instanceof PropertyTableColumnTreeObject) {
            PropertyTableRowTreeObject propertyTableRowTreeObject = (PropertyTableRowTreeObject) treeObject.getParent();
            PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) propertyTableRowTreeObject.getParent();
            while (count-- > 0) {
                if ((treeObject = propertyTableRowTreeObject.moveColumn((PropertyTableColumnTreeObject) treeObject, true)) != null) {
                    databaseObjectTreeObject = (DatabaseObjectTreeObject) propertyTableTreeObject.getParent();
                }
            }
        }
        if (databaseObjectTreeObject != null) {
            if (databaseObjectTreeObject.hasChanged()) {
                DatabaseObjectTreeObject parentTreeObject = null;
                TreeParent treeParent = databaseObjectTreeObject.getParent();
                if (treeParent instanceof FolderTreeObject)
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
                else
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent;
                if (!treeNodesToUpdate.contains(parentTreeObject)) {
                    treeNodesToUpdate.add(parentTreeObject);
                }
            }
        }
    }
}
Also used : PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) IContainerOrdered(com.twinsoft.convertigo.beans.core.IContainerOrdered) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)

Example 3 with DatabaseObjectTreeObject

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

the class ChangeToSingleValuedVariableAction method run.

@Override
public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            TreeParent treeParent = treeObject.getParent();
            DatabaseObjectTreeObject parentTreeObject = null;
            if (treeParent instanceof DatabaseObjectTreeObject)
                parentTreeObject = (DatabaseObjectTreeObject) treeParent;
            else
                parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
            if (parentTreeObject != null) {
                Object databaseObject = treeObject.getObject();
                if (databaseObject != null) {
                    Variable multi = (Variable) databaseObject;
                    Variable simple = null;
                    if (databaseObject instanceof TestCaseMultiValuedVariable)
                        simple = new TestCaseVariable();
                    if (databaseObject instanceof StepMultiValuedVariable)
                        simple = new StepVariable();
                    if (databaseObject instanceof RequestableMultiValuedVariable)
                        simple = new RequestableVariable();
                    if (databaseObject instanceof RequestableHttpMultiValuedVariable)
                        simple = new RequestableHttpVariable();
                    if (databaseObject instanceof HttpStatementMultiValuedVariable)
                        simple = new HttpStatementVariable();
                    if (simple != null) {
                        if (multi instanceof StepMultiValuedVariable) {
                            ((StepVariable) simple).setSourceDefinition(((StepVariable) multi).getSourceDefinition());
                        }
                        if (multi instanceof RequestableVariable) {
                            ((RequestableVariable) simple).setXmlTypeAffectation(((RequestableVariable) multi).getXmlTypeAffectation());
                        }
                        if (multi instanceof RequestableHttpVariable) {
                            // HttpName
                            ((RequestableHttpVariable) simple).setHttpName(((RequestableHttpVariable) multi).getHttpName());
                            // HttpMethod
                            ((RequestableHttpVariable) simple).setHttpMethod(((RequestableHttpVariable) multi).getHttpMethod());
                        }
                        XMLVector<Object> xmlv = GenericUtils.cast(multi.getValueOrNull());
                        Object value = (xmlv == null) ? null : (xmlv.isEmpty() ? "" : xmlv.get(0).toString());
                        simple.setValueOrNull(value);
                        simple.setVisibility(multi.getVisibility());
                        // Comment
                        simple.setComment(multi.getComment());
                        // Description
                        simple.setDescription(multi.getDescription());
                        // Required
                        simple.setRequired(multi.isRequired());
                        simple.bNew = true;
                        simple.hasChanged = true;
                        // Add new variable to parent
                        DatabaseObject parentDbo = multi.getParent();
                        parentDbo.add(simple);
                        // Set correct order
                        if (parentDbo instanceof TestCase)
                            ((TestCase) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof RequestableStep)
                            ((RequestableStep) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof Sequence)
                            ((Sequence) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof TransactionWithVariables)
                            ((TransactionWithVariables) parentDbo).insertAtOrder(simple, multi.priority);
                        if (parentDbo instanceof HTTPStatement)
                            ((HTTPStatement) parentDbo).insertAtOrder(simple, multi.priority);
                        // Add new variable in Tree
                        VariableTreeObject2 varTreeObject = new VariableTreeObject2(explorerView.viewer, simple);
                        treeParent.addChild(varTreeObject);
                        // Delete simple variable
                        multi.delete();
                        // Set correct name
                        simple.setName(multi.getName());
                        parentTreeObject.hasBeenModified(true);
                        explorerView.reloadTreeObject(parentTreeObject);
                        explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(simple));
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change simple variable to multi valuated variable!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) RequestableMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable) RequestableHttpVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpVariable) HttpStatementVariable(com.twinsoft.convertigo.beans.variables.HttpStatementVariable) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable) HttpStatementMultiValuedVariable(com.twinsoft.convertigo.beans.variables.HttpStatementMultiValuedVariable) Variable(com.twinsoft.convertigo.beans.core.Variable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) StepMultiValuedVariable(com.twinsoft.convertigo.beans.variables.StepMultiValuedVariable) TestCaseMultiValuedVariable(com.twinsoft.convertigo.beans.variables.TestCaseMultiValuedVariable) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) HttpStatementMultiValuedVariable(com.twinsoft.convertigo.beans.variables.HttpStatementMultiValuedVariable) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) Cursor(org.eclipse.swt.graphics.Cursor) HTTPStatement(com.twinsoft.convertigo.beans.statements.HTTPStatement) StepMultiValuedVariable(com.twinsoft.convertigo.beans.variables.StepMultiValuedVariable) Shell(org.eclipse.swt.widgets.Shell) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) VariableTreeObject2(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject2) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence) HttpStatementVariable(com.twinsoft.convertigo.beans.variables.HttpStatementVariable) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable) TestCaseMultiValuedVariable(com.twinsoft.convertigo.beans.variables.TestCaseMultiValuedVariable) RequestableHttpMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableHttpMultiValuedVariable) TestCase(com.twinsoft.convertigo.beans.core.TestCase) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) RequestableMultiValuedVariable(com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TransactionWithVariables(com.twinsoft.convertigo.beans.core.TransactionWithVariables) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) Display(org.eclipse.swt.widgets.Display)

Example 4 with DatabaseObjectTreeObject

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

the class ChangeToXMLElementStepAction method selectionChanged.

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 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) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) 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) ActionModel(com.twinsoft.convertigo.engine.studio.ActionModel) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 5 with DatabaseObjectTreeObject

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

the class CreateNgxUIComponentAction 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 NgxComponentTreeObject;
            }
        } 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) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) 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) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) 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)

Aggregations

DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)116 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)91 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)78 Shell (org.eclipse.swt.widgets.Shell)66 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)65 Cursor (org.eclipse.swt.graphics.Cursor)63 Display (org.eclipse.swt.widgets.Display)63 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)37 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)31 Sequence (com.twinsoft.convertigo.beans.core.Sequence)26 EngineException (com.twinsoft.convertigo.engine.EngineException)26 ObjectsFolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject)23 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)20 PropertyTableRowTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject)20 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)20 Step (com.twinsoft.convertigo.beans.core.Step)18 TreeObjectEvent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent)18 PropertyTableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)18 IPropertyTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)17 FolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject)16