Search in sources :

Example 81 with ProjectExplorerView

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

the class ChangeToIfXpathExistsThenElseStatementAction method run.

/* (non-Javadoc)
	 * @see com.twinsoft.convertigo.eclipse.popup.actions.MyAbstractAction#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) {
            DatabaseObjectTreeObject treeObject = (DatabaseObjectTreeObject) explorerView.getFirstSelectedTreeObject();
            DatabaseObject databaseObject = treeObject.getObject();
            // IfXpathExists
            if ((databaseObject != null) && (databaseObject instanceof IfXpathExistsStatement)) {
                IfXpathExistsStatement ifStatement = (IfXpathExistsStatement) databaseObject;
                DatabaseObjectTreeObject parentTreeObject = treeObject.getOwnerDatabaseObjectTreeObject();
                if (parentTreeObject != null) {
                    // New IfXpathExistsThenElseStatement statement
                    IfXpathExistsThenElseStatement ifThenElseStatement = new IfXpathExistsThenElseStatement();
                    ifThenElseStatement.bNew = true;
                    ifThenElseStatement.hasChanged = true;
                    // Add new IfThenElseStatement statement to parent
                    StatementWithExpressions parentDbo = (StatementWithExpressions) ifStatement.getParent();
                    parentDbo.addStatementAfter(ifThenElseStatement, ifStatement);
                    // Add Then/Else statement
                    ThenStatement thenStatement = new ThenStatement();
                    thenStatement.bNew = true;
                    ifThenElseStatement.addStatement(thenStatement);
                    ElseStatement elseStatement = new ElseStatement();
                    elseStatement.bNew = true;
                    ifThenElseStatement.addStatement(elseStatement);
                    for (Statement statement : ifStatement.getStatements()) {
                        thenStatement.addStatement(statement);
                    }
                    String name = ifStatement.getName();
                    // Set properties
                    ifThenElseStatement.setCondition(ifStatement.getCondition());
                    ifThenElseStatement.setComment(ifStatement.getComment());
                    ifThenElseStatement.setEnabled(ifStatement.isEnabled());
                    ifThenElseStatement.setVersion(ifStatement.getVersion());
                    // Delete If statement
                    ifStatement.delete();
                    ifThenElseStatement.setName(name);
                    parentTreeObject.hasBeenModified(true);
                    explorerView.reloadTreeObject(parentTreeObject);
                    explorerView.setSelectedTreeObject(parentTreeObject.findTreeObjectByUserObject(ifThenElseStatement));
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change statement to IfThenElse statement!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) IfXpathExistsThenElseStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsThenElseStatement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) Statement(com.twinsoft.convertigo.beans.core.Statement) IfXpathExistsStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsStatement) IfXpathExistsThenElseStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsThenElseStatement) ThenStatement(com.twinsoft.convertigo.beans.statements.ThenStatement) Cursor(org.eclipse.swt.graphics.Cursor) Shell(org.eclipse.swt.widgets.Shell) StatementWithExpressions(com.twinsoft.convertigo.beans.core.StatementWithExpressions) ElseStatement(com.twinsoft.convertigo.beans.statements.ElseStatement) IfXpathExistsThenElseStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsThenElseStatement) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IfXpathExistsStatement(com.twinsoft.convertigo.beans.statements.IfXpathExistsStatement) Display(org.eclipse.swt.widgets.Display)

Example 82 with ProjectExplorerView

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

the class ChangeToElementStepAction method run.

/* (non-Javadoc)
	 * @see com.twinsoft.convertigo.eclipse.popup.actions.MyAbstractAction#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();
            Object databaseObject = treeObject.getObject();
            // Attribute
            if ((databaseObject != null) && (databaseObject instanceof AttributeStep)) {
                AttributeStep attributeStep = (AttributeStep) databaseObject;
                TreeParent treeParent = treeObject.getParent();
                DatabaseObjectTreeObject parentTreeObject = null;
                if (treeParent instanceof DatabaseObjectTreeObject)
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent;
                else
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
                if (parentTreeObject != null) {
                    // New Element step
                    ElementStep jelementStep = new ElementStep();
                    if (DatabaseObjectsManager.acceptDatabaseObjects(attributeStep.getParent(), jelementStep)) {
                        // Set properties
                        jelementStep.setOutput(attributeStep.isOutput());
                        jelementStep.setEnabled(attributeStep.isEnabled());
                        jelementStep.setComment(attributeStep.getComment());
                        jelementStep.setExpression(attributeStep.getExpression());
                        jelementStep.setNodeText(attributeStep.getNodeText());
                        jelementStep.setNodeName(attributeStep.getNodeName());
                        jelementStep.bNew = true;
                        jelementStep.hasChanged = true;
                        // Add new Element step to parent
                        DatabaseObject parentDbo = attributeStep.getParent();
                        parentDbo.add(jelementStep);
                        // Set correct order
                        if (parentDbo instanceof StepWithExpressions)
                            ((StepWithExpressions) parentDbo).insertAtOrder(jelementStep, attributeStep.priority);
                        else if (parentDbo instanceof Sequence)
                            ((Sequence) parentDbo).insertAtOrder(jelementStep, attributeStep.priority);
                        // Add new Element step in Tree
                        StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, attributeStep);
                        treeParent.addChild(stepTreeObject);
                        // Delete Attribute step
                        long oldPriority = attributeStep.priority;
                        attributeStep.delete();
                        jelementStep.getSequence().fireStepMoved(new StepEvent(jelementStep, String.valueOf(oldPriority)));
                        parentTreeObject.hasBeenModified(true);
                        explorerView.reloadTreeObject(parentTreeObject);
                        explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(jelementStep));
                    } else {
                        throw new EngineException("You cannot paste to a " + attributeStep.getParent().getClass().getSimpleName() + " a database object of type " + jelementStep.getClass().getSimpleName());
                    }
                }
            }
            // XML Element
            if ((databaseObject != null) && (databaseObject instanceof XMLElementStep)) {
                XMLElementStep elementStep = (XMLElementStep) databaseObject;
                TreeParent treeParent = treeObject.getParent();
                DatabaseObjectTreeObject parentTreeObject = null;
                if (treeParent instanceof DatabaseObjectTreeObject)
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent;
                else
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
                if (parentTreeObject != null) {
                    // New Element step
                    ElementStep jelementStep = new ElementStep();
                    if (DatabaseObjectsManager.acceptDatabaseObjects(elementStep.getParent(), jelementStep)) {
                        // Set properties
                        jelementStep.setOutput(elementStep.isOutput());
                        jelementStep.setEnabled(elementStep.isEnabled());
                        jelementStep.setComment(elementStep.getComment());
                        // jelementStep.setSourceDefinition(elementStep.getSourceDefinition());
                        jelementStep.setNodeText(elementStep.getNodeText());
                        jelementStep.setNodeName(elementStep.getNodeName());
                        jelementStep.bNew = true;
                        jelementStep.hasChanged = true;
                        // Add new XMLElement step to parent
                        DatabaseObject parentDbo = elementStep.getParent();
                        parentDbo.add(jelementStep);
                        for (Step step : elementStep.getAllSteps()) {
                            try {
                                jelementStep.addStep(step);
                            } catch (Throwable t) {
                            }
                        }
                        // Set correct order
                        if (parentDbo instanceof StepWithExpressions)
                            ((StepWithExpressions) parentDbo).insertAtOrder(jelementStep, elementStep.priority);
                        else if (parentDbo instanceof Sequence)
                            ((Sequence) parentDbo).insertAtOrder(jelementStep, elementStep.priority);
                        // Add new Element step in Tree
                        StepTreeObject stepTreeObject = new StepTreeObject(explorerView.viewer, elementStep);
                        treeParent.addChild(stepTreeObject);
                        // Delete XMLAttribute step
                        long oldPriority = elementStep.priority;
                        elementStep.delete();
                        jelementStep.getSequence().fireStepMoved(new StepEvent(jelementStep, String.valueOf(oldPriority)));
                        parentTreeObject.hasBeenModified(true);
                        explorerView.reloadTreeObject(parentTreeObject);
                        explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(jelementStep));
                    } else {
                        throw new EngineException("You cannot paste to a " + elementStep.getParent().getClass().getSimpleName() + " a database object of type " + jelementStep.getClass().getSimpleName());
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change step to Element step!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : StepEvent(com.twinsoft.convertigo.beans.core.StepEvent) 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) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) XMLElementStep(com.twinsoft.convertigo.beans.steps.XMLElementStep) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) EngineException(com.twinsoft.convertigo.engine.EngineException) Sequence(com.twinsoft.convertigo.beans.core.Sequence) Step(com.twinsoft.convertigo.beans.core.Step) ElementStep(com.twinsoft.convertigo.beans.steps.ElementStep) XMLElementStep(com.twinsoft.convertigo.beans.steps.XMLElementStep) AttributeStep(com.twinsoft.convertigo.beans.steps.AttributeStep) Cursor(org.eclipse.swt.graphics.Cursor) Shell(org.eclipse.swt.widgets.Shell) AttributeStep(com.twinsoft.convertigo.beans.steps.AttributeStep) 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) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) 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) ElementStep(com.twinsoft.convertigo.beans.steps.ElementStep) XMLElementStep(com.twinsoft.convertigo.beans.steps.XMLElementStep) Display(org.eclipse.swt.widgets.Display)

Example 83 with ProjectExplorerView

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

the class ChangeToFormParameterAction 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();
            Object databaseObject = treeObject.getObject();
            if ((databaseObject != null) && (databaseObject instanceof UrlMappingParameter)) {
                UrlMappingParameter parameter = (UrlMappingParameter) databaseObject;
                TreeParent treeParent = treeObject.getParent();
                DatabaseObjectTreeObject parentTreeObject = null;
                if (treeParent instanceof DatabaseObjectTreeObject)
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent;
                else
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
                if (parentTreeObject != null) {
                    // Create new Form parameter
                    FormParameter formParameter = new FormParameter();
                    if (DatabaseObjectsManager.acceptDatabaseObjects(parameter.getParent(), formParameter)) {
                        formParameter.setComment(parameter.getComment());
                        formParameter.setInputType(parameter.getInputType());
                        formParameter.setArray(parameter.isArray());
                        formParameter.setExposed(parameter.isExposed());
                        formParameter.setMultiValued(parameter.isMultiValued());
                        formParameter.setRequired(parameter.isRequired());
                        formParameter.setValueOrNull(parameter.getValueOrNull());
                        formParameter.setMappedVariableName(parameter.getMappedVariableName());
                        formParameter.bNew = true;
                        formParameter.hasChanged = true;
                        // Add new parameter to parent operation
                        UrlMappingOperation operation = (UrlMappingOperation) parameter.getParent();
                        operation.changeTo(formParameter);
                        // Add new parameter in Tree
                        UrlMappingParameterTreeObject parameterTreeObject = new UrlMappingParameterTreeObject(explorerView.viewer, formParameter);
                        treeParent.addChild(parameterTreeObject);
                        // Delete old parameter
                        parameter.delete();
                        // Rename new parameter
                        formParameter.setName(parameter.getName());
                        // Reload in tree
                        parentTreeObject.hasBeenModified(true);
                        explorerView.reloadTreeObject(parentTreeObject);
                        explorerView.setSelectedTreeObject(explorerView.findTreeObjectByUserObject(formParameter));
                    } else {
                        throw new EngineException("You cannot paste to a " + parameter.getParent().getClass().getSimpleName() + " a database object of type " + formParameter.getClass().getSimpleName());
                    }
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to change parameter to Form parameter!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) UrlMappingOperation(com.twinsoft.convertigo.beans.core.UrlMappingOperation) UrlMappingParameter(com.twinsoft.convertigo.beans.core.UrlMappingParameter) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) EngineException(com.twinsoft.convertigo.engine.EngineException) Cursor(org.eclipse.swt.graphics.Cursor) FormParameter(com.twinsoft.convertigo.beans.rest.FormParameter) Shell(org.eclipse.swt.widgets.Shell) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) UrlMappingParameterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingParameterTreeObject) 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) UrlMappingParameterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingParameterTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) UrlMappingParameterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingParameterTreeObject) Display(org.eclipse.swt.widgets.Display)

Example 84 with ProjectExplorerView

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

the class TreeDropAdapter method performDrop.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ViewerDropAdapter#performDrop(java.lang.Object)
	 */
