Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » MessageConsole
MessageConsole [message #1740292] Thu, 11 August 2016 09:34
Martin Jacob is currently offline Martin JacobFriend
Messages: 191
Registered: July 2009
Senior Member
Hi,

I need to create a message console and show this console by using a
ConsoleHelper class with following methods.

	public MessageConsole findConsole(String name) {
		ConsolePlugin plugin = ConsolePlugin.getDefault();
		IConsoleManager conMan = plugin.getConsoleManager();
		IConsole[] existing = conMan.getConsoles();
		for (int i = 0; i < existing.length; i++)
			if (name.equals(existing[i].getName()))
				return (MessageConsole) existing[i];
		// no console found, so create a new one
		MessageConsole myConsole = new MessageConsole(name, null);
		conMan.addConsoles(new IConsole[] { myConsole });
		return myConsole;
	}


and pin the console

	public void pinConsole(String pConsoleName, String pSecondaryID) {
		IWorkbench lWb = PlatformUI.getWorkbench();
		IWorkbenchWindow lWindow = lWb.getActiveWorkbenchWindow();
		IWorkbenchPage lPage = lWindow.getActivePage();
		IConsole lConsole = findConsole(pConsoleName);
		try {
			if (null != lPage) {
				IViewPart lVp = lPage.showView(IConsoleConstants.ID_CONSOLE_VIEW, 
null, IWorkbenchPage.VIEW_ACTIVATE);
				if (null != lVp && lVp instanceof IConsoleView) {
					IConsoleView lCv = ((IConsoleView) lVp);
					lCv.setPinned(false);
					lCv.display(lConsole);
					lCv.setPinned(true);
				}
			}
		} catch (PartInitException e) {
			e.printStackTrace();
		}
	}


this works fine, but when I switch the perspectives I get:

!ENTRY org.eclipse.equinox.event 4 0 2016-08-11 11:32:57.206
!MESSAGE Exception while dispatching event org.osgi.service.event.Event 
[topic=org/eclipse/e4/ui/model/ui/ElementContainer/selectedElement/SET] 
{ChangedElement=org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveStackImpl@36857d32 
(elementId: org.eclipse.ui.ide.perspectivestack, tags: [], 
contributorURI: null) (widget: Composite {}, renderer: 
org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer@3d2b13f, 
toBeRendered: true, onTop: false, visible: true, containerData: 7500, 
accessibilityPhrase: null), 
org.eclipse.e4.data={ChangedElement=org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveStackImpl@36857d32 
(elementId: org.eclipse.ui.ide.perspectivestack, tags: [], 
contributorURI: null) (widget: Composite {}, renderer: 
org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer@3d2b13f, 
toBeRendered: true, onTop: false, visible: true, containerData: 7500, 
accessibilityPhrase: null), AttName=selectedElement, EventType=SET, 
OldValue=org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveImpl@6ea1fc9 
(elementId: org.eclipse.wst.xml.ui.perspective, tags: 
[persp.actionSet:org.eclipse.ui.cheatsheets.actionSet, 
persp.actionSet:org.eclipse.search.searchActionSet, 
persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation, 
persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation, 
persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo, 
persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet, 
persp.actionSet:org.eclipse.ui.actionSet.keyBindings, 
persp.actionSet:org.eclipse.ui.actionSet.openFiles, 
persp.actionSet:file.actions, persp.actionSet:edit.actions, 
persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer, 
persp.perspSC:de.bahntechnik.dd.opn.ui.perspective, 
persp.perspSC:org.eclipse.ui.resourcePerspective, 
persp.perspSC:org.eclipse.wst.xml.ui.perspective, 
persp.perspSC:de.bahntechnik.dd.opn.psc.prj.ui.perspective, 
persp.actionSet:org.eclipse.debug.ui.launchActionSet, 
persp.newWizSC:org.eclipse.wst.xml.ui.internal.wizards.NewXMLWizard, 
persp.newWizSC:org.eclipse.wst.xsd.ui.internal.wizards.NewXSDWizard, 
persp.newWizSC:org.eclipse.wst.dtd.ui.internal.wizard.NewDTDWizard, 
persp.newWizSC:org.eclipse.ui.wizards.new.folder, 
persp.newWizSC:org.eclipse.ui.wizards.new.file, 
persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard, 
persp.viewSC:org.eclipse.ui.views.ResourceNavigator, 
persp.viewSC:org.eclipse.ui.views.ContentOutline, 
persp.viewSC:org.eclipse.ui.views.PropertySheet, 
persp.viewSC:org.eclipse.ui.views.ProblemView, 
persp.viewSC:org.eclipse.ui.console.ConsoleView, 
persp.viewSC:org.eclipse.ui.views.TaskList, 
persp.viewSC:org.eclipse.search.ui.views.SearchView, 
persp.viewSC:org.eclipse.ui.views.ProgressView, 
persp.perspSC:org.eclipse.debug.ui.DebugPerspective], contributorURI: 
null) (widget: Composite {}, renderer: 
org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveRenderer@f10927f, 
toBeRendered: true, onTop: false, visible: true, containerData: null, 
accessibilityPhrase: null) (label: XML, iconURI: 
platform:/plugin/org.eclipse.wst.xml.ui/$nl$/icons/full/xml_perspective.gif, 
tooltip: null, context: PerspectiveImpl 
(org.eclipse.wst.xml.ui.perspective) Context, variables: []), 
Widget=Composite {}, 
NewValue=org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveImpl@3497ecea 
(elementId: de.bahntechnik.dd.opn.ui.perspective, tags: 
[persp.actionSet:org.eclipse.search.searchActionSet], contributorURI: 
platform:/plugin/de.bahntechnik.dd.opn.ui) (widget: Composite {}, 
renderer: 
org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveRenderer@f10927f, 
toBeRendered: true, onTop: false, visible: true, containerData: null, 
accessibilityPhrase: null) (label: Simulation, iconURI: 
platform:/plugin/de.bahntechnik.dd.opn.ui/icons/obj16/OPN_start_16x16.png, 
tooltip: , context: PerspectiveImpl 
(de.bahntechnik.dd.opn.ui.perspective) Context, variables: [])}, 
AttName=selectedElement, EventType=SET, 
OldValue=org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveImpl@6ea1fc9 
(elementId: org.eclipse.wst.xml.ui.perspective, tags: 
[persp.actionSet:org.eclipse.ui.cheatsheets.actionSet, 
persp.actionSet:org.eclipse.search.searchActionSet, 
persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation, 
persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation, 
persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo, 
persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet, 
persp.actionSet:org.eclipse.ui.actionSet.keyBindings, 
persp.actionSet:org.eclipse.ui.actionSet.openFiles, 
persp.actionSet:file.actions, persp.actionSet:edit.actions, 
persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer, 
persp.perspSC:de.bahntechnik.dd.opn.ui.perspective, 
persp.perspSC:org.eclipse.ui.resourcePerspective, 
persp.perspSC:org.eclipse.wst.xml.ui.perspective, 
persp.perspSC:de.bahntechnik.dd.opn.psc.prj.ui.perspective, 
persp.actionSet:org.eclipse.debug.ui.launchActionSet, 
persp.newWizSC:org.eclipse.wst.xml.ui.internal.wizards.NewXMLWizard, 
persp.newWizSC:org.eclipse.wst.xsd.ui.internal.wizards.NewXSDWizard, 
persp.newWizSC:org.eclipse.wst.dtd.ui.internal.wizard.NewDTDWizard, 
persp.newWizSC:org.eclipse.ui.wizards.new.folder, 
persp.newWizSC:org.eclipse.ui.wizards.new.file, 
persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard, 
persp.viewSC:org.eclipse.ui.views.ResourceNavigator, 
persp.viewSC:org.eclipse.ui.views.ContentOutline, 
persp.viewSC:org.eclipse.ui.views.PropertySheet, 
persp.viewSC:org.eclipse.ui.views.ProblemView, 
persp.viewSC:org.eclipse.ui.console.ConsoleView, 
persp.viewSC:org.eclipse.ui.views.TaskList, 
persp.viewSC:org.eclipse.search.ui.views.SearchView, 
persp.viewSC:org.eclipse.ui.views.ProgressView, 
persp.perspSC:org.eclipse.debug.ui.DebugPerspective], contributorURI: 
null) (widget: Composite {}, renderer: 
org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveRenderer@f10927f, 
toBeRendered: true, onTop: false, visible: true, containerData: null, 
accessibilityPhrase: null) (label: XML, iconURI: 
platform:/plugin/org.eclipse.wst.xml.ui/$nl$/icons/full/xml_perspective.gif, 
tooltip: null, context: PerspectiveImpl 
(org.eclipse.wst.xml.ui.perspective) Context, variables: []), 
Widget=Composite {}, 
NewValue=org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveImpl@3497ecea 
(elementId: de.bahntechnik.dd.opn.ui.perspective, tags: 
[persp.actionSet:org.eclipse.search.searchActionSet], contributorURI: 
platform:/plugin/de.bahntechnik.dd.opn.ui) (widget: Composite {}, 
renderer: 
org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveRenderer@f10927f, 
toBeRendered: true, onTop: false, visible: true, containerData: null, 
accessibilityPhrase: null) (label: Simulation, iconURI: 
platform:/plugin/de.bahntechnik.dd.opn.ui/icons/obj16/OPN_start_16x16.png, 
tooltip: , context: PerspectiveImpl 
(de.bahntechnik.dd.opn.ui.perspective) Context, variables: [])} to 
handler org.eclipse.e4.ui.services.internal.events.UIEventHandler@2bd2fa2c
!STACK 0
java.lang.NullPointerException
	at 
org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.showElementRecursive(LazyStackRenderer.java:238)
	at 
org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.showElementRecursive(LazyStackRenderer.java:284)
	at 
org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.showElementRecursive(LazyStackRenderer.java:290)
	at 
org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.showElementRecursive(LazyStackRenderer.java:290)
	at 
org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.showElementRecursive(LazyStackRenderer.java:290)
	at 
org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.showElementRecursive(LazyStackRenderer.java:290)
	at 
org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer.showTab(LazyStackRenderer.java:162)
	at 
org.eclipse.e4.ui.workbench.renderers.swt.PerspectiveStackRenderer.showTab(PerspectiveStackRenderer.java:88)
	at 
org.eclipse.e4.ui.workbench.renderers.swt.LazyStackRenderer$1.handleEvent(LazyStackRenderer.java:72)
	at 
org.eclipse.e4.ui.services.internal.events.UIEventHandler$1.run(UIEventHandler.java:40)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:233)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:145)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:4813)
	at 
