Search in sources :

Example 6 with FolderRepositoryObject

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

the class NewDataModelAction method run.

public void run(IIntroSite site, Properties params) {
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (factory.isUserReadOnlyOnCurrentProject()) {
        MessageDialog.openWarning(null, Messages.NewDataModelAction_UserAuthority, Messages.NewDataModelAction_CanNotCreateModel);
    } else {
        PlatformUI.getWorkbench().getIntroManager().closeIntro(PlatformUI.getWorkbench().getIntroManager().getIntro());
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (null == workbenchWindow) {
            return;
        }
        IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
        if (null == workbenchPage) {
            return;
        }
        IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
        if (!IBrandingConfiguration.PERSPECTIVE_MDM_ID.equals(currentPerspective.getId())) {
            // show mdm perspective
            try {
                workbenchWindow.getWorkbench().showPerspective(IBrandingConfiguration.PERSPECTIVE_MDM_ID, workbenchWindow);
                workbenchPage = workbenchWindow.getActivePage();
            } catch (WorkbenchException e) {
                ExceptionHandler.process(e);
                return;
            }
        }
        // 
        // $NON-NLS-1$
        IRepositoryViewObject folderViewObj = ContainerCacheService.get(IServerObjectRepositoryType.TYPE_DATAMODEL, "");
        selectObj = folderViewObj;
        if (folderViewObj != null && folderViewObj instanceof FolderRepositoryObject) {
            Item pItem = folderViewObj.getProperty().getItem();
            if (pItem instanceof ContainerItem) {
                setParentItem((ContainerItem) pItem);
            }
        }
        run();
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) WSDataModelItem(org.talend.mdm.repository.model.mdmproperties.WSDataModelItem) Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPerspectiveDescriptor(org.eclipse.ui.IPerspectiveDescriptor) WorkbenchException(org.eclipse.ui.WorkbenchException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 7 with FolderRepositoryObject

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

the class CopyAction method doRun.

protected void doRun() {
    ITreeSelection selection = (ITreeSelection) getStructuredSelection();
    List<TreePath> paths = new ArrayList<TreePath>(selection.getPaths().length);
    for (TreePath path : selection.getPaths()) {
        Object lastObj = path.getLastSegment();
        if (lastObj instanceof WSRootRepositoryObject) {
            continue;
        }
        if (lastObj instanceof FolderRepositoryObject) {
            continue;
        }
        paths.add(path);
    }
    selection = new TreeSelection(paths.toArray(new TreePath[] {}));
    LocalSelectionTransfer.getTransfer().setSelection(selection);
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) TreePath(org.eclipse.jface.viewers.TreePath) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ArrayList(java.util.ArrayList) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 8 with FolderRepositoryObject

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

the class CreateFolderAction method doRun.

@Override
protected void doRun() {
    Object object = getSelectedObject().get(0);
    if (object != null && object instanceof FolderRepositoryObject) {
        final FolderRepositoryObject containerViewObject = (FolderRepositoryObject) object;
        InputDialog dlg = new InputDialog(getShell(), Messages.CreateFolderAction_newCategory, Messages.CreateFolderAction_inputCategoryName, null, new IInputValidator() {

            public String isValid(String newText) {
                if ((newText == null) || "".equals(newText)) {
                    return Messages.Common_nameCanNotBeEmpty;
                }
                // $NON-NLS-1$
                Pattern p = Pattern.compile("([\\s*|\\W*]+)");
                Matcher m = p.matcher(newText);
                if (m.find()) {
                    m.group(1);
                    return Messages.Common_nameInvalid;
                }
                if (RepositoryResourceUtil.isDeletedFolder(containerViewObject.getRepositoryObjectType(), containerViewObject, newText)) {
                    return Messages.Common_nameIsUsed;
                }
                for (IRepositoryViewObject viewObj : containerViewObject.getChildren()) {
                    Item item = viewObj.getProperty().getItem();
                    if (item instanceof ContainerItem) {
                        if (((ContainerItem) item).getLabel().equals(newText)) {
                            return Messages.CreateFolderAction_nameIsUsed;
                        }
                    }
                }
                return null;
            }
        });
        dlg.setBlockOnOpen(true);
        if (dlg.open() == Window.CANCEL) {
            return;
        }
        String categoryName = dlg.getValue();
        // 
        if (categoryName != null) {
            IRepositoryViewObject folderViewObject = RepositoryResourceUtil.createFolderViewObject(containerViewObject.getRepositoryObjectType(), categoryName, containerViewObject.getProperty().getItem(), false);
            containerViewObject.getChildren().add(folderViewObject);
            commonViewer.refresh(containerViewObject);
            commonViewer.expandToLevel(containerViewObject, 1);
        }
    }
}
Also used : Pattern(java.util.regex.Pattern) Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) InputDialog(org.eclipse.jface.dialogs.InputDialog) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) Matcher(java.util.regex.Matcher) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 9 with FolderRepositoryObject

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

