Search in sources :

Example 16 with FolderRepositoryObject

use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.

the class RepositoryViewObjectCheckedWidget method getSelectedCommands.

public List<AbstractDeployCommand> getSelectedCommands() {
    List<AbstractDeployCommand> commands = new LinkedList<AbstractDeployCommand>();
    CommandManager commandManager = CommandManager.getInstance();
    for (Object obj : treeViewer.getCheckedElements()) {
        if (obj instanceof FolderRepositoryObject) {
            continue;
        }
        IRepositoryViewObject viewObject = (IRepositoryViewObject) obj;
        String id = viewObject.getId();
        AbstractDeployCommand e = cmdMap.get(id);
        if (e == null) {
            List<IRepositoryViewObject> objs = new ArrayList<IRepositoryViewObject>();
            objs.add(viewObject);
            List<AbstractDeployCommand> newCommands = commandManager.getDeployCommands(objs, ICommand.CMD_MODIFY);
            if (!newCommands.isEmpty()) {
                e = newCommands.get(0);
            }
        }
        commands.add(e);
        List<AbstractDeployCommand> associatedCommands = getAssociatedObjectCommand(viewObject, ICommand.CMD_MODIFY);
        if (associatedCommands != null) {
            commands.addAll(associatedCommands);
        }
    }
    return commands;
}
Also used : CommandManager(org.talend.mdm.repository.core.command.CommandManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ArrayList(java.util.ArrayList) AbstractDeployCommand(org.talend.mdm.repository.core.command.deploy.AbstractDeployCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) LinkedList(java.util.LinkedList) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 17 with FolderRepositoryObject

use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.

the class RepositoryViewObjectCheckedWidget method initWidget.

private void initWidget() {
    // 
    setLayout(new GridLayout());
    treeViewer = new ContainerCheckedTreeViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
    Tree tree = getTree();
    tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    installColumns();
    treeViewer.setContentProvider(new ContentProvider());
    treeViewer.getTree().addListener(SWT.PaintItem, new Listener() {

        public void handleEvent(Event event) {
            TreeItem item = (TreeItem) event.item;
            Object data = item.getData();
            if (data != null && lockedViewObjs.contains(data)) {
                String text = item.getText(event.index);
                Point point = event.gc.textExtent(text);
                int y = event.y + point.y / 2 + 2;
                int x = event.x + 20;
                event.gc.drawLine(x, y, x + point.x, y);
                event.gc.drawText(Messages.RepositoryViewObjectCheckedWidget_lock, x + point.x + 2, event.y + 2);
            }
        }
    });
    treeViewer.addCheckStateListener(new ICheckStateListener() {

        private void checkSubElement(IRepositoryViewObject viewObj) {
            if (viewObj instanceof FolderRepositoryObject) {
                Item item = viewObj.getProperty().getItem();
                List<IRepositoryViewObject> children = RepositoryResourceUtil.findViewObjects(viewObj.getRepositoryObjectType(), item, true, true);
                if (children != null) {
                    for (IRepositoryViewObject child : children) {
                        checkSubElement(child);
                    }
                }
            } else {
                if (lockedViewObjs.contains(viewObj)) {
                    treeViewer.setChecked(viewObj, false);
                }
            }
        }

        public void checkStateChanged(CheckStateChangedEvent event) {
            Object element = event.getElement();
            if (element instanceof IRepositoryViewObject) {
                checkSubElement((IRepositoryViewObject) element);
            }
        }
    });
    if (adapter != null) {
        treeViewer.addCheckStateListener(new ICheckStateListener() {

            public void checkStateChanged(CheckStateChangedEvent event) {
                updateSeverityCount();
            }
        });
    }
    treeViewer.addFilter(new ViewerFilter() {

        private boolean containVisibleElement(FolderRepositoryObject parent) {
            Item item = parent.getProperty().getItem();
            List<IRepositoryViewObject> children = RepositoryResourceUtil.findViewObjects(parent.getRepositoryObjectType(), item, true, true);
            boolean result = false;
            for (IRepositoryViewObject viewObj : children) {
                if (viewObj instanceof FolderRepositoryObject) {
                    boolean r = containVisibleElement((FolderRepositoryObject) viewObj);
                    if (r) {
                        result = true;
                    }
                } else if (viewObj instanceof IRepositoryViewObject) {
                    if (isVisibleViewObj(viewObj)) {
                        updateServerDef(viewObj);
                        // updateLockedObject(viewObj);
                        result = true;
                    }
                }
            }
            return result;
        }

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (reconciliation) {
                return true;
            } else {
                if (element instanceof FolderRepositoryObject) {
                    return containVisibleElement((FolderRepositoryObject) element);
                } else {
                    IRepositoryViewObject viewObj = (IRepositoryViewObject) element;
                    return isVisibleViewObj(viewObj);
                }
            }
        }
    });
    // show time
    final Button showTimestampBun = new Button(this, SWT.CHECK);
    showTimestampBun.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            showTimeStampColumns(showTimestampBun.getSelection());
        }
    });
    showTimestampBun.setText(Messages.ConsistencyConflict_showTimeStampColumn);
    // 
    treeViewer.setInput(input);
    selectAll(true);
    treeViewer.expandAll();
    if (adapter != null) {
        adapter.initSeverityControl(this);
    }
    updateSeverityCount();
}
Also used : ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Listener(org.eclipse.swt.widgets.Listener) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeItem(org.eclipse.swt.widgets.TreeItem) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Point(org.eclipse.swt.graphics.Point) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) TreeItem(org.eclipse.swt.widgets.TreeItem) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Tree(org.eclipse.swt.widgets.Tree) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 18 with FolderRepositoryObject

