Search in sources :

Example 1 with ServerTreeLabelProvider

use of com.amalto.workbench.providers.ServerTreeLabelProvider 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 2 with ServerTreeLabelProvider

use of com.amalto.workbench.providers.ServerTreeLabelProvider in project tmdm-studio-se by Talend.

the class TreeObjectCheckTreeViewer method createTreeViewer.

@Override
protected void createTreeViewer(Composite itemComposite) {
    filteredCheckboxTree = new FilteredCheckboxTree(itemComposite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.FULL_SELECTION) {

        ContainerCheckedTreeViewer treeViewer;

        @Override
        protected CheckboxTreeViewer doCreateTreeViewer(Composite parent, int style) {
            treeViewer = new ContainerCheckedTreeViewer(parent, style);
            contentProvider = new TreeObjectContentProvider(serverRoot);
            treeViewer.setContentProvider(contentProvider);
            installColumns();
            treeViewer.setInput(serverRoot);
            return treeViewer;
        }

        private void installColumns() {
            treeViewer.getTree().setHeaderVisible(true);
            // 
            TreeViewerColumn nameColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
            nameColumn.getColumn().setWidth(320);
            nameColumn.getColumn().setText(Messages.ConsistencyConflict_name);
            nameColumn.setLabelProvider(new ServerTreeLabelProvider());
            // compare result
            TreeViewerColumn resultColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
            resultColumn.getColumn().setWidth(120);
            resultColumn.getColumn().setText(Messages.ConsistencyConflict_compareResult);
            resultColumn.setLabelProvider(new CompareResultColumnProvider());
            // 
            localTimeColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
            localTimeColumn.getColumn().setText(Messages.ConsistencyConflict_retrievalTimestamp);
            localTimeColumn.setLabelProvider(new TimeStampColumnProvider(true));
            // 
            serverTimeColumn = new TreeViewerColumn(treeViewer, SWT.NONE);
            serverTimeColumn.getColumn().setText(Messages.ConsistencyConflict_serverTimestamp);
            serverTimeColumn.setLabelProvider(new TimeStampColumnProvider(false));
            // 
            showTimeStampColumns(false);
        }

        @Override
        protected boolean isNodeCollectable(TreeItem item) {
            return false;
        }

        @Override
        protected void refreshCompleted() {
            treeViewer.expandToLevel(3);
            restoreCheckedElements();
        }
    };
    filteredCheckboxTree.getViewer().addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            TreeObject node = (TreeObject) element;
            return filterRepositoryNode(node, isOverWrite);
        }
    });
}
Also used : FilteredCheckboxTree(com.amalto.workbench.widgets.FilteredCheckboxTree) Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeItem(org.eclipse.swt.widgets.TreeItem) Viewer(org.eclipse.jface.viewers.Viewer) AbstractNodeCheckTreeViewer(org.talend.mdm.repository.ui.widgets.AbstractNodeCheckTreeViewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) TreeObject(com.amalto.workbench.models.TreeObject) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) TreeObject(com.amalto.workbench.models.TreeObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ServerTreeLabelProvider(com.amalto.workbench.providers.ServerTreeLabelProvider)

Aggregations

TreeObject (com.amalto.workbench.models.TreeObject)2 ServerTreeLabelProvider (com.amalto.workbench.providers.ServerTreeLabelProvider)2 TreeParent (com.amalto.workbench.models.TreeParent)1 ServerTreeContentProvider (com.amalto.workbench.providers.ServerTreeContentProvider)1 FilteredCheckboxTree (com.amalto.workbench.widgets.FilteredCheckboxTree)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TreeViewerColumn (org.eclipse.jface.viewers.TreeViewerColumn)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 ViewerSorter (org.eclipse.jface.viewers.ViewerSorter)1 Composite (org.eclipse.swt.widgets.Composite)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 ContainerCheckedTreeViewer (org.eclipse.ui.dialogs.ContainerCheckedTreeViewer)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 AbstractNodeCheckTreeViewer (org.talend.mdm.repository.ui.widgets.AbstractNodeCheckTreeViewer)1