use of org.eclipse.ui.IWorkbenchPage in project bndtools by bndtools.
the class OpenMainConfigHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
IFile buildFile = Central.getWorkspaceBuildFile();
if (buildFile == null)
return null;
FileEditorInput input = new FileEditorInput(buildFile);
IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindowChecked(event).getActivePage();
page.openEditor(input, "bndtools.bndWorkspaceConfigEditor", true);
} catch (PartInitException e) {
ErrorDialog.openError(HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(), "Error", "Unable to open editor", e.getStatus());
} catch (Exception e) {
logger.logError("Error retrieving bnd configuration file", e);
}
return null;
}
use of org.eclipse.ui.IWorkbenchPage in project bndtools by bndtools.
the class RepositoriesView method openURI.
protected void openURI(URI uri) {
IWorkbenchPage page = getSite().getPage();
try {
IFileStore fileStore = EFS.getLocalFileSystem().getStore(uri);
IDE.openEditorOnFileStore(page, fileStore);
} catch (PartInitException e) {
logger.logError("Error opening editor for " + uri, e);
}
}
use of org.eclipse.ui.IWorkbenchPage in project bndtools by bndtools.
the class BlueprintXmlFileWizard method performFinish.
@Override
public boolean performFinish() {
IFile file = mainPage.createNewFile();
if (file == null) {
deleteSpeculativelyCreatedFolders();
return false;
}
if (!speculativelyCreatedFolders.isEmpty() && !speculativelyCreatedFolders.peek().getFullPath().isPrefixOf(file.getFullPath())) {
deleteSpeculativelyCreatedFolders();
}
for (IFile bndFile : bndFileSelector.getSelectedBndFiles()) {
try {
updateBundleBlueprintAndIncludeResource(file, bndFile);
} catch (Exception e) {
ErrorDialog.openError(getShell(), "New Blueprint XML File", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error updating Bnd file", e));
}
}
// Open editor on new file.
IWorkbenchWindow dw = workbench.getActiveWorkbenchWindow();
try {
if (dw != null) {
IWorkbenchPage page = dw.getActivePage();
if (page != null) {
IDE.openEditor(page, file, true);
}
}
} catch (PartInitException e) {
ErrorDialog.openError(getShell(), "New Blueprint XML File", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error opening editor", e));
}
return true;
}
use of org.eclipse.ui.IWorkbenchPage in project eclipse.platform.text by eclipse.
the class EncodingChangeTests method testChangeEncodingViaFile.
@Test
public void testChangeEncodingViaFile() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
try {
fFile.setCharset(NON_DEFAULT_ENCODING, null);
} catch (CoreException ex) {
fail();
}
try {
fEditor = IDE.openEditor(page, fFile);
if (fEditor instanceof TextEditor) {
TextEditor editor = (TextEditor) fEditor;
Accessor accessor = new Accessor(editor, StatusTextEditor.class);
while (editor.getSite().getShell().getDisplay().readAndDispatch()) {
}
ScrolledComposite composite = (ScrolledComposite) accessor.get("fStatusControl");
assertNull(composite);
DefaultEncodingSupport encodingSupport = (DefaultEncodingSupport) editor.getAdapter(IEncodingSupport.class);
assertEquals(NON_DEFAULT_ENCODING, encodingSupport.getEncoding());
} else
fail();
} catch (PartInitException e) {
fail();
}
}
use of org.eclipse.ui.IWorkbenchPage in project eclipse.platform.text by eclipse.
the class EncodingChangeTests method testChangeEncodingViaEncodingSupport.
@Test
public void testChangeEncodingViaEncodingSupport() {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
try {
fEditor = IDE.openEditor(page, fFile);
if (fEditor instanceof TextEditor) {
TextEditor editor = (TextEditor) fEditor;
while (editor.getSite().getShell().getDisplay().readAndDispatch()) {
}
DefaultEncodingSupport encodingSupport = (DefaultEncodingSupport) editor.getAdapter(IEncodingSupport.class);
encodingSupport.setEncoding(NON_DEFAULT_ENCODING);
Accessor accessor = new Accessor(editor, StatusTextEditor.class);
while (editor.getSite().getShell().getDisplay().readAndDispatch()) {
}
ScrolledComposite composite = (ScrolledComposite) accessor.get("fStatusControl");
assertNull(composite);
String actual = null;
try {
actual = fFile.getCharset(false);
} catch (CoreException e1) {
fail();
}
assertEquals(NON_DEFAULT_ENCODING, actual);
} else
fail();
} catch (PartInitException e) {
fail();
}
}
Aggregations