Search in sources :

Example 6 with MobileComponent

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

the class MobilePickerContentProvider method getChildren.

@Override
public Object[] getChildren(Object parentElement) {
    if (parentElement instanceof TVObject) {
        return ((TVObject) parentElement).children.toArray();
    } else if (parentElement instanceof MobileComponent) {
        MobileComponent mobileComponent = (MobileComponent) parentElement;
        Project project = mobileComponent.getProject();
        ProjectExplorerView projectExplorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
        List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
        Map<String, Set<String>> map = mobileComponent.getApplication().getInfoMap();
        TVObject root = new TVObject("root", mobileComponent, null);
        if (filter.equals(Filter.Action)) {
            TVObject tvi = root.add(new TVObject("actions"));
            TVObject tvEvents = tvi.add(new TVObject("events"));
            TVObject tvControls = tvi.add(new TVObject("controls"));
            addActions(tvi, mobileComponent);
            if (tvEvents.isEmpty()) {
                tvi.remove(tvEvents);
            }
            if (tvControls.isEmpty()) {
                tvi.remove(tvControls);
            }
        }
        if (filter.equals(Filter.Shared)) {
            TVObject tvi = root.add(new TVObject("shared"));
            addSharedComponents(tvi, mobileComponent);
        }
        if (filter.equals(Filter.Sequence)) {
            TVObject tvs = root.add(new TVObject("sequences"));
            for (String projectName : projectNames) {
                try {
                    Project p = projectExplorerView.getProject(projectName);
                    boolean isReferenced = !p.getName().equals(project.getName());
                    addSequences(map, tvs, isReferenced ? p : project, isReferenced);
                } catch (Exception e) {
                }
            }
        }
        if (filter.equals(Filter.Database)) {
            TVObject tvd = root.add(new TVObject("databases"));
            for (String projectName : projectNames) {
                try {
                    Project p = projectExplorerView.getProject(projectName);
                    boolean isReferenced = !p.getName().equals(project.getName());
                    addFsObjects(map, tvd, isReferenced ? p : project, isReferenced);
                } catch (Exception e) {
                }
            }
        }
        if (filter.equals(Filter.Iteration)) {
            TVObject tvi = root.add(new TVObject("iterations"));
            addIterations(tvi, mobileComponent);
        }
        if (filter.equals(Filter.Form)) {
            TVObject tvi = root.add(new TVObject("forms"));
            addForms(tvi, mobileComponent);
        }
        if (filter.equals(Filter.Global)) {
            TVObject tvi = root.add(new TVObject("globals"));
            addGlobals(tvi, mobileComponent.getApplication());
        }
        return root.children.toArray();
    } else if (parentElement instanceof JSONObject) {
        JSONObject jsonObject = (JSONObject) parentElement;
        TVObject root = new TVObject("root", jsonObject, null);
        addJsonObjects(root);
        return root.children.toArray();
    }
    return new Object[0];
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) JSONObject(org.codehaus.jettison.json.JSONObject) ArrayList(java.util.ArrayList) List(java.util.List) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) HashMap(java.util.HashMap) Map(java.util.Map) JSONException(org.codehaus.jettison.json.JSONException) MobileComponent(com.twinsoft.convertigo.beans.mobile.components.MobileComponent)

Aggregations

MobileComponent (com.twinsoft.convertigo.beans.mobile.components.MobileComponent)6 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)5 UIUseShared (com.twinsoft.convertigo.beans.mobile.components.UIUseShared)4 PageComponent (com.twinsoft.convertigo.beans.mobile.components.PageComponent)3 UIComponent (com.twinsoft.convertigo.beans.mobile.components.UIComponent)3 UISharedComponent (com.twinsoft.convertigo.beans.mobile.components.UISharedComponent)3 ApplicationComponent (com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent)2 JSONException (org.codehaus.jettison.json.JSONException)2 CoreException (org.eclipse.core.runtime.CoreException)2 Document (com.teamdev.jxbrowser.dom.Document)1 Element (com.teamdev.jxbrowser.dom.Element)1 Node (com.teamdev.jxbrowser.dom.Node)1 Project (com.twinsoft.convertigo.beans.core.Project)1 UIActionStack (com.twinsoft.convertigo.beans.mobile.components.UIActionStack)1 UIDynamicElement (com.twinsoft.convertigo.beans.mobile.components.UIDynamicElement)1 UIDynamicInvoke (com.twinsoft.convertigo.beans.mobile.components.UIDynamicInvoke)1 CompositeEvent (com.twinsoft.convertigo.eclipse.editors.CompositeEvent)1 ComponentFileEditorInput (com.twinsoft.convertigo.eclipse.editors.mobile.ComponentFileEditorInput)1 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)1 DatabaseObjectFoundException (com.twinsoft.convertigo.engine.DatabaseObjectFoundException)1