Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Refresh RootEditPart
Refresh RootEditPart [message #663821] Wed, 06 April 2011 10:30 Go to next message
Eclipse UserFriend
I have a custom layer on my
org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart ,
I tried everything to refresh and show its figure, but it only refreshes
when i add or move something, and also when I resize the editor area, of
course.

Any hints?


my createFigure() and getContentPane():

@Override
/**
* Replaces default figure with layered pane. Lower layer for
decorations, upper is original figure.
*/
protected IFigure createFigure() {
FreeformLayeredPane pane = new FreeformLayeredPane();
FreeformLayer roseLayer = new FreeformLayer() {

public Rectangle getFreeformExtent() {
// Do not count children; they are decorations that
should not interfere with diagram contents.
Insets insets = getInsets();
return new Rectangle(0, 0, insets.getWidth(),
insets.getHeight());
}
};
roseLayer.setLayoutManager(new StackLayout());
pane.add(roseLayer);
roseLayer.add(new Figure() {
@Override
public void paint(Graphics g) {
g.setLineWidth(1);
g.setForegroundColor(new Color(null, 100, 100, 100));

DiagramImpl d = (DiagramImpl) getModel();

Sketch s = ((Diagram) d.getElement()).getRootSketch();

if (s != null) {

for (int i = 1; i < s.getPointlist().size(); i++) {
Point p = (Point) s.getPointlist().get(i);
Point lastp = p;
lastp = (Point) s.getPointlist().get(i - 1);

if (lastp.x == -1) {
//if the last point is a pen lift, then
consider just the current one
g.drawLine(p.x, p.y, p.x, p.y);

} else if (p.x > 0) {
//if is a normal point, then traces a line
from the last point to the current
g.drawLine(lastp.x, lastp.y, p.x, p.y);
}

}
}

}
});

pane.add(contentPane = super.createFigure());
return pane;
}

@Override
public IFigure getContentPane() {
return contentPane;
}
Re: Refresh RootEditPart [message #664674 is a reply to message #663821] Mon, 11 April 2011 10:49 Go to previous messageGo to next message
Eclipse UserFriend
Nobody?
=(
Le 06/04/11 16:30, Ugo Sangiorgi a écrit :
> I have a custom layer on my
> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart ,
> I tried everything to refresh and show its figure, but it only
> refreshes when i add or move something, and also when I resize the
> editor area, of course.
>
> Any hints?
>
>
> my createFigure() and getContentPane():
>
> @Override
> /**
> * Replaces default figure with layered pane. Lower layer for
> decorations, upper is original figure.
> */
> protected IFigure createFigure() {
> FreeformLayeredPane pane = new FreeformLayeredPane();
> FreeformLayer roseLayer = new FreeformLayer() {
>
> public Rectangle getFreeformExtent() {
> // Do not count children; they are decorations that
> should not interfere with diagram contents.
> Insets insets = getInsets();
> return new Rectangle(0, 0, insets.getWidth(),
> insets.getHeight());
> }
> };
> roseLayer.setLayoutManager(new StackLayout());
> pane.add(roseLayer);
> roseLayer.add(new Figure() {
> @Override
> public void paint(Graphics g) {
> g.setLineWidth(1);
> g.setForegroundColor(new Color(null, 100, 100, 100));
>
> DiagramImpl d = (DiagramImpl) getModel();
>
> Sketch s = ((Diagram) d.getElement()).getRootSketch();
>
> if (s != null) {
>
> for (int i = 1; i < s.getPointlist().size(); i++) {
> Point p = (Point) s.getPointlist().get(i);
> Point lastp = p;
> lastp = (Point) s.getPointlist().get(i - 1);
>
> if (lastp.x == -1) {
> //if the last point is a pen lift, then
> consider just the current one
> g.drawLine(p.x, p.y, p.x, p.y);
>
> } else if (p.x > 0) {
> //if is a normal point, then traces a line
> from the last point to the current
> g.drawLine(lastp.x, lastp.y, p.x, p.y);
> }
>
> }
> }
>
> }
> });
>
> pane.add(contentPane = super.createFigure());
> return pane;
> }
>
> @Override
> public IFigure getContentPane() {
> return contentPane;
> }
>
Re: Refresh RootEditPart [message #664679 is a reply to message #664674] Mon, 11 April 2011 11:06 Go to previous messageGo to next message
Eclipse UserFriend
HI,

may be sthis link could help you :
http://www.eclipse.org/forums/index.php?t=msg&goto=17663 1&S=d407a8cee29e2c8d83a8478067722c4c#msg_176631
Re: Refresh RootEditPart [message #666062 is a reply to message #663821] Mon, 18 April 2011 16:06 Go to previous messageGo to next message
Eclipse UserFriend
Hi, did you refresh the diagram (as DiagramEditPart.refresh()) at the
end of after your code, if it doesnt work maybe try to refresh all children

for(Object o : yourDiagramEditPart.getChildren()){
if(o instanceof EditPart){//or ur costumized EditPart
EditPart editPart = (EditPart)o;
editPart.refresh();
}
}
maybe u have to go deeper in the childrentree.
I had a problem like this before, that some labels didnt refresh, so i
had to refresh the LabelEditParts children of the Figures in the diagram.


Am 06.04.2011 16:30, schrieb Ugo Sangiorgi:
> I have a custom layer on my
> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart ,
> I tried everything to refresh and show its figure, but it only refreshes
> when i add or move something, and also when I resize the editor area, of
> course.
>
> Any hints?
>
>
> my createFigure() and getContentPane():
>
> @Override
> /**
> * Replaces default figure with layered pane. Lower layer for
> decorations, upper is original figure.
> */
> protected IFigure createFigure() {
> FreeformLayeredPane pane = new FreeformLayeredPane();
> FreeformLayer roseLayer = new FreeformLayer() {
>
> public Rectangle getFreeformExtent() {
> // Do not count children; they are decorations that should not interfere
> with diagram contents.
> Insets insets = getInsets();
> return new Rectangle(0, 0, insets.getWidth(),
> insets.getHeight());
> }
> };
> roseLayer.setLayoutManager(new StackLayout());
> pane.add(roseLayer);
> roseLayer.add(new Figure() {
> @Override
> public void paint(Graphics g) {
> g.setLineWidth(1);
> g.setForegroundColor(new Color(null, 100, 100, 100));
>
> DiagramImpl d = (DiagramImpl) getModel();
>
> Sketch s = ((Diagram) d.getElement()).getRootSketch();
>
> if (s != null) {
>
> for (int i = 1; i < s.getPointlist().size(); i++) {
> Point p = (Point) s.getPointlist().get(i);
> Point lastp = p;
> lastp = (Point) s.getPointlist().get(i - 1);
>
> if (lastp.x == -1) {
> //if the last point is a pen lift, then consider just the current one
> g.drawLine(p.x, p.y, p.x, p.y);
>
> } else if (p.x > 0) {
> //if is a normal point, then traces a line from the last point to the
> current
> g.drawLine(lastp.x, lastp.y, p.x, p.y);
> }
>
> }
> }
>
> }
> });
>
> pane.add(contentPane = super.createFigure());
> return pane;
> }
>
> @Override
> public IFigure getContentPane() {
> return contentPane;
> }
>
Re: Refresh RootEditPart [message #666113 is a reply to message #666062] Tue, 19 April 2011 03:54 Go to previous messageGo to next message
Eclipse UserFriend
check this link
https://bugs.eclipse.org/bugs/show_bug.cgi?id=281014
Re: Refresh RootEditPart [message #666600 is a reply to message #666062] Thu, 21 April 2011 05:21 Go to previous messageGo to next message
Eclipse UserFriend
Hello Robin,

thank you, but actually my editor starts with no editparts at all. I
write some freehand drawn pixels at the RootEditPart and want it to be
displayed.

If I resize the editor, the RootEditPart is refreshed and shows the
drawing.

I just want to activate that =(

Le 18/04/11 22:06, Robin Brandstädter a écrit :
> Hi, did you refresh the diagram (as DiagramEditPart.refresh()) at the
> end of after your code, if it doesnt work maybe try to refresh all
> children
>
> for(Object o : yourDiagramEditPart.getChildren()){
> if(o instanceof EditPart){//or ur costumized EditPart
> EditPart editPart = (EditPart)o;
> editPart.refresh();
> }
> }
> maybe u have to go deeper in the childrentree.
> I had a problem like this before, that some labels didnt refresh, so i
> had to refresh the LabelEditParts children of the Figures in the diagram.
>
>
> Am 06.04.2011 16:30, schrieb Ugo Sangiorgi:
>> I have a custom layer on my
>> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart ,
>> I tried everything to refresh and show its figure, but it only refreshes
>> when i add or move something, and also when I resize the editor area, of
>> course.
>>
>> Any hints?
>>
>>
>> my createFigure() and getContentPane():
>>
>> @Override
>> /**
>> * Replaces default figure with layered pane. Lower layer for
>> decorations, upper is original figure.
>> */
>> protected IFigure createFigure() {
>> FreeformLayeredPane pane = new FreeformLayeredPane();
>> FreeformLayer roseLayer = new FreeformLayer() {
>>
>> public Rectangle getFreeformExtent() {
>> // Do not count children; they are decorations that should not interfere
>> with diagram contents.
>> Insets insets = getInsets();
>> return new Rectangle(0, 0, insets.getWidth(),
>> insets.getHeight());
>> }
>> };
>> roseLayer.setLayoutManager(new StackLayout());
>> pane.add(roseLayer);
>> roseLayer.add(new Figure() {
>> @Override
>> public void paint(Graphics g) {
>> g.setLineWidth(1);
>> g.setForegroundColor(new Color(null, 100, 100, 100));
>>
>> DiagramImpl d = (DiagramImpl) getModel();
>>
>> Sketch s = ((Diagram) d.getElement()).getRootSketch();
>>
>> if (s != null) {
>>
>> for (int i = 1; i < s.getPointlist().size(); i++) {
>> Point p = (Point) s.getPointlist().get(i);
>> Point lastp = p;
>> lastp = (Point) s.getPointlist().get(i - 1);
>>
>> if (lastp.x == -1) {
>> //if the last point is a pen lift, then consider just the current one
>> g.drawLine(p.x, p.y, p.x, p.y);
>>
>> } else if (p.x > 0) {
>> //if is a normal point, then traces a line from the last point to the
>> current
>> g.drawLine(lastp.x, lastp.y, p.x, p.y);
>> }
>>
>> }
>> }
>>
>> }
>> });
>>
>> pane.add(contentPane = super.createFigure());
>> return pane;
>> }
>>
>> @Override
>> public IFigure getContentPane() {
>> return contentPane;
>> }
>>
>
Re: Refresh RootEditPart [message #666603 is a reply to message #666113] Thu, 21 April 2011 05:36 Go to previous messageGo to next message
Eclipse UserFriend
Le 19/04/11 09:54, Sophia a écrit :
> check this link
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=281014
Thank you Sophia,
I've tried to remove the semanticHints, apparently it did nothing.

Also, i tried to refresh the editpolicies, see:

EObject modelElement = ((View)
(editor.getDiagramEditPart().getModel())).getElement();
List editPolicies =
CanonicalEditPolicy.getRegisteredEditPolicies(modelElement);
for (Iterator it = editPolicies.iterator(); it.hasNext();) {
DiagramCanonicalEditPolicy nextEditPolicy =
(DiagramCanonicalEditPolicy) it
.next();
nextEditPolicy.activate();
nextEditPolicy.getViewer().getControl().redraw();
nextEditPolicy.refresh();
}

but nothing
=(
Re: Refresh RootEditPart [message #666783 is a reply to message #663821] Fri, 22 April 2011 10:28 Go to previous messageGo to next message
Eclipse UserFriend
What is even more weird is that:
When I open the diagram it doesnt show anything, only if I resize the
editor area.
Then the next drawings shows up normally, the editor is refreshed and all.

What could be hapening? How can I tell that the editor needs to be
repainted upfront?

Le 06/04/11 16:30, Ugo Sangiorgi a écrit :
> I have a custom layer on my
> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart ,
> I tried everything to refresh and show its figure, but it only
> refreshes when i add or move something, and also when I resize the
> editor area, of course.
>
> Any hints?
>
>
> my createFigure() and getContentPane():
>
> @Override
> /**
> * Replaces default figure with layered pane. Lower layer for
> decorations, upper is original figure.
> */
> protected IFigure createFigure() {
> FreeformLayeredPane pane = new FreeformLayeredPane();
> FreeformLayer roseLayer = new FreeformLayer() {
>
> public Rectangle getFreeformExtent() {
> // Do not count children; they are decorations that
> should not interfere with diagram contents.
> Insets insets = getInsets();
> return new Rectangle(0, 0, insets.getWidth(),
> insets.getHeight());
> }
> };
> roseLayer.setLayoutManager(new StackLayout());
> pane.add(roseLayer);
> roseLayer.add(new Figure() {
> @Override
> public void paint(Graphics g) {
> g.setLineWidth(1);
> g.setForegroundColor(new Color(null, 100, 100, 100));
>
> DiagramImpl d = (DiagramImpl) getModel();
>
> Sketch s = ((Diagram) d.getElement()).getRootSketch();
>
> if (s != null) {
>
> for (int i = 1; i < s.getPointlist().size(); i++) {
> Point p = (Point) s.getPointlist().get(i);
> Point lastp = p;
> lastp = (Point) s.getPointlist().get(i - 1);
>
> if (lastp.x == -1) {
> //if the last point is a pen lift, then
> consider just the current one
> g.drawLine(p.x, p.y, p.x, p.y);
>
> } else if (p.x > 0) {
> //if is a normal point, then traces a line
> from the last point to the current
> g.drawLine(lastp.x, lastp.y, p.x, p.y);
> }
>
> }
> }
>
> }
> });
>
> pane.add(contentPane = super.createFigure());
> return pane;
> }
>
> @Override
> public IFigure getContentPane() {
> return contentPane;
> }
>
Re: Refresh RootEditPart [SOLVED] [message #667045 is a reply to message #666783] Tue, 26 April 2011 03:57 Go to previous message
Eclipse UserFriend
I did solved.

My DiagramEditPart reads the model (which has some x,y points) and draws
them accordingly:

private IFigure contentPane;

@Override
/**
* Replaces default figure with layered pane. Lower layer for
decorations, upper is original figure.
*/
protected IFigure createFigure() {
FreeformLayeredPane pane = new FreeformLayeredPane();
FreeformLayer sketchLayer = new FreeformLayer() {

public Rectangle getFreeformExtent() {
// Do not count children; they are decorations that
should not interfere with diagram contents.
Insets insets = getInsets();
return new Rectangle(0, 0, insets.getWidth(),
insets.getHeight());
}
};
sketchLayer.setLayoutManager(new StackLayout());
pane.add(sketchLayer);
sketchLayer.add(new Figure() {
@Override
public void paint(Graphics g) {


[here i draw whatever i want]

}
});

pane.add(contentPane = super.createFigure());
return pane;
}

I just neeeded to refresh through a request, with this the editpart is
refreshed upon creation:
...
@Override
public IFigure getContentPane() {
performRequest(new Request(RequestConstants.REQ_REFRESH));
return contentPane;
}
....

Outside the DiagramEditPart I just performed the refresh request:
editor.getDiagramEditPart().performRequest(new
Request(RequestConstants.REQ_REFRESH));



Thats it =)

Le 22/04/11 16:28, Ugo Sangiorgi a écrit :
> What is even more weird is that:
> When I open the diagram it doesnt show anything, only if I resize the
> editor area.
> Then the next drawings shows up normally, the editor is refreshed and
> all.
>
> What could be hapening? How can I tell that the editor needs to be
> repainted upfront?
>
> Le 06/04/11 16:30, Ugo Sangiorgi a écrit :
>> I have a custom layer on my
>> org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart ,
>> I tried everything to refresh and show its figure, but it only
>> refreshes when i add or move something, and also when I resize the
>> editor area, of course.
>>
>> Any hints?
>>
>>
>> my createFigure() and getContentPane():
>>
>> @Override
>> /**
>> * Replaces default figure with layered pane. Lower layer for
>> decorations, upper is original figure.
>> */
>> protected IFigure createFigure() {
>> FreeformLayeredPane pane = new FreeformLayeredPane();
>> FreeformLayer roseLayer = new FreeformLayer() {
>>
>> public Rectangle getFreeformExtent() {
>> // Do not count children; they are decorations that
>> should not interfere with diagram contents.
>> Insets insets = getInsets();
>> return new Rectangle(0, 0, insets.getWidth(),
>> insets.getHeight());
>> }
>> };
>> roseLayer.setLayoutManager(new StackLayout());
>> pane.add(roseLayer);
>> roseLayer.add(new Figure() {
>> @Override
>> public void paint(Graphics g) {
>> g.setLineWidth(1);
>> g.setForegroundColor(new Color(null, 100, 100, 100));
>>
>> DiagramImpl d = (DiagramImpl) getModel();
>>
>> Sketch s = ((Diagram) d.getElement()).getRootSketch();
>>
>> if (s != null) {
>>
>> for (int i = 1; i < s.getPointlist().size(); i++) {
>> Point p = (Point) s.getPointlist().get(i);
>> Point lastp = p;
>> lastp = (Point) s.getPointlist().get(i - 1);
>>
>> if (lastp.x == -1) {
>> //if the last point is a pen lift, then
>> consider just the current one
>> g.drawLine(p.x, p.y, p.x, p.y);
>>
>> } else if (p.x > 0) {
>> //if is a normal point, then traces a
>> line from the last point to the current
>> g.drawLine(lastp.x, lastp.y, p.x, p.y);
>> }
>>
>> }
>> }
>>
>> }
>> });
>>
>> pane.add(contentPane = super.createFigure());
>> return pane;
>> }
>>
>> @Override
>> public IFigure getContentPane() {
>> return contentPane;
>> }
>>
>
Previous Topic:Drag and Drop Java files
Next Topic:[SOLVED] How to programmatically set the location of a label?
Goto Forum:
  


Current Time: Tue Jul 22 12:49:55 EDT 2025

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

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

Back to the top