Search in sources :

Example 1 with TVObject

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

the class MobilePickerComposite 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.MobilePickerContentProvider.TVObject) TreeItem(org.eclipse.swt.widgets.TreeItem)

Example 2 with TVObject

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

the class MobilePickerComposite method getModelData.

// private List<String> getSourceList() {
// TVObject tvoSelected = null;
// Object selected = checkboxTreeViewer.getStructuredSelection().getFirstElement();
// if (selected != null && selected instanceof TVObject) {
// tvoSelected = (TVObject)selected;
// }
// 
// List<String> sourceList =  new ArrayList<String>();
// List<TVObject> tvoList = GenericUtils.cast(Arrays.asList(checkboxTreeViewer.getCheckedElements()));
// for (TVObject tvo : tvoList) {
// if (tvo.equals(tvoSelected)) {
// sourceList.add(0, tvo.getSource());
// }
// else {
// sourceList.add(tvo.getSource());
// }
// }
// return sourceList;
// }
private List<SourceData> getModelData() {
    TVObject tvoSelected = null;
    Object selected = checkboxTreeViewer.getStructuredSelection().getFirstElement();
    if (selected != null && selected instanceof TVObject) {
        tvoSelected = (TVObject) selected;
    }
    List<SourceData> sourceList = new ArrayList<SourceData>();
    List<TVObject> tvoList = GenericUtils.cast(Arrays.asList(checkboxTreeViewer.getCheckedElements()));
    for (TVObject tvo : tvoList) {
        SourceData sd = tvo.getSourceData();
        if (sd != null) {
            if (tvo.equals(tvoSelected)) {
                sourceList.add(0, sd);
            } else {
                sourceList.add(sd);
            }
        }
    }
    return sourceList;
}
Also used : TVObject(com.twinsoft.convertigo.eclipse.views.mobile.MobilePickerContentProvider.TVObject) ArrayList(java.util.ArrayList) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) TVObject(com.twinsoft.convertigo.eclipse.views.mobile.MobilePickerContentProvider.TVObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject) SourceData(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData)

Example 3 with TVObject

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

the class MobilePickerComposite 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) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) TVObject(com.twinsoft.convertigo.eclipse.views.mobile.MobilePickerContentProvider.TVObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject) Map(java.util.Map) HashMap(java.util.HashMap) PartInitException(org.eclipse.ui.PartInitException) JSONException(org.codehaus.jettison.json.JSONException)

Example 4 with TVObject

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

the class MobilePickerComposite 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.MobilePickerContentProvider.TVObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) TVObject(com.twinsoft.convertigo.eclipse.views.mobile.MobilePickerContentProvider.TVObject) MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) MobileObject(com.twinsoft.convertigo.beans.core.MobileObject) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject)

Example 5 with TVObject

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

the class MobilePickerComposite 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.MobilePickerContentProvider.TVObject) MobileSmartSource(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource) TreeItem(org.eclipse.swt.widgets.TreeItem) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

TVObject (com.twinsoft.convertigo.eclipse.views.mobile.MobilePickerContentProvider.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 MobileComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject)5 MobilePageComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject)5 MobileUIComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject)5 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)5 JSONObject (org.codehaus.jettison.json.JSONObject)5 MobileSmartSource (com.twinsoft.convertigo.beans.mobile.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.mobile.components.ApplicationComponent)1 IAction (com.twinsoft.convertigo.beans.mobile.components.IAction)1 SourceData (com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceData)1 MobileSmartSourceType (com.twinsoft.convertigo.beans.mobile.components.MobileSmartSourceType)1 UIActionStack (com.twinsoft.convertigo.beans.mobile.components.UIActionStack)1