@Override
public boolean performDrop(Object data) {
    MobileBuilder mb = null;
    Engine.logStudio.info("---------------------- Drop started ----------------------");
    try {
        Object targetObject = getCurrentTarget();
        IEditorPart editorPart = ConvertigoPlugin.getDefault().getApplicationComponentEditor();
        if (editorPart != null) {
            IEditorInput input = editorPart.getEditorInput();
            if (input instanceof com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput) {
                com.twinsoft.convertigo.eclipse.editors.mobile.ApplicationComponentEditorInput editorInput = GenericUtils.cast(input);
                mb = editorInput.getApplication().getProject().getMobileBuilder();
            }
            if (input instanceof com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput) {
                com.twinsoft.convertigo.eclipse.editors.ngx.ApplicationComponentEditorInput editorInput = GenericUtils.cast(input);
                mb = editorInput.getApplication().getProject().getMobileBuilder();
            }
        }
        // Handle objects copy or move with Drag and drop
        if (targetObject instanceof TreeObject) {
            TreeObject targetTreeObject = (TreeObject) targetObject;
            if (targetTreeObject != null) {
                ProjectExplorerView explorerView = targetTreeObject.getProjectExplorerView();
                Document document = null;
                try {
                    Shell shell = Display.getDefault().getActiveShell();
                    try {
                        // Try to parse text data into an XML document
                        String source = data.toString();
                        document = XMLUtils.getDefaultDocumentBuilder().parse(new InputSource(new StringReader(source)));
                        if (mb != null) {
                            mb.prepareBatchBuild();
                        }
                        BatchOperationHelper.start();
                        boolean insertBefore = (feedback & DND.FEEDBACK_INSERT_BEFORE) != 0;
                        boolean insertAfter = (feedback & DND.FEEDBACK_INSERT_AFTER) != 0;
                        TreeObject sourceObject = (TreeObject) getSelectedObject();
                        if (insertBefore || insertAfter) {
                            TreeParent targetTreeParent = ((TreeObject) targetObject).getParent();
                            if (sourceObject.getParent() != targetTreeParent) {
                                ProjectTreeObject prjTree = targetTreeParent.getProjectTreeObject();
                                String path = targetTreeParent.getPath();
                                ClipboardAction.dnd.paste(source, shell, explorerView, targetTreeParent, true);
                                targetTreeParent = (TreeParent) explorerView.findTreeObjectByPath(prjTree, path);
                            }
                            explorerView.moveChildTo(targetTreeParent, sourceObject, targetTreeObject, insertBefore);
                        } else {
                            ClipboardAction.dnd.paste(source, shell, explorerView, targetTreeObject, true);
                        }
                        BatchOperationHelper.stop();
                        return true;
                    } catch (SAXException sax) {
                        BatchOperationHelper.cancel();
                        if (mb != null) {
                            mb.prepareBatchBuild();
                        }
                        BatchOperationHelper.start();
                        // Parse failed probably because data was not XML but an XPATH String
                        // in this case, create DatabaseObjects of the correct Type according to the folder where the XPATH is dropped on
                        performDrop(data, explorerView, targetTreeObject);
                        BatchOperationHelper.stop();
                        return true;
                    }
                } catch (Exception e) {
                    BatchOperationHelper.cancel();
                    if (e instanceof ObjectWithSameNameException) {
                        document = null;
                    }
                    if (e instanceof InvalidOperationException) {
                        document = null;
                    }
                    // Case of unauthorized databaseObject paste
                    if (document != null) {
                        try {
                            if (!(targetTreeObject instanceof IPropertyTreeObject)) {
                                Element rootElement = document.getDocumentElement();
                                NodeList nodeList = rootElement.getChildNodes();
                                boolean unauthorized = false;
                                int len = nodeList.getLength();
                                Node node;
                                // case of folder, retrieve owner object
                                targetTreeObject = explorerView.getFirstSelectedDatabaseObjectTreeObject(targetTreeObject);
                                if (detail == DND.DROP_COPY) {
                                    for (int i = 0; i < len; i++) {
                                        node = (Node) nodeList.item(i);
                                        if (node.getNodeType() != Node.TEXT_NODE) {
                                            // Special objects paste
                                            if (!paste(node, targetTreeObject)) {
                                                // Real unauthorized databaseObject paste
                                                unauthorized = true;
                                            }
                                        }
                                    }
                                    reloadTreeObject(explorerView, targetTreeObject);
                                } else if (detail == DND.DROP_MOVE) {
                                    for (int i = 0; i < len; i++) {
                                        node = (Node) nodeList.item(i);
                                        if (node.getNodeType() != Node.TEXT_NODE) {
                                            // Special objects move
                                            if (!move(node, targetTreeObject)) {
                                                // Real unauthorized databaseObject move
                                                unauthorized = true;
                                            }
                                        }
                                    }
                                    reloadTreeObject(explorerView, targetTreeObject);
                                } else {
                                    // Real unauthorized databaseObject
                                    unauthorized = true;
                                }
                                if (unauthorized) {
                                    throw e;
                                }
                                return true;
                            }
                        } catch (Exception ex) {
                            ConvertigoPlugin.errorMessageBox(ex.getMessage());
                            return false;
                        }
                    } else {
                        ConvertigoPlugin.errorMessageBox(e.getMessage());
                        return false;
                    }
                }
            }
        }
        return false;
    } finally {
        Engine.logStudio.info("---------------------- Drop ended   ----------------------");
        BatchOperationHelper.cancel();
    }
}
Also used : InputSource(org.xml.sax.InputSource) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException) Shell(org.eclipse.swt.widgets.Shell) StringReader(java.io.StringReader) InvalidOperationException(com.twinsoft.convertigo.engine.InvalidOperationException) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) NodeList(org.w3c.dom.NodeList) IEditorPart(org.eclipse.ui.IEditorPart) 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) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) MobileBuilder(com.twinsoft.convertigo.engine.mobile.MobileBuilder) 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) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) 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) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) 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) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) IEditorInput(org.eclipse.ui.IEditorInput) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)

