Search in sources :

Example 56 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.

the class MetadataDbConnectionsContentProvider method refreshTopLevelNode.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.repository.viewer.content.FolderListenerSingleTopContentProvider#refreshTopLevelNode(org.talend.repository
     * .model.RepositoryNode)
     */
@Override
protected void refreshTopLevelNode(RepositoryNode repoNode) {
    super.refreshTopLevelNode(repoNode);
    // Make sure the linked Hadoop Cluster to do refresh synchronously
    //$NON-NLS-1$
    ERepositoryObjectType hcType = ERepositoryObjectType.valueOf("HADOOPCLUSTER");
    if (hcType != null) {
        IRepositoryNode hcRootNode = repoNode.getRoot().getRootRepositoryNode(hcType);
        if (hcRootNode != null && hcRootNode instanceof RepositoryNode) {
            super.refreshTopLevelNode((RepositoryNode) hcRootNode);
        }
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 57 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.

the class OpenAnotherVersionResrouceWizard method performFinish.

@Override
public boolean performFinish() {
    if (mainPage.isCreateNewVersionJob()) {
        IWorkspaceRunnable runnable = new IWorkspaceRunnable() {

            public void run(final IProgressMonitor monitor) throws CoreException {
                if (!alreadyEditedByUser) {
                    getProperty().setVersion(mainPage.getNewVersion());
                    refreshNewJob();
                    try {
                        ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
                    } catch (PersistenceException e) {
                        ExceptionHandler.process(e);
                    }
                }
                try {
                    ProxyRepositoryFactory.getInstance().lock(repoObject);
                } catch (PersistenceException | LoginException e) {
                    ExceptionHandler.process(e);
                }
                //					boolean locked = repoObject.getRepositoryStatus().equals(
                //							ERepositoryStatus.LOCK_BY_USER);
                openAnotherVersion((IRepositoryNode) repoObject.getRepositoryNode());
                try {
                    ProxyRepositoryFactory.getInstance().saveProject(ProjectManager.getInstance().getCurrentProject());
                } catch (PersistenceException e) {
                    ExceptionHandler.process(e);
                }
            }
        };
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        try {
            ISchedulingRule schedulingRule = workspace.getRoot();
            // the update the project files need to be done in the workspace
            // runnable to avoid all notification
            // of changes before the end of the modifications.
            workspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, null);
        } catch (CoreException e) {
            MessageBoxExceptionHandler.process(e);
        }
    } else {
        StructuredSelection selection = (StructuredSelection) mainPage.getSelection();
        IRepositoryNode node = (IRepositoryNode) selection.getFirstElement();
        boolean lastVersion = node.getObject().getVersion().equals(repoObject.getVersion());
        repoObject.getProperty().setVersion(originalVersion);
        if (lastVersion) {
            lockObject(repoObject);
        }
        //			ERepositoryStatus status = node.getObject().getRepositoryStatus();
        //			boolean isLocked = false;
        //			if (status == ERepositoryStatus.LOCK_BY_USER) {
        //				isLocked = true;
        //			}
        // Only latest version can be editted
        openAnotherVersion(node);
    }
    return true;
}
Also used : IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IWorkspace(org.eclipse.core.resources.IWorkspace) PersistenceException(org.talend.commons.exception.PersistenceException) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) LoginException(org.talend.commons.exception.LoginException) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Example 58 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.

the class EditRouteResourcePropertiesAction method init.

