Search in sources :

Example 36 with PageComponent

use of com.twinsoft.convertigo.beans.mobile.components.PageComponent in project convertigo by convertigo.

the class MobilePageComponentTreeObject method getNamedSourceSelector.

@Override
public NamedSourceSelector getNamedSourceSelector() {
    return new NamedSourceSelector() {

        @Override
        Object thisTreeObject() {
            return MobilePageComponentTreeObject.this;
        }

        @Override
        protected List<String> getPropertyNamesForSource(Class<?> c) {
            List<String> list = new ArrayList<String>();
            if (getObject() instanceof PageComponent) {
                if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || MobileApplicationComponentTreeObject.class.isAssignableFrom(c) || MobileUIComponentTreeObject.class.isAssignableFrom(c)) {
                    list.add("menu");
                }
            }
            return list;
        }

        @Override
        protected boolean isNamedSource(String propertyName) {
            if (getObject() instanceof PageComponent) {
                return "menu".equals(propertyName);
            }
            return false;
        }

        @Override
        public boolean isSelectable(String propertyName, Object nsObject) {
            if (getObject() instanceof PageComponent) {
                if ("menu".equals(propertyName)) {
                    PageComponent pc = getObject();
                    if (nsObject instanceof UIDynamicMenu) {
                        return (((UIDynamicMenu) nsObject).getProject().equals(pc.getProject()));
                    }
                }
            }
            return false;
        }

        @Override
        protected void handleSourceCleared(String propertyName) {
        // nothing to do
        }

        @Override
        protected void handleSourceRenamed(String propertyName, String oldName, String newName) {
            if (isNamedSource(propertyName)) {
                boolean hasBeenRenamed = false;
                String pValue = (String) getPropertyValue(propertyName);
                if (pValue != null && pValue.startsWith(oldName)) {
                    String _pValue = newName + pValue.substring(oldName.length());
                    if (!pValue.equals(_pValue)) {
                        if (getObject() instanceof PageComponent) {
                            if ("menu".equals(propertyName)) {
                                getObject().setMenu(_pValue);
                                hasBeenRenamed = true;
                            }
                        }
                    }
                }
                if (hasBeenRenamed) {
                    hasBeenModified(true);
                    ConvertigoPlugin.projectManager.getProjectExplorerView().updateTreeObject(MobilePageComponentTreeObject.this);
                    // refresh editors (e.g labels in combobox)
                    getDescriptors();
                    TreeObjectEvent treeObjectEvent = new TreeObjectEvent(MobilePageComponentTreeObject.this, propertyName, "", "");
                    ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent);
                }
            }
        }
    };
}
Also used : ArrayList(java.util.ArrayList) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) UIDynamicMenu(com.twinsoft.convertigo.beans.mobile.components.UIDynamicMenu) TreeObjectEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent)

Example 37 with PageComponent

use of com.twinsoft.convertigo.beans.mobile.components.PageComponent in project convertigo by convertigo.

the class MobilePageComponentTreeObject method rename.

@Override
public boolean rename(String newName, boolean bDialog) {
    PageComponent page = getObject();
    String oldName = page.getName();
    boolean isRenamed = super.rename(newName, bDialog);
    if (isRenamed && !oldName.equals(newName)) {
        String oldSegment = page.getSegment();
        if (oldSegment.equals(PageComponent.SEGMENT_PREFIX + oldName.toLowerCase())) {
            // path-to-<page_name>
            page.setSegment(oldSegment.replace(oldName.toLowerCase(), newName.toLowerCase()));
            Engine.logEngine.debug("For page renamed to \"" + newName + "\", segment has been replaced with \"" + page.getSegment() + "\"");
        }
    }
    return isRenamed;
}
Also used : PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent)

Example 38 with PageComponent

use of com.twinsoft.convertigo.beans.mobile.components.PageComponent in project convertigo by convertigo.

the class MobileRouteActionComponentTreeObject method getNamedSourceSelector.

