Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] NPEx when setLayoutConstraint on GMF editors
[CDO] NPEx when setLayoutConstraint on GMF editors [message #650510] Tue, 25 January 2011 11:04 Go to next message
Ugo Sangiorgi is currently offline Ugo SangiorgiFriend
Messages: 59
Registered: January 2010
Member
Hi all, I'm getting this on my Dawn/GMF editor. My editor is not refreshed, but when saved, the other editors are refreshed properly:

java.lang.NullPointerException
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.setLayou tConstraint(AbstractGraphicalEditPart.java:906)
at org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeEditPart.r efreshBounds(ShapeEditPart.java:197)
at org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeEditPart.r efreshVisuals(ShapeEditPart.java:205)
at org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractE ditPart.java:717)
at org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh( AbstractGraphicalEditPart.java:633)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$3(GraphicalEditPart.java:1)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt$3.run(GraphicalEditPart.java:861)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:328)
at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.refresh(GraphicalEditPart.java:851)
at org.eclipse.emf.cdo.dawn.util.DawnDiagramUpdater.refeshEditp artInternal(DawnDiagramUpdater.java:142)
at org.eclipse.emf.cdo.dawn.util.DawnDiagramUpdater.refeshEditp artInternal(DawnDiagramUpdater.java:167)
at org.eclipse.emf.cdo.dawn.util.DawnDiagramUpdater.refeshEditp artInternal(DawnDiagramUpdater.java:167)
at org.eclipse.emf.cdo.dawn.util.DawnDiagramUpdater.refreshEdit Part(DawnDiagramUpdater.java:72)
at org.eclipse.emf.cdo.dawn.util.DawnDiagramUpdater$2.run(DawnD iagramUpdater.java:83)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:328)
at org.eclipse.emf.cdo.dawn.util.DawnDiagramUpdater.refreshEdit Part(DawnDiagramUpdater.java:79)
at org.eclipse.emf.cdo.dawn.notifications.impl.DawnGMFHandler.r efresh(DawnGMFHandler.java:275)
at org.eclipse.emf.cdo.dawn.notifications.impl.DawnGMFHandler.m odifyingObject(DawnGMFHandler.java:115)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl. registerFeatureDelta(CDOTransactionImpl.java:1514)
at org.eclipse.emf.internal.cdo.view.CDOStateMachine$WriteNewTr ansition.execute(CDOStateMachine.java:819)
at org.eclipse.emf.internal.cdo.view.CDOStateMachine$WriteNewTr ansition.execute(CDOStateMachine.java:1)
at org.eclipse.net4j.util.fsm.FiniteStateMachine.process(Finite StateMachine.java:162)
at org.eclipse.emf.internal.cdo.view.CDOStateMachine.writeWitho utViewLock(CDOStateMachine.java:386)
at org.eclipse.emf.internal.cdo.view.CDOStateMachine.write(CDOS tateMachine.java:371)
at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.getRevisionFo rWriting(CDOStoreImpl.java:621)
at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.set(CDOStoreI mpl.java:342)
at org.eclipse.emf.internal.cdo.object.CDOLegacyAdapter.notifyC hanged(CDOLegacyAdapter.java:83)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:380)
at org.eclipse.gmf.runtime.notation.impl.ViewImpl.setElement(Vi ewImpl.java:377)
at org.eclipse.sketch.examples.shapes.diagram.providers.ShapesV iewProvider.createUnknown_2003(ShapesViewProvider.java:343)
at org.eclipse.sketch.examples.shapes.diagram.providers.ShapesV iewProvider.createNode(ShapesViewProvider.java:238)
at org.eclipse.gmf.runtime.diagram.core.services.view.CreateNod eViewOperation.execute(CreateNodeViewOperation.java:67)
at org.eclipse.gmf.runtime.common.core.service.ExecutionStrateg y$1.execute(ExecutionStrategy.java:71)
at org.eclipse.gmf.runtime.common.core.service.Service.execute( Service.java:652)
at org.eclipse.gmf.runtime.diagram.core.services.ViewService.ex ecute(ViewService.java:184)
at org.eclipse.gmf.runtime.diagram.core.services.ViewService.cr eateNode(ViewService.java:499)
at org.eclipse.gmf.runtime.diagram.core.services.ViewService.cr eateView(ViewService.java:265)
at org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand.do ExecuteWithResult(CreateCommand.java:91)
at org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTr ansactionalCommand.doExecute(AbstractTransactionalCommand.ja va:247)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:150)
at org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:403)
at org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:135)
at org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:403)
at org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:135)
at org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:511)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:206)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:169)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:156)
at org.eclipse.sketch.examples.shapes.diagram.MyShapesSketchCli ent.createUnknownNode(MyShapesSketchClient.java:213)
at org.eclipse.sketch.examples.shapes.diagram.MyShapesSketchCli ent.receiveNewProcessedSketch(MyShapesSketchClient.java:73)
at org.eclipse.sketch.SketchManager.notifyNewSketch(SketchManag er.java:120)
at org.eclipse.sketch.SketchRecognizer$1.run(SketchRecognizer.j ava:79)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3515)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3164)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 38)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.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(EclipseS tarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)


