Search in sources :

Example 1 with IXPathValidator

use of com.amalto.workbench.widgets.celleditor.IXPathValidator in project tmdm-studio-se by Talend.

the class ValidationRuleDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    parent.getShell().setText(this.title);
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.setLayout(new GridLayout(2, false));
    Label label = new Label(composite, SWT.NONE);
    label.setText(Messages.ValidationRuleDialog_);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
    text = new Text(composite, SWT.BORDER);
    text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, true, 1, 1));
    columns = new ComplexTableViewerColumn[] { new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "Type", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn.COMBO_STYLE, IConstants.SCHEMATRON_TYPES, 0), new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "Context XPath", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "newXPath", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "newXPath", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", ComplexTableViewerColumn.XPATH_STYLE, new String[] {}, 0), new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "Expression", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn.VALIDATIONRULE_STYLE, new String[] {}, 0), new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "Message", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn.MULTIMESSAGE_STYLE, new String[] {}, 0) };
    columns[0].setColumnWidth(70);
    columns[1].setColumnWidth(130);
    columns[2].setColumnWidth(300);
    columns[3].setColumnWidth(300);
    viewer = getNewTisTableViewer(Arrays.asList(columns), WidgetFactory.getWidgetFactory(), composite);
    Map<ComplexTableViewerColumn, IXPathValidator> validators = new HashMap<ComplexTableViewerColumn, IXPathValidator>();
    // set to "Context XPath" column the xpath validator
    validators.put(columns[1], new DefaultXPathValidator());
    viewer.setValidators(validators);
    // Modified by hhb,to fix bug 21784
    TreeParent treeParent = (TreeParent) page.getAdapter(TreeParent.class);
    viewer.setTreeParent(treeParent);
    // The ending| bug:21784
    viewer.setXpath(true);
    // viewer.setMainPage(page);
    String modelName = page.getDataModel().getName();
    viewer.setDatamodelName(modelName);
    viewer.setConceptName(conceptName);
    viewer.setContext(true);
    viewer.create();
    viewer.getViewer().setInput(parseRules());
    viewer.setHeight(110);
    viewer.setWidth(800);
    viewer.getMainComposite().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 3));
    parent.getShell().addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            XpathSelectDialog.setContext(null);
        }
    });
    return composite;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) Composite(org.eclipse.swt.widgets.Composite) HashMap(java.util.HashMap) TreeParent(com.amalto.workbench.models.TreeParent) Label(org.eclipse.swt.widgets.Label) ComplexTableViewerColumn(com.amalto.workbench.widgets.ComplexTableViewerColumn) DefaultXPathValidator(com.amalto.workbench.widgets.celleditor.DefaultXPathValidator) Text(org.eclipse.swt.widgets.Text) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IXPathValidator(com.amalto.workbench.widgets.celleditor.IXPathValidator) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData)

Example 2 with IXPathValidator

use of com.amalto.workbench.widgets.celleditor.IXPathValidator in project tmdm-studio-se by Talend.

the class FKFilterDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    parent.getShell().setText(this.title);
    dialogAreaComposite = (Composite) super.createDialogArea(parent);
    dialogAreaComposite.setLayout(new GridLayout(2, false));
    columns = new ComplexTableViewerColumn[] { new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "XPath", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "newXPath", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "newXPath", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn.XPATH_STYLE, new String[] {}, 0), new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "Operator", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    false, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn.COMBO_STYLE, IConstants.VIEW_CONDITION_OPERATORS, 0), // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    new ComplexTableViewerColumn("Value", false, "", "", "", ComplexTableViewerColumn.XPATH_STYLE, new String[] {}, 0), new // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn(// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "Predicate", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    true, // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    "", // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
    ComplexTableViewerColumn.COMBO_STYLE, IConstants.PREDICATES, 0) };
    columns[0].setColumnWidth(200);
    columns[1].setColumnWidth(140);
    columns[2].setColumnWidth(200);
    columns[3].setColumnWidth(140);
    viewer = getNewTisTableViewer(Arrays.asList(columns), WidgetFactory.getWidgetFactory(), dialogAreaComposite);
    viewer.setModelLock(lock);
    viewer.setXpath(true);
    viewer.setDatamodelName(dataModelName);
    Map<ComplexTableViewerColumn, IXPathValidator> validators = new HashMap<ComplexTableViewerColumn, IXPathValidator>();
    // set to "XPath" column the xpath validator
    validators.put(columns[0], new DefaultXPathValidator());
    viewer.setValidators(validators);
    // viewer.setMainPage(page);//TODO
    // viewer.setConceptName(conceptName);
    // viewer.setContext(true);
    // Modified by hbhong,to fix bug 21784
    TreeParent treeParent = (TreeParent) page.getAdapter(TreeParent.class);
    viewer.setTreeParent(treeParent);
    // The ending| bug:21784
    viewer.create();
    viewer.setHeight(140);
    viewer.setWidth(680);
    viewer.getMainComposite().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 3));
    parent.getShell().addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent e) {
            XpathSelectDialog.setContext(null);
        }
    });
    // init data
    parseRules();
    return dialogAreaComposite;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) GridLayout(org.eclipse.swt.layout.GridLayout) HashMap(java.util.HashMap) TreeParent(com.amalto.workbench.models.TreeParent) ComplexTableViewerColumn(com.amalto.workbench.widgets.ComplexTableViewerColumn) DefaultXPathValidator(com.amalto.workbench.widgets.celleditor.DefaultXPathValidator) GridData(org.eclipse.swt.layout.GridData) DisposeEvent(org.eclipse.swt.events.DisposeEvent) IXPathValidator(com.amalto.workbench.widgets.celleditor.IXPathValidator)

Aggregations

TreeParent (com.amalto.workbench.models.TreeParent)2 ComplexTableViewerColumn (com.amalto.workbench.widgets.ComplexTableViewerColumn)2 DefaultXPathValidator (com.amalto.workbench.widgets.celleditor.DefaultXPathValidator)2 IXPathValidator (com.amalto.workbench.widgets.celleditor.IXPathValidator)2 HashMap (java.util.HashMap)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)2 DisposeListener (org.eclipse.swt.events.DisposeListener)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1