Search in sources :

Example 6 with IPropertyTreeObject

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

the class CreatePropertyTableColumnAction 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) {
            PropertyTableRowTreeObject propertyTableRowTreeObject = (PropertyTableRowTreeObject) explorerView.getFirstSelectedTreeObject();
            TreeParent owner = propertyTableRowTreeObject.getTreeObjectOwner();
            IPropertyTreeObject pto = propertyTableRowTreeObject.addNewColumn();
            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 column!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) 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) Display(org.eclipse.swt.widgets.Display) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)

Example 7 with IPropertyTreeObject

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

the class ClipboardManager method cutAndPaste.

public void cutAndPaste(Object object, TreeObject targetTreeObject) throws ConvertigoException {
    // Ignore cut paste on itself
    if (object.equals(targetTreeObject)) {
        return;
    }
    // Check for cut paste into itself
    if (object instanceof TreeObject) {
        if (targetTreeObject.isChildOf((TreeObject) object)) {
            throw new InvalidOperationException("You cannot cut and paste this object into itself");
        }
    }
    if (object instanceof DatabaseObjectTreeObject) {
        if (targetTreeObject instanceof DatabaseObjectTreeObject) {
            DatabaseObjectTreeObject sourceTreeObject = (DatabaseObjectTreeObject) object;
            DatabaseObject databaseObject = (DatabaseObject) sourceTreeObject.getObject();
            DatabaseObject targetObject = (DatabaseObject) targetTreeObject.getObject();
            String oldQName = databaseObject.getQName();
            cutAndPaste(databaseObject, targetObject);
            String newQName = databaseObject.getQName();
            ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
            if (projectExplorerView != null) {
                TreeObjectEvent treeObjectEvent = new TreeObjectEvent(sourceTreeObject, "qname", oldQName, newQName, TreeObjectEvent.UPDATE_ALL);
                projectExplorerView.fireTreeObjectPropertyChanged(treeObjectEvent);
            }
        }
    } else if (object instanceof IPropertyTreeObject) {
        if (targetTreeObject instanceof IPropertyTreeObject) {
            IPropertyTreeObject tpo = (IPropertyTreeObject) object;
            IPropertyTreeObject ttpo = (IPropertyTreeObject) targetTreeObject;
            if (tpo.getParent().equals(ttpo.getParent())) {
                return;
            }
            if (tpo.getParent().equals(ttpo)) {
                return;
            }
            tpo.remove(object);
            ttpo.add(object, false);
        }
    } else if (object instanceof IDesignTreeObject) {
        if (targetTreeObject instanceof IDesignTreeObject) {
            IDesignTreeObject tpo = (IDesignTreeObject) object;
            IDesignTreeObject ttpo = (IDesignTreeObject) targetTreeObject;
            if (tpo.getParent().equals(ttpo.getParent())) {
                return;
            }
            if (tpo.getParent().equals(ttpo)) {
                return;
            }
            if (ttpo.canPaste(object)) {
                tpo.remove(object);
                ttpo.add(object, false);
            }
        }
    }
}
Also used : DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) InvalidOperationException(com.twinsoft.convertigo.engine.InvalidOperationException) 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) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)

Example 8 with IPropertyTreeObject

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

Example 9 with IPropertyTreeObject

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

the class ClipboardManager method paste.

public Object paste(Node node, IPropertyTreeObject parentPropertyTreeObject, boolean bChangeName) throws EngineException {
    Object object = read(node);
    if (object instanceof PropertyData) {
        PropertyData propertyData = (PropertyData) object;
        IPropertyTreeObject propertyTreeObject = parentPropertyTreeObject.add(propertyData, bChangeName);
        if (propertyTreeObject != null) {
            NodeList childNodes = node.getChildNodes();
            int len = childNodes.getLength();
            Node childNode;
            String childNodeName;
            for (int i = 0; i < len; i++) {
                childNode = childNodes.item(i);
                if (childNode.getNodeType() != Node.ELEMENT_NODE) {
                    continue;
                }
                childNodeName = childNode.getNodeName();
                if (!(childNodeName.equalsIgnoreCase("property"))) {
                    paste(childNode, propertyTreeObject, bChangeName);
                }
            }
            return propertyTreeObject;
        }
    }
    return null;
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) 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)

Example 10 with IPropertyTreeObject

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

the class TreeDropAdapter method dragOver.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ViewerDropAdapter#dragOver(org.eclipse.swt.dnd.DropTargetEvent)
	 */
@Override
public void dragOver(DropTargetEvent event) {
    super.dragOver(event);
    // Overrides feedback: by default is DND.FEEDBACK_SELECT
    feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND;
    boolean shouldFeedBack = true;
    if (PaletteSourceTransfer.getInstance().isSupportedType(event.currentDataType)) {
        int currentLocation = getCurrentLocation();
        switch(currentLocation) {
            case LOCATION_BEFORE:
                feedback = DND.FEEDBACK_INSERT_BEFORE;
                break;
            case LOCATION_AFTER:
                feedback = DND.FEEDBACK_INSERT_AFTER;
                break;
            case LOCATION_ON:
            default:
                break;
        }
        shouldFeedBack = false;
    }
    // Handles feedback for objects that can be ordered
    if (shouldFeedBack && getCurrentOperation() == DND.DROP_MOVE) {
        Object targetObject = getCurrentTarget();
        Object sourceObject = getSelectedObject();
        if ((sourceObject != null) && (targetObject != null)) {
            // Source and target objects must be different
            if (!sourceObject.equals(targetObject)) {
                if ((sourceObject instanceof TreeObject) && (targetObject instanceof TreeObject)) {
                    // Source and target objects can be ordered
                    if ((sourceObject instanceof IOrderableTreeObject) && (targetObject instanceof IOrderableTreeObject)) {
                        // Source and target objects must have the same parent
                        boolean srcInherited = false;
                        if (sourceObject instanceof DatabaseObjectTreeObject)
                            srcInherited = ((DatabaseObjectTreeObject) sourceObject).isInherited;
                        else if (sourceObject instanceof IPropertyTreeObject)
                            srcInherited = ((IPropertyTreeObject) sourceObject).isInherited();
                        // Source object musn't be inherited
                        if (!srcInherited) {
                            int currentLocation = getCurrentLocation();
                            switch(currentLocation) {
                                case LOCATION_BEFORE:
                                    feedback = DND.FEEDBACK_INSERT_BEFORE;
                                    break;
                                case LOCATION_AFTER:
                                    feedback = DND.FEEDBACK_INSERT_AFTER;
                                    break;
                                case LOCATION_ON:
                                default:
                                    break;
                            }
                        }
                    }
                }
            }
        }
    }
    // Set feedback
    event.feedback = feedback;
}
Also used : IOrderableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IOrderableTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) 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) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)

Aggregations

DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)10 IPropertyTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)10 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)8 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)8 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)6 FolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject)6 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)5 IDesignTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject)5 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)4 ProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject)4 PropertyTableRowTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject)4 PropertyTableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)4 EngineException (com.twinsoft.convertigo.engine.EngineException)4 Shell (org.eclipse.swt.widgets.Shell)4 Node (org.w3c.dom.Node)4 NodeList (org.w3c.dom.NodeList)4 MobileObject (com.twinsoft.convertigo.beans.core.MobileObject)3 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)3 IOrderableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IOrderableTreeObject)3 MobileComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject)3