use of org.eclipse.ui.IEditorDescriptor in project webtools.sourceediting by eclipse.
the class WorkspaceFileHyperlink method getEditorLabel.
private String getEditorLabel() throws CoreException {
final IContentDescription description = fFile.getContentDescription();
final IEditorDescriptor defaultEditor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(fFile.getName(), description != null ? description.getContentType() : null);
return defaultEditor != null ? defaultEditor.getLabel() : null;
}
use of org.eclipse.ui.IEditorDescriptor in project webtools.sourceediting by eclipse.
the class NewXSLFileWizard method openEditor.
private void openEditor(final IFile file, final int cursorOffset) {
// Open editor on new file.
String editorId = null;
try {
IEditorDescriptor editor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getFullPath().toString(), file.getContentDescription().getContentType());
if (editor != null) {
editorId = editor.getId();
}
} catch (CoreException e1) {
// editor id could not be retrieved, so we can not open editor
return;
}
final String finalEditorId = editorId;
Display.getDefault().asyncExec(new Runnable() {
public void run() {
IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
try {
if (dw != null) {
IWorkbenchPage page = dw.getActivePage();
if (page != null) {
IEditorPart editor = page.openEditor(new FileEditorInput(file), finalEditorId, true);
ITextEditor textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
if (textEditor != null)
textEditor.selectAndReveal(cursorOffset, 0);
editor.setFocus();
}
}
} catch (PartInitException e) {
// editor can not open for some reason
XSLUIPlugin.log(e);
}
}
});
}
use of org.eclipse.ui.IEditorDescriptor in project webtools.sourceediting by eclipse.
the class NewXMLWizard method openEditor.
public void openEditor(IFile file) {
long length = 0;
IPath location = file.getLocation();
if (location != null) {
File localFile = location.toFile();
length = localFile.length();
}
if (length < XML_EDITOR_FILE_SIZE_LIMIT) {
// Open editor on new file.
String editorId = null;
try {
IEditorDescriptor editor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getLocation().toOSString(), file.getContentDescription().getContentType());
if (editor != null) {
editorId = editor.getId();
}
} catch (CoreException e1) {
// editor id could not be retrieved, so we can not open editor
return;
}
IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
try {
if (dw != null) {
IWorkbenchPage page = dw.getActivePage();
if (page != null) {
page.openEditor(new FileEditorInput(file), editorId, true);
}
}
} catch (PartInitException e) {
// editor can not open for some reason
return;
}
}
}
use of org.eclipse.ui.IEditorDescriptor in project azure-tools-for-java by Microsoft.
the class UIHelperImpl method openWebAppPropertyView.
@Override
public void openWebAppPropertyView(WebAppNode node) {
if (Utils.isEmptyString(node.getId())) {
return;
}
AzureTaskManager.getInstance().runLater(() -> {
IWorkbench workbench = PlatformUI.getWorkbench();
WebAppPropertyEditorInput input = new WebAppPropertyEditorInput(node.getSubscriptionId(), node.getId(), node.getName());
IEditorDescriptor descriptor = workbench.getEditorRegistry().findEditor(WebAppPropertyEditor.ID);
openEditor(EditorType.WEBAPP_EXPLORER, input, descriptor);
});
}
use of org.eclipse.ui.IEditorDescriptor in project azure-tools-for-java by Microsoft.
the class UIHelperImpl method openRedisExplorer.
@Override
public void openRedisExplorer(@NotNull RedisCacheNode node) {
IWorkbench workbench = PlatformUI.getWorkbench();
RedisExplorerEditorInput input = new RedisExplorerEditorInput(node.getSubscriptionId(), node.getResourceId(), node.getName());
IEditorDescriptor descriptor = workbench.getEditorRegistry().findEditor(RedisExplorerEditor.ID);
openEditor(EditorType.REDIS_EXPLORER, input, descriptor);
}
Aggregations