Search in sources :

Example 71 with TreeObject

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

the class UnloadedProjectDeleteAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    MultipleDeletionDialog dialog;
    try {
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            TreeObject[] treeObjects = explorerView.getSelectedTreeObjects();
            if (treeObjects.length == 1) {
                dialog = new MultipleDeletionDialog(shell, "Project Deletion", false);
            } else {
                dialog = new MultipleDeletionDialog(shell, "Project Deletion", true);
            }
            dialog.setToggle("Delete project content on disk (cannot be undone)", false);
            if (treeObjects != null && treeObjects.length > 0) {
                for (TreeObject treeObject : treeObjects) {
                    if (treeObject instanceof UnloadedProjectTreeObject) {
                        String projectName = ((UnloadedProjectTreeObject) treeObject).getName();
                        if (dialog.shouldBeDeleted("Do you really want to delete the project \"" + projectName + "\" and all its sub-objects?")) {
                            // Deleted project will be backup, car will be deleted to avoid its deployment at engine restart
                            // Engine.theApp.databaseObjectsManager.deleteProject(projectName);
                            Job rmProject = new Job("Remove '" + projectName + "' project") {

                                @Override
                                protected IStatus run(IProgressMonitor monitor) {
                                    try {
                                        if (dialog.getToggleState()) {
                                            Engine.theApp.databaseObjectsManager.deleteProjectAndCar(projectName);
                                        }
                                        ConvertigoPlugin.getDefault().deleteProjectPluginResource(dialog.getToggleState(), projectName);
                                    } catch (Exception e) {
                                        ConvertigoPlugin.logException(e, "Unable to delete the '" + projectName + "' project.");
                                        return new MultiStatus(ConvertigoPlugin.PLUGIN_UNIQUE_ID, IStatus.ERROR, "Failed to remove the '" + projectName + "' project.", e);
                                    }
                                    return Status.OK_STATUS;
                                }
                            };
                            rmProject.schedule();
                            explorerView.removeProjectTreeObject(treeObject);
                            explorerView.fireTreeObjectRemoved(new TreeObjectEvent(treeObject));
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to delete the project!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) MultiStatus(org.eclipse.core.runtime.MultiStatus) MultipleDeletionDialog(com.twinsoft.convertigo.eclipse.dialogs.MultipleDeletionDialog) Cursor(org.eclipse.swt.graphics.Cursor) Shell(org.eclipse.swt.widgets.Shell) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) TreeObjectEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent) Job(org.eclipse.core.runtime.jobs.Job) Display(org.eclipse.swt.widgets.Display)

Example 72 with TreeObject

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

the class UpdateXSDTypesAction method selectionChanged.

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

Example 73 with TreeObject

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

the class VariableGenerateFromXmlAndLinkAction 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) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            Object databaseObject = treeObject.getObject();
            if ((databaseObject != null) && ((databaseObject instanceof StepVariable))) {
                StepVariable stepVariable = (StepVariable) databaseObject;
                RequestableStep requestableStep = (RequestableStep) stepVariable.getParent();
                if (requestableStep != null) {
                    DatabaseObjectTreeObject parentDboTreeObject = ((DatabaseObjectTreeObject) treeObject).getParentDatabaseObjectTreeObject().getParentDatabaseObjectTreeObject();
                    RequestableObject requestableObject = null;
                    if (requestableStep instanceof SequenceStep) {
                        requestableObject = ((SequenceStep) requestableStep).getTargetSequence();
                    } else if (requestableStep instanceof TransactionStep) {
                        requestableObject = ((TransactionStep) requestableStep).getTargetTransaction();
                    }
                    if ((requestableObject != null) && (requestableObject instanceof IVariableContainer)) {
                        String variableName = stepVariable.getName();
                        IVariableContainer container = (IVariableContainer) requestableObject;
                        RequestableVariable variable = (RequestableVariable) container.getVariable(variableName);
                        // generate dom model
                        Document document = null;
                        try {
                            String description = variable.getDescription();
                            document = XMLUtils.parseDOMFromString(description);
                        } catch (Exception e) {
                        }
                        if (document != null) {
                            Element root = document.getDocumentElement();
                            if (root != null) {
                                // create step's structure from dom
                                DatabaseObject parentObject = requestableStep.getParent();
                                Step step = StepUtils.createStepFromXmlDomModel(parentObject, root);
                                // add step's structure to parent of requestableStep
                                if (parentObject instanceof Sequence) {
                                    Sequence parentSequence = (Sequence) parentObject;
                                    parentSequence.addStep(step);
                                    parentSequence.insertAtOrder(step, requestableStep.priority);
                                } else {
                                    StepWithExpressions parentSwe = (StepWithExpressions) parentObject;
                                    parentSwe.addStep(step);
                                    parentSwe.insertAtOrder(step, requestableStep.priority);
                                }
                                // set source definition of variable
                                XMLVector<String> sourceDefinition = new XMLVector<String>();
                                sourceDefinition.add(String.valueOf(step.priority));
                                sourceDefinition.add(".");
                                stepVariable.setSourceDefinition(sourceDefinition);
                                stepVariable.hasChanged = true;
                                // Reload parent dbo in tree
                                explorerView.reloadTreeObject(parentDboTreeObject);
                                // Select variable dbo in tree
                                explorerView.objectSelected(new CompositeEvent(databaseObject));
                            }
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to generate and link variable!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) Element(org.w3c.dom.Element) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) Step(com.twinsoft.convertigo.beans.core.Step) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) Cursor(org.eclipse.swt.graphics.Cursor) Document(org.w3c.dom.Document) Shell(org.eclipse.swt.widgets.Shell) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) IVariableContainer(com.twinsoft.convertigo.beans.core.IVariableContainer) 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) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) Display(org.eclipse.swt.widgets.Display)

