Search in sources :

Example 31 with ERepositoryStatus

use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tmdm-studio-se by Talend.

the class OpenObjectAction method isLocked.

@Override
protected boolean isLocked() {
    List<Object> selectedObject = getSelectedObject();
    if (!selectedObject.isEmpty()) {
        Object object = selectedObject.get(0);
        if (object instanceof IRepositoryViewObject) {
            IRepositoryViewObject viewObj = (IRepositoryViewObject) object;
            ERepositoryStatus status = factory.getStatus(viewObj);
            if (status == ERepositoryStatus.LOCK_BY_USER) {
                return !status.isEditable();
            } else if (status == ERepositoryStatus.LOCK_BY_OTHER) {
                return false;
            }
        }
    }
    return false;
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MDMServerObject(org.talend.mdm.repository.model.mdmserverobject.MDMServerObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSRootRepositoryObject(org.talend.mdm.repository.models.WSRootRepositoryObject) TreeObject(com.amalto.workbench.models.TreeObject)

Example 32 with ERepositoryStatus

use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tmdm-studio-se by Talend.

the class AbstractBridgeLabelProvider method getRepositoryImage.

protected Image getRepositoryImage(IRepositoryViewObject object) {
    // Item item = property.getItem();
    ERepositoryObjectType itemType = object.getRepositoryObjectType();
    Image img = null;
    if (object instanceof RepositoryViewObject && ((RepositoryViewObject) object).getCustomImage() != null) {
        img = ((RepositoryViewObject) object).getCustomImage();
    } else {
        img = CoreImageProvider.getImage(itemType);
    }
    ERepositoryStatus repositoryStatus = object.getRepositoryStatus();
    // For offline mode,its item is locked by default but need show the default image.
    if (editableAsReadOnly) {
        if (repositoryStatus == ERepositoryStatus.LOCK_BY_USER) {
            repositoryStatus = ERepositoryStatus.DEFAULT;
        }
    }
    Image image = OverlayImageProvider.getImageWithStatus(img, repositoryStatus);
    ERepositoryStatus informationStatus = object.getInformationStatus();
    return OverlayImageProvider.getImageWithStatus(image, informationStatus);
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Image(org.eclipse.swt.graphics.Image) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 33 with ERepositoryStatus

use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tesb-studio-se by Talend.

the class OpenWSDLAction method init.

@Override
protected void init(RepositoryNode node) {
    ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
    if (!currentNodeType.equals(nodeType)) {
        return;
    }
    this.setText(createLabel);
    // IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    if (node.getType() != ENodeType.REPOSITORY_ELEMENT) {
        return;
    }
    try {
        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        factory.updateLockStatus();
        ERepositoryStatus status = factory.getStatus(node.getObject());
        if (status.isEditable() || ERepositoryStatus.DEFAULT == status) {
            setEnabled(isLastVersion(node));
        } else {
            setEnabled(false);
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 34 with ERepositoryStatus

use of org.talend.commons.runtime.model.repository.ERepositoryStatus in project tesb-studio-se by Talend.

the class PublishMetadataAction method init.

/*
     * (non-Javadoc)
     *
     * @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
     * org.eclipse.jface.viewers.IStructuredSelection)
     */
public void init(TreeViewer viewer, IStructuredSelection selection) {
    setEnabled(false);
    if (selection.size() != 1) {
        return;
    }
    RepositoryNode node = (RepositoryNode) selection.iterator().next();
    if (node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getProperties(EProperties.CONTENT_TYPE) == ESBRepositoryNodeType.SERVICES && node.getObject() != null && ProxyRepositoryFactory.getInstance().getStatus(node.getObject()) != ERepositoryStatus.DELETED) {
        serviceItem = (ServiceItem) node.getObject().getProperty().getItem();
        if (viewer != null) {
            shell = viewer.getTree().getShell();
        } else {
            shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        }
        try {
            IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            factory.updateLockStatus();
            ERepositoryStatus status = factory.getStatus(node.getObject());
            if (!status.isEditable() && !status.isPotentiallyEditable()) {
                setEnabled(false);
                return;
            }
        } catch (PersistenceException e) {
            e.printStackTrace();
        }
        setEnabled(true);
    }
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) PersistenceException(org.talend.commons.exception.PersistenceException) RepositoryNode(org.talend.repository.model.RepositoryNode) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Aggregations

ERepositoryStatus (org.talend.commons.runtime.model.repository.ERepositoryStatus)34 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)21 PersistenceException (org.talend.commons.exception.PersistenceException)14 Item (org.talend.core.model.properties.Item)12 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)12 InvocationTargetException (java.lang.reflect.InvocationTargetException)7 CoreException (org.eclipse.core.runtime.CoreException)7 LoginException (org.talend.commons.exception.LoginException)7 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)7 RepositoryNode (org.talend.repository.model.RepositoryNode)7 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)6 ProcessItem (org.talend.core.model.properties.ProcessItem)6 IOException (java.io.IOException)5 PartInitException (org.eclipse.ui.PartInitException)5 IRepositoryService (org.talend.repository.model.IRepositoryService)5 ArrayList (java.util.ArrayList)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 IProcess2 (org.talend.core.model.process.IProcess2)3