Search in sources :

Example 1 with ILogListener

use of org.eclipse.core.runtime.ILogListener in project eclipse.platform.text by eclipse.

the class MarkerAnnotationOrderTest method testDirectDependency.

@Test
public void testDirectDependency() {
    final ArrayList<IStatus> list = new ArrayList<>(2);
    Bundle bundle = Platform.getBundle(EditorsUI.PLUGIN_ID);
    ILog log = Platform.getLog(bundle);
    log.addLogListener(new ILogListener() {

        @Override
        public void logging(IStatus status, String plugin) {
            list.add(status);
        }
    });
    TestMarkerAnnotationModel t1 = new TestMarkerAnnotationModel();
    Position position = new Position(0);
    position.delete();
    IDocument d = null;
    try {
        t1.updateMarker(d, null, position);
    } catch (CoreException e) {
        fail("update marker failed to execute");
        log(e);
    }
    assertEquals("Wrong number of messages", 2, list.size());
    assertEquals("Wrong Message for first status", "Marker Updater 'org.eclipse.ui.texteditor.BasicMarkerUpdaterTest2' and 'org.eclipse.ui.texteditor.BasicMarkerUpdaterTest1' depend on each other, 'org.eclipse.ui.texteditor.BasicMarkerUpdaterTest2' will run before 'org.eclipse.ui.texteditor.BasicMarkerUpdaterTest1'", ((Status) list.get(0)).getMessage());
    assertEquals("Wrong Message for second status", "Marker Updater 'org.eclipse.ui.texteditor.BasicMarkerUpdaterTest4' and 'org.eclipse.ui.texteditor.BasicMarkerUpdaterTest1' depend on each other, 'org.eclipse.ui.texteditor.BasicMarkerUpdaterTest4' will run before 'org.eclipse.ui.texteditor.BasicMarkerUpdaterTest1'", ((Status) list.get(1)).getMessage());
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) Position(org.eclipse.jface.text.Position) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) ILog(org.eclipse.core.runtime.ILog) ILogListener(org.eclipse.core.runtime.ILogListener) IDocument(org.eclipse.jface.text.IDocument) Test(org.junit.Test)

Example 2 with ILogListener

use of org.eclipse.core.runtime.ILogListener in project eclipse.platform.text by eclipse.

the class StatusEditorTest method doNotThrowOnActivationInStale.

/*
	 * https://bugs.eclipse.org/bugs/attachment.cgi?bugid=320672
	 *
	 * No exceptions are thrown when a status editor displaying an erroneous status is activated with a mouse click.
	 * @throws Exception
	 */
@Test
public void doNotThrowOnActivationInStale() throws Exception {
    IEditorPart editor1 = openNonExistentFile(page, new URI("file:/1.txt"));
    openNonExistentFile(page, new URI("file:/2.txt"));
    ILog log = Platform.getLog(Platform.getBundle("org.eclipse.e4.ui.workbench"));
    List<String> logEvents = new ArrayList<>();
    ILogListener listener = (status, plugin) -> logEvents.add(status.toString());
    log.addLogListener(listener);
    // Clicks are not equivalent to activation from API, so we need this
    // hack to imitate tab clicks.
    CTabFolder folder = (CTabFolder) (((PartSite) editor1.getSite()).getModel().getParent().getWidget());
    try {
        folder.setSelection(0);
        processEvents();
        folder.setSelection(1);
        processEvents();
    } finally {
        log.removeLogListener(listener);
    }
    if (!logEvents.isEmpty()) {
        Assert.assertEquals("Unexpected errors logged", "", logEvents.toString());
    }
}
Also used : WorkbenchException(org.eclipse.ui.WorkbenchException) ForwardingDocumentProvider(org.eclipse.ui.editors.text.ForwardingDocumentProvider) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) PartSite(org.eclipse.ui.internal.PartSite) ArrayList(java.util.ArrayList) IStatus(org.eclipse.core.runtime.IStatus) After(org.junit.After) URI(java.net.URI) TextEditor(org.eclipse.ui.editors.text.TextEditor) Method(java.lang.reflect.Method) EFS(org.eclipse.core.filesystem.EFS) IEditorPart(org.eclipse.ui.IEditorPart) Before(org.junit.Before) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) CTabFolder(org.eclipse.swt.custom.CTabFolder) ILog(org.eclipse.core.runtime.ILog) PlatformUI(org.eclipse.ui.PlatformUI) Status(org.eclipse.core.runtime.Status) Test(org.junit.Test) Display(org.eclipse.swt.widgets.Display) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) EditorsUI(org.eclipse.ui.editors.text.EditorsUI) FileStoreEditorInput(org.eclipse.ui.ide.FileStoreEditorInput) List(java.util.List) AbstractTextEditor(org.eclipse.ui.texteditor.AbstractTextEditor) Platform(org.eclipse.core.runtime.Platform) Assert(org.junit.Assert) ILogListener(org.eclipse.core.runtime.ILogListener) CTabFolder(org.eclipse.swt.custom.CTabFolder) PartSite(org.eclipse.ui.internal.PartSite) ArrayList(java.util.ArrayList) ILog(org.eclipse.core.runtime.ILog) ILogListener(org.eclipse.core.runtime.ILogListener) IEditorPart(org.eclipse.ui.IEditorPart) URI(java.net.URI) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 ILog (org.eclipse.core.runtime.ILog)2 ILogListener (org.eclipse.core.runtime.ILogListener)2 IStatus (org.eclipse.core.runtime.IStatus)2 Test (org.junit.Test)2 Method (java.lang.reflect.Method)1 URI (java.net.URI)1 List (java.util.List)1 EFS (org.eclipse.core.filesystem.EFS)1 CoreException (org.eclipse.core.runtime.CoreException)1 Platform (org.eclipse.core.runtime.Platform)1 Status (org.eclipse.core.runtime.Status)1 IDocument (org.eclipse.jface.text.IDocument)1 Position (org.eclipse.jface.text.Position)1 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 Display (org.eclipse.swt.widgets.Display)1 IEditorPart (org.eclipse.ui.IEditorPart)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 PlatformUI (org.eclipse.ui.PlatformUI)1