Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Forms] Null Pointer Exception on Custom View
[EMF Forms] Null Pointer Exception on Custom View [message #1700513] Fri, 03 July 2015 07:35 Go to next message
Annamalai Mising name is currently offline Annamalai Mising nameFriend
Messages: 124
Registered: July 2009
Senior Member
Hello There

I am trying to use EMF Forms with my custom Details Page which is placed
on an Form Editor.

Attaching the PageDetails Class for your reference.
I am using the following code

try {
ECPSWTViewRenderer.INSTANCE.render(composite, (EObject)firstElement);
} catch (ECPRendererException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

And on running i am getting this error.

!ENTRY org.eclipse.jface 4 2 2015-07-03 13:02:21.555
!MESSAGE Problems occurred when invoking code from plug-in:
"org.eclipse.jface".
!STACK 0
java.lang.NullPointerException
at
org.eclipse.emf.ecp.view.spi.model.util.ViewModelUtil.resolveDomainReferences(ViewModelUtil.java:53)
at
org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl.instantiate(ViewModelContextImpl.java:202)
at
org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl.<init>(ViewModelContextImpl.java:142)

Any help would be appreciated.

Regards
Malai

package com.herzog.pmide.mergedconfigxml.ui.editors;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecp.ui.view.ECPRendererException;
import org.eclipse.emf.ecp.ui.view.swt.ECPSWTViewRenderer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.IDetailsPage;
import org.eclipse.ui.forms.IFormPart;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

import MachineLibrary.Units;

public class UnitsPageDetails implements IDetailsPage {

private IManagedForm managedForm;
private Composite composite;

/**
* Create the details page.
* @param unitConfigurationMasterDetailsBlock
*/
public UnitsPageDetails(UnitConfigurationMasterDetailsBlock unitConfigurationMasterDetailsBlock) {
// Create the details page
}

/**
* Initialize the details page.
* @param form
*/
public void initialize(IManagedForm form) {
managedForm = form;
}

/**
* Create contents of the details page.
* @param parent
*/
public void createContents(Composite parent) {
FormToolkit toolkit = managedForm.getToolkit();
parent.setLayout(new FillLayout());
//
Section sctnUnitsDetails = toolkit.createSection(parent,
ExpandableComposite.EXPANDED | ExpandableComposite.TITLE_BAR);
sctnUnitsDetails.setText("Units Details");
composite = toolkit.createComposite(sctnUnitsDetails, SWT.NONE);
toolkit.paintBordersFor(composite);
sctnUnitsDetails.setClient(composite);
composite.setLayout(new GridLayout(4, false));
}

public void dispose() {
// Dispose
}

public void setFocus() {
// Set focus
}

private void update() {
// Update
}

public boolean setFormInput(Object input) {
return false;
}

public void selectionChanged(IFormPart part, ISelection selection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
update();

Object firstElement = structuredSelection.getFirstElement();
if (firstElement instanceof Units) {
Units units = (Units) firstElement;
try {
ECPSWTViewRenderer.INSTANCE.render(composite, (EObject)firstElement);
} catch (ECPRendererException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}
}

public void commit(boolean onSave) {
// Commit
}

public boolean isDirty() {
return false;
}

public boolean isStale() {
return false;
}

public void refresh() {
update();
}

}
Re: [EMF Forms] Null Pointer Exception on Custom View [message #1700528 is a reply to message #1700513] Fri, 03 July 2015 09:08 Go to previous messageGo to next message
Annamalai Mising name is currently offline Annamalai Mising nameFriend
Messages: 124
Registered: July 2009
Senior Member
Hello There

I read further in your tutorial and understood that when i put the
ViewRenderer on an editor, References required a Context as explained in
your tutorial
http://eclipsesource.com/blogs/tutorials/getting-started-with-EMF-Forms/#embbededitor

I even attempted to write my own Custom Renderer but even then i am
getting a null pointer exception.

Help required pls.

Regards
Malai

On 7/3/2015 1:05 PM, Annamalai wrote:
> Hello There
>
> I am trying to use EMF Forms with my custom Details Page which is placed
> on an Form Editor.
>
> Attaching the PageDetails Class for your reference.
> I am using the following code
>
> try {
> ECPSWTViewRenderer.INSTANCE.render(composite, (EObject)firstElement);
> } catch (ECPRendererException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> And on running i am getting this error.
>
> !ENTRY org.eclipse.jface 4 2 2015-07-03 13:02:21.555
> !MESSAGE Problems occurred when invoking code from plug-in:
> "org.eclipse.jface".
> !STACK 0
> java.lang.NullPointerException
> at
> org.eclipse.emf.ecp.view.spi.model.util.ViewModelUtil.resolveDomainReferences(ViewModelUtil.java:53)
>
> at
> org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl.instantiate(ViewModelContextImpl.java:202)
>
> at
> org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl.<init>(ViewModelContextImpl.java:142)
>
>
> Any help would be appreciated.
>
> Regards
> Malai
Re: [EMF Forms] Null Pointer Exception on Custom View [message #1700817 is a reply to message #1700528] Tue, 07 July 2015 11:55 Go to previous message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 97
Registered: December 2013
Member

Hi,

Looking at the stracktrace I think that no viewmodel could be found/created for Units.
Could you check if the org.eclipse.emf.ecp.view.model.provider.generator bundle is included in the run configuration? This provider will generate a default view model.
If you have modelled the view, make sure that the org.eclipse.emf.ecp.view.model.provider.xmi bundle is part of the run config and that you are registering the view at the org.eclipse.emf.ecp.view.model.provider.xmi.file extension point.

I hope this will solve the problem. Otherwise I would need a running demo including target definition.

Best regards
Johannes


Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Previous Topic:XMLRPCException during commit
Next Topic:Import/Export of XMI models to/from the EMFStore
Goto Forum:
  


Current Time: Fri Aug 14 10:05:02 GMT 2020

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

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

Back to the top