Search in sources :

Example 16 with TreeParent

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

the class DataClusterComposite method getServerRoot.

private TreeParent getServerRoot(MDMServerDef serverDef) {
    if (serverDef == null) {
        return null;
    }
    if (serverMap.containsKey(serverDef)) {
        return serverMap.get(serverDef);
    }
    String serverName = serverDef.getName();
    String username = serverDef.getUser();
    String password = serverDef.getPasswd();
    String endpointaddress = serverDef.getUrl();
    TreeParent serverRoot = new TreeParent(serverName, null, TreeObject._SERVER_, endpointaddress, username + ":" + // $NON-NLS-1$//$NON-NLS-2$
    (password == null ? "" : password));
    UserInfo user = new UserInfo();
    user.setUsername(username);
    user.setPassword(password);
    user.setServerUrl(endpointaddress);
    serverRoot.setUser(user);
    serverMap.put(serverDef, serverRoot);
    return serverRoot;
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) UserInfo(com.amalto.workbench.utils.UserInfo)

Example 17 with TreeParent

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

the class DataClusterDialog method getAllDataContainers.

private boolean getAllDataContainers(List<TreeObject> dataContainers) {
    MDMServerDef serverDef = getSelectedMdmServerDef();
    String username = serverDef.getUser();
    String password = serverDef.getPasswd();
    String serverName = serverDef.getName();
    String endpointaddress = serverDef.getUrl();
    boolean canConnect = checkConnection(endpointaddress, username, password);
    if (!canConnect) {
        MessageDialog.openError(site.getShell(), Messages.DataClusterDialog_7, Messages.DataClusterDialog_8);
        return false;
    }
    List<WSDataClusterPK> xdcPKs = null;
    try {
        TMDMService service = Util.getMDMService(new URL(endpointaddress), username, password);
        TreeParent serverRoot = new TreeParent(serverName, null, TreeObject._SERVER_, endpointaddress, username + ":" + // $NON-NLS-1$//$NON-NLS-2$
        (password == null ? "" : password));
        // $NON-NLS-1$
        xdcPKs = service.getDataClusterPKs(new WSRegexDataClusterPKs("*")).getWsDataClusterPKs();
        for (WSDataClusterPK pk : xdcPKs) {
            String name = pk.getPk();
            if (!("CACHE".equals(name))) {
                // $NON-NLS-1$
                WSDataCluster wsObject = null;
                boolean retriveWSObject = false;
                try {
                    if (retriveWSObject) {
                        wsObject = service.getDataCluster(new WSGetDataCluster(pk));
                    }
                    TreeObject obj = new TreeObject(name, serverRoot, TreeObject.DATA_CLUSTER, pk, wsObject);
                    dataContainers.add(obj);
                } catch (Exception e) {
                    log.error(e.getMessage(), e);
                }
            }
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        return false;
    }
    return true;
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) URL(java.net.URL) XtentisException(com.amalto.workbench.utils.XtentisException) MalformedURLException(java.net.MalformedURLException) WebServiceException(javax.xml.ws.WebServiceException) WSDataCluster(com.amalto.workbench.webservices.WSDataCluster) WSGetDataCluster(com.amalto.workbench.webservices.WSGetDataCluster) WSDataClusterPK(com.amalto.workbench.webservices.WSDataClusterPK) TMDMService(com.amalto.workbench.webservices.TMDMService) TreeObject(com.amalto.workbench.models.TreeObject) MDMServerDef(com.amalto.workbench.utils.MDMServerDef) WSRegexDataClusterPKs(com.amalto.workbench.webservices.WSRegexDataClusterPKs)

Example 18 with TreeParent

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

the class DataModelSelectDialog method selectDataModel.

private void selectDataModel() {
    Object input = domViewer.getInput();
    TreeObject[] elements = (TreeObject[]) contentProvider.getElements(input);
    selectDefaultDataModel(elements);
    domViewer.addTreeListener(new ITreeViewerListener() {

        public void treeExpanded(TreeExpansionEvent event) {
            TreeParent parent = (TreeParent) event.getElement();
            TreeObject[] children = parent.getChildren();
            selectDefaultDataModel(children);
        }

        public void treeCollapsed(TreeExpansionEvent event) {
        // 
        }
    });
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) ITreeViewerListener(org.eclipse.jface.viewers.ITreeViewerListener) TreeObject(com.amalto.workbench.models.TreeObject) TreeObject(com.amalto.workbench.models.TreeObject) TreeExpansionEvent(org.eclipse.jface.viewers.TreeExpansionEvent)

Example 19 with TreeParent

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

the class DataModelSelectDialog method changeToResource.

private void changeToResource() {
    TreeParent parent = null;
    // Modified by hbhong,to fix bug 21784
    TreeObject[] children = treeParent.getChildren();
    for (TreeObject element : children) {
        parent = (TreeParent) element;
        if (parent.getType() == TreeObject.DATA_MODEL) {
            break;
        }
    }
    // The ending| bug:21784
    contentProvider = new ServerTreeContentProvider(site, parent);
    setTreeContentProvider(contentProvider);
    domViewer.setLabelProvider(new ServerTreeLabelProvider());
    domViewer.setSorter(new ViewerSorter() {

        @Override
        public int category(Object element) {
            if (element instanceof TreeParent) {
                TreeParent category = (TreeParent) element;
                if (category.getType() == TreeObject.CATEGORY_FOLDER) {
                    return -1;
                }
            }
            return 0;
        }
    });
    domViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent e) {
            StructuredSelection sel = (StructuredSelection) e.getSelection();
            List<String> xpathList = new ArrayList<String>();
            Object[] selections = sel.toArray();
            for (Object obj : selections) {
                TreeObject treeObj = (TreeObject) obj;
                if (treeObj != null && treeObj.getType() == TreeObject.DATA_MODEL) {
                    xpathList.add(treeObj.getDisplayName());
                }
            }
            xpaths = xpathList.toArray(new String[0]);
            if (getButton(IDialogConstants.OK_ID) != null) {
                getButton(IDialogConstants.OK_ID).setEnabled(xpathList.size() > 0);
            }
        }
    });
    domViewer.setInput(site);
}
Also used : TreeParent(com.amalto.workbench.models.TreeParent) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ServerTreeContentProvider(com.amalto.workbench.providers.ServerTreeContentProvider) TreeObject(com.amalto.workbench.models.TreeObject) TreeObject(com.amalto.workbench.models.TreeObject) ArrayList(java.util.ArrayList) List(java.util.List) ServerTreeLabelProvider(com.amalto.workbench.providers.ServerTreeLabelProvider)

Example 20 with TreeParent

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