Search in sources :

Example 1 with DiagramResourceManager

use of org.talend.designer.business.diagram.custom.actions.DiagramResourceManager in project tdi-studio-se by Talend.

the class DiagramModelService method getDiagramFileAndUpdateResource.

public IFile getDiagramFileAndUpdateResource(IWorkbenchPage page, BusinessProcessItem businessProcessItem) {
    DiagramResourceManager diagramResourceManager = new DiagramResourceManager(page, new NullProgressMonitor());
    IFile file = diagramResourceManager.createDiagramFile();
    diagramResourceManager.updateResource(businessProcessItem, file);
    return file;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) DiagramResourceManager(org.talend.designer.business.diagram.custom.actions.DiagramResourceManager)

Example 2 with DiagramResourceManager

use of org.talend.designer.business.diagram.custom.actions.DiagramResourceManager in project tdi-studio-se by Talend.

the class BusinessDiagramEditor method doSave.

@Override
public void doSave(IProgressMonitor progressMonitor) {
    if (repositoryEditorInput != null) {
        final BusinessProcessItem businessProcessItem = (BusinessProcessItem) repositoryEditorInput.getItem();
        IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
        IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
        try {
            repFactory.updateLockStatus();
            // For TDI-23825, if not lock by user try to lock again.
            boolean locked = repFactory.getStatus(businessProcessItem) == ERepositoryStatus.LOCK_BY_USER;
            if (!locked) {
                repFactory.lock(businessProcessItem);
            }
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
        ERepositoryStatus status = repFactory.getStatus(businessProcessItem);
        if (!status.equals(ERepositoryStatus.LOCK_BY_USER) && !repFactory.getRepositoryContext().isEditableAsReadOnly()) {
            MessageDialog.openWarning(getEditorSite().getShell(), //$NON-NLS-1$
            Messages.getString("BusinessDiagramEditor.canNotSaveTitle"), //$NON-NLS-1$
            Messages.getString("BusinessDiagramEditor.canNotSaveMessage"));
            return;
        }
        super.doSave(progressMonitor);
        DiagramResourceManager diagramResourceManager = new DiagramResourceManager();
        diagramResourceManager.updateFromResource(businessProcessItem, repositoryEditorInput.getFile());
        final IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
        RepositoryWorkUnit rwu = new RepositoryWorkUnit("save Business") {

            @Override
            protected void run() throws LoginException, PersistenceException {
                ProxyRepositoryFactory.getInstance().save(businessProcessItem);
            }
        };
        rwu.setAvoidUnloadResources(true);
        rwu.setAvoidSvnUpdate(true);
        factory.executeRepositoryWorkUnit(rwu);
        propertyIsDirty = false;
        firePropertyChange(IEditorPart.PROP_DIRTY);
    }
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) DiagramResourceManager(org.talend.designer.business.diagram.custom.actions.DiagramResourceManager) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) PartInitException(org.eclipse.ui.PartInitException) LoginException(org.talend.commons.exception.LoginException) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryService(org.talend.repository.model.IRepositoryService)

Aggregations

DiagramResourceManager (org.talend.designer.business.diagram.custom.actions.DiagramResourceManager)2 IFile (org.eclipse.core.resources.IFile)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 PartInitException (org.eclipse.ui.PartInitException)1 LoginException (org.talend.commons.exception.LoginException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 ERepositoryStatus (org.talend.commons.runtime.model.repository.ERepositoryStatus)1 BusinessProcessItem (org.talend.core.model.properties.BusinessProcessItem)1 RepositoryWorkUnit (org.talend.repository.RepositoryWorkUnit)1 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1 IRepositoryService (org.talend.repository.model.IRepositoryService)1