Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » show/hide all editparts of a given type
show/hide all editparts of a given type [message #187905] Sun, 17 July 2005 12:17 Go to next message
Jason Grant is currently offline Jason GrantFriend
Messages: 77
Registered: July 2009
Member
I'd like to introduce an action that allows the user to hide all EditParts
of a particular type. To do this, the action will manipulate a single
boolean field in my model.

I'm unsure of the best way to make the corresponding figures invisible,
based on this field. One technique that comes to mind is to affect the
parent/child EditPart relationship, based on the status of the field.
When the parts are invisible, they would not appear as children of the
parent part. That seems like a hack to me.

Another approach would be to iterate over all relevant EditParts
when the field is altered, and call part.getFigure().setVisible(false).
Not sure how well this will work in my UI, since I anticipate that there
will be hundreds of EditParts in the diagram.

I'm wondering if there might be a better alternative: e.g. would it be
better (possible) to put the figures on a custom layer whose visibility
could be toggled easily?

Suggestions appreciated.

Jason.
Re: show/hide all editparts of a given type [message #187930 is a reply to message #187905] Mon, 18 July 2005 05:21 Go to previous messageGo to next message
Dazhen Gao is currently offline Dazhen GaoFriend
Messages: 21
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.

------=_NextPart_000_0040_01C58B9B.8BCEE130
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

You have a base class extends Figure?

if you don't have, I suggest you set up it.

The you can extends the paintChildren(Graphics graphics) method

protected void paintChildren(Graphics graphics) {
IFigure child;

=20

Rectangle clip =3D Rectangle.SINGLETON;
for (int i =3D 0; i < children.size(); i++) {
child =3D (IFigure)children.get(i);
if (child.isVisible() && child.intersects(graphics.getClip(clip))) {
graphics.clipRect(child.getBounds());
child.paint(graphics);
graphics.restoreState();
}
}

modify the condition ( if (child.isVisible() && =
child.intersects(graphics.getClip(clip))) ) add your logic.

=20

Is it doable?




"Jason Grant" <junk@logular.com> wrote in message =
news:pan.2005.07.17.12.17.51.14151@logular.com...
> I'd like to introduce an action that allows the user to hide all =
EditParts
> of a particular type. To do this, the action will manipulate a single
> boolean field in my model.
>=20
> I'm unsure of the best way to make the corresponding figures =
invisible,
> based on this field. One technique that comes to mind is to affect =
the
> parent/child EditPart relationship, based on the status of the field.
> When the parts are invisible, they would not appear as children of the
> parent part. That seems like a hack to me.
>=20
> Another approach would be to iterate over all relevant EditParts
> when the field is altered, and call =
part.getFigure().setVisible(false).=20
> Not sure how well this will work in my UI, since I anticipate that =
there
> will be hundreds of EditParts in the diagram.
>=20
> I'm wondering if there might be a better alternative: e.g. would it be
> better (possible) to put the figures on a custom layer whose =
visibility
> could be toggled easily?
>=20
> Suggestions appreciated.
>=20
> Jason.
------=_NextPart_000_0040_01C58B9B.8BCEE130
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">You have a base class =
extends=20
Figure?<?xml:namespace prefix =3D o ns =3D =
"urn:schemas-microsoft-com:office:office"=20
/><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">if you don't have, I=20
suggest&nbsp; you set up it.<o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">The you can extends =
the=20
paintChildren(Graphics graphics) method<o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">protected void=20
paintChildren(Graphics graphics) {<BR>&nbsp;IFigure =
child;<o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">&nbsp;<o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">&nbsp;Rectangle clip =
=3D=20
Rectangle.SINGLETON;<BR>&nbsp;for (int i =3D 0; i &lt; children.size(); =
i++)=20
{<BR>&nbsp;&nbsp;child =3D (IFigure)children.get(i);<BR>&nbsp;&nbsp;if=20
(child.isVisible() &amp;&amp; child.intersects(graphics.getClip(clip)))=20
{<BR> &nbsp;&nbsp;&nbsp;graphics.clipRect(child.getBou nds()); <BR>&nbsp;&nb=
sp;&nbsp;child.paint(graphics);<BR>&nbsp;&nbsp;&nbsp;graphics.restoreStat=
e();<BR>&nbsp;&nbsp;}<BR>&nbsp;}<o:p></o:p ></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">modify the condition =
(&nbsp;if=20
(child.isVisible() &amp;&amp; child.intersects(graphics.getClip(clip))) =
) add=20
your logic.<o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">Is it =
doable?<o:p></o:p></P><FONT=20
face=3DArial size=3D2><FONT face=3D"Times New Roman" =
size=3D3></FONT></DIV>
<DIV><BR></DIV></FONT>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>"Jason Grant" &lt;<A=20
href=3D"mailto:junk@logular.com">junk@logular.com</A>&gt; wrote in =
message <A=20
href=3D"news:pan.2005.07.17.12.17.51.14151@logular.com">news:pan.2005.07.=
17.12.17.51.14151@logular.com</A>...</DIV>&gt;=20
I'd like to introduce an action that allows the user to hide all=20
EditParts<BR>&gt; of a particular type.&nbsp; To do this, the action =
will=20
manipulate a single<BR>&gt; boolean field in my model.<BR>&gt; <BR>&gt; =
I'm=20
unsure of the best way to make the corresponding figures =
invisible,<BR>&gt;=20
based on this field.&nbsp; One technique that comes to mind is to affect =

the<BR>&gt; parent/child EditPart relationship, based on the status of =
the=20
field.<BR>&gt; When the parts are invisible, they would not appear as =
children=20
of the<BR>&gt; parent part.&nbsp; That seems like a hack to me.<BR>&gt; =
<BR>&gt;=20
Another approach would be to iterate over all relevant EditParts<BR>&gt; =
when=20
the field is altered, and call part.getFigure().setVisible(false). =
<BR>&gt; Not=20
sure how well this will work in my UI, since I anticipate that =
there<BR>&gt;=20
will be hundreds of EditParts in the diagram.<BR>&gt; <BR>&gt; I'm =
wondering if=20
there might be a better alternative: e.g. would it be<BR>&gt; better =
(possible)=20
to put the figures on a custom layer whose visibility<BR>&gt; could be =
toggled=20
easily?<BR>&gt; <BR>&gt; Suggestions appreciated.<BR>&gt; <BR>&gt;=20
Jason.</BODY></HTML>

------=_NextPart_000_0040_01C58B9B.8BCEE130--
Re: show/hide all editparts of a given type [message #187977 is a reply to message #187905] Mon, 18 July 2005 14:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

Layers are figures, so a separate layers for the figures of those editparts
is not feasible. The other two approaches that you mentioned are both fine.
Keep in mind that if you go the route of modifying the parent-child
relationship, editparts will be deactivated and junked. When they're made
visible again, brand new parts will be created. That could get expensive if
you have a lot of parts, and the visibility is toggled often.

"Jason Grant" <junk@logular.com> wrote in message
news:pan.2005.07.17.12.17.51.14151@logular.com...
> I'd like to introduce an action that allows the user to hide all EditParts
> of a particular type. To do this, the action will manipulate a single
> boolean field in my model.
>
> I'm unsure of the best way to make the corresponding figures invisible,
> based on this field. One technique that comes to mind is to affect the
> parent/child EditPart relationship, based on the status of the field.
> When the parts are invisible, they would not appear as children of the
> parent part. That seems like a hack to me.
>
> Another approach would be to iterate over all relevant EditParts
> when the field is altered, and call part.getFigure().setVisible(false).
> Not sure how well this will work in my UI, since I anticipate that there
> will be hundreds of EditParts in the diagram.
>
> I'm wondering if there might be a better alternative: e.g. would it be
> better (possible) to put the figures on a custom layer whose visibility
> could be toggled easily?
>
> Suggestions appreciated.
>
> Jason.
Re: show/hide all editparts of a given type [message #188110 is a reply to message #187930] Tue, 19 July 2005 01:54 Go to previous message
Dazhen Gao is currently offline Dazhen GaoFriend
Messages: 21
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.

------=_NextPart_000_0119_01C58C47.EC9E9670
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

My way has a problem:

Thought the figure don't paint but they can select by mouse.<S>

But it can resolved (two method

1: overwrite the ScrollingGraphicalViewer method =
findObjectAtExcluding(Point pt,
Collection exclude,
final Conditional condition), in this method have a inner class =
ConditionalTreeSearch, rewrite it.

2: overwrite the figure isVisible()(dangers?)

=20

Is it doable?

"gao" <dgao@actuate.com> wrote in message =
news:dbfe85$g9b$1@news.eclipse.org...
You have a base class extends Figure?

if you don't have, I suggest you set up it.

The you can extends the paintChildren(Graphics graphics) method

protected void paintChildren(Graphics graphics) {
IFigure child;

=20

Rectangle clip =3D Rectangle.SINGLETON;
for (int i =3D 0; i < children.size(); i++) {
child =3D (IFigure)children.get(i);
if (child.isVisible() && child.intersects(graphics.getClip(clip))) {
graphics.clipRect(child.getBounds());
child.paint(graphics);
graphics.restoreState();
}
}

modify the condition ( if (child.isVisible() && =
child.intersects(graphics.getClip(clip))) ) add your logic.

=20

Is it doable?




"Jason Grant" <junk@logular.com> wrote in message =
news:pan.2005.07.17.12.17.51.14151@logular.com...
> I'd like to introduce an action that allows the user to hide all =
EditParts
> of a particular type. To do this, the action will manipulate a =
single
> boolean field in my model.
>=20
> I'm unsure of the best way to make the corresponding figures =
invisible,
> based on this field. One technique that comes to mind is to affect =
the
> parent/child EditPart relationship, based on the status of the =
field.
> When the parts are invisible, they would not appear as children of =
the
> parent part. That seems like a hack to me.
>=20
> Another approach would be to iterate over all relevant EditParts
> when the field is altered, and call =
part.getFigure().setVisible(false).=20
> Not sure how well this will work in my UI, since I anticipate that =
there
> will be hundreds of EditParts in the diagram.
>=20
> I'm wondering if there might be a better alternative: e.g. would it =
be
> better (possible) to put the figures on a custom layer whose =
visibility
> could be toggled easily?
>=20
> Suggestions appreciated.
>=20
> Jason.
------=_NextPart_000_0119_01C58C47.EC9E9670
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:o =3D "urn:schemas-microsoft-com:office:office"><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">My way has a=20
problem:</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Thought the figure don't =
paint but=20
they can select by mouse.&lt;S&gt;</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">But it&nbsp;can resolved =
(two=20
method</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">1: overwrite=20
the&nbsp;ScrollingGraphicalViewer method findObjectAtExcluding(Point=20
pt,<BR>&nbsp;Collection exclude,<BR>&nbsp;final Conditional =
condition),&nbsp;in=20
this method have a inner class ConditionalTreeSearch, rewrite=20
it.</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">2: overwrite the figure=20
isVisible()(dangers?)</SPAN><o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><FONT size=3D3><FONT=20
face=3D"Times New Roman">&nbsp;<o:p></o:p></FONT></FONT></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt"><SPAN=20
style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Is it=20
doable?</SPAN><o:p></o:p></P></FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"gao" &lt;<A =
href=3D"mailto:dgao@actuate.com">dgao@actuate.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:dbfe85$g9b$1@news.eclipse.org">news:dbfe85$g9b$1@news.eclips=
e.org</A>...</DIV>
<DIV>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">You have a base =
class extends=20
Figure?<o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">if you don't have, =
I=20
suggest&nbsp; you set up it.<o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">The you can extends =
the=20
paintChildren(Graphics graphics) method<o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">protected void=20
paintChildren(Graphics graphics) {<BR>&nbsp;IFigure =
child;<o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in =
0pt">&nbsp;<o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">&nbsp;Rectangle =
clip =3D=20
Rectangle.SINGLETON;<BR>&nbsp;for (int i =3D 0; i &lt; =
children.size(); i++)=20
{<BR>&nbsp;&nbsp;child =3D (IFigure)children.get(i);<BR>&nbsp;&nbsp;if =

(child.isVisible() &amp;&amp; =
child.intersects(graphics.getClip(clip)))=20
=
{<BR> &nbsp;&nbsp;&nbsp;graphics.clipRect(child.getBou nds()); <BR>&nbsp;&nb=
sp;&nbsp;child.paint(graphics);<BR>&nbsp;&nbsp;&nbsp;graphics.restoreStat=
e();<BR>&nbsp;&nbsp;}<BR>&nbsp;}<o:p></o:p ></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">modify the =
condition (&nbsp;if=20
(child.isVisible() &amp;&amp; =
child.intersects(graphics.getClip(clip))) ) add=20
your logic.<o:p></o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in =
0pt"><o:p>&nbsp;</o:p></P>
<P class=3DMsoNormal style=3D"MARGIN: 0in 0in 0pt">Is it=20
doable?<o:p></o:p></P><FONT face=3DArial size=3D2><FONT face=3D"Times =
New Roman"=20
size=3D3></FONT></DIV>
<DIV><BR></DIV></FONT>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>"Jason Grant" &lt;<A=20
href=3D"mailto:junk@logular.com">junk@logular.com</A>&gt; wrote in =
message <A=20
=
href=3D"news:pan.2005.07.17.12.17.51.14151@logular.com">news:pan.2005.07.=
17.12.17.51.14151@logular.com</A>...</DIV>&gt;=20
I'd like to introduce an action that allows the user to hide all=20
EditParts<BR>&gt; of a particular type.&nbsp; To do this, the action =
will=20
manipulate a single<BR>&gt; boolean field in my model.<BR>&gt; =
<BR>&gt; I'm=20
unsure of the best way to make the corresponding figures =
invisible,<BR>&gt;=20
based on this field.&nbsp; One technique that comes to mind is to =
affect=20
the<BR>&gt; parent/child EditPart relationship, based on the status of =
the=20
field.<BR>&gt; When the parts are invisible, they would not appear as =
children=20
of the<BR>&gt; parent part.&nbsp; That seems like a hack to =
me.<BR>&gt;=20
<BR>&gt; Another approach would be to iterate over all relevant=20
EditParts<BR>&gt; when the field is altered, and call=20
part.getFigure().setVisible(false). <BR>&gt; Not sure how well this =
will work=20
in my UI, since I anticipate that there<BR>&gt; will be hundreds of =
EditParts=20
in the diagram.<BR>&gt; <BR>&gt; I'm wondering if there might be a =
better=20
alternative: e.g. would it be<BR>&gt; better (possible) to put the =
figures on=20
a custom layer whose visibility<BR>&gt; could be toggled =
easily?<BR>&gt;=20
<BR>&gt; Suggestions appreciated.<BR>&gt; <BR>&gt; Jason.=20
</BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0119_01C58C47.EC9E9670--
Previous Topic:How to show rectangle with label
Next Topic:Multipage GEF editor problem with palette
Goto Forum:
  


Current Time: Tue Dec 10 16:06:21 GMT 2024

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

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

Back to the top