Search in sources :

Example 1 with PropertyTableRowTreeObject

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

the class DatabaseObjectIncreasePriorityAction method increasePriority.

private void increasePriority(TreeObject treeObject) throws EngineException {
    int count = counter;
    if (treeObject instanceof DatabaseObjectTreeObject) {
        DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
        DatabaseObject parent = databaseObject.getParent();
        if (parent != null && parent instanceof IContainerOrdered) {
            IContainerOrdered containerOrdered = (IContainerOrdered) parent;
            while (count-- > 0) {
                containerOrdered.increasePriority(databaseObject);
            }
            if (parent.hasChanged) {
                TreeParent parentTreeObject = null;
                TreeParent treeParent = treeObject.getParent();
                if (treeParent instanceof FolderTreeObject) {
                    parentTreeObject = treeObject.getParent().getParent();
                } else {
                    parentTreeObject = treeParent;
                }
                if (!treeNodesToUpdate.contains(parentTreeObject)) {
                    treeNodesToUpdate.add(parentTreeObject);
                }
            }
        }
    } else {
        DatabaseObjectTreeObject databaseObjectTreeObject = null;
        if (treeObject instanceof PropertyTableRowTreeObject) {
            PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) treeObject.getParent();
            while (count-- > 0) {
                if ((treeObject = propertyTableTreeObject.moveRow((PropertyTableRowTreeObject) treeObject, true)) != null) {
                    databaseObjectTreeObject = (DatabaseObjectTreeObject) propertyTableTreeObject.getParent();
                }
            }
        } else if (treeObject instanceof PropertyTableColumnTreeObject) {
            PropertyTableRowTreeObject propertyTableRowTreeObject = (PropertyTableRowTreeObject) treeObject.getParent();
            PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) propertyTableRowTreeObject.getParent();
            while (count-- > 0) {
                if ((treeObject = propertyTableRowTreeObject.moveColumn((PropertyTableColumnTreeObject) treeObject, true)) != null) {
                    databaseObjectTreeObject = (DatabaseObjectTreeObject) propertyTableTreeObject.getParent();
                }
            }
        }
        if (databaseObjectTreeObject != null) {
            if (databaseObjectTreeObject.hasChanged()) {
                DatabaseObjectTreeObject parentTreeObject = null;
                TreeParent treeParent = databaseObjectTreeObject.getParent();
                if (treeParent instanceof FolderTreeObject)
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
                else
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent;
                if (!treeNodesToUpdate.contains(parentTreeObject)) {
                    treeNodesToUpdate.add(parentTreeObject);
                }
            }
        }
    }
}
Also used : PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) IContainerOrdered(com.twinsoft.convertigo.beans.core.IContainerOrdered) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)

Example 2 with PropertyTableRowTreeObject

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

the class DeletePropertyTableRowAction 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[] treeObjects = explorerView.getSelectedTreeObjects();
            if (treeObjects != null) {
                HashSet<TreeParent> treeParentToReload = new HashSet<TreeParent>();
                HashSet<TreeParent> treeParentToRefresh = new HashSet<TreeParent>();
                int len = treeObjects.length;
                for (int i = 0; i < len; i++) {
                    try {
                        PropertyTableRowTreeObject propertyTableRowTreeObject = (PropertyTableRowTreeObject) treeObjects[i];
                        if (propertyTableRowTreeObject != null) {
                            MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_QUESTION | SWT.APPLICATION_MODAL);
                            String message = java.text.MessageFormat.format("Do you really want to delete the object \"{0}\" and all its sub-objects?", new Object[] { propertyTableRowTreeObject.getName() });
                            messageBox.setMessage(message);
                            if (messageBox.open() == SWT.YES) {
                                PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) propertyTableRowTreeObject.getParent();
                                TreeParent owner = propertyTableTreeObject.getParent();
                                propertyTableTreeObject.removeRow(propertyTableRowTreeObject);
                                if (owner instanceof DatabaseObjectTreeObject) {
                                    DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) owner;
                                    if (databaseObjectTreeObject.hasChanged()) {
                                        TreeParent treeParent = databaseObjectTreeObject.getParent();
                                        if (treeParent instanceof FolderTreeObject)
                                            treeParent = treeParent.getParent();
                                        treeParentToReload.add(treeParent);
                                    }
                                } else
                                    treeParentToRefresh.add(owner);
                            }
                        }
                    } catch (ClassCastException e) {
                    }
                }
                for (TreeParent treeParent : treeParentToReload) {
                    explorerView.reloadTreeObject(treeParent);
                }
                for (TreeParent owner : treeParentToRefresh) {
                    explorerView.refreshTreeObject(owner, true);
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to delete row!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) 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) MessageBox(org.eclipse.swt.widgets.MessageBox) Shell(org.eclipse.swt.widgets.Shell) PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) Display(org.eclipse.swt.widgets.Display) HashSet(java.util.HashSet)

