Search in sources :

Example 1 with SourceModel

use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceModel 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 SourceModel

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

the class NgxPickerComposite method updateTexts.

private void updateTexts(MobileSmartSource cs) {
    if (cs != null) {
        SourceModel sm = cs.getModel();
        if (sm != null) {
            t_prefix.setText(sm.getPrefix());
            t_data.setText(sm.getData());
            t_suffix.setText(sm.getSuffix());
            t_custom.setText(sm.getCustom());
            if (sm.getUseCustom()) {
                b_custom.setSelection(true);
                b_custom.notifyListeners(SWT.Selection, null);
            }
        } else {
            // t_custom.setText(cs.getInput());
            t_custom.setText(cs.getValue(false));
            b_custom.setSelection(false);
            b_custom.notifyListeners(SWT.Selection, null);
        }
    }
}
Also used : SourceModel(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceModel)

Example 3 with SourceModel

use of com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceModel 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

SourceModel (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceModel)3 Filter (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.Filter)2 MobileSmartSource (com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource)1 JSONException (org.codehaus.jettison.json.JSONException)1 JSONObject (org.codehaus.jettison.json.JSONObject)1 PartInitException (org.eclipse.ui.PartInitException)1