Search in sources :

Example 1 with Filter

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

the class MobilePickerComposite method setCurrentInput.

public void setCurrentInput(Object selected, String source) {
    if (isUpdating)
        return;
    currentMC = null;
    setWidgetsEnabled(true);
    if (selected instanceof MobileComponentTreeObject) {
        UIComponent uic = null;
        if (selected instanceof MobilePageComponentTreeObject) {
            currentMC = ((MobilePageComponentTreeObject) selected).getObject();
        } else if (selected instanceof MobileUIComponentTreeObject) {
            uic = ((MobileUIComponentTreeObject) selected).getObject();
            // currentMC = uic.getPage() != null ? uic.getPage() : (uic.getMenu() != null ?  uic.getMenu() : uic.getApplication());
            currentMC = currentMC == null ? uic.getPage() : currentMC;
            currentMC = currentMC == null ? uic.getMenu() : currentMC;
            currentMC = currentMC == null ? uic.getSharedAction() : currentMC;
            currentMC = currentMC == null ? uic.getSharedComponent() : currentMC;
            currentMC = currentMC == null ? uic.getApplication() : currentMC;
        }
        if (currentMC == null) {
            resetViewers();
        } else {
            if (!currentMC.equals(checkboxTreeViewer.getInput())) {
                resetViewers();
                checkboxTreeViewer.setInput(currentMC);
                initTreeSelection(checkboxTreeViewer, null);
            }
            MobileSmartSource cs = MobileSmartSource.valueOf(source);
            if (cs != null) {
                MobilePickerContentProvider contentProvider = (MobilePickerContentProvider) checkboxTreeViewer.getContentProvider();
                if (isParentDialog) {
                    // when dbo's property edition
                    contentProvider.setSelectedDbo(uic);
                }
                ToolItem buttonToSelect = btnSequence;
                currentSource = source;
                Filter filter = cs.getFilter();
                if (Filter.Sequence.equals(filter)) {
                    buttonToSelect = btnSequence;
                }
                if (Filter.Database.equals(filter)) {
                    buttonToSelect = btnDatabase;
                }
                if (Filter.Action.equals(filter)) {
                    buttonToSelect = btnAction;
                }
                if (Filter.Shared.equals(filter)) {
                    buttonToSelect = btnShared;
                }
                if (Filter.Iteration.equals(filter)) {
                    buttonToSelect = btnIteration;
                }
                if (Filter.Form.equals(filter)) {
                    buttonToSelect = btnForm;
                }
                if (Filter.Global.equals(filter)) {
                    buttonToSelect = btnGlobal;
                }
                buttonToSelect.notifyListeners(SWT.Selection, null);
            }
        }
        updateMessage();
    } else {
        resetViewers();
        updateMessage();
    }
}
Also used : MobileUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) MobileSmartSource(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource) Filter(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.Filter) UIComponent(com.twinsoft.convertigo.beans.mobile.components.UIComponent) MobileComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 2 with Filter

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

the class MobilePickerComposite method updateTexts.

// private void updateText() {
// boolean isDirective = btnIteration.getSelection();
// boolean isForm = btnForm.getSelection();
// boolean isGlobal = btnGlobal.getSelection();
// List<String> sourceData = getSourceList();
// int size = sourceData.size();
// 
// StringBuffer buf = new StringBuffer();
// if ((isDirective || isForm || isGlobal) && size > 0) {
// String data = sourceData.get(0);
// if (!data.isEmpty()) {
// buf.append(data);
// }
// }
// else {
// for (String data : sourceData) {
// if (!data.isEmpty()) {
// buf.append(buf.length() > 0 ? ", ":"").append(data);
// }
// }
// }
// 
// String path = getModelPath();
// String searchPath = "root";
// int index = path.indexOf(searchPath);
// if (index != -1) {
// path = path.substring(index + searchPath.length());
// }
// 
// String computedText = buf.length() > 0 ? (isDirective || isForm || isGlobal ? buf + path : "listen(["+ buf +"])" + path):"";
// t_data.setText(computedText);
// }
// private void updateText(String s) {
// t_custom.setText(s);
// }
private void updateTexts() {
    Filter filter = getFilter();
    String path = getModelPath();
    String searchPath = "root";
    int index = path.indexOf(searchPath);
    if (index != -1) {
        path = path.substring(index + searchPath.length());
    }
    SourceModel model = MobileSmartSource.emptyModel(filter);
    model.setSourceData(getModelData());
    model.setPath(path);
    t_data.setText(model.computeValue());
}
Also used : SourceModel(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceModel) Filter(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.Filter)

Example 3 with Filter

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

the class MobilePickerComposite method getSmartSourceString.

public String getSmartSourceString() {
    try {
        Filter filter = getFilter();
        String projectName = currentMC.getProject().getName();
        MobileSmartSource cmss = MobileSmartSource.valueOf(currentSource);
        String input = cmss == null ? "" : cmss.getInput();
        String path = getModelPath();
        String searchPath = "root";
        int index = path.indexOf(searchPath);
        if (index != -1) {
            path = path.substring(index + searchPath.length());
        }
        SourceModel model = MobileSmartSource.emptyModel(filter);
        model.setCustom(t_custom.getText());
        model.setPrefix(t_prefix.getText());
        model.setSuffix(t_suffix.getText());
        model.setUseCustom(b_custom.getSelection());
        model.setSourceData(getModelData());
        model.setPath(path);
        JSONObject jsonModel = model.toJson();
        // System.out.println(jsonModel.toString(1));
        MobileSmartSource nmss = new MobileSmartSource(filter, projectName, input, jsonModel);
        // System.out.println(nmss.toJsonString(1));
        return nmss.toJsonString();
    } catch (Exception e) {
        return "";
    }
}
Also used : SourceModel(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceModel) MobileSmartSource(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource) JSONObject(org.codehaus.jettison.json.JSONObject) Filter(com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.Filter) PartInitException(org.eclipse.ui.PartInitException) JSONException(org.codehaus.jettison.json.JSONException)

Aggregations

Filter (com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.Filter)3 MobileSmartSource (com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource)2 SourceModel (com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.SourceModel)2 UIComponent (com.twinsoft.convertigo.beans.mobile.components.UIComponent)1 MobileComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileComponentTreeObject)1 MobilePageComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject)1 MobileUIComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobileUIComponentTreeObject)1 JSONException (org.codehaus.jettison.json.JSONException)1 JSONObject (org.codehaus.jettison.json.JSONObject)1 ToolItem (org.eclipse.swt.widgets.ToolItem)1 PartInitException (org.eclipse.ui.PartInitException)1