Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Creating EditPart + setting size no longer working
Creating EditPart + setting size no longer working [message #661637] Fri, 25 March 2011 16:09 Go to next message
Ugo Sangiorgi is currently offline Ugo SangiorgiFriend
Messages: 59
Registered: January 2010
Member
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>Hello, after re-generating my code my CreateViewRequest seems to
be failing on setting the size of my editpart.<br>
I've checked over and over to see if there is something i forgot
to mark as @generated NOT, but everything seems right.<br>
<br>
The editpart is created, but with a default (small) size.<br>
<br>
here is my code, is there something missing?:<br>
<br>
<small>final DiagramEditor editor = (DiagramEditor)
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor(); <br>
<br>
CreateViewRequest.ViewDescriptor viewDescriptor = new
CreateViewRequest.ViewDescriptor(<br>
&nbsp;&nbsp; &nbsp;new EObjectAdapter(unknown_element), Node.class, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;((IHintedType)ShapesElementTypes.Unknown_2003).get SemanticHint(),
true,editor.getDiagramEditPart().getDiagramPreferencesHint() ); <br>
<br>
viewDescriptor.setPersisted(true);<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
<br>
CreateViewRequest createRequest = new
CreateViewRequest(viewDescriptor);<br>
<b>createRequest.setLocation(s.getLocation());<br>
createRequest.setSize(s.getSize());</b><br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
//command to add the element to the model<br>
Command c = new Command(){<br>
&nbsp;&nbsp; &nbsp;@Override<br>
&nbsp;&nbsp; &nbsp;public void execute() {<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;AbstractEMFOperation emfOp = new
AbstractEMFOperation(editor.getEditingDomain(), "Insert sketched
element") {<br>
<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;@Override<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;protected IStatus doExecute(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException {<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DiagramImpl n =
(DiagramImpl)editor.getDiagramEditPart().getModel();<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Diagram s = (Diagram) n.basicGetElement(); <br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;s.getShapes().add(unknown_element);<br>
<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return Status.OK_STATUS;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;};<br>
<br>
<br>
&nbsp;&nbsp; &nbsp;try {<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;OperationHistoryFactory.getOperationHistory().exec ute(emfOp,
null, null);<br>
&nbsp;&nbsp;&nbsp; } catch (ExecutionException e) {}<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; };<br>
<br>
editor.getDiagramEditDomain().getDiagramCommandStack().execu te(c); <br>
&nbsp;&nbsp;&nbsp; &nbsp;
editor.getDiagramEditDomain().getDiagramCommandStack().execu te(editor.getDiagramEditPart().getCommand(createRequest)); <br>
</small><br>
<br>
<br>
Thank you!<br>
</tt>
</body>
</html>
Re: Creating EditPart + setting size no longer working [message #661833 is a reply to message #661637] Mon, 28 March 2011 07:34 Go to previous messageGo to next message
Matthias Kloppenborg is currently offline Matthias KloppenborgFriend
Messages: 17
Registered: April 2010
Junior Member
Hello Ugo.

Maybe this might help you to solve the problem.

There are inner ...Figure classes in the EditParts.
Have a deeper look at the createContents functions there.
Maybe this was changed by regenerating the code.

Greetings Matthias

Am 25.03.2011 17:09, schrieb Ugo Sangiorgi:
> Hello, after re-generating my code my CreateViewRequest seems to be
> failing on setting the size of my editpart.
> I've checked over and over to see if there is something i forgot to mark
> as @generated NOT, but everything seems right.
>
> The editpart is created, but with a default (small) size.
>
> here is my code, is there something missing?:
>
> final DiagramEditor editor = (DiagramEditor)
> PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getActiveEditor();
>
> CreateViewRequest.ViewDescriptor viewDescriptor = new
> CreateViewRequest.ViewDescriptor(
> new EObjectAdapter(unknown_element), Node.class,
> ((IHintedType)ShapesElementTypes.Unknown_2003).getSemanticHi nt(),
> true,editor.getDiagramEditPart().getDiagramPreferencesHint() );
>
> viewDescriptor.setPersisted(true);
>
>
> CreateViewRequest createRequest = new CreateViewRequest(viewDescriptor);
> *createRequest.setLocation(s.getLocation());
> createRequest.setSize(s.getSize());*
>
>
> //command to add the element to the model
> Command c = new Command(){
> @Override
> public void execute() {
> AbstractEMFOperation emfOp = new
> AbstractEMFOperation(editor.getEditingDomain(), "Insert sketched element") {
>
> @Override
> protected IStatus doExecute(IProgressMonitor monitor, IAdaptable info)
> throws ExecutionException {
>
> DiagramImpl n = (DiagramImpl)editor.getDiagramEditPart().getModel();
> Diagram s = (Diagram) n.basicGetElement();
>
> s.getShapes().add(unknown_element);
>
> return Status.OK_STATUS;
> }
> };
>
>
> try {
> OperationHistoryFactory.getOperationHistory().execute(emfOp, null, null);
> } catch (ExecutionException e) {}
> }
> };
>
> editor.getDiagramEditDomain().getDiagramCommandStack().execu te(c);
> editor.getDiagramEditDomain().getDiagramCommandStack().execu te(editor.getDiagramEditPart().getCommand(createRequest));
>
>
>
> Thank you!
Re: Creating EditPart + setting size no longer working [message #661927 is a reply to message #661833] Mon, 28 March 2011 14:26 Go to previous message
Ugo Sangiorgi is currently offline Ugo SangiorgiFriend
Messages: 59
Registered: January 2010
Member
This is a multi-part message in MIME format.
--------------090302040905060902070400
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Thanks Matthias, I looked all over, the figure is the same.
something is generated differently from previous version, and I cant
tell what is it.

The thing is that is an SVG figure, when I construct the Figure I do:

public SVGSketchFigure(RenderedImage i) {
super(i, false, true, true);

Unknown model = (Unknown) ((ShapeImpl) getModel())
.basicGetElement();
this.image = i;

this.setMaintainAspectRatio(true);

this.setRenderedImage(image);

createContents();

this.setLayoutManager(new StackLayout() {
public void layout(IFigure figure) {
*Rectangle r = figure.getClientArea();*
....

This figure.getClientArea() returns differently between the two versions
(original and re-generated).

I'm clueless.
Thanks anyway ^^

Le 28/03/11 09:34, Matthias Kloppenborg a
Previous Topic:Question according to http://wiki.eclipse.org/GMF_Constraints
Next Topic:GMF in eclipse 3.6 SR2
Goto Forum:
  


Current Time: Fri Dec 06 21:07:17 GMT 2024

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

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

Back to the top