Example 85 with ProjectExplorerView

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

the class JavelinConnectorComposite method add.

/**
 * Adds an element to the selected property with the selected zone from the
 * connector
 */
public void add() {
    try {
        if (connector != null) {
            // gets the projectExplorerView
            ProjectExplorerView pev = ConvertigoPlugin.getDefault().getProjectExplorerView();
            if (pev != null) {
                // gets the databaseObject of the selected element in
                // project tree
                DatabaseObject databaseObject = (DatabaseObject) pev.getFirstSelectedDatabaseObject();
                // gets the BeanInfo
                BeanInfo bi = pev.getFirstSelectedDatabaseObjectBeanInfo();
                // gets the propertyDescriptor of the selected property in
                // the Properties panel
                PropertyDescriptor propertyDescriptor = ConvertigoPlugin.getDefault().getSelectedPropertyDescriptor(bi);
                if (propertyDescriptor != null) {
                    // test if the selected property is addable with a
                    // screen selection zone (we can add an element to the
                    // property from the selected zone)
                    Class<?> editorClass = propertyDescriptor.getPropertyEditorClass();
                    if (editorClass != null) {
                        Method propertySelectionAddMethod = editorClass.getMethod("addPropertyElementFromSelectionZone", new Class[] { DatabaseObject.class, Connector.class, Method.class });
                        if (propertySelectionAddMethod != null) {
                            propertySelectionAddMethod.invoke(null, new Object[] { databaseObject, connector, propertyDescriptor.getWriteMethod() });
                        } else {
                        // the selected property is not addable with a
                        // screen selection zone
                        }
                        databaseObject.hasChanged = true;
                        pev.updateDatabaseObject(databaseObject);
                        StructuredSelection structuredSelection = new StructuredSelection(((DatabaseObjectTreeObject) pev.getFirstSelectedTreeObject()));
                        PropertySheet pv = ConvertigoPlugin.getDefault().getPropertiesView();
                        boolean isPinned = pv.isPinned();
                        if (!isPinned) {
                            pv.setPinned(true);
                        }
                        pv.selectionChanged((IWorkbenchPart) pev, structuredSelection);
                        if (!isPinned) {
                            pv.setPinned(false);
                        }
                    }
                } else {
                // no PropertyDescriptor corresponding to the selected
                // property
                }
            } else {
            // pev null
            }
        } else {
        // connector null
        }
    } catch (NoSuchMethodException e) {
        // the selected property is not addable with a screen selection zone
        ConvertigoPlugin.logInfo("Not possible to add an element from a selection zone to the selected Property.");
    } catch (Throwable e) {
        String message = "Error : " + e.getMessage();
        ConvertigoPlugin.logException(e, message);
    }
}
Also used : ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) PropertyDescriptor(java.beans.PropertyDescriptor) PropertySheet(org.eclipse.ui.views.properties.PropertySheet) BeanInfo(java.beans.BeanInfo) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Method(java.lang.reflect.Method) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject)

Aggregations

ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)175 Cursor (org.eclipse.swt.graphics.Cursor)144 Display (org.eclipse.swt.widgets.Display)144 Shell (org.eclipse.swt.widgets.Shell)144 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)113 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)73 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)49 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)38 Sequence (com.twinsoft.convertigo.beans.core.Sequence)35 EngineException (com.twinsoft.convertigo.engine.EngineException)26 Project (com.twinsoft.convertigo.beans.core.Project)24 Step (com.twinsoft.convertigo.beans.core.Step)22 TreeObjectEvent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent)22 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)22 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)21 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)19 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)19 StepEvent (com.twinsoft.convertigo.beans.core.StepEvent)15 Transaction (com.twinsoft.convertigo.beans.core.Transaction)14 File (java.io.File)14