Example 3 with PropertyTableRowTreeObject

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

the class DeletePropertyTableColumnAction 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[] treeObjects = explorerView.getSelectedTreeObjects();
            if (treeObjects != null) {
                HashSet<TreeParent> treeParentToReload = new HashSet<TreeParent>();
                HashSet<TreeParent> treeParentToRefresh = new HashSet<TreeParent>();
                int len = treeObjects.length;
                for (int i = 0; i < len; i++) {
                    try {
                        PropertyTableColumnTreeObject propertyTableColumnTreeObject = (PropertyTableColumnTreeObject) treeObjects[i];
                        if (propertyTableColumnTreeObject != null) {
                            MessageBox messageBox = new MessageBox(shell, SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_QUESTION | SWT.APPLICATION_MODAL);
                            String message = java.text.MessageFormat.format("Do you really want to delete the object \"{0}\" and all its sub-objects?", new Object[] { propertyTableColumnTreeObject.getName() });
                            messageBox.setMessage(message);
                            if (messageBox.open() == SWT.YES) {
                                PropertyTableRowTreeObject propertyTableRowTreeObject = (PropertyTableRowTreeObject) propertyTableColumnTreeObject.getParent();
                                TreeParent owner = propertyTableRowTreeObject.getParent().getParent();
                                propertyTableRowTreeObject.removeColumn(propertyTableColumnTreeObject);
                                if (owner instanceof DatabaseObjectTreeObject) {
                                    DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) owner;
                                    if (databaseObjectTreeObject.hasChanged()) {
                                        TreeParent treeParent = databaseObjectTreeObject.getParent();
                                        if (treeParent instanceof FolderTreeObject)
                                            treeParent = treeParent.getParent();
                                        treeParentToReload.add(treeParent);
                                    }
                                } else
                                    treeParentToRefresh.add(owner);
                            }
                        }
                    } catch (ClassCastException e) {
                    }
                }
                for (TreeParent treeParent : treeParentToReload) {
                    explorerView.reloadTreeObject(treeParent);
                }
                for (TreeParent owner : treeParentToRefresh) {
                    explorerView.refreshTreeObject(owner, true);
                }
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to delete column!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) 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) MessageBox(org.eclipse.swt.widgets.MessageBox) Shell(org.eclipse.swt.widgets.Shell) PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) Display(org.eclipse.swt.widgets.Display) HashSet(java.util.HashSet)

Example 4 with PropertyTableRowTreeObject

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

the class TreeDropAdapter method performDrop.

