Creating EditPart + setting size no longer working [message #661637] |
Fri, 25 March 2011 16:09 |
|
<!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>
new EObjectAdapter(unknown_element), Node.class,
((IHintedType)ShapesElementTypes.Unknown_2003).get SemanticHint(),
true,editor.getDiagramEditPart().getDiagramPreferencesHint() ); <br>
<br>
viewDescriptor.setPersisted(true);<br>
<br>
<br>
CreateViewRequest createRequest = new
CreateViewRequest(viewDescriptor);<br>
<b>createRequest.setLocation(s.getLocation());<br>
createRequest.setSize(s.getSize());</b><br>
<br>
<br>
//command to add the element to the model<br>
Command c = new Command(){<br>
@Override<br>
public void execute() {<br>
AbstractEMFOperation emfOp = new
AbstractEMFOperation(editor.getEditingDomain(), "Insert sketched
element") {<br>
<br>
@Override<br>
protected IStatus doExecute(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException {<br>
<br>
DiagramImpl n =
(DiagramImpl)editor.getDiagramEditPart().getModel();<br>
Diagram s = (Diagram) n.basicGetElement(); <br>
<br>
s.getShapes().add(unknown_element);<br>
<br>
return Status.OK_STATUS;<br>
}<br>
};<br>
<br>
<br>
try {<br>
OperationHistoryFactory.getOperationHistory().exec ute(emfOp,
null, null);<br>
} catch (ExecutionException e) {}<br>
}<br>
};<br>
<br>
editor.getDiagramEditDomain().getDiagramCommandStack().execu te(c); <br>
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 |
Matthias Kloppenborg 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 |
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03021 seconds