@Override
public NamedSourceSelector getNamedSourceSelector() {
    return new NamedSourceSelector() {

        @Override
        Object thisTreeObject() {
            return MobileRouteActionComponentTreeObject.this;
        }

        @Override
        protected List<String> getPropertyNamesForSource(Class<?> c) {
            List<String> list = new ArrayList<String>();
            if (getObject() instanceof RouteActionComponent) {
                if (ProjectTreeObject.class.isAssignableFrom(c) || MobileApplicationTreeObject.class.isAssignableFrom(c) || MobileApplicationComponentTreeObject.class.isAssignableFrom(c) || MobilePageComponentTreeObject.class.isAssignableFrom(c)) {
                    list.add("page");
                }
            }
            return list;
        }

        @Override
        protected boolean isNamedSource(String propertyName) {
            if (getObject() instanceof RouteActionComponent) {
                return "page".equals(propertyName);
            }
            return false;
        }

        @Override
        public boolean isSelectable(String propertyName, Object nsObject) {
            if (getObject() instanceof RouteActionComponent) {
                if ("page".equals(propertyName)) {
                    RouteActionComponent rc = getObject();
                    if (rc instanceof RouteDataActionComponent) {
                        if (nsObject instanceof PageComponent) {
                            return (((PageComponent) nsObject).getProject().equals(rc.getProject()));
                        }
                    }
                }
            }
            return false;
        }

        @Override
        protected void handleSourceCleared(String propertyName) {
        // nothing to do
        }

        @Override
        protected void handleSourceRenamed(String propertyName, String oldName, String newName) {
            if (isNamedSource(propertyName)) {
                boolean hasBeenRenamed = false;
                String pValue = (String) getPropertyValue(propertyName);
                if (pValue != null && pValue.startsWith(oldName)) {
                    String _pValue = newName + pValue.substring(oldName.length());
                    if (!pValue.equals(_pValue)) {
                        if (getObject() instanceof RouteActionComponent) {
                            if ("page".equals(propertyName)) {
                                getObject().setPage(_pValue);
                                hasBeenRenamed = true;
                            }
                        }
                    }
                }
                if (hasBeenRenamed) {
                    hasBeenModified(true);
                    ConvertigoPlugin.projectManager.getProjectExplorerView().updateTreeObject(MobileRouteActionComponentTreeObject.this);
                    // refresh editors (e.g labels in combobox)
                    getDescriptors();
                    TreeObjectEvent treeObjectEvent = new TreeObjectEvent(MobileRouteActionComponentTreeObject.this, propertyName, "", "");
                    ConvertigoPlugin.projectManager.getProjectExplorerView().fireTreeObjectPropertyChanged(treeObjectEvent);
                }
            }
        }
    };
}
Also used : RouteActionComponent(com.twinsoft.convertigo.beans.mobile.components.RouteActionComponent) ArrayList(java.util.ArrayList) RouteDataActionComponent(com.twinsoft.convertigo.beans.mobile.components.RouteDataActionComponent) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) TreeObjectEvent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent)

Example 39 with PageComponent

use of com.twinsoft.convertigo.beans.mobile.components.PageComponent in project convertigo by convertigo.

the class SharedComponentWizard method doFinish.

