[EMF Forms] Null Pointer Exception on Custom View [message #1700513] |
Fri, 03 July 2015 03:35  |
Eclipse User |
|
|
|
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 #1700817 is a reply to message #1700528] |
Tue, 07 July 2015 07:55  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.10282 seconds