Search in sources :

Example 1 with XMLMultiPageEditorPart

use of org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart in project liferay-ide by liferay.

the class UITestsUtils method getEditor.

public static StructuredTextEditor getEditor(IFile file) {
    StructuredTextEditor editor = (StructuredTextEditor) fileToEditorMap.get(file);
    if (editor == null) {
        try {
            final IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            final IWorkbenchPage page = workbenchWindow.getActivePage();
            final IEditorPart editorPart = IDE.openEditor(page, file, true, true);
            assertNotNull(editorPart);
            if (editorPart instanceof SapphireEditorForXml) {
                editor = ((SapphireEditorForXml) editorPart).getXmlEditor();
            } else if (editorPart instanceof StructuredTextEditor) {
                editor = ((StructuredTextEditor) editorPart);
            } else if (editorPart instanceof XMLMultiPageEditorPart) {
                XMLMultiPageEditorPart xmlEditorPart = (XMLMultiPageEditorPart) editorPart;
                editor = (StructuredTextEditor) xmlEditorPart.getAdapter(StructuredTextEditor.class);
            }
            assertNotNull(editor);
            standardizeLineEndings(editor);
            fileToEditorMap.put(file, editor);
        } catch (Exception e) {
            fail("Could not open editor for " + file + " exception: " + e.getMessage());
        }
    }
    return editor;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) SapphireEditorForXml(org.eclipse.sapphire.ui.swt.xml.editor.SapphireEditorForXml) XMLMultiPageEditorPart(org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor)

Example 2 with XMLMultiPageEditorPart

use of org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart in project webtools.sourceediting by eclipse.

the class TestReconcilerXML method setUp.

protected void setUp() throws Exception {
    // only create project and file once
    if (!fIsSetup) {
        // create project
        createProject(PROJECT_NAME);
        fFile = getOrCreateFile(PROJECT_NAME + "/" + FILE_NAME);
        fIsSetup = true;
    }
    // editor is opened each time
    if (fIsSetup && fEditor == null) {
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        IWorkbenchPage page = workbenchWindow.getActivePage();
        fEditor = IDE.openEditor(page, fFile, true, true);
        if (!((fEditor instanceof XMLMultiPageEditorPart) || (fEditor instanceof StructuredTextEditor)))
            assertTrue("Unable to open structured text editor", false);
    }
    // turn on reconciling
    IPreferenceStore store = SSEUIPlugin.getDefault().getPreferenceStore();
    fReconcilerPref = store.getBoolean(CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS);
    if (!fReconcilerPref)
        store.setValue(CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS, true);
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) XMLMultiPageEditorPart(org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor)

Example 3 with XMLMultiPageEditorPart

use of org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart in project webtools.sourceediting by eclipse.

the class XMLCodeFoldingTest method getEditor.

/**
 * <p>Given a <code>file</code> get an editor for it. If an editor has already
 * been retrieved for the given <code>file</code> then return the same already
 * open editor.</p>
 *
 * <p>When opening the editor it will also standardized the line
 * endings to <code>\n</code></p>
 *
 * @param file open and return an editor for this
 * @return <code>StructuredTextEditor</code> opened from the given <code>file</code>
 */