private void performDrop(Object data, final ProjectExplorerView explorerView, TreeObject targetTreeObject) throws EngineException, IOException {
    boolean needReload = false;
    final DatabaseObject dbo;
    if (data instanceof String) {
        String source = data.toString();
        if (targetTreeObject instanceof ObjectsFolderTreeObject) {
            ObjectsFolderTreeObject folderTreeObject = (ObjectsFolderTreeObject) targetTreeObject;
            dbo = (DatabaseObject) folderTreeObject.getParent().getObject();
            switch(folderTreeObject.folderType) {
                case ObjectsFolderTreeObject.FOLDER_TYPE_CRITERIAS:
                    if (dbo instanceof HtmlScreenClass) {
                        // Creates a XPath criteria for this screen class
                        if (!dbo.equals(((HtmlConnector) dbo.getConnector()).getDefaultScreenClass())) {
                            ((HtmlScreenClass) dbo).addCriteria(createXPath(source));
                            needReload = true;
                        }
                    }
                    break;
                case ObjectsFolderTreeObject.FOLDER_TYPE_INHERITED_SCREEN_CLASSES:
                    if (dbo instanceof HtmlScreenClass) {
                        // Creates an inherited screen class with an XPath criteria for this screen class
                        HtmlScreenClass newSc = createHtmlScreenClass(dbo.priority + 1);
                        ((HtmlScreenClass) dbo).addInheritedScreenClass(newSc);
                        newSc.addCriteria(createXPath(source));
                        needReload = true;
                    }
                    break;
                case ObjectsFolderTreeObject.FOLDER_TYPE_EXTRACTION_RULES:
                    if (dbo instanceof HtmlScreenClass) {
                        NewObjectWizard newObjectWizard = new NewObjectWizard(dbo, "com.twinsoft.convertigo.beans.core.ExtractionRule", source, null);
                        WizardDialog wzdlg = new WizardDialog(Display.getDefault().getActiveShell(), newObjectWizard);
                        wzdlg.setPageSize(850, 650);
                        wzdlg.open();
                        needReload = true;
                    }
                    break;
                default:
                    break;
            }
            if (needReload)
                reloadTreeObject(explorerView, folderTreeObject.getParent());
        } else if (targetTreeObject instanceof DatabaseObjectTreeObject) {
            DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) targetTreeObject;
            dbo = (DatabaseObject) targetTreeObject.getObject();
            if (databaseObjectTreeObject instanceof ScreenClassTreeObject) {
                if (dbo instanceof HtmlScreenClass) {
                    // Creates an inherited screen class with an XPath criteria for this screen class
                    HtmlScreenClass newSc = createHtmlScreenClass(dbo.priority + 1);
                    ((HtmlScreenClass) dbo).addInheritedScreenClass(newSc);
                    newSc.addCriteria(createXPath(source));
                    needReload = true;
                }
            } else if (dbo instanceof IXPathable) {
                // Set XPath property
                if (dbo instanceof XpathableStatement)
                    ((XpathableStatement) dbo).setPureXpath(source);
                else
                    ((IXPathable) dbo).setXpath(source);
                ((DatabaseObject) dbo).hasChanged = true;
                needReload = true;
            }
            if (needReload)
                reloadTreeObject(explorerView, databaseObjectTreeObject);
        } else if (targetTreeObject instanceof IPropertyTreeObject) {
            IPropertyTreeObject pto = null;
            if (detail == DND.DROP_MOVE) {
                // Set XPath property
                if (targetTreeObject instanceof IXPathable) {
                    ((IXPathable) targetTreeObject).setXpath("." + source);
                    needReload = true;
                } else // Add new row with xpath
                if (targetTreeObject instanceof PropertyTableTreeObject) {
                    // // See Ticket #679 : Drag and drop without Control
                    // PropertyTableTreeObject description = (PropertyTableTreeObject)targetTreeObject;
                    // pto = description.addNewRow();
                    // needReload = true;
                    // if ((pto != null) && (pto instanceof IXPathable)) {
                    // ((IXPathable)pto).setXpath("."+source);
                    // }
                    String label = ((PropertyTableTreeObject) targetTreeObject).getRowDefaultLabel().toLowerCase();
                    throw new EngineException("Please hold on the 'Ctrl' key while dragging to create a new " + label);
                }
            } else if (detail == DND.DROP_COPY) {
                // Add new row with xpath
                if (targetTreeObject instanceof PropertyTableTreeObject) {
                    PropertyTableTreeObject description = (PropertyTableTreeObject) targetTreeObject;
                    pto = description.addNewRow();
                    needReload = true;
                    if ((pto != null) && (pto instanceof IXPathable)) {
                        ((IXPathable) pto).setXpath("." + source);
                    }
                } else // Add new column with xpath
                if (targetTreeObject instanceof PropertyTableRowTreeObject) {
                    PropertyTableRowTreeObject row = (PropertyTableRowTreeObject) targetTreeObject;
                    pto = row.addNewColumn();
                    needReload = true;
                    if ((pto != null) && (pto instanceof IXPathable)) {
                        ((IXPathable) pto).setXpath("." + source);
                    }
                }
            }
            if (needReload) {
                pto = (pto == null) ? (IPropertyTreeObject) targetTreeObject : pto;
                targetTreeObject = ((IPropertyTreeObject) targetTreeObject).getTreeObjectOwner();
                if (targetTreeObject instanceof DatabaseObjectTreeObject) {
                    // reloadTreeObject(explorerView, targetTreeObject);
                    TreeParent treeParent = targetTreeObject.getParent();
                    if (treeParent instanceof FolderTreeObject)
                        treeParent = treeParent.getParent();
                    explorerView.objectChanged(new CompositeEvent(treeParent.getObject(), pto.getPath()));
                }
            }
        }
    } else if (data instanceof StepSource) {
        if (targetTreeObject instanceof DatabaseObjectTreeObject) {
            final DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) targetTreeObject;
            dbo = (DatabaseObject) targetTreeObject.getObject();
            final Set<PropertyDescriptor> propertyDescriptors = new TreeSet<PropertyDescriptor>(new Comparator<PropertyDescriptor>() {

                @Override
                public int compare(PropertyDescriptor o1, PropertyDescriptor o2) {
                    return o1.getDisplayName().compareTo(o2.getDisplayName());
                }
            });
            propertyDescriptors.addAll(CachedIntrospector.getPropertyDescriptors(dbo, Property.smartType));
            propertyDescriptors.addAll(CachedIntrospector.getPropertyDescriptors(dbo, Property.sourceDefinition));
            propertyDescriptors.addAll(CachedIntrospector.getPropertyDescriptors(dbo, Property.sourcesDefinition));
            if (!propertyDescriptors.isEmpty()) {
                // Retrieve Source definition
                final XMLVector<String> sourceDefinition = new XMLVector<String>(2);
                sourceDefinition.add(((StepSource) data).getPriority());
                sourceDefinition.add(((StepSource) data).getXpath());
                SelectionListener selectionListener = new SelectionListener() {

                    @Override
                    public void widgetSelected(SelectionEvent e) {
                        PropertyDescriptor propertyDescriptor = (e == null) ? propertyDescriptors.iterator().next() : (PropertyDescriptor) e.widget.getData();
                        String propertyName = propertyDescriptor.getName();
                        if (propertyDescriptor.getPropertyType().isAssignableFrom(SmartType.class)) {
                            SmartType smartType = new SmartType();
                            smartType.setMode(Mode.SOURCE);
                            smartType.setSourceDefinition(sourceDefinition);
                            databaseObjectTreeObject.setPropertyValue(propertyDescriptor.getName(), smartType);
                        } else if (propertyName.equals("sourceDefinition")) {
                            // Use setPropertyValue in order to set object's value and fire necessary events
                            databaseObjectTreeObject.setPropertyValue(propertyDescriptor.getName(), sourceDefinition);
                        } else if (propertyName.equals("sourcesDefinition")) {
                            try {
                                XMLVector<XMLVector<Object>> sourcesDefinition = GenericUtils.cast(propertyDescriptor.getReadMethod().invoke(dbo));
                                // make a copy to make a property change
                                sourcesDefinition = new XMLVector<XMLVector<Object>>(sourcesDefinition);
                                XMLVector<Object> row = new XMLVector<Object>();
                                row.add("");
                                row.add(sourceDefinition);
                                row.add("");
                                sourcesDefinition.add(row);
                                databaseObjectTreeObject.setPropertyValue(propertyName, sourcesDefinition);
                            } catch (Exception ex) {
                                ConvertigoPlugin.logError("failed to add to sourcesDefinition of " + dbo.getName());
                            }
                        }
                        // Properties view needs to be refreshed
                        refreshPropertiesView(explorerView, databaseObjectTreeObject);
                    }

                    @Override
                    public void widgetDefaultSelected(SelectionEvent e) {
                    }
                };
                if (propertyDescriptors.size() == 1) {
                    selectionListener.widgetSelected(null);
                } else {
                    Shell shell = ConvertigoPlugin.getMainShell();
                    Menu dropMenu = new Menu(shell, SWT.POP_UP);
                    shell.setMenu(dropMenu);
                    for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
                        MenuItem itemCheck = new MenuItem(dropMenu, SWT.NONE);
                        itemCheck.setText(propertyDescriptor.getDisplayName());
                        itemCheck.setData(propertyDescriptor);
                        itemCheck.addSelectionListener(selectionListener);
                    }
                    dropMenu.setVisible(true);
                }
            }
        }
    } else if (data instanceof PaletteSource) {
        try {
            if (targetTreeObject instanceof ObjectsFolderTreeObject) {
                ObjectsFolderTreeObject folderTreeObject = (ObjectsFolderTreeObject) targetTreeObject;
                targetTreeObject = folderTreeObject.getParent();
            }
            if (targetTreeObject instanceof DatabaseObjectTreeObject) {
                DatabaseObject parent = (DatabaseObject) targetTreeObject.getObject();
                String xmlData = ((PaletteSource) data).getXmlData();
                Document document = XMLUtils.getDefaultDocumentBuilder().parse(new InputSource(new StringReader(xmlData)));
                Element rootElement = document.getDocumentElement();
                NodeList nodeList = rootElement.getChildNodes();
                int len = nodeList.getLength();
                Node node;
                // Special objects move from palette
                if (detail == DND.DROP_MOVE) {
                    for (int i = 0; i < len; i++) {
                        node = (Node) nodeList.item(i);
                        if (node.getNodeType() != Node.TEXT_NODE) {
                            if (paste(node, parent, true) == null) {
                                throw new Exception();
                            }
                        }
                    }
                    reloadTreeObject(explorerView, targetTreeObject);
                }
            } else {
                throw new Exception();
            }
        } catch (Exception ex) {
            ConvertigoPlugin.logError("failed to add from palette");
        }
    } else if (data instanceof MobileSource) {
        try {
            String jsonString = ((MobileSource) data).getJsonString();
            if (targetTreeObject instanceof MobileUIComponentTreeObject) {
                Shell shell = ConvertigoPlugin.getMainShell();
                Menu dropMenu = new Menu(shell, SWT.POP_UP);
                shell.setMenu(dropMenu);
                MobileUIComponentTreeObject mcto = GenericUtils.cast(targetTreeObject);
                for (IPropertyDescriptor descriptor : mcto.getPropertyDescriptors()) {
                    if (descriptor instanceof MobileSmartSourcePropertyDescriptor) {
                        MobileSmartSourcePropertyDescriptor cspd = GenericUtils.cast(descriptor);
                        if (!cspd.isReadOnly()) {
                            String propertyName = (String) cspd.getId();
                            String propertyLabel = (String) cspd.getDisplayName();
                            MenuItem itemCheck = new MenuItem(dropMenu, SWT.NONE);
                            itemCheck.setText(propertyLabel);
                            itemCheck.addSelectionListener(new SelectionListener() {

                                @Override
                                public void widgetSelected(SelectionEvent e) {
                                    com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType cst = new com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType();
                                    cst.setMode(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType.Mode.SOURCE);
                                    cst.setSmartValue(jsonString);
                                    mcto.setPropertyValue(propertyName, cst);
                                    refreshPropertiesView(explorerView, mcto);
                                }

                                @Override
                                public void widgetDefaultSelected(SelectionEvent e) {
                                }
                            });
                        }
                    }
                }
                dropMenu.setVisible(true);
            }
            if (targetTreeObject instanceof NgxUIComponentTreeObject) {
                Shell shell = ConvertigoPlugin.getMainShell();
                Menu dropMenu = new Menu(shell, SWT.POP_UP);
                shell.setMenu(dropMenu);
                NgxUIComponentTreeObject mcto = GenericUtils.cast(targetTreeObject);
                for (IPropertyDescriptor descriptor : mcto.getPropertyDescriptors()) {
                    if (descriptor instanceof NgxSmartSourcePropertyDescriptor) {
                        NgxSmartSourcePropertyDescriptor cspd = GenericUtils.cast(descriptor);
                        if (!cspd.isReadOnly()) {
                            String propertyName = (String) cspd.getId();
                            String propertyLabel = (String) cspd.getDisplayName();
                            MenuItem itemCheck = new MenuItem(dropMenu, SWT.NONE);
                            itemCheck.setText(propertyLabel);
                            itemCheck.addSelectionListener(new SelectionListener() {

                                @Override
                                public void widgetSelected(SelectionEvent e) {
                                    com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType cst = new com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType();
                                    cst.setMode(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType.Mode.SOURCE);
                                    cst.setSmartValue(jsonString);
                                    mcto.setPropertyValue(propertyName, cst);
                                    refreshPropertiesView(explorerView, mcto);
                                }

                                @Override
                                public void widgetDefaultSelected(SelectionEvent e) {
                                }
                            });
                        }
                    }
                }
                dropMenu.setVisible(true);
            } else {
                throw new Exception();
            }
        } catch (Exception ex) {
            ConvertigoPlugin.logError("failed to add mobile source");
        }
    }
}
Also used : PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) InputSource(org.xml.sax.InputSource) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) Node(org.w3c.dom.Node) EngineException(com.twinsoft.convertigo.engine.EngineException) Document(org.w3c.dom.Document) Comparator(java.util.Comparator) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) HtmlScreenClass(com.twinsoft.convertigo.beans.screenclasses.HtmlScreenClass) IXPathable(com.twinsoft.convertigo.beans.core.IXPathable) NodeList(org.w3c.dom.NodeList) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) 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) 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) SelectionListener(org.eclipse.swt.events.SelectionListener) Set(java.util.Set) TreeSet(java.util.TreeSet) MobileSmartSourcePropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.MobileSmartSourcePropertyDescriptor) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) Element(org.w3c.dom.Element) NgxSmartSourcePropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.NgxSmartSourcePropertyDescriptor) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) NewObjectWizard(com.twinsoft.convertigo.eclipse.wizards.new_object.NewObjectWizard) Shell(org.eclipse.swt.widgets.Shell) StringReader(java.io.StringReader) Menu(org.eclipse.swt.widgets.Menu) SmartType(com.twinsoft.convertigo.beans.steps.SmartType) CompositeEvent(com.twinsoft.convertigo.eclipse.editors.CompositeEvent) XpathableStatement(com.twinsoft.convertigo.beans.statements.XpathableStatement) HtmlConnector(com.twinsoft.convertigo.beans.connectors.HtmlConnector) PropertyDescriptor(java.beans.PropertyDescriptor) NgxSmartSourcePropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.NgxSmartSourcePropertyDescriptor) MobileSmartSourcePropertyDescriptor(com.twinsoft.convertigo.eclipse.property_editors.MobileSmartSourcePropertyDescriptor) IPropertyDescriptor(org.eclipse.ui.views.properties.IPropertyDescriptor) MenuItem(org.eclipse.swt.widgets.MenuItem) 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) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) IPropertyDescriptor(org.eclipse.ui.views.properties.IPropertyDescriptor) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) WizardDialog(org.eclipse.jface.wizard.WizardDialog) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)

