Search in sources :

Example 1 with Filter

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

the class NgxPickerComposite 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.ngx.components.MobileSmartSource.SourceModel) MobileSmartSource(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource) JSONObject(org.codehaus.jettison.json.JSONObject) Filter(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.Filter) PartInitException(org.eclipse.ui.PartInitException) JSONException(org.codehaus.jettison.json.JSONException)

Example 2 with Filter

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

the class NgxPickerComposite method setCurrentInput.

public void setCurrentInput(Object selected, String source) {
    if (isUpdating)
        return;
    currentMC = null;
    setWidgetsEnabled(true);
    if (selected instanceof NgxComponentTreeObject) {
        UIComponent uic = null;
        if (selected instanceof NgxPageComponentTreeObject) {
            currentMC = ((NgxPageComponentTreeObject) selected).getObject();
        } else if (selected instanceof NgxUIComponentTreeObject) {
            uic = ((NgxUIComponentTreeObject) 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) {
                NgxPickerContentProvider contentProvider = (NgxPickerContentProvider) 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 : NgxUIComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject) MobileSmartSource(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource) NgxComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject) NgxPageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject) Filter(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.Filter) UIComponent(com.twinsoft.convertigo.beans.ngx.components.UIComponent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 3 with Filter

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

the class NgxPickerComposite 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.ngx.components.MobileSmartSource.SourceModel) Filter(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.Filter)

Aggregations

Filter (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.Filter)3 MobileSmartSource (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource)2 SourceModel (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceModel)2 UIComponent (com.twinsoft.convertigo.beans.ngx.components.UIComponent)1 NgxComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxComponentTreeObject)1 NgxPageComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxPageComponentTreeObject)1 NgxUIComponentTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.NgxUIComponentTreeObject)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