Search in sources :

Example 16 with StepEvent

use of com.twinsoft.convertigo.beans.core.StepEvent in project convertigo by convertigo.

the class ClipboardManager method paste.

public void paste(String xmlData, Object parentObject, boolean bChangeName) throws EngineException, SAXException, IOException {
    Document document = XMLUtils.getDefaultDocumentBuilder().parse(new InputSource(new StringReader(xmlData)));
    Element rootElement = document.getDocumentElement();
    NodeList nodeList = rootElement.getChildNodes();
    int len = nodeList.getLength();
    Node node;
    pastedSteps.clear();
    pastedComponents.clear();
    pastedObjects = new Object[] {};
    if (len > 0) {
        pastedObjects = new Object[len];
    }
    Object object = null;
    for (int i = 0; i < len; i++) {
        node = (Node) nodeList.item(i);
        if (node.getNodeType() != Node.TEXT_NODE) {
            if (parentObject instanceof IPropertyTreeObject) {
                object = paste(node, (IPropertyTreeObject) parentObject, bChangeName);
            } else if (parentObject instanceof IDesignTreeObject) {
                object = paste(node, (IDesignTreeObject) parentObject, bChangeName);
            } else {
                object = paste(node, (DatabaseObject) parentObject, bChangeName);
            }
            pastedObjects[i] = object;
        }
    }
    for (Entry<String, Step> entry : pastedSteps.entrySet()) {
        Step step = entry.getValue();
        step.getSequence().fireStepCopied(new StepEvent(step, entry.getKey()));
    }
    for (Object ob : pastedObjects) {
        // MOBILE COMPONENTS
        if (ob instanceof com.twinsoft.convertigo.beans.mobile.components.MobileComponent) {
            if (ob instanceof com.twinsoft.convertigo.beans.mobile.components.PageComponent) {
                com.twinsoft.convertigo.beans.mobile.components.PageComponent page = GenericUtils.cast(ob);
                for (Entry<String, MobileObject> entry : pastedComponents.entrySet()) {
                    if (page.updateSmartSources(entry.getKey(), String.valueOf(entry.getValue().priority))) {
                        page.markPageAsDirty();
                    }
                }
            } else if (ob instanceof com.twinsoft.convertigo.beans.mobile.components.UIComponent) {
                com.twinsoft.convertigo.beans.mobile.components.UIComponent uic = GenericUtils.cast(ob);
                for (Entry<String, MobileObject> entry : pastedComponents.entrySet()) {
                    if (uic.updateSmartSources(entry.getKey(), String.valueOf(entry.getValue().priority))) {
                        uic.markAsDirty();
                    }
                }
            }
        }
        // NGX COMPONENTS
        if (ob instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
            if (ob instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent) {
                com.twinsoft.convertigo.beans.ngx.components.PageComponent page = GenericUtils.cast(ob);
                for (Entry<String, MobileObject> entry : pastedComponents.entrySet()) {
                    if (page.updateSmartSources(entry.getKey(), String.valueOf(entry.getValue().priority))) {
                        page.markPageAsDirty();
                    }
                }
            } else if (ob instanceof com.twinsoft.convertigo.beans.ngx.components.UIComponent) {
                com.twinsoft.convertigo.beans.ngx.components.UIComponent uic = GenericUtils.cast(ob);
                for (Entry<String, MobileObject> entry : pastedComponents.entrySet()) {
                    if (uic.updateSmartSources(entry.getKey(), String.valueOf(entry.getValue().priority))) {
                        uic.markAsDirty();
                    }
                }
            }
        }
    }
}
Also used : InputSource(org.xml.sax.InputSource) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) Step(com.twinsoft.convertigo.beans.core.Step) ElseStep(com.twinsoft.convertigo.beans.steps.ElseStep) RequestableStep(com.twinsoft.convertigo.beans.core.RequestableStep) ThenStep(com.twinsoft.convertigo.beans.steps.ThenStep) Document(org.w3c.dom.Document) Entry(java.util.Map.Entry) StringReader(java.io.StringReader) StepEvent(com.twinsoft.convertigo.beans.core.StepEvent) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject) NodeList(org.w3c.dom.NodeList) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)

Aggregations

DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)16 StepEvent (com.twinsoft.convertigo.beans.core.StepEvent)16 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)16 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)16 Sequence (com.twinsoft.convertigo.beans.core.Sequence)15 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)15 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)15 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)15 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)15 Cursor (org.eclipse.swt.graphics.Cursor)15 Display (org.eclipse.swt.widgets.Display)15 Shell (org.eclipse.swt.widgets.Shell)15 Step (com.twinsoft.convertigo.beans.core.Step)11 ThenStep (com.twinsoft.convertigo.beans.steps.ThenStep)9 TreePath (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreePath)8 ElseStep (com.twinsoft.convertigo.beans.steps.ElseStep)5 EngineException (com.twinsoft.convertigo.engine.EngineException)5 XMLElementStep (com.twinsoft.convertigo.beans.steps.XMLElementStep)4 AttributeStep (com.twinsoft.convertigo.beans.steps.AttributeStep)3 ElementStep (com.twinsoft.convertigo.beans.steps.ElementStep)3