Example 5 with PropertyTableRowTreeObject

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

the class ProjectExplorerView method handleKeyReleased.

private void handleKeyReleased(KeyEvent event) {
    boolean bCtrl = (((event.stateMask & SWT.CONTROL) != 0) || ((event.stateMask & SWT.CTRL) != 0));
    // boolean bAlt = (event.stateMask & SWT.ALT) != 0;
    int stateMask = event.stateMask;
    int keyCode = event.keyCode;
    char c = event.character;
    if (stateMask == 0) {
        // F2 for renaming
        if (keyCode == SWT.F2) {
            renameSelectedTreeObject();
        }
        // F5 for refreshing and executing selected requestable
        if (keyCode == SWT.F5) {
            refreshTree();
            Object object = getFirstSelectedDatabaseObject();
            if (object instanceof Transaction) {
                executeTransaction.run();
            } else if (object instanceof Sequence) {
                executeSequence.run();
            } else if (object instanceof TestCase) {
                executeTestCase.run();
            }
        }
        // DEL for deleting
        if (c == SWT.DEL) {
            Object object = getFirstSelectedTreeObject();
            if (object instanceof DatabaseObjectTreeObject) {
                deleteDatabaseObjectAction.runWithEvent(null);
            } else if (object instanceof PropertyTableRowTreeObject) {
                deletePropertyTableRowAction.run();
            } else if (object instanceof PropertyTableColumnTreeObject) {
                deletePropertyTableColumnAction.run();
            }
        }
    }
    if (bCtrl) {
        // Copy/Cut/Paste
        if (c == 'c') {
            copyAction.runWithEvent(null);
        }
        if (c == 'x') {
            cutAction.runWithEvent(null);
        }
        if (c == 'v') {
            pasteAction.runWithEvent(null);
        }
        if (c == 'g') {
            transactionEditHandlersAction.run();
        }
        // Saving
        if ((c == 's') || (keyCode == 115)) {
            projectExplorerSaveAllAction.run();
        }
        // F5 for executing default transaction
        if (keyCode == SWT.F5) {
            executeDefaultTransaction.run();
        }
    }
    // +/- for Priority
    if ((c == '+') || (keyCode == SWT.KEYPAD_ADD)) {
        increasePriorityAction.runWithEvent(null);
    }
    if ((c == '-') || (keyCode == SWT.KEYPAD_SUBTRACT)) {
        decreasePriorityAction.runWithEvent(null);
    }
}
Also used : PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) Transaction(com.twinsoft.convertigo.beans.core.Transaction) JavelinTransaction(com.twinsoft.convertigo.beans.transactions.JavelinTransaction) TestCase(com.twinsoft.convertigo.beans.core.TestCase) UrlMappingParameterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingParameterTreeObject) MobileApplicationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationTreeObject) IClosableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IClosableTreeObject) XMLRecordDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLRecordDescriptionTreeObject) DesignDocumentValidateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentValidateTreeObject) UrlMappingTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingTreeObject) DesignDocumentUpdateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentUpdateTreeObject) DesignDocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentTreeObject) MobileApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileApplicationComponentTreeObject) UrlMappingOperationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingOperationTreeObject) ReferenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ReferenceTreeObject) HandlersDeclarationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.HandlersDeclarationTreeObject) UrlMappingResponseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMappingResponseTreeObject) UnloadedProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) CriteriaTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.CriteriaTreeObject) IPropertyTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject) UrlAuthenticationTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlAuthenticationTreeObject) SequenceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SequenceTreeObject) MobileRouteActionComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteActionComponentTreeObject) ListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ListenerTreeObject) TransactionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TransactionTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject) FullSyncListenerTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FullSyncListenerTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) ConnectorTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ConnectorTreeObject) IDesignTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IDesignTreeObject) ScreenClassTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ScreenClassTreeObject) StatementTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StatementTreeObject) NgxApplicationComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxApplicationComponentTreeObject) MobileRouteEventComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteEventComponentTreeObject) PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) IEditableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IEditableTreeObject) XMLTableDescriptionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.XMLTableDescriptionTreeObject) ProjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ProjectTreeObject) DesignDocumentViewTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject) TemplateTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TemplateTreeObject) TestCaseTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TestCaseTreeObject) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) DesignDocumentFilterTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFilterTreeObject) VariableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.VariableTreeObject) DesignDocumentFunctionTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject) MobilePlatformTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePlatformTreeObject) ExtractionRuleTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ExtractionRuleTreeObject) MobileRouteComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileRouteComponentTreeObject) SheetTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.SheetTreeObject) UrlMapperTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UrlMapperTreeObject) StepTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) TraceTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TraceTreeObject) DocumentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DocumentTreeObject) Sequence(com.twinsoft.convertigo.beans.core.Sequence) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) Point(org.eclipse.swt.graphics.Point)

Aggregations

DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)11 PropertyTableRowTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject)11 FolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject)9 PropertyTableColumnTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject)7 PropertyTableTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)7 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)6 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)5 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)5 IPropertyTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.IPropertyTreeObject)4 Shell (org.eclipse.swt.widgets.Shell)4 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)3 DesignDocumentFunctionTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentFunctionTreeObject)3 ObjectsFolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject)3 UnloadedProjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.UnloadedProjectTreeObject)3 Cursor (org.eclipse.swt.graphics.Cursor)3 Display (org.eclipse.swt.widgets.Display)3 IContainerOrdered (com.twinsoft.convertigo.beans.core.IContainerOrdered)2 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)2 DesignDocumentViewTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DesignDocumentViewTreeObject)2 MobileUIComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject)2