Search in sources :

Example 1 with TreeParent

use of com.amalto.workbench.models.TreeParent 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 TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class Util method getRevision.

public static String getRevision(TreeObject xobject) {
    // $NON-NLS-1$
    String revision = "";
    if (xobject.getType() != TreeObject.DATA_CLUSTER) {
        TreeParent parent = xobject.findServerFolder(xobject.getType());
        if (parent != null) {
            // $NON-NLS-1$
            Pattern p = Pattern.compile("\\[.*\\]");
            Matcher m = p.matcher(parent.getDisplayName());
            while (m.find()) {
                revision = m.group();
                break;
            }
        }
    }
    return revision;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) TreeParent(com.amalto.workbench.models.TreeParent)

Example 3 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class Util method getForeingKeyInDataModel.

/**
 * set the list with all the foreign concepty name in the parent
 *
 * @author ymli
 * @param list
 * @param parent
 * @throws Exception
 */
public static void getForeingKeyInDataModel(Set<String> list, TreeParent parent, TMDMService service) throws Exception {
    TreeObject[] children = parent.getChildren();
    for (TreeObject object : children) {
        if (object instanceof TreeParent) {
            getForeingKeyInDataModel(list, (TreeParent) object, service);
            continue;
        }
        WSDataModel wsDataModel = service.getDataModel(new WSGetDataModel(new WSDataModelPK(object.getDisplayName())));
        XSDSchema xsd = Util.createXsdSchema(wsDataModel.getXsdSchema(), object);
        getForeingKeyInSchema(list, xsd);
    }
}
Also used : WSDataModel(com.amalto.workbench.webservices.WSDataModel) TreeParent(com.amalto.workbench.models.TreeParent) TreeObject(com.amalto.workbench.models.TreeObject) WSGetDataModel(com.amalto.workbench.webservices.WSGetDataModel) WSDataModelPK(com.amalto.workbench.webservices.WSDataModelPK) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 4 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class Util method getCachedXObjectsNameSet.

/**
 * @deprecated using getChildren(TreeParent xObject,int objectType)
 * @param xObject
 * @param objectType
 * @return
 */
@Deprecated
public static List<String> getCachedXObjectsNameSet(TreeObject xObject, int objectType) {
    List<String> xObjectsNameSet = new ArrayList<String>();
    if (xObject != null) {
        TreeParent treeNode = xObject.findServerFolder(objectType);
        TreeObject[] xObjectsSet = treeNode.getChildren();
        for (TreeObject element : xObjectsSet) {
            xObject = element;
            String xObjectName = xObject.getDisplayName();
            xObjectsNameSet.add(xObjectName);
        }
    }
    return xObjectsNameSet;
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) ArrayList(java.util.ArrayList) TreeObject(com.amalto.workbench.models.TreeObject)

Example 5 with TreeParent

use of com.amalto.workbench.models.TreeParent in project tmdm-studio-se by Talend.

the class Util method getChildren.

public static List<String> getChildren(TreeParent xObject, int objectType) {
    List<String> objs = new ArrayList<String>();
    for (TreeObject obj : xObject.getChildren()) {
        if (obj instanceof TreeParent) {
            TreeParent parent = (TreeParent) obj;
            objs.addAll(getChildren(parent, objectType));
        } else {
            if (obj.getType() == objectType) {
                objs.add(obj.getDisplayName());
            }
        }
    }
    return objs;
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) ArrayList(java.util.ArrayList) TreeObject(com.amalto.workbench.models.TreeObject)

Aggregations

TreeParent (com.amalto.workbench.models.TreeParent)38 TreeObject (com.amalto.workbench.models.TreeObject)21 Document (org.dom4j.Document)7 Element (org.dom4j.Element)7 GridData (org.eclipse.swt.layout.GridData)7 UserInfo (com.amalto.workbench.utils.UserInfo)6 ArrayList (java.util.ArrayList)6 GridLayout (org.eclipse.swt.layout.GridLayout)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 Composite (org.eclipse.swt.widgets.Composite)5 WSDataClusterPK (com.amalto.workbench.webservices.WSDataClusterPK)4 HashMap (java.util.HashMap)4 SelectionListener (org.eclipse.swt.events.SelectionListener)4 Combo (org.eclipse.swt.widgets.Combo)4 Label (org.eclipse.swt.widgets.Label)4 XtentisException (com.amalto.workbench.utils.XtentisException)3 WSDataModel (com.amalto.workbench.webservices.WSDataModel)3 WSDataModelPK (com.amalto.workbench.webservices.WSDataModelPK)3 WSGetDataModel (com.amalto.workbench.webservices.WSGetDataModel)3 ModifyEvent (org.eclipse.swt.events.ModifyEvent)3