Search in sources :

Example 6 with FolderTreeObject

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

the class CreateDesignDocumentFilterAction method run.

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) {
            DesignDocumentTreeObject ddto = (DesignDocumentTreeObject) explorerView.getFirstSelectedTreeObject();
            DesignDocumentFilterTreeObject ddfto = ddto.addNewFilter();
            if (ddto.hasChanged()) {
                TreeParent treeParent = ddto.getParent();
                if (treeParent instanceof FolderTreeObject)
                    treeParent = treeParent.getParent();
                explorerView.objectChanged(new CompositeEvent(treeParent.getObject(), ddfto.getPath()));
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to create a new filter!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) Cursor(org.eclipse.swt.graphics.Cursor) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) Display(org.eclipse.swt.widgets.Display) DesignDocumentFilterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFilterTreeObject)

Example 7 with FolderTreeObject

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

the class CreateDesignDocumentUpdateAction method run.

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) {
            DesignDocumentTreeObject ddto = (DesignDocumentTreeObject) explorerView.getFirstSelectedTreeObject();
            DesignDocumentUpdateTreeObject dduto = ddto.addNewUpdate();
            if (ddto.hasChanged()) {
                TreeParent treeParent = ddto.getParent();
                if (treeParent instanceof FolderTreeObject)
                    treeParent = treeParent.getParent();
                explorerView.objectChanged(new CompositeEvent(treeParent.getObject(), dduto.getPath()));
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to create a new update!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) Cursor(org.eclipse.swt.graphics.Cursor) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) Display(org.eclipse.swt.widgets.Display) DesignDocumentUpdateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentUpdateTreeObject)

Example 8 with FolderTreeObject

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

the class CreateDesignDocumentValidateAction method run.

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) {
            DesignDocumentTreeObject ddto = (DesignDocumentTreeObject) explorerView.getFirstSelectedTreeObject();
            DesignDocumentValidateTreeObject ddvto = ddto.addNewValidate();
            if (ddto.hasChanged()) {
                TreeParent treeParent = ddto.getParent();
                if (treeParent instanceof FolderTreeObject)
                    treeParent = treeParent.getParent();
                explorerView.objectChanged(new CompositeEvent(treeParent.getObject(), ddvto.getPath()));
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to create a new Validate!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) Cursor(org.eclipse.swt.graphics.Cursor) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) DesignDocumentValidateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentValidateTreeObject) Display(org.eclipse.swt.widgets.Display)

Example 9 with FolderTreeObject

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

the class CreatePropertyTableRowAction method run.

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) {
            PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) explorerView.getFirstSelectedTreeObject();
            TreeParent owner = propertyTableTreeObject.getTreeObjectOwner();
            IPropertyTreeObject pto = propertyTableTreeObject.addNewRow();
            if (owner instanceof DatabaseObjectTreeObject) {
                DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) owner;
                if (databaseObjectTreeObject.hasChanged()) {
                    TreeParent treeParent = databaseObjectTreeObject.getParent();
                    if (treeParent instanceof FolderTreeObject)
                        treeParent = treeParent.getParent();
                    // explorerView.reloadTreeObject(treeParent);
                    explorerView.objectChanged(new CompositeEvent(treeParent.getObject(), pto.getPath()));
                }
            } else
                explorerView.refreshTreeObject(owner, true);
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to create a new row!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) Cursor(org.eclipse.swt.graphics.Cursor) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) Display(org.eclipse.swt.widgets.Display) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)

Example 10 with FolderTreeObject

use of com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject 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)

Aggregations

FolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject)20 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)15 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)14 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)12 Shell (org.eclipse.swt.widgets.Shell)12 Cursor (org.eclipse.swt.graphics.Cursor)11 Display (org.eclipse.swt.widgets.Display)11 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)9 PropertyTableRowTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject)9 PropertyTableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)8 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)7 DesignDocumentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject)6 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)5 IPropertyTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)5 PropertyTableColumnTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject)5 IOException (java.io.IOException)5 DesignDocumentViewTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject)4 EngineException (com.twinsoft.convertigo.engine.EngineException)4 HashSet (java.util.HashSet)4 MessageBox (org.eclipse.swt.widgets.MessageBox)4