public void init(TreeViewer viewer, IStructuredSelection selection) {
    boolean canWork = selection.size() == 1;
    if (canWork) {
        Object o = ((IStructuredSelection) selection).getFirstElement();
        if (o instanceof IRepositoryNode) {
            final IRepositoryNode node = (IRepositoryNode) o;
            canWork = node.getType() == ENodeType.REPOSITORY_ELEMENT && node.getObjectType() == CamelRepositoryNodeType.repositoryRouteResourceType && node.getObject().getRepositoryStatus() != ERepositoryStatus.DELETED && isLastVersion(node);
        }
    }
    setEnabled(canWork);
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 59 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.

the class CamelFeatureUtil method getJobProjectName.

private static String getJobProjectName(String jobId, String jobName, String defaultProject) {
    if (jobId == null || jobId.isEmpty()) {
        return defaultProject;
    }
    if (jobName == null || jobName.isEmpty()) {
        return defaultProject;
    }
    IRepositoryNode referencedJobNode = null;
    Project referenceProject = null;
    try {
        List<Project> projects = ProjectManager.getInstance().getAllReferencedProjects();
        if (projects == null) {
            return defaultProject;
        }
        for (Project p : projects) {
            List<IRepositoryViewObject> jobs = ProxyRepositoryFactory.getInstance().getAll(p, ERepositoryObjectType.PROCESS);
            if (jobs == null) {
                continue;
            }
            for (IRepositoryViewObject job : jobs) {
                if (job.getId().equals(jobId)) {
                    referencedJobNode = new RepositoryNode(job, null, IRepositoryNode.ENodeType.REPOSITORY_ELEMENT);
                    referenceProject = p;
                    break;
                }
            }
            if (referenceProject != null) {
                break;
            }
        }
    } catch (PersistenceException e) {
        return defaultProject;
    }
    if (referencedJobNode == null) {
        return defaultProject;
    }
    Property p = referencedJobNode.getObject().getProperty();
    String jobNameFound = p.getDisplayName();
    String jobLabelFound = p.getLabel();
    if ((jobNameFound == null || !jobNameFound.equals(jobName)) && (jobLabelFound == null || !jobNameFound.equals(jobName))) {
        return defaultProject;
    }
    if (referenceProject != null) {
        return referenceProject.getLabel().toLowerCase();
    }
    return defaultProject;
}
Also used : Project(org.talend.core.model.general.Project) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Property(org.talend.core.model.properties.Property)

Example 60 with IRepositoryNode

use of org.talend.repository.model.IRepositoryNode in project tesb-studio-se by Talend.

the class CreateRouteResourceAction method doRun.

@Override
protected void doRun() {
    IRepositoryNode node = null;
    NewRouteResourceWizard wizard = null;
    ISelection selection = getSelection();
    if (selection == null) {
        return;
    }
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    node = (IRepositoryNode) obj;
    IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
    IPath path = service.getRepositoryPath(node);
    if (RepositoryConstants.isSystemFolder(path.toString())) {
        // Not allowed to create in system folder.
        return;
    }
    wizard = new NewRouteResourceWizard(path);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
    int open = dlg.open();
    if (open == Window.OK) {
        RouteResourceItem item = wizard.getItem();
        IWorkbenchPage page = getActivePage();
        RouteResourceEditorUtil.openEditor(page, null, item);
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) IPath(org.eclipse.core.runtime.IPath) RouteResourceItem(org.talend.camel.core.model.camelProperties.RouteResourceItem) ISelection(org.eclipse.jface.viewers.ISelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NewRouteResourceWizard(org.talend.designer.camel.resource.ui.wizards.NewRouteResourceWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IRepositoryService(org.talend.repository.model.IRepositoryService)

Aggregations

IRepositoryNode (org.talend.repository.model.IRepositoryNode)73 RepositoryNode (org.talend.repository.model.RepositoryNode)24 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)21 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)13 PersistenceException (org.talend.commons.exception.PersistenceException)13 ArrayList (java.util.ArrayList)12 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)12 WizardDialog (org.eclipse.jface.wizard.WizardDialog)10 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)8 IEditorPart (org.eclipse.ui.IEditorPart)8 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)8 ISelection (org.eclipse.jface.viewers.ISelection)6 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)6 ProcessItem (org.talend.core.model.properties.ProcessItem)6 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)6 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)6 IRepositoryView (org.talend.repository.ui.views.IRepositoryView)6 IPath (org.eclipse.core.runtime.IPath)5 PartInitException (org.eclipse.ui.PartInitException)5 Item (org.talend.core.model.properties.Item)5