use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.

the class MDMExportRepositoryItemsWizard method recursiveExpand.

private boolean recursiveExpand(TreeItem[] items, List<IRepositoryViewObject> leafItems) {
    boolean expanda = false;
    for (TreeItem item : items) {
        IRepositoryViewObject viewObj = (IRepositoryViewObject) item.getData();
        if (leafItems.contains(viewObj)) {
            expanda = true;
            break;
        }
        if (viewObj instanceof FolderRepositoryObject) {
            boolean expand = recursiveExpand(item.getItems(), leafItems);
            item.setExpanded(expand);
            if (expand) {
                expanda = true;
            }
        }
    }
    return expanda;
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 19 with FolderRepositoryObject

use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.

the class MDMExportRepositoryItemsWizard method getCheckedViewObjects.

private void getCheckedViewObjects(IStructuredSelection sel, List<IRepositoryViewObject> leafItems, List<IRepositoryViewObject> noneLeafItems) {
    Map<String, List<IRepositoryViewObject>> viewObjTypeMap = new TreeMap<String, List<IRepositoryViewObject>>();
    Map<String, List<String>> pathMap = new HashMap<String, List<String>>();
    Map<String, ERepositoryObjectType> types = new HashMap<String, ERepositoryObjectType>();
    List<IRepositoryViewObject> seList = sel.toList();
    for (IRepositoryViewObject iRepositoryViewObject : seList) {
        IRepositoryViewObject viewObj = iRepositoryViewObject;
        ERepositoryObjectType repositoryObjectType = viewObj.getRepositoryObjectType();
        if (repositoryObjectType != null) {
            List<IRepositoryViewObject> list = viewObjTypeMap.get(repositoryObjectType.name());
            List<String> typePaths = pathMap.get(repositoryObjectType.name());
            if (list == null) {
                list = new LinkedList<IRepositoryViewObject>();
                viewObjTypeMap.put(repositoryObjectType.name(), list);
                typePaths = new LinkedList<String>();
                pathMap.put(repositoryObjectType.name(), typePaths);
                types.put(repositoryObjectType.name(), repositoryObjectType);
            }
            list.add(viewObj);
            typePaths.add(viewObj.getPath());
        }
    }
    List<IRepositoryViewObject> childs = new LinkedList<IRepositoryViewObject>();
    for (String etype : types.keySet()) {
        List<IRepositoryViewObject> viewObjectsWithDeleted = getAllViewObjectByType(types.get(etype));
        for (IRepositoryViewObject vObject : viewObjectsWithDeleted) {
            List<String> pathList = pathMap.get(etype);
            for (int i = 0; i < pathList.size(); i++) {
                if (vObject.getPath().equals(pathList.get(i))) {
                    IRepositoryViewObject vo = viewObjTypeMap.get(etype).get(i);
                    if (vo instanceof FolderRepositoryObject && !(vObject instanceof FolderRepositoryObject)) {
                        childs.add(vObject);
                        break;
                    }
                } else if (vObject.getPath().contains(pathList.get(i)) && viewObjTypeMap.get(etype).get(i) instanceof FolderRepositoryObject) {
                    childs.add(vObject);
                    break;
                }
            }
        }
    }
    childs.addAll(seList);
    for (int i = 0; i < childs.size(); i++) {
        if (childs.get(i) instanceof FolderRepositoryObject) {
            noneLeafItems.add(childs.get(i));
        } else {
            leafItems.add(childs.get(i));
        }
    }
}
Also used : HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) LinkedList(java.util.LinkedList) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Example 20 with FolderRepositoryObject

use of org.talend.mdm.repository.models.FolderRepositoryObject in project tmdm-studio-se by Talend.

the class TreeViewerListener method treeCollapsed.

@Override
public void treeCollapsed(TreeExpansionEvent event) {
    Object element = event.getElement();
    if (element instanceof FolderRepositoryObject) {
        FolderRepositoryObject fro = (FolderRepositoryObject) element;
        String path = fro.getPath();
        if (!path.isEmpty()) {
            TreeItem item = getObject(viewer.getTree(), event.getElement());
            if (item != null) {
                item.setImage(ImageProvider.getImage(ECoreImage.FOLDER_CLOSE_ICON));
            }
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Aggregations

FolderRepositoryObject (org.talend.mdm.repository.models.FolderRepositoryObject)37 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)32 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)16 ContainerItem (org.talend.mdm.repository.model.mdmproperties.ContainerItem)14 ArrayList (java.util.ArrayList)7 Item (org.talend.core.model.properties.Item)7 Property (org.talend.core.model.properties.Property)7 PersistenceException (org.talend.commons.exception.PersistenceException)6 ItemState (org.talend.core.model.properties.ItemState)6 TreeItem (org.eclipse.swt.widgets.TreeItem)5 LinkedList (java.util.LinkedList)4 Project (org.talend.core.model.general.Project)4 RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)4 IProject (org.eclipse.core.resources.IProject)3 Path (org.eclipse.core.runtime.Path)3 FolderItem (org.talend.core.model.properties.FolderItem)3 WSRootRepositoryObject (org.talend.mdm.repository.models.WSRootRepositoryObject)3 List (java.util.List)2 Matcher (java.util.regex.Matcher)2 IFolder (org.eclipse.core.resources.IFolder)2