use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class CreateProcess method selectRootObject.
protected final void selectRootObject(Properties params) {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == workbenchWindow) {
return;
}
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
if (null == workbenchPage) {
return;
}
IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
if (!getPerspectiveId().equals(currentPerspective.getId())) {
// show di perspective
try {
workbenchWindow.getWorkbench().showPerspective(getPerspectiveId(), workbenchWindow);
workbenchPage = workbenchWindow.getActivePage();
} catch (WorkbenchException e) {
ExceptionHandler.process(e);
return;
}
}
IRepositoryView view = RepositoryManagerHelper.getRepositoryView();
if (view != null) {
Object type = params.get("type");
if (getProcessType().name().equals(type)) {
IRepositoryNode processNode = ((ProjectRepositoryNode) view.getRoot()).getRootRepositoryNode(getProcessType());
if (processNode != null) {
setWorkbenchPart(view);
final StructuredViewer viewer = view.getViewer();
if (viewer instanceof TreeViewer) {
((TreeViewer) viewer).expandToLevel(processNode, 1);
}
viewer.setSelection(new StructuredSelection(processNode));
}
}
}
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class CreateProcess method init.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.actions.ITreeContextualAction#init(org.eclipse.jface.viewers.TreeViewer,
* org.eclipse.jface.viewers.IStructuredSelection)
*/
@Override
public void init(TreeViewer viewer, IStructuredSelection selection) {
boolean canWork = !selection.isEmpty() && selection.size() == 1;
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (factory.isUserReadOnlyOnCurrentProject()) {
canWork = false;
}
if (canWork) {
IRepositoryNode node = (IRepositoryNode) selection.getFirstElement();
switch(node.getType()) {
case SIMPLE_FOLDER:
case SYSTEM_FOLDER:
ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
if (nodeType != getProcessType()) {
canWork = false;
}
if (node.getObject() != null && node.getObject().isDeleted()) {
canWork = false;
}
break;
default:
canWork = false;
}
if (canWork && !ProjectManager.getInstance().isInCurrentMainProject(node)) {
canWork = false;
}
}
setEnabled(canWork);
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class EditProcess method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
@Override
protected void doRun() {
IRepositoryNode node = getSelectedObject();
if (node == null) {
return;
}
Property property = node.getObject().getProperty();
if (property != null) {
Assert.isTrue(property.getItem() instanceof ProcessItem);
ProcessItem processItem = (ProcessItem) property.getItem();
IWorkbenchPage page = getActivePage();
try {
final JobEditorInput fileEditorInput = getEditorInput(processItem);
checkUnLoadedNodeForProcess(fileEditorInput);
final IEditorPart editorPart = page.findEditor(fileEditorInput);
if (editorPart == null) {
fileEditorInput.setRepositoryNode(node);
page.openEditor(fileEditorInput, getEditorId(), true);
} else {
((AbstractMultiPageTalendEditor) editorPart).setReadOnly(fileEditorInput.setForceReadOnly(false));
page.activate(editorPart);
}
} catch (PartInitException e) {
MessageBoxExceptionHandler.process(e);
} catch (PersistenceException e) {
MessageBoxExceptionHandler.process(e);
}
}
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class EditProcess method getSelectedObject.
private IRepositoryNode getSelectedObject() {
if (params == null) {
ISelection selection = getSelection();
if (selection != null) {
return (IRepositoryNode) ((IStructuredSelection) selection).getFirstElement();
}
} else {
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == workbenchWindow) {
return null;
}
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
if (null == workbenchPage) {
return null;
}
IPerspectiveDescriptor currentPerspective = workbenchPage.getPerspective();
if (!getPerspectiveId().equals(currentPerspective.getId())) {
// show di perspective
try {
workbenchWindow.getWorkbench().showPerspective(getPerspectiveId(), workbenchWindow);
workbenchPage = workbenchWindow.getActivePage();
} catch (WorkbenchException e) {
ExceptionHandler.process(e);
return null;
}
}
IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(params.getProperty("nodeId"), false);
IRepositoryView viewPart = getViewPart();
if (repositoryNode != null && viewPart != null) {
RepositoryNodeUtilities.expandParentNode(viewPart, repositoryNode);
return repositoryNode;
}
}
return null;
}
use of org.talend.repository.model.IRepositoryNode in project tdi-studio-se by Talend.
the class SaveAsProcessAction method run.
@Override
public void run() {
SaveAsProcessWizard processWizard = new SaveAsProcessWizard(editorPart);
WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), processWizard);
if (dlg.open() == Window.OK) {
try {
// Set readonly to false since created job will always be editable.
JobEditorInput newJobEditorInput = new ProcessEditorInput(processWizard.getProcess(), true, true, false);
IWorkbenchPage page = getActivePage();
IRepositoryNode repositoryNode = RepositoryNodeUtilities.getRepositoryNode(newJobEditorInput.getItem().getProperty().getId(), false);
newJobEditorInput.setRepositoryNode(repositoryNode);
// close the old editor
page.closeEditor(((AbstractTalendEditor) this.editorPart).getParent(), false);
// open the new editor, because at the same time, there will update the jobSetting/componentSetting view
page.openEditor(newJobEditorInput, MultiPageTalendEditor.ID, true);
} catch (Exception e) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Error", "Job could not be saved" + " : " + e.getMessage());
ExceptionHandler.process(e);
}
}
}
Aggregations