use of org.eclipse.ui.internal.browser.WebBrowserEditorInput in project tdi-studio-se by Talend.
the class OpenDocumentationAction method openedByBrowser.
//
// private void progress(final Item item, final String extension) {
// if (item == null) {
// return;
// }
//
// ProgressDialog progressDialog = new ProgressDialog(Display.getCurrent().getActiveShell()) {
//
// @Override
// public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
//
// // use the system program to open the documentation by extension.
// Program program = null;
// if (extension != null) {
// program = Program.findProgram(extension);
// }
// boolean opened = false;
// if (program != null) {
// IFile file = LinkDocumentationHelper.getTempFile(item.getProperty().getId());
// if (file != null) {
// try {
// boolean canExec = false;
// if (item instanceof DocumentationItem) {
// DocumentationItem documentationItem = (DocumentationItem) item;
// documentationItem.getContent().setInnerContentToFile(file.getLocation().toFile());
// canExec = true;
// } else if (item instanceof LinkDocumentationItem) { // link documenation
// LinkDocumentationItem linkDocItem = (LinkDocumentationItem) item;
// ByteArray byteArray = LinkDocumentationHelper.getLinkItemContent(linkDocItem);
// if (byteArray != null) {
// byteArray.setInnerContentToFile(file.getLocation().toFile());
// canExec = true;
// }
// }
// if (canExec) {
// program.execute(file.getLocation().toOSString());
// opened = true;
// }
// } catch (IOException e) {
// MessageBoxExceptionHandler.process(e);
// }
// }
// }
// // if not opened, extract the content.
// if (!opened) {
// ExtractDocumentationAction extractAction = new ExtractDocumentationAction();
// extractAction.setWorkbenchPart(getWorkbenchPart());
// extractAction.run();
// }
// }
//
// };
// try {
// progressDialog.executeProcess();
// } catch (InvocationTargetException e) {
// ExceptionHandler.process(e);
// } catch (InterruptedException e) {
// // Nothing to do
// }
// }
private void openedByBrowser(Item item, URL url) {
if (url == null || item == null) {
return;
}
WebBrowserEditorInput input = new WebBrowserEditorInput(url);
// add for bug TDI-21189 at 2012-6-8,that a document exist is only opened one time in studio
try {
IWorkbenchPage page = getActivePage();
IEditorReference[] iEditorReference = page.getEditorReferences();
for (IEditorReference editors : iEditorReference) {
if (WebBrowserEditor.WEB_BROWSER_EDITOR_ID.equals(editors.getId())) {
IEditorPart iEditorPart = editors.getEditor(true);
if (iEditorPart != null && iEditorPart instanceof WebBrowserEditor) {
WebBrowserEditorInput webBrowserEditorInput = (WebBrowserEditorInput) iEditorPart.getEditorInput();
if (webBrowserEditorInput != null && url.equals(webBrowserEditorInput.getURL())) {
// page.activate(iEditorPart);
iEditorPart.init(iEditorPart.getEditorSite(), webBrowserEditorInput);
DocumentationUtil.setPartItemId((WebBrowserEditor) iEditorPart, item.getProperty().getId(), ERepositoryObjectType.getItemType(item));
return;
}
}
}
}
input.setName(item.getProperty().getLabel());
//$NON-NLS-1$
input.setToolTipText(item.getProperty().getLabel() + " " + item.getProperty().getVersion());
IEditorPart editorPart = page.openEditor(input, WebBrowserEditor.WEB_BROWSER_EDITOR_ID);
if (editorPart != null && editorPart instanceof WebBrowserEditor) {
DocumentationUtil.setPartItemId((WebBrowserEditor) editorPart, item.getProperty().getId(), ERepositoryObjectType.getItemType(item));
}
} catch (PartInitException e) {
MessageBoxExceptionHandler.process(e);
}
}
Aggregations