Search in sources :

Example 6 with IDesignTreeObject

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

DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)6 IDesignTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject)6 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)6 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)5 IPropertyTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)5 EngineException (com.twinsoft.convertigo.engine.EngineException)3 MobileObject (com.twinsoft.convertigo.beans.core.MobileObject)2 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)2 ButtonSpec (com.twinsoft.convertigo.eclipse.dialogs.ButtonSpec)2 CustomDialog (com.twinsoft.convertigo.eclipse.dialogs.CustomDialog)2 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)2 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)2 DesignDocumentFilterTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFilterTreeObject)2 DesignDocumentFunctionTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject)2 DesignDocumentUpdateTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentUpdateTreeObject)2 DesignDocumentValidateTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentValidateTreeObject)2 FolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject)2 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)2 Shell (org.eclipse.swt.widgets.Shell)2 Project (com.twinsoft.convertigo.beans.core.Project)1