Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Nullpointerexception (opening editor)
Nullpointerexception (opening editor) [message #819924] Tue, 13 March 2012 13:56 Go to next message
El Shorty is currently offline El ShortyFriend
Messages: 37
Registered: March 2012
Member
Hey,

I think this belongs here. I'm working with RCP and EMF.
I've made a view and am trying to open this in an editor trough the addpages method but I keep getting an nullpointerexception.
The complete error:

Quote:

!SESSION 2012-03-13 14:54:17.969 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.7.0_03
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments: -product smartapps.smartsignature.ui.product
Command-line arguments: -product smartapps.smartsignature.ui.product -data C:\Users\...\Workspace/../runtime-smartsignature.product -dev file:C:/Users/.../Workspace/.metadata/.plugins/org.eclipse.pde.core/smartsignature.product/dev.properties -os win32 -ws win32 -arch x86 -consoleLog

!ENTRY org.eclipse.ui 4 0 2012-03-13 14:54:24.370
!MESSAGE Unable to create editor ID smartapps.smartsignature.ui.editors.personEditor: An unexpected exception was thrown.
!STACK 0
java.lang.NullPointerException
at org.eclipse.ui.forms.editor.FormEditor.pageChange(FormEditor.java:473)
at org.eclipse.ui.part.MultiPageEditorPart.setActivePage(MultiPageEditorPart.java:1067)
at org.eclipse.ui.forms.editor.FormEditor.setActivePage(FormEditor.java:603)
at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:352)
at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:670)
at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1245)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1198)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1597)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:493)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:479)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)
at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:808)
at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:707)
at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:666)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2942)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2850)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2842)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2793)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2789)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2773)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2756)
at smartapps.smartsignature.ui.views.LeftView$2.mouseDown(LeftView.java:75)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:191)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at smartapps.smartsignature.ui.views.Application.start(Application.java:20)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
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:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)




The code when I try to open the editor:

		btnNew.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseDown(MouseEvent e) {
				PersonEditorInput editorInput = new PersonEditorInput();
				IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
				IWorkbenchPage page = window.getActivePage();
				try {
					page.openEditor(editorInput, PersonEditor.ID);
				} catch (PartInitException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
		});



This is the code from the editor to add the view:

	protected void addPages() {
		PersonEditorInput editorInput = (PersonEditorInput) getEditorInput();
		personView = new PersonView();
		person = editorInput.getPerson();
		setPartName(person.getFirstName());		
		
		try {
			addPage(personView);
		} catch (PartInitException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}		
	}


And finally the PersonEditorInput

package smartapps.smartsignature.ui.editors;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;

import smartapps.smartsignature.model.smartsignature.Person;
import smartapps.smartsignature.model.smartsignature.SmartsignatureFactory;

public class PersonEditorInput implements IEditorInput {
	
	private Person person;
	
	private boolean newItem = false;
	
	private TableViewer viewer;
	
	public PersonEditorInput(){
		SmartsignatureFactory factory = SmartsignatureFactory.eINSTANCE;
		Person ps = factory.createPerson();
		this.person = ps;
		newItem = true;
		
		person.setFirstName("Nieuw");
	}

    public PersonEditorInput(TableViewer viewer){
    	this.viewer = viewer;
    	
    	SmartsignatureFactory factory = SmartsignatureFactory.eINSTANCE;
		Person ps = factory.createPerson();
		this.person = ps;
		newItem = true;
		
		person.setFirstName("Nieuw");
    }
    
    public PersonEditorInput(Person person) {
        this.person = person;
    }


Re: Nullpointerexception (opening editor) [message #820790 is a reply to message #819924] Wed, 14 March 2012 15:11 Go to previous messageGo to next message
El Shorty is currently offline El ShortyFriend
Messages: 37
Registered: March 2012
Member
Got this fixed, I was trying something I think really isn't possible. Anyway I figured out I was looking at this the wrong way so instead of working with a view I'm just directly working on the editor wich works fine. However I got another question, hoping anyone still gonna read this topic Razz

I have a view on the left with a treeviewer listing groups. When I click on a group a groupeditor opens wich allows me to either edit or add a new view. However when I do this the treeviewer in the left view doesn't get updated. Anyone knows how I can do this?
Re: Nullpointerexception (opening editor) [message #821319 is a reply to message #820790] Thu, 15 March 2012 07:38 Go to previous message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
I am not sure if I understand this correct. Do you mean that your editor modifies the model of the treeviewer and the changes are not reflected in the viewer? Then maybe it's as simple as refreshing the viewer after model change?
Previous Topic:Open custom editor from cnf
Next Topic:Restore expanded tree items in CommonNavigator
Goto Forum:
  


Current Time: Fri Mar 29 05:57:28 GMT 2024

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

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

Back to the top