the class ContainerCacheService method removeContainer.

public static void removeContainer(ERepositoryObjectType repObjType, String path) {
    Map<String, IRepositoryViewObject> map = containerMap.get(repObjType);
    if (map != null) {
        for (Iterator<String> il = map.keySet().iterator(); il.hasNext(); ) {
            String next = il.next();
            if (next.startsWith(path)) {
                IRepositoryViewObject viewObj = map.get(next);
                if (viewObj != null && viewObj instanceof FolderRepositoryObject) {
                    if (viewObj.getChildren() != null) {
                        for (IRepositoryViewObject child : viewObj.getChildren()) {
                            remove(child.getProperty());
                        }
                    }
                }
                il.remove();
            }
        }
    }
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject)

Example 10 with FolderRepositoryObject

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

the class RepositoryResourceUtil method assertViewObject.

public static IRepositoryViewObject assertViewObject(IRepositoryViewObject viewObj) {
    if (viewObj == null) {
        throw new IllegalArgumentException();
    }
    if (viewObj instanceof IRepositoryViewObject && !(viewObj instanceof FolderRepositoryObject || viewObj instanceof WSRootRepositoryObject) && viewObj instanceof RepositoryObject) {
        boolean reload = false;
        Property property = viewObj.getProperty();
        if (property != null) {
            Item item = property.getItem();
            Resource eResource = item.eResource();
            reload = eResource == null || eResource.getResourceSet() == null;
        } else {
            reload = true;
        }
        if (reload) {
            IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
            try {
                IRepositoryViewObject newViewObj = factory.getLastVersion(viewObj.getId());
                property = viewObj.getProperty();
                if (property != null) {
                    Item item = property.getItem();
                    Resource eResource = item.eResource();
                    reload = eResource == null || eResource.getResourceSet() == null;
                    if (reload) {
                        if (property.eResource() != null && property.eResource().getURI() != null) {
                            property = factory.reload(property);
                            newViewObj = new RepositoryViewObject(property);
                        } else {
                            log.error(// $NON-NLS-1$
                            "Can not reload property " + property.getLabel() + // $NON-NLS-1$
                            ", because property.eResource is null or eResource.getURI is null");
                        }
                    }
                }
                if (newViewObj != null) {
                    ContainerCacheService.put(newViewObj);
                    return newViewObj;
                }
            } catch (PersistenceException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
    return viewObj;
}
Also used : ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) WorkspaceRootItem(org.talend.mdm.repository.model.mdmproperties.WorkspaceRootItem) Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) MDMServerObjectItem(org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem) RepositoryObject(org.talend.core.model.repository.RepositoryObject) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Resource(org.eclipse.emf.ecore.resource.Resource) IResource(org.eclipse.core.resources.IResource) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) FolderRepositoryObject(org.talend.mdm.repository.models.FolderRepositoryObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

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