use of org.eclipse.ui.IEditorReference in project tdi-studio-se by Talend.
the class ProblemsView method selectInDesigner.
private void selectInDesigner(BasicJobInfo jobInfo, String nodeName) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editorParts = page.getEditorReferences();
for (IEditorReference reference : editorParts) {
IEditorPart editor = reference.getEditor(false);
if (editor instanceof AbstractMultiPageTalendEditor) {
AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) editor;
if (mpte.getTalendEditor().getProcess().getId().equals(jobInfo.getJobId()) && mpte.getTalendEditor().getProcess().getVersion().equals(jobInfo.getJobVersion())) {
page.bringToTop(mpte);
mpte.selectNode(nodeName);
}
}
}
}
use of org.eclipse.ui.IEditorReference in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method updateRunJobContext.
protected void updateRunJobContext() {
final JobContextManager manager = (JobContextManager) getProcess().getContextManager();
if (manager.isModified()) {
final Map<String, String> nameMap = manager.getNameMap();
// gcui:add a progressDialog.
Shell shell = null;
Display display = PlatformUI.getWorkbench().getDisplay();
if (display != null) {
shell = display.getActiveShell();
}
if (shell == null) {
display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
}
if (display != null) {
shell = display.getActiveShell();
}
}
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(shell);
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) {
//$NON-NLS-1$
monitor.beginTask(Messages.getString("AbstractMultiPageTalendEditor_pleaseWait"), IProgressMonitor.UNKNOWN);
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
factory.executeRepositoryWorkUnit(new //$NON-NLS-1$
RepositoryWorkUnit<Object>(//$NON-NLS-1$
"..", //$NON-NLS-1$
this) {
@Override
protected void run() throws LoginException, PersistenceException {
try {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
Set<String> curContextVars = getCurrentContextVariables(manager);
IProcess2 process2 = getProcess();
String jobId = process2.getProperty().getId();
IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
List<IProcess2> processes = CorePlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
// gcui:if nameMap is empty it do nothing.
if (!nameMap.isEmpty()) {
UpdateRunJobComponentContextHelper.updateItemRunJobComponentReference(factory, nameMap, jobId, curContextVars);
UpdateRunJobComponentContextHelper.updateOpenedJobRunJobComponentReference(processes, nameMap, jobId, curContextVars);
}
// add for bug 9564
List<IRepositoryViewObject> all = factory.getAll(ERepositoryObjectType.PROCESS, true);
List<ProcessItem> allProcess = new ArrayList<ProcessItem>();
for (IRepositoryViewObject repositoryObject : all) {
Item item = repositoryObject.getProperty().getItem();
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
allProcess.add(processItem);
}
}
UpdateRunJobComponentContextHelper.updateRefJobRunJobComponentContext(factory, allProcess, process2);
} catch (PersistenceException e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
manager.setModified(false);
}
});
}
});
monitor.done();
if (monitor.isCanceled()) {
try {
//$NON-NLS-1$
throw new InterruptedException("Save Fail");
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
}
};
try {
progressDialog.run(true, true, runnable);
} catch (InvocationTargetException e1) {
ExceptionHandler.process(e1);
} catch (InterruptedException e1) {
ExceptionHandler.process(e1);
}
}
}
use of org.eclipse.ui.IEditorReference in project tdi-studio-se by Talend.
the class ActiveProcessTracker method partOpened.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
*/
@Override
public void partOpened(IWorkbenchPart part) {
boolean existedJobOpened = false;
if (part instanceof AbstractMultiPageTalendEditor) {
AbstractMultiPageTalendEditor mpte = (AbstractMultiPageTalendEditor) part;
if (mpte.isJobAlreadyOpened()) {
mpte.updateChildrens();
// close the first editor and keep the new one. (so only one will remain)
IEditorReference[] ref = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findEditors(mpte.getEditorInput(), mpte.getEditorId(), IWorkbenchPage.MATCH_INPUT);
IEditorPart editorPart = ref[0].getEditor(false);
editorPart.doSave(new NullProgressMonitor());
((AbstractMultiPageTalendEditor) editorPart).setKeepPropertyLocked(true);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeEditor(editorPart, false);
existedJobOpened = true;
}
} else {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDiagramModelService.class)) {
CorePlugin.getDefault().getDiagramModelService().handleNewEditorAction(part);
}
}
IProcess2 process = getJobFromActivatedEditor(part);
if (part instanceof AbstractMultiPageTalendEditor && process instanceof Process) {
((Process) process).setEditor((AbstractMultiPageTalendEditor) part);
}
if (process != null && currentProcess != process && lastProcessOpened != process) {
lastProcessOpened = process;
addJobInProblemView(process);
} else if (existedJobOpened) {
currentProcess = process;
for (IJobTrackerListener listener : jobTrackerListeners) {
listener.focusOnJob(process);
}
}
}
use of org.eclipse.ui.IEditorReference in project tdi-studio-se by Talend.
the class EditPropertiesAction method getCorrespondingEditor.
/**
* Find the editor that is related to the node.
*
* @param node
* @return
*/
protected IEditorPart getCorrespondingEditor(final IRepositoryNode node) {
IEditorReference[] eidtors = getActivePage().getEditorReferences();
for (IEditorReference eidtor : eidtors) {
try {
IEditorInput input = eidtor.getEditorInput();
if (!(input instanceof RepositoryEditorInput)) {
continue;
}
RepositoryEditorInput repositoryInput = (RepositoryEditorInput) input;
if (node.getId() != null && node.getId().equals(repositoryInput.getId())) {
IPath path = repositoryInput.getFile().getLocation();
return eidtor.getEditor(false);
}
} catch (PartInitException e) {
continue;
}
}
return null;
}
use of org.eclipse.ui.IEditorReference in project tdi-studio-se by Talend.
the class DesignerCoreService method refreshComponentView.
@Override
public void refreshComponentView(Item item) {
try {
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
IEditorReference[] editors = activePage.getEditorReferences();
for (IEditorReference er : editors) {
IEditorPart part = er.getEditor(false);
if (part instanceof AbstractMultiPageTalendEditor) {
AbstractMultiPageTalendEditor editor = (AbstractMultiPageTalendEditor) part;
CommandStack stack = (CommandStack) editor.getTalendEditor().getAdapter(CommandStack.class);
if (stack != null) {
IProcess process = editor.getProcess();
for (final INode processNode : process.getGraphicalNodes()) {
if (processNode instanceof Node) {
checkRepository((Node) processNode, item, stack);
}
}
}
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
Aggregations