Search in sources :

Example 1 with TVObject

use of com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject in project convertigo by convertigo.

the class NgxPickerComposite method initTreeSelection.

private void initTreeSelection(TreeViewer treeViewer, Object object) {
    if (treeViewer != null) {
        if (object == null) {
            TreeItem[] treeItems = treeViewer.getTree().getItems();
            if (treeItems.length > 0) {
                object = treeItems[0].getData();
            }
        }
        StructuredSelection structuredSelection = null;
        if (object != null) {
            structuredSelection = new StructuredSelection(object);
        }
        MobileSmartSource cs = MobileSmartSource.valueOf(currentSource);
        if (treeViewer.equals(checkboxTreeViewer)) {
            checkboxTreeViewer.expandAll();
            if (cs != null) {
                checkedList.clear();
                fillCheckedList(null, cs.getSources());
                if (checkedList.size() > 0) {
                    structuredSelection = new StructuredSelection(checkedList.get(0));
                }
            }
            if (checkedList.isEmpty() && structuredSelection != null) {
                checkedList.add((TVObject) structuredSelection.getFirstElement());
            }
            checkboxTreeViewer.setSelection(structuredSelection);
            updateGrayChecked();
        } else if (treeViewer.equals(modelTreeViewer)) {
            modelTreeViewer.refresh();
            if (cs != null) {
                String modelPath = cs.getModelPath();
                if (!modelPath.isEmpty()) {
                    modelTreeViewer.expandAll();
                    TVObject tvo = findModelItem(null, modelPath.replaceAll("\\?\\.", "."));
                    if (tvo != null) {
                        modelTreeViewer.collapseAll();
                        modelTreeViewer.expandToLevel(tvo, 0);
                        modelTreeViewer.setSelection(new StructuredSelection(tvo));
                    } else {
                        modelTreeViewer.collapseAll();
                        modelTreeViewer.expandToLevel(1);
                    }
                }
            }
        }
        if (cs != null) {
            if (treeViewer.equals(checkboxTreeViewer)) {
                checkedList.clear();
                fillCheckedList(null, cs.getSources());
                updateGrayChecked();
                updateTexts(cs);
            } else {
                if (lastSelected.equals(firstSelected)) {
                    updateTexts(cs);
                } else {
                    updateTexts();
                }
            }
        } else {
            updateTexts();
        }
    }
}
Also used : TVObject(com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject) MobileSmartSource(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource) TreeItem(org.eclipse.swt.widgets.TreeItem) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 2 with TVObject

use of com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject in project convertigo by convertigo.

the class NgxPickerComposite method updateModel.

