Search in sources :

Example 91 with IWorkbenchPage

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;
}
Also used : IFile(org.eclipse.core.resources.IFile) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) PartInitException(org.eclipse.ui.PartInitException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 92 with IWorkbenchPage

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);
    }
}
Also used : IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IFileStore(org.eclipse.core.filesystem.IFileStore) PartInitException(org.eclipse.ui.PartInitException)

Example 93 with IWorkbenchPage

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IFile(org.eclipse.core.resources.IFile) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) IOException(java.io.IOException)

Example 94 with IWorkbenchPage

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();
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) DefaultEncodingSupport(org.eclipse.ui.editors.text.DefaultEncodingSupport) StatusTextEditor(org.eclipse.ui.texteditor.StatusTextEditor) TextEditor(org.eclipse.ui.editors.text.TextEditor) CoreException(org.eclipse.core.runtime.CoreException) IEncodingSupport(org.eclipse.ui.editors.text.IEncodingSupport) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) PartInitException(org.eclipse.ui.PartInitException) Accessor(org.eclipse.text.tests.Accessor) Test(org.junit.Test)

Example 95 with IWorkbenchPage

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();
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) DefaultEncodingSupport(org.eclipse.ui.editors.text.DefaultEncodingSupport) StatusTextEditor(org.eclipse.ui.texteditor.StatusTextEditor) TextEditor(org.eclipse.ui.editors.text.TextEditor) CoreException(org.eclipse.core.runtime.CoreException) IEncodingSupport(org.eclipse.ui.editors.text.IEncodingSupport) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) PartInitException(org.eclipse.ui.PartInitException) Accessor(org.eclipse.text.tests.Accessor) Test(org.junit.Test)

Aggregations

IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)294 IEditorPart (org.eclipse.ui.IEditorPart)126 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)102 PartInitException (org.eclipse.ui.PartInitException)96 IFile (org.eclipse.core.resources.IFile)63 IViewPart (org.eclipse.ui.IViewPart)58 IEditorReference (org.eclipse.ui.IEditorReference)40 IWorkbench (org.eclipse.ui.IWorkbench)32 CoreException (org.eclipse.core.runtime.CoreException)31 ArrayList (java.util.ArrayList)30 IViewReference (org.eclipse.ui.IViewReference)29 IEditorInput (org.eclipse.ui.IEditorInput)28 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)27 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)22 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)18 Path (org.eclipse.core.runtime.Path)18 FileEditorInput (org.eclipse.ui.part.FileEditorInput)17 IOException (java.io.IOException)16 IProject (org.eclipse.core.resources.IProject)16 ISelection (org.eclipse.jface.viewers.ISelection)16