Example 74 with TreeObject

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

the class SetMobileRootPageAction method selectionChanged.

public void selectionChanged(IAction action, ISelection selection) {
    super.selectionChanged(action, selection);
    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
    TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
    if (treeObject instanceof MobilePageComponentTreeObject) {
        DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
        ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
        action.setChecked(actionModel.isChecked);
    }
}
Also used : MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ActionModel(com.twinsoft.convertigo.engine.studio.ActionModel)

Example 75 with TreeObject

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

the class ShowStepInPickerAction 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) {
            TreeObject treeObject = explorerView.getFirstSelectedTreeObject();
            if (treeObject != null) {
                if (treeObject instanceof DatabaseObjectTreeObject) {
                    DatabaseObject selectedDbo = ((DatabaseObjectTreeObject) treeObject).getObject();
                    if (selectedDbo != null) {
                        StepSourceEvent event = null;
                        if (showSource) {
                            if (selectedDbo instanceof Step) {
                                Step step = (Step) selectedDbo;
                                Set<StepSource> sources = step.getSources();
                                if (!sources.isEmpty()) {
                                    event = new StepSourceEvent(sources.iterator().next());
                                } else {
                                    throw new Exception("No Source defined");
                                }
                            }
                        } else {
                            event = new StepSourceEvent(selectedDbo);
                        }
                        if (event != null) {
                            SourcePickerView spv = ConvertigoPlugin.getDefault().getSourcePickerView();
                            if (spv == null) {
                                spv = (SourcePickerView) getActivePage().showView("com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView");
                            }
                            if (spv != null) {
                                spv.sourceSelected(event);
                            }
                        }
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to show object in Picker!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : SourcePickerView(com.twinsoft.convertigo.eclipse.views.sourcepicker.SourcePickerView) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) Step(com.twinsoft.convertigo.beans.core.Step) Cursor(org.eclipse.swt.graphics.Cursor) StepSourceEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.StepSourceEvent) StepSource(com.twinsoft.convertigo.beans.core.StepSource) Shell(org.eclipse.swt.widgets.Shell) 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) Display(org.eclipse.swt.widgets.Display)

Aggregations

TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)207 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)129 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)112 Shell (org.eclipse.swt.widgets.Shell)111 Cursor (org.eclipse.swt.graphics.Cursor)107 Display (org.eclipse.swt.widgets.Display)107 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)97 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)64 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)53 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)47 ObjectsFolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject)45 ConnectorTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject)36 TransactionTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject)36 EngineException (com.twinsoft.convertigo.engine.EngineException)36 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)35 IPropertyTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)33 Sequence (com.twinsoft.convertigo.beans.core.Sequence)32 PropertyTableRowTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject)32 SequenceTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject)32 PropertyTableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)31