private void doFinish(IProgressMonitor monitor) throws CoreException {
    UISharedComponent uisc = null;
    UIUseShared uius = null;
    try {
        if (page1 != null) {
            shared_comp_name = page1.getSharedComponentName();
            keep_original = page1.keepComponent();
        }
        if (page2 != null) {
            dlg_map = page2.getVariableMap();
        }
        // Create shared component
        uisc = createSharedComponent();
        monitor.setTaskName("SharedComponent created");
        monitor.worked(1);
        // Create UseShared
        uius = createUseShared(uisc.getQName());
        monitor.setTaskName("UseShared component created");
        monitor.worked(1);
        // Disable or Remove selected databaseObject(s)
        for (DatabaseObject dbo : objectList) {
            UIComponent uic = (UIComponent) dbo;
            if (keep_original) {
                uic.setEnabled(false);
                uic.hasChanged = true;
            } else {
                MobileComponent mc = (MobileComponent) uic.getParent();
                if (mc instanceof ApplicationComponent) {
                    ApplicationComponent parent = (ApplicationComponent) mc;
                    parent.remove(uic);
                    parent.hasChanged = true;
                } else if (mc instanceof PageComponent) {
                    PageComponent parent = (PageComponent) mc;
                    parent.remove(uic);
                    parent.hasChanged = true;
                } else if (mc instanceof UIComponent) {
                    UIComponent parent = (UIComponent) mc;
                    parent.remove(uic);
                    parent.hasChanged = true;
                }
            }
        }
        // Set newBean to new shared component
        newBean = uisc;
    } catch (Exception e) {
        try {
            if (uisc != null) {
                uisc.getParent().remove(uisc);
            }
            if (uius != null) {
                uius.getParent().remove(uius);
            }
        } catch (Exception ex) {
        }
        String message = "Unable to create a new object from class '" + this.className + "'.";
        ConvertigoPlugin.logException(e, message);
        newBean = null;
    }
}
Also used : ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) UIUseShared(com.twinsoft.convertigo.beans.mobile.components.UIUseShared) UIComponent(com.twinsoft.convertigo.beans.mobile.components.UIComponent) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) UISharedComponent(com.twinsoft.convertigo.beans.mobile.components.UISharedComponent) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MobileComponent(com.twinsoft.convertigo.beans.mobile.components.MobileComponent)

Example 40 with PageComponent

use of com.twinsoft.convertigo.beans.mobile.components.PageComponent in project convertigo by convertigo.

the class SharedComponentWizard method createUseShared.

private UIUseShared createUseShared(String qname) throws Exception {
    UIUseShared uius = new UIUseShared();
    uius.setSharedComponentQName(qname);
    uius.hasChanged = true;
    uius.bNew = true;
    for (String name : dlg_map.keySet()) {
        String value = ovarMap.get(name).keySet().iterator().next();
        uius.add(createControlVariable(dlg_map.get(name), value));
    }
    UIComponent uic = (UIComponent) getLastInList();
    MobileComponent mc = (MobileComponent) uic.getParent();
    if (mc instanceof ApplicationComponent) {
        ApplicationComponent parent = (ApplicationComponent) mc;
        parent.add((DatabaseObject) uius, uic.priority);
    } else if (mc instanceof PageComponent) {
        PageComponent parent = (PageComponent) mc;
        parent.add((DatabaseObject) uius, uic.priority);
    } else if (mc instanceof UIComponent) {
        UIComponent parent = (UIComponent) mc;
        parent.add((DatabaseObject) uius, uic.priority);
    }
    return uius;
}
Also used : ApplicationComponent(com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent) UIUseShared(com.twinsoft.convertigo.beans.mobile.components.UIUseShared) UIComponent(com.twinsoft.convertigo.beans.mobile.components.UIComponent) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) PageComponent(com.twinsoft.convertigo.beans.mobile.components.PageComponent) MobileComponent(com.twinsoft.convertigo.beans.mobile.components.MobileComponent)

Aggregations

PageComponent (com.twinsoft.convertigo.beans.mobile.components.PageComponent)41 IPageComponent (com.twinsoft.convertigo.beans.core.IPageComponent)20 EngineException (com.twinsoft.convertigo.engine.EngineException)16 File (java.io.File)15 ApplicationComponent (com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent)14 IOException (java.io.IOException)11 UIComponent (com.twinsoft.convertigo.beans.mobile.components.UIComponent)9 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)8 UISharedComponent (com.twinsoft.convertigo.beans.mobile.components.UISharedComponent)6 UIUseShared (com.twinsoft.convertigo.beans.mobile.components.UIUseShared)6 ArrayList (java.util.ArrayList)6 IApplicationComponent (com.twinsoft.convertigo.beans.core.IApplicationComponent)5 Project (com.twinsoft.convertigo.beans.core.Project)4 Contributor (com.twinsoft.convertigo.beans.mobile.components.Contributor)4 UIActionStack (com.twinsoft.convertigo.beans.mobile.components.UIActionStack)4 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)4 TreeObjectEvent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeObjectEvent)4 HashMap (java.util.HashMap)4 JSONObject (org.codehaus.jettison.json.JSONObject)4 Cursor (org.eclipse.swt.graphics.Cursor)4