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);
}
}
}
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;
}
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);
}
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;
}
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);
}
}
Aggregations