private StructuredTextEditor getEditor(IFile file) {
    StructuredTextEditor editor = (StructuredTextEditor) fFileToEditorMap.get(file);
    if (editor == null) {
        try {
            IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            IWorkbenchPage page = workbenchWindow.getActivePage();
            IEditorPart editorPart = IDE.openEditor(page, file, true, true);
            if (editorPart instanceof XMLMultiPageEditorPart) {
                XMLMultiPageEditorPart xmlEditorPart = (XMLMultiPageEditorPart) editorPart;
                editor = (StructuredTextEditor) xmlEditorPart.getAdapter(StructuredTextEditor.class);
            } else if (editorPart instanceof StructuredTextEditor) {
                editor = ((StructuredTextEditor) editorPart);
            } else {
                fail("Unable to open structured text editor: " + editorPart.getClass().getName());
            }
            standardizeLineEndings(editor);
            if (editor != null) {
                fFileToEditorMap.put(file, editor);
            } else {
                fail("Could not open viewer for " + file);
            }
        } catch (Exception e) {
            fail("Could not open editor for " + file + " exception: " + e.getMessage());
        }
    }
    return editor;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) XMLMultiPageEditorPart(org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 4 with XMLMultiPageEditorPart

use of org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart in project webtools.sourceediting by eclipse.

the class TestOpenEditorXML method testOpenOnLocalFileStore.

public void testOpenOnLocalFileStore() throws Exception {
    // filebuffers for local files have a location
    IPath stateLocation = XMLUITestsPlugin.getDefault().getStateLocation();
    File file = stateLocation.append(FILE_NAME).toFile();
    FileOutputStream fileOutputStream = new FileOutputStream(file);
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    InputStream contents = fFile.getContents();
    if (contents != null) {
        int c;
        byte[] bytes = new byte[2048];
        try {
            while ((c = contents.read(bytes)) >= 0) {
                buffer.write(bytes, 0, c);
            }
            contents.close();
        } catch (IOException ioe) {
        // no cleanup can be done
        }
    }
    fileOutputStream.write(buffer.toByteArray());
    URI uri = URIUtil.toURI(new Path(file.getAbsolutePath()));
    IFileStore store = EFS.getStore(uri);
    FileStoreEditorInput input = new FileStoreEditorInput(store);
    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage page = workbenchWindow.getActivePage();
    IEditorPart editor = IDE.openEditor(page, input, "org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart");
    page.closeEditor(editor, false);
    assertTrue("Unable to open structured text editor " + fEditor, (fEditor instanceof XMLMultiPageEditorPart) || (fEditor instanceof StructuredTextEditor));
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IPath(org.eclipse.core.runtime.IPath) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) IEditorPart(org.eclipse.ui.IEditorPart) URI(java.net.URI) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor) FileOutputStream(java.io.FileOutputStream) XMLMultiPageEditorPart(org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart) IFileStore(org.eclipse.core.filesystem.IFileStore) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IFile(org.eclipse.core.resources.IFile) File(java.io.File) FileStoreEditorInput(org.eclipse.ui.ide.FileStoreEditorInput)

Example 5 with XMLMultiPageEditorPart

use of org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart in project webtools.sourceediting by eclipse.

the class TestOpenEditorXML method setUp.

protected void setUp() throws Exception {
    // only create project and file once
    if (!fIsSetup) {
        // create project
        createProject(PROJECT_NAME);
        fFile = getOrCreateFile(PROJECT_NAME + "/" + FILE_NAME);
        fIsSetup = true;
    }
    assertTrue("Input file not accessible: " + fFile.getFullPath(), fFile.isAccessible());
    // editor is opened each time
    if (fIsSetup && fEditor == null) {
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        IWorkbenchPage page = workbenchWindow.getActivePage();
        fEditor = IDE.openEditor(page, fFile, true, true);
        assertTrue("Unable to open structured text editor " + fEditor, (fEditor instanceof XMLMultiPageEditorPart) || (fEditor instanceof StructuredTextEditor));
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) XMLMultiPageEditorPart(org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) StructuredTextEditor(org.eclipse.wst.sse.ui.StructuredTextEditor)

Aggregations

IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)6 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)6 StructuredTextEditor (org.eclipse.wst.sse.ui.StructuredTextEditor)6 XMLMultiPageEditorPart (org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart)6 IEditorPart (org.eclipse.ui.IEditorPart)4 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 IFileStore (org.eclipse.core.filesystem.IFileStore)1 IFile (org.eclipse.core.resources.IFile)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 SapphireEditorForXml (org.eclipse.sapphire.ui.swt.xml.editor.SapphireEditorForXml)1 FileStoreEditorInput (org.eclipse.ui.ide.FileStoreEditorInput)1