thanks a lot!
Ugo
Re: [CDO] NPEx when setLayoutConstraint on GMF editors [message #650568 is a reply to message #650510] Tue, 25 January 2011 14:39 Go to previous messageGo to next message
Martin Fluegge is currently offline Martin FlueggeFriend
Messages: 141
Registered: July 2009
Senior Member
> Hi all, I'm getting this on my Dawn/GMF editor. My editor is not refreshed, but when saved, the other editors are refreshed properly:

With "not refreshed" you mean that the element you placed on your diagram is not visible?

Following the excpetion I would say that the getFigure() method from your ShapeEditPart subclass seems to deliver null. Did you customize the method in the affected class?

Could you provide more information about the structuire of the node? Does it have labels or any compartments?

Cheers,

Martin

[Updated on: Tue, 25 January 2011 15:10]

Report message to a moderator

Re: [CDO] NPEx when setLayoutConstraint on GMF editors [message #650598 is a reply to message #650568] Tue, 25 January 2011 16:38 Go to previous messageGo to next message
Ugo Sangiorgi is currently offline Ugo SangiorgiFriend
Messages: 59
Registered: January 2010
Member
Exactly, I mean the node is not visible, although the editor gets dirty and all :)
And it only happens with my custom figure, and for creation only (editing labels and moving the node performs fine)

I have two types of nodes:
-Squares/Triangles, which are classic GMF figures.
-Unknown, sketched figures (SVGSketchFigure that is constructed based on a property of the node, which is an svg encoded in base64)


Here is how I create the figure:

protected IFigure createNodeShape() {

Bundle bundle = Platform.getBundle("org.eclipse.sketch.examples.shapes");
try {

NodeImpl n = (NodeImpl) getModel();
Unknown s = (Unknown) n.basicGetElement();

if (s.getSvg() != null) {

IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
File imgfile = myWorkspaceRoot.getLocation()
.append("s" + System.currentTimeMillis() + ".svg")
.toFile();

Base64.decodeToFile(s.getSvg(), imgfile.getPath());

RenderedImage img = RenderedImageFactory.getInstance(imgfile.getPath());
img.getRenderInfo().setValues(0, 0, true, true,new RGB(255, 0, 0), new RGB(255, 0, 0));

primaryShape = new SVGSketchFigure(img);

} else {
primaryShape = new SVGSketchFigure(RenderedImageFactory.getInstance(bundle
.getEntry("/icons/square.svg")));
}

} catch (IOException e) {
e.printStackTrace();
}
return primaryShape;

}

....

public class SVGSketchFigure extends ScalableImageFigure {

/**
* @generated
*/
private WrappingLabel fFigureSketchLabelFigure;

/**
* @generated NOT
*/
private RenderedImage image;

/**
* @generated NOT
*/
public SVGSketchFigure() {
super(null, true, true, true);
createContents();
}

/**
* @generated NOT
*/
public SVGSketchFigure(RenderedImage i) {
super(i, true, true, true);

Unknown model = (Unknown) ((ShapeImpl) getModel())
.basicGetElement();
setToolTip(new Label(model.getElement()));

this.image = i;

this.setMaintainAspectRatio(true);

this.setRenderedImage(image);

createContents();

//center the children
this.setLayoutManager(new StackLayout() {
public void layout(IFigure figure) {
Rectangle r = figure.getClientArea();
List children = figure.getChildren();
IFigure child;
Dimension d;
for (int i = 0; i < children.size(); i++) {
child = (IFigure) children.get(i);
d = child.getPreferredSize(r.width, r.height);
d.width = Math.min(d.width, r.width);
d.height = Math.min(d.height, r.height);
Rectangle childRect = new Rectangle(r.x
+ (r.width - d.width) / 2, r.y
+ (r.height - d.height) / 2, d.width, d.height);
child.setBounds(childRect);
}
}
});
}

/**
* @generated NOT
*/
private void createContents() {

fFigureSketchLabelFigure = new WrappingLabel();
fFigureSketchLabelFigure.setAlignment(PositionConstants.CENT ER);
fFigureSketchLabelFigure.setText("");
fFigureSketchLabelFigure.setBackgroundColor(ColorConstants.w hite);

this.add(fFigureSketchLabelFigure);

}

/**
* @generated
*/
public WrappingLabel getFigureSketchLabelFigure() {
return fFigureSketchLabelFigure;
}

}



On 25-01-2011 15:39, Martin Fluegge wrote:
>> Hi all, I'm getting this on my Dawn/GMF editor. My editor is not refreshed, but when saved, the other editors are refreshed properly:
>
> With "not refreshed" you mean that the element you placed on your diagram is not visible?
>
> Following the excpetion I would say that the getFigure() method from your ShapeEditPart subclass seems the deleiver null. Did you customize the cdo in the affected class?
>
> Could you provide more information about the node? Does it have labels or any compartments?
>
> Cheers,
>
> Martin
Re: [CDO] NPEx when setLayoutConstraint on GMF editors [message #650653 is a reply to message #650598] Tue, 25 January 2011 20:44 Go to previous messageGo to next message
Martin Fluegge is currently offline Martin FlueggeFriend
Messages: 141
Registered: July 2009
Senior Member
Hi Ugo,

I had a quick look at the problem. I would say that GMF should handle
the call of getFigure() more carefully and not pass the result if it is
null.

But it might also indicate an error in Dawn. Could you please send me
you code (the one with the "Diagram_") or put it on specific branch.

Then I'll try to reproduce the problem to get a better understanding of
what happens.

Cheers,

Martin

Am 25.01.2011 17:38, schrieb Ugo Sangiorgi:
> Exactly, I mean the node is not visible, although the editor gets dirty
> and all :)
> And it only happens with my custom figure, and for creation only
> (editing labels and moving the node performs fine)
>
> I have two types of nodes:
> -Squares/Triangles, which are classic GMF figures.
> -Unknown, sketched figures (SVGSketchFigure that is constructed based on
> a property of the node, which is an svg encoded in base64)
>
>
> Here is how I create the figure:
>
> protected IFigure createNodeShape() {
>
> Bundle bundle =
> Platform.getBundle("org.eclipse.sketch.examples.shapes");
> try {
>
> NodeImpl n = (NodeImpl) getModel();
> Unknown s = (Unknown) n.basicGetElement();
>
> if (s.getSvg() != null) {
>
> IWorkspaceRoot myWorkspaceRoot =
> ResourcesPlugin.getWorkspace().getRoot();
> File imgfile = myWorkspaceRoot.getLocation()
> .append("s" + System.currentTimeMillis() + ".svg")
> .toFile();
>
> Base64.decodeToFile(s.getSvg(), imgfile.getPath());
>
> RenderedImage img =
> RenderedImageFactory.getInstance(imgfile.getPath());
> img.getRenderInfo().setValues(0, 0, true, true,new RGB(255,
> 0, 0), new RGB(255, 0, 0));
>
> primaryShape = new SVGSketchFigure(img);
>
> } else {
> primaryShape = new
> SVGSketchFigure(RenderedImageFactory.getInstance(bundle
> .getEntry("/icons/square.svg")));
> }
>
> } catch (IOException e) {
> e.printStackTrace();
> }
> return primaryShape;
>
> }
>
> ...
>
> public class SVGSketchFigure extends ScalableImageFigure {
>
> /**
> * @generated
> */
> private WrappingLabel fFigureSketchLabelFigure;
>
> /**
> * @generated NOT
> */
> private RenderedImage image;
>
> /**
> * @generated NOT
> */
> public SVGSketchFigure() {
> super(null, true, true, true);
> createContents();
> }
>
> /**
> * @generated NOT
> */
> public SVGSketchFigure(RenderedImage i) {
> super(i, true, true, true);
>
> Unknown model = (Unknown) ((ShapeImpl) getModel())
> .basicGetElement();
> setToolTip(new Label(model.getElement()));
>
> this.image = i;
>
> this.setMaintainAspectRatio(true);
>
> this.setRenderedImage(image);
>
> createContents();
>
> //center the children
> this.setLayoutManager(new StackLayout() {
> public void layout(IFigure figure) {
> Rectangle r = figure.getClientArea();
> List children = figure.getChildren();
> IFigure child;
> Dimension d;
> for (int i = 0; i < children.size(); i++) {
> child = (IFigure) children.get(i);
> d = child.getPreferredSize(r.width, r.height);
> d.width = Math.min(d.width, r.width);
> d.height = Math.min(d.height, r.height);
> Rectangle childRect = new Rectangle(r.x
> + (r.width - d.width) / 2, r.y
> + (r.height - d.height) / 2, d.width,
> d.height);
> child.setBounds(childRect);
> }
> }
> });
> }
>
> /**
> * @generated NOT
> */
> private void createContents() {
>
> fFigureSketchLabelFigure = new WrappingLabel();
>
> fFigureSketchLabelFigure.setAlignment(PositionConstants.CENT ER);
> fFigureSketchLabelFigure.setText("");
>
> fFigureSketchLabelFigure.setBackgroundColor(ColorConstants.w hite);
>
> this.add(fFigureSketchLabelFigure);
>
> }
>
> /**
> * @generated
> */
> public WrappingLabel getFigureSketchLabelFigure() {
> return fFigureSketchLabelFigure;
> }
>
> }
>
>
>
> On 25-01-2011 15:39, Martin Fluegge wrote:
>>> Hi all, I'm getting this on my Dawn/GMF editor. My editor is not
>>> refreshed, but when saved, the other editors are refreshed properly:
>>
>> With "not refreshed" you mean that the element you placed on your
>> diagram is not visible?
>>
>> Following the excpetion I would say that the getFigure() method from
>> your ShapeEditPart subclass seems the deleiver null. Did you customize
>> the cdo in the affected class?
>>
>> Could you provide more information about the node? Does it have labels
>> or any compartments?
>>
>> Cheers,
>>
>> Martin
>
Re: [CDO] NPEx when setLayoutConstraint on GMF editors [message #650715 is a reply to message #650598] Wed, 26 January 2011 09:02 Go to previous messageGo to next message
Martin Fluegge is currently offline Martin FlueggeFriend
Messages: 141
Registered: July 2009
Senior Member
Ugo,

sorry, somehow my reply from yesterday got lost Sad

Could you send me you code again (the one with the "Diagram_"). I'tt try to reproduce it and see whether the problem is related to your customization or is Dawn specific.

Cheers,

Martin
Re: [CDO] NPEx when setLayoutConstraint on GMF editors [message #650721 is a reply to message #650715] Wed, 26 January 2011 09:29 Go to previous messageGo to next message
Martin Fluegge is currently offline Martin FlueggeFriend
Messages: 141
Registered: July 2009
Senior Member
Darn, seems that the reply did not get lost. So just forget my last post.

Either my browser cache tricked me or I need glasses.

Sorry for the confusion Sad
Re: [CDO] NPEx when setLayoutConstraint on GMF editors [message #650722 is a reply to message #650653] Wed, 26 January 2011 09:31 Go to previous messageGo to next message
Ugo Sangiorgi is currently offline Ugo SangiorgiFriend
Messages: 59
Registered: January 2010
Member
Hi Martin,
I've put into github, under the cdo-dawn branch.

The Shapes app projects are under examples
https://github.com/ugosan/sketch/tree/cdo-dawn/examples
and the sketch core plugin is under:
https://github.com/ugosan/sketch/tree/cdo-dawn/plugins

thank you very much for that!
Ugo

On 25-01-2011 21:44, Martin Flügge wrote:
> Hi Ugo,
>
> I had a quick look at the problem. I would say that GMF should handle
> the call of getFigure() more carefully and not pass the result if it is
> null.
>
> But it might also indicate an error in Dawn. Could you please send me
> you code (the one with the "Diagram_") or put it on specific branch.
>
> Then I'll try to reproduce the problem to get a better understanding of
> what happens.
>
> Cheers,
>
> Martin
>
> Am 25.01.2011 17:38, schrieb Ugo Sangiorgi:
>> Exactly, I mean the node is not visible, although the editor gets dirty
>> and all :)
>> And it only happens with my custom figure, and for creation only
>> (editing labels and moving the node performs fine)
>>
>> I have two types of nodes:
>> -Squares/Triangles, which are classic GMF figures.
>> -Unknown, sketched figures (SVGSketchFigure that is constructed based on
>> a property of the node, which is an svg encoded in base64)
>>
>>
>> Here is how I create the figure:
>>
>> protected IFigure createNodeShape() {
>>
>> Bundle bundle =
>> Platform.getBundle("org.eclipse.sketch.examples.shapes");
>> try {
>>
>> NodeImpl n = (NodeImpl) getModel();
>> Unknown s = (Unknown) n.basicGetElement();
>>
>> if (s.getSvg() != null) {
>>
>> IWorkspaceRoot myWorkspaceRoot =
>> ResourcesPlugin.getWorkspace().getRoot();
>> File imgfile = myWorkspaceRoot.getLocation()
>> .append("s" + System.currentTimeMillis() + ".svg")
>> .toFile();
>>
>> Base64.decodeToFile(s.getSvg(), imgfile.getPath());
>>
>> RenderedImage img =
>> RenderedImageFactory.getInstance(imgfile.getPath());
>> img.getRenderInfo().setValues(0, 0, true, true,new RGB(255,
>> 0, 0), new RGB(255, 0, 0));
>>
>> primaryShape = new SVGSketchFigure(img);
>>
>> } else {
>> primaryShape = new
>> SVGSketchFigure(RenderedImageFactory.getInstance(bundle
>> .getEntry("/icons/square.svg")));
>> }
>>
>> } catch (IOException e) {
>> e.printStackTrace();
>> }
>> return primaryShape;
>>
>> }
>>
>> ...
>>
>> public class SVGSketchFigure extends ScalableImageFigure {
>>
>> /**
>> * @generated
>> */
>> private WrappingLabel fFigureSketchLabelFigure;
>>
>> /**
>> * @generated NOT
>> */
>> private RenderedImage image;
>>
>> /**
>> * @generated NOT
>> */
>> public SVGSketchFigure() {
>> super(null, true, true, true);
>> createContents();
>> }
>>
>> /**
>> * @generated NOT
>> */
>> public SVGSketchFigure(RenderedImage i) {
>> super(i, true, true, true);
>>
>> Unknown model = (Unknown) ((ShapeImpl) getModel())
>> .basicGetElement();
>> setToolTip(new Label(model.getElement()));
>>
>> this.image = i;
>>
>> this.setMaintainAspectRatio(true);
>>
>> this.setRenderedImage(image);
>>
>> createContents();
>>
>> //center the children
>> this.setLayoutManager(new StackLayout() {
>> public void layout(IFigure figure) {
>> Rectangle r = figure.getClientArea();
>> List children = figure.getChildren();
>> IFigure child;
>> Dimension d;
>> for (int i = 0; i< children.size(); i++) {
>> child = (IFigure) children.get(i);
>> d = child.getPreferredSize(r.width, r.height);
>> d.width = Math.min(d.width, r.width);
>> d.height = Math.min(d.height, r.height);
>> Rectangle childRect = new Rectangle(r.x
>> + (r.width - d.width) / 2, r.y
>> + (r.height - d.height) / 2, d.width,
>> d.height);
>> child.setBounds(childRect);
>> }
>> }
>> });
>> }
>>
>> /**
>> * @generated NOT
>> */
>> private void createContents() {
>>
>> fFigureSketchLabelFigure = new WrappingLabel();
>>
>> fFigureSketchLabelFigure.setAlignment(PositionConstants.CENT ER);
>> fFigureSketchLabelFigure.setText("");
>>
>> fFigureSketchLabelFigure.setBackgroundColor(ColorConstants.w hite);
>>
>> this.add(fFigureSketchLabelFigure);
>>
>> }
>>
>> /**
>> * @generated
>> */
>> public WrappingLabel getFigureSketchLabelFigure() {
>> return fFigureSketchLabelFigure;
>> }
>>
>> }
>>
>>
>>
>> On 25-01-2011 15:39, Martin Fluegge wrote:
>>>> Hi all, I'm getting this on my Dawn/GMF editor. My editor is not
>>>> refreshed, but when saved, the other editors are refreshed properly:
>>>
>>> With "not refreshed" you mean that the element you placed on your
>>> diagram is not visible?
>>>
>>> Following the excpetion I would say that the getFigure() method from
>>> your ShapeEditPart subclass seems the deleiver null. Did you customize
>>> the cdo in the affected class?
>>>
>>> Could you provide more information about the node? Does it have labels
>>> or any compartments?
>>>
>>> Cheers,
>>>
>>> Martin
>>
>
Re: [CDO] NPEx when setLayoutConstraint on GMF editors [message #651092 is a reply to message #650722] Thu, 27 January 2011 17:12 Go to previous messageGo to next message
Martin Fluegge is currently offline Martin FlueggeFriend
Messages: 141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030100060102030306030304
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Hi Ugo,

I managed to run your example diagram and played a bit around with it.
The problem was that your customized UnknowEditPart was missing some
null checks. After I added (see attached file) them it seems to work. :)



Cheers,

Martin


Am 26.01.2011 10:31, schrieb Ugo Sangiorgi:
> Hi Martin,
> I've put into github, under the cdo-dawn branch.
>
> The Shapes app projects are under examples
> https://github.com/ugosan/sketch/tree/cdo-dawn/examples
> and the sketch core plugin is under:
> https://github.com/ugosan/sketch/tree/cdo-dawn/plugins
>
> thank you very much for that!
> Ugo
>
> On 25-01-2011 21:44, Martin Flügge wrote:
>> Hi Ugo,
>>
>> I had a quick look at the problem. I would say that GMF should handle
>> the call of getFigure() more carefully and not pass the result if it is
>> null.
>>
>> But it might also indicate an error in Dawn. Could you please send me
>> you code (the one with the "Diagram_") or put it on specific branch.
>>
>> Then I'll try to reproduce the problem to get a better understanding of
>> what happens.
>>
>> Cheers,
>>
>> Martin
>>
>> Am 25.01.2011 17:38, schrieb Ugo Sangiorgi:
>>> Exactly, I mean the node is not visible, although the editor gets dirty
>>> and all :)
>>> And it only happens with my custom figure, and for creation only
>>> (editing labels and moving the node performs fine)
>>>
>>> I have two types of nodes:
>>> -Squares/Triangles, which are classic GMF figures.
>>> -Unknown, sketched figures (SVGSketchFigure that is constructed based on
>>> a property of the node, which is an svg encoded in base64)
>>>
>>>
>>> Here is how I create the figure:
>>>
>>> protected IFigure createNodeShape() {
>>>
>>> Bundle bundle =
>>> Platform.getBundle("org.eclipse.sketch.examples.shapes");
>>> try {
>>>
>>> NodeImpl n = (NodeImpl) getModel();
>>> Unknown s = (Unknown) n.basicGetElement();
>>>
>>> if (s.getSvg() != null) {
>>>
>>> IWorkspaceRoot myWorkspaceRoot =
>>> ResourcesPlugin.getWorkspace().getRoot();
>>> File imgfile = myWorkspaceRoot.getLocation()
>>> .append("s" + System.currentTimeMillis() + ".svg")
>>> .toFile();
>>>
>>> Base64.decodeToFile(s.getSvg(), imgfile.getPath());
>>>
>>> RenderedImage img =
>>> RenderedImageFactory.getInstance(imgfile.getPath());
>>> img.getRenderInfo().setValues(0, 0, true, true,new RGB(255,
>>> 0, 0), new RGB(255, 0, 0));
>>>
>>> primaryShape = new SVGSketchFigure(img);
>>>
>>> } else {
>>> primaryShape = new
>>> SVGSketchFigure(RenderedImageFactory.getInstance(bundle
>>> .getEntry("/icons/square.svg")));
>>> }
>>>
>>> } catch (IOException e) {
>>> e.printStackTrace();
>>> }
>>> return primaryShape;
>>>
>>> }
>>>
>>> ...
>>>
>>> public class SVGSketchFigure extends ScalableImageFigure {
>>>
>>> /**
>>> * @generated
>>> */
>>> private WrappingLabel fFigureSketchLabelFigure;
>>>
>>> /**
>>> * @generated NOT
>>> */
>>> private RenderedImage image;
>>>
>>> /**
>>> * @generated NOT
>>> */
>>> public SVGSketchFigure() {
>>> super(null, true, true, true);
>>> createContents();
>>> }
>>>
>>> /**
>>> * @generated NOT
>>> */
>>> public SVGSketchFigure(RenderedImage i) {
>>> super(i, true, true, true);
>>>
>>> Unknown model = (Unknown) ((ShapeImpl) getModel())
>>> .basicGetElement();
>>> setToolTip(new Label(model.getElement()));
>>>
>>> this.image = i;
>>>
>>> this.setMaintainAspectRatio(true);
>>>
>>> this.setRenderedImage(image);
>>>
>>> createContents();
>>>
>>> //center the children
>>> this.setLayoutManager(new StackLayout() {
>>> public void layout(IFigure figure) {
>>> Rectangle r = figure.getClientArea();
>>> List children = figure.getChildren();
>>> IFigure child;
>>> Dimension d;
>>> for (int i = 0; i< children.size(); i++) {
>>> child = (IFigure) children.get(i);
>>> d = child.getPreferredSize(r.width, r.height);
>>> d.width = Math.min(d.width, r.width);
>>> d.height = Math.min(d.height, r.height);
>>> Rectangle childRect = new Rectangle(r.x
>>> + (r.width - d.width) / 2, r.y
>>> + (r.height - d.height) / 2, d.width,
>>> d.height);
>>> child.setBounds(childRect);
>>> }
>>> }
>>> });
>>> }
>>>
>>> /**
>>> * @generated NOT
>>> */
>>> private void createContents() {
>>>
>>> fFigureSketchLabelFigure = new WrappingLabel();
>>>
>>> fFigureSketchLabelFigure.setAlignment(PositionConstants.CENT ER);
>>> fFigureSketchLabelFigure.setText("");
>>>
>>> fFigureSketchLabelFigure.setBackgroundColor(ColorConstants.w hite);
>>>
>>> this.add(fFigureSketchLabelFigure);
>>>
>>> }
>>>
>>> /**
>>> * @generated
>>> */
>>> public WrappingLabel getFigureSketchLabelFigure() {
>>> return fFigureSketchLabelFigure;
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> On 25-01-2011 15:39, Martin Fluegge wrote:
>>>>> Hi all, I'm getting this on my Dawn/GMF editor. My editor is not
>>>>> refreshed, but when saved, the other editors are refreshed properly:
>>>>
>>>> With "not refreshed" you mean that the element you placed on your
>>>> diagram is not visible?
>>>>
>>>> Following the excpetion I would say that the getFigure() method from
>>>> your ShapeEditPart subclass seems the deleiver null. Did you customize
>>>> the cdo in the affected class?
>>>>
>>>> Could you provide more information about the node? Does it have labels
>>>> or any compartments?
>>>>
>>>> Cheers,
>>>>
>>>> Martin
>>>
>>
>


--------------030100060102030306030304
Content-Type: text/plain;
name="UnknownEditPart.java"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="UnknownEditPart.java"

LyoqCiAqIENvcHlyaWdodCAoYykgMjAxMCBVZ28gU2FuZ2lvcmdpIGFuZCBv dGhlcnMuCiAq
ICBBbGwgcmlnaHRzIHJlc2VydmVkLiBUaGlzIHByb2dyYW0gYW5kIHRoZSBh Y2NvbXBhbnlp
bmcgbWF0ZXJpYWxzCiAqICBhcmUgbWFkZSBhdmFpbGFibGUgdW5kZXIgdGhl IHRlcm1zIG9m
IHRoZSBFY2xpcHNlIFB1YmxpYyBMaWNlbnNlIHYxLjAKICogIHdoaWNoIGFj Y29tcGFuaWVz
IHRoaXMgZGlzdHJpYnV0aW9uLCBhbmQgaXMgYXZhaWxhYmxlIGF0CiAqICBo dHRwOi8vd3d3
LmVjbGlwc2Uub3JnL2xlZ2FsL2VwbC12MTAuaHRtbAogKiAgCiAqICBDb250 cmlidXRvcnM6
CiAqICBVZ28gU2FuZ2lvcmdpIDx1Z28uc2FuZ2lvcmdpQGdtYWlsLmNvbT4g LSBJbml0aWFs
IGNvbnRyaWJ1dGlvbgogKiAgCiAqCiAqICRJZCQKICovIAogcGFja2FnZSBv cmcuZWNsaXBz
ZS5za2V0Y2guZXhhbXBsZXMuc2hhcGVzLmRpYWdyYW0uZWRpdC5wYXJ0czsK CmltcG9ydCBq
YXZhLmlvLkZpbGU7CmltcG9ydCBqYXZhLmlvLklPRXhjZXB0aW9uOwppbXBv cnQgamF2YS51
dGlsLkF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CQkgKi8KCQlwcm90ZWN0ZWQgdm9pZCBzZXRVc2VMb2NhbENvb3JkaW5h dGVzKGJvb2xl
YW4gdXNlTG9jYWxDb29yZGluYXRlcykgewoJCQlteVVzZUxvY2FsQ29vcmRp bmF0ZXMgPSB1
c2VMb2NhbENvb3JkaW5hdGVzOwoJCX0KCgkJLyoqCgkJICogQGdlbmVyYXRl ZAoJCSAqLwoJ
CXB1YmxpYyBXcmFwcGluZ0xhYmVsIGdldEZpZ3VyZVNrZXRjaExhYmVsRmln dXJlKCkgewoJ
CQlyZXR1cm4gZkZpZ3VyZVNrZXRjaExhYmVsRmlndXJlOwoJCX0KCgl9Cgp9 Cg==
--------------030100060102030306030304--
Re: [CDO] NPEx when setLayoutConstraint on GMF editors [message #652070 is a reply to message #651092] Wed, 02 February 2011 14:48 Go to previous message
Ugo Sangiorgi is currently offline Ugo SangiorgiFriend
Messages: 59
Registered: January 2010
Member
Hi Martin,
Sorry for the late response,

Yes the editpart is created, but the SVG figure (the one based the EMF property) doesnt.
All I get is a blue square (the default figure).

I believe the view is being created before the EObject is ready, or something.
What do you think?

thank you, its party solved anyway
Ugo
On 27-01-2011 18:12, Martin Flügge wrote:
> Hi Ugo,
>
> I managed to run your example diagram and played a bit around with it.
> The problem was that your customized UnknowEditPart was missing some
> null checks. After I added (see attached file) them it seems to work. :)
>
>
>
> Cheers,
>
> Martin
>
>
> Am 26.01.2011 10:31, schrieb Ugo Sangiorgi:
>> Hi Martin,
>> I've put into github, under the cdo-dawn branch.
>>
>> The Shapes app projects are under examples
>> https://github.com/ugosan/sketch/tree/cdo-dawn/examples
>> and the sketch core plugin is under:
>> https://github.com/ugosan/sketch/tree/cdo-dawn/plugins
>>
>> thank you very much for that!
>> Ugo
>>
>> On 25-01-2011 21:44, Martin Flügge wrote:
>>> Hi Ugo,
>>>
>>> I had a quick look at the problem. I would say that GMF should handle
>>> the call of getFigure() more carefully and not pass the result if it is
>>> null.
>>>
>>> But it might also indicate an error in Dawn. Could you please send me
>>> you code (the one with the "Diagram_") or put it on specific branch.
>>>
>>> Then I'll try to reproduce the problem to get a better understanding of
>>> what happens.
>>>
>>> Cheers,
>>>
>>> Martin
>>>
>>> Am 25.01.2011 17:38, schrieb Ugo Sangiorgi:
>>>> Exactly, I mean the node is not visible, although the editor gets dirty
>>>> and all :)
>>>> And it only happens with my custom figure, and for creation only
>>>> (editing labels and moving the node performs fine)
>>>>
>>>> I have two types of nodes:
>>>> -Squares/Triangles, which are classic GMF figures.
>>>> -Unknown, sketched figures (SVGSketchFigure that is constructed based on
>>>> a property of the node, which is an svg encoded in base64)
>>>>
>>>>
>>>> Here is how I create the figure:
>>>>
>>>> protected IFigure createNodeShape() {
>>>>
>>>> Bundle bundle =
>>>> Platform.getBundle("org.eclipse.sketch.examples.shapes");
>>>> try {
>>>>
>>>> NodeImpl n = (NodeImpl) getModel();
>>>> Unknown s = (Unknown) n.basicGetElement();
>>>>
>>>> if (s.getSvg() != null) {
>>>>
>>>> IWorkspaceRoot myWorkspaceRoot =
>>>> ResourcesPlugin.getWorkspace().getRoot();
>>>> File imgfile = myWorkspaceRoot.getLocation()
>>>> .append("s" + System.currentTimeMillis() + ".svg")
>>>> .toFile();
>>>>
>>>> Base64.decodeToFile(s.getSvg(), imgfile.getPath());
>>>>
>>>> RenderedImage img =
>>>> RenderedImageFactory.getInstance(imgfile.getPath());
>>>> img.getRenderInfo().setValues(0, 0, true, true,new RGB(255,
>>>> 0, 0), new RGB(255, 0, 0));
>>>>
>>>> primaryShape = new SVGSketchFigure(img);
>>>>
>>>> } else {
>>>> primaryShape = new
>>>> SVGSketchFigure(RenderedImageFactory.getInstance(bundle
>>>> .getEntry("/icons/square.svg")));
>>>> }
>>>>
>>>> } catch (IOException e) {
>>>> e.printStackTrace();
>>>> }
>>>> return primaryShape;
>>>>
>>>> }
>>>>
>>>> ...
>>>>
>>>> public class SVGSketchFigure extends ScalableImageFigure {
>>>>
>>>> /**
>>>> * @generated
>>>> */
>>>> private WrappingLabel fFigureSketchLabelFigure;
>>>>
>>>> /**
>>>> * @generated NOT
>>>> */
>>>> private RenderedImage image;
>>>>
>>>> /**
>>>> * @generated NOT
>>>> */
>>>> public SVGSketchFigure() {
>>>> super(null, true, true, true);
>>>> createContents();
>>>> }
>>>>
>>>> /**
>>>> * @generated NOT
>>>> */
>>>> public SVGSketchFigure(RenderedImage i) {
>>>> super(i, true, true, true);
>>>>
>>>> Unknown model = (Unknown) ((ShapeImpl) getModel())
>>>> .basicGetElement();
>>>> setToolTip(new Label(model.getElement()));
>>>>
>>>> this.image = i;
>>>>
>>>> this.setMaintainAspectRatio(true);
>>>>
>>>> this.setRenderedImage(image);
>>>>
>>>> createContents();
>>>>
>>>> //center the children
>>>> this.setLayoutManager(new StackLayout() {
>>>> public void layout(IFigure figure) {
>>>> Rectangle r = figure.getClientArea();
>>>> List children = figure.getChildren();
>>>> IFigure child;
>>>> Dimension d;
>>>> for (int i = 0; i< children.size(); i++) {
>>>> child = (IFigure) children.get(i);
>>>> d = child.getPreferredSize(r.width, r.height);
>>>> d.width = Math.min(d.width, r.width);
>>>> d.height = Math.min(d.height, r.height);
>>>> Rectangle childRect = new Rectangle(r.x
>>>> + (r.width - d.width) / 2, r.y
>>>> + (r.height - d.height) / 2, d.width,
>>>> d.height);
>>>> child.setBounds(childRect);
>>>> }
>>>> }
>>>> });
>>>> }
>>>>
>>>> /**
>>>> * @generated NOT
>>>> */
>>>> private void createContents() {
>>>>
>>>> fFigureSketchLabelFigure = new WrappingLabel();
>>>>
>>>> fFigureSketchLabelFigure.setAlignment(PositionConstants.CENT ER);
>>>> fFigureSketchLabelFigure.setText("");
>>>>
>>>> fFigureSketchLabelFigure.setBackgroundColor(ColorConstants.w hite);
>>>>
>>>> this.add(fFigureSketchLabelFigure);
>>>>
>>>> }
>>>>
>>>> /**
>>>> * @generated
>>>> */
>>>> public WrappingLabel getFigureSketchLabelFigure() {
>>>> return fFigureSketchLabelFigure;
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> On 25-01-2011 15:39, Martin Fluegge wrote:
>>>>>> Hi all, I'm getting this on my Dawn/GMF editor. My editor is not
>>>>>> refreshed, but when saved, the other editors are refreshed properly:
>>>>>
>>>>> With "not refreshed" you mean that the element you placed on your
>>>>> diagram is not visible?
>>>>>
>>>>> Following the excpetion I would say that the getFigure() method from
>>>>> your ShapeEditPart subclass seems the deleiver null. Did you customize
>>>>> the cdo in the affected class?
>>>>>
>>>>> Could you provide more information about the node? Does it have labels
>>>>> or any compartments?
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Martin
>>>>
>>>
>>
>
Previous Topic:EMF : from xml file to instance emf
Next Topic:[EMF Query 2]Parameter in XText query
Goto Forum:
  


Current Time: Sat Oct 19 20:15:02 GMT 2019

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

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

Back to the top