private void updateModel(TVObject tvObject) {
    Object object = tvObject.getObject();
    if (object != null) {
        Thread t = new Thread(new Runnable() {

            public void run() {
                isUpdating = true;
                Display.getDefault().asyncExec(new Runnable() {

                    public void run() {
                        setWidgetsEnabled(false);
                        updateMessage("generating model...");
                    }
                });
                try {
                    Map<String, Object> data = lookupModelData(tvObject);
                    JSONObject jsonModel = getJsonModel(data, null);
                    Display.getDefault().asyncExec(new Runnable() {

                        public void run() {
                            modelTreeViewer.setInput(jsonModel);
                            initTreeSelection(modelTreeViewer, null);
                            setWidgetsEnabled(true);
                            updateMessage();
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                    Display.getDefault().asyncExec(new Runnable() {

                        public void run() {
                            setWidgetsEnabled(true);
                            updateMessage();
                        }
                    });
                } finally {
                    isUpdating = false;
                }
            }
        });
        t.start();
    } else {
        modelTreeViewer.setInput(null);
    }
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) TVObject(com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject) Map(java.util.Map) HashMap(java.util.HashMap) PartInitException(org.eclipse.ui.PartInitException) JSONException(org.codehaus.jettison.json.JSONException)

Example 3 with TVObject

use of com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject in project convertigo by convertigo.

the class NgxPickerComposite method updateGrayChecked.

private void updateGrayChecked() {
    checkboxTreeViewer.setCheckedElements(new Object[] {});
    checkboxTreeViewer.setGrayedElements(new Object[] {});
    for (TVObject tvo : checkedList) {
        checkboxTreeViewer.setParentsGrayed(tvo, true);
    }
    for (Object ob : checkboxTreeViewer.getGrayedElements()) {
        checkboxTreeViewer.setChecked(ob, true);
        if (ob instanceof TVObject && !((TVObject) ob).getSource().isEmpty()) {
            if (btnIteration.getSelection() || btnForm.getSelection() || btnGlobal.getSelection()) {
                checkboxTreeViewer.setGrayed(ob, !ob.equals(lastSelected));
            } else {
                checkboxTreeViewer.setGrayed(ob, false);
            }
        }
    }
}
Also used : TVObject(com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) TVObject(com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject)

Example 4 with TVObject

use of com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject in project convertigo by convertigo.

the class NgxPickerComposite method fillCheckedList.

private void fillCheckedList(TreeItem parent, List<String> csSourceList) {
    if (csSourceList != null && !csSourceList.isEmpty()) {
        TreeItem[] items = null;
        if (parent == null) {
            items = checkboxTreeViewer.getTree().getItems();
        } else {
            items = parent.getItems();
            TVObject tvo = (TVObject) parent.getData();
            String tvoSource = tvo.getSource();
            if (csSourceList.contains(tvoSource)) {
                int index = csSourceList.indexOf(tvoSource);
                if (index == 0)
                    checkedList.add(0, tvo);
                else
                    checkedList.add(tvo);
            }
        }
        for (int i = 0; i < items.length; i++) {
            fillCheckedList(items[i], csSourceList);
        }
    }
}
Also used : TVObject(com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject) TreeItem(org.eclipse.swt.widgets.TreeItem)

Example 5 with TVObject

use of com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject in project convertigo by convertigo.

the class NgxPickerComposite method findModelItem.

private TVObject findModelItem(TreeItem parent, String modelPath) {
    if (modelPath != null && !modelPath.isEmpty()) {
        TreeItem[] items = null;
        items = parent == null ? modelTreeViewer.getTree().getItems() : parent.getItems();
        for (int i = 0; i < items.length; i++) {
            TreeItem treeItem = items[i];
            TVObject tvo = (TVObject) treeItem.getData();
            if (tvo != null) {
                String tvoPath = tvo.getPath().replaceAll("\\?\\.", ".");
                if (modelPath.startsWith(tvoPath.replaceFirst("root", ""))) {
                    if (modelPath.equals(tvoPath.replaceFirst("root", ""))) {
                        return tvo;
                    }
                    return findModelItem(items[i], modelPath);
                }
            }
        }
    }
    return null;
}
Also used : TVObject(com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject) TreeItem(org.eclipse.swt.widgets.TreeItem)

Aggregations

TVObject (com.twinsoft.convertigo.eclipse.views.mobile.NgxPickerContentProvider.TVObject)9 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)5 MobileObject (com.twinsoft.convertigo.beans.core.MobileObject)5 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)5 NgxComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject)5 NgxPageComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject)5 NgxUIComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject)5 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)5 JSONObject (org.codehaus.jettison.json.JSONObject)5 MobileSmartSource (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource)3 JSONException (org.codehaus.jettison.json.JSONException)3 TreeItem (org.eclipse.swt.widgets.TreeItem)3 PartInitException (org.eclipse.ui.PartInitException)3 HashMap (java.util.HashMap)2 DesignDocument (com.twinsoft.convertigo.beans.couchdb.DesignDocument)1 ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)1 IAction (com.twinsoft.convertigo.beans.ngx.components.IAction)1 SourceData (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData)1 MobileSmartSourceType (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType)1 UIActionStack (com.twinsoft.convertigo.beans.ngx.components.UIActionStack)1