org.eclipse.e4.ui.internal.workbench.swt.E4Application$1.syncExec(E4Application.java:211)
	at 
org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:36)
	at 
org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:201)
	at 
org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:197)
	at 
org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at 
org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at 
org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
	at 
org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:135)
	at 
org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:78)
	at 
org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:39)
	at 
org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:94)
	at 
org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:60)
	at 
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:374)
	at 
org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveStackImpl.setSelectedElement(PerspectiveStackImpl.java:135)
	at 
org.eclipse.e4.ui.model.application.ui.advanced.impl.PerspectiveStackImpl.setSelectedElement(PerspectiveStackImpl.java:1)
	at 
org.eclipse.e4.ui.workbench.addons.perspectiveswitcher.PerspectiveSwitcher$12.widgetSelected(PerspectiveSwitcher.java:593)
	at 
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4410)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4228)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3816)
	at 
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
	at 
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at 
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
	at 
org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:687)
	at 
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at 
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:604)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
	at 
org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
	at 
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at 
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at 
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at 
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
	at 
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1492)


Does any one have an idea how to overcome this error?
I tried to find the console be EPartService but could not get hold of an
instance of EPartService as injection works only for framework created
object. But my ConsleHelper class is not instantiated by the framework.

Martin
Previous Topic:How to add a banner to an e4 application
Next Topic:Get position or triggering mouse event of MPopupMenu
Goto Forum:
  


Current Time: Tue Jun 28 04:10:09 GMT 2022

Powered by FUDForum. Page generated in 0.01856 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top