Home » Eclipse Projects » GEF » Layouts with (occasionally) hidden parts
| Layouts with (occasionally) hidden parts [message #78152] |
Tue, 06 May 2003 20:17  |
Eclipse User |
|
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_004A_01C313F3.59DD1E70
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_004B_01C313F3.59DD1E70"
------=_NextPart_001_004B_01C313F3.59DD1E70
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
I have a need to show/hide certain graphical elements as the user =
clicks, and I would prefer to change their visibility instead of adding =
and removing elements. However, the ToolbarLayout (and, it appears, the =
other "gridded" layouts) don't seem to take visibility into account when =
computing a layout.
If I create 4 elements in a row, all works fine. If I hide one of them, =
there's a "hole":
Figure contents =3D new Figure();
ToolbarLayout layout =3D new ToolbarLayout(ToolbarLayout.HORIZONTAL);
layout.setStretchMinorAxis(true);
layout.setSpacing(3);
contents.setLayoutManager(layout);
Label a =3D new Label("a");
Label b =3D new Label("b");
Label c =3D new Label("c");
Label d =3D new Label("d");
contents.add(a);
contents.add(b);
contents.add(c);
contents.add(d);
This does what you want:=20
But, hide one of the elements and you get a hole:
contents.add(c); c.setVisible(false);=20
Is this a bug?
....Richard
------=_NextPart_001_004B_01C313F3.59DD1E70
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.2800.1170" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>I have a need to show/hide certain =
graphical=20
elements as the user clicks, and I would prefer to change their =
visibility=20
instead of adding and removing elements. However, the ToolbarLayout =
(and, it=20
appears, the other "gridded" layouts) don't seem to take visibility into =
account=20
when computing a layout.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>If I create 4 elements in a row, all =
works fine. If=20
I hide one of them, there's a "hole":</FONT></DIV>
<DIV>
<P><FONT face=3DArial size=3D2>Figure contents =3D new =
Figure();<BR>ToolbarLayout=20
layout =3D new=20
ToolbarLayout(ToolbarLayout.HORIZONTAL);<BR>layout.setStretchMinorAxis(tr=
ue);<BR>layout.setSpacing(3);<BR>contents.setLayoutManager(layout); <BR>La=
bel=20
a =3D new Label("a");<BR>Label b =3D new Label("b");<BR>Label c =3D new=20
Label("c");<BR>Label d =3D new=20
Label("d");<BR>contents.add(a);<BR>contents.add(b);<BR >contents.add(c);<B=
R>contents.add(d);</FONT></P>
<P><FONT face=3DArial size=3D2>This does what you want: </FONT><IMG =
alt=3D"" hspace=3D0=20
src=3D"cid:004401c3142e$06345550$0200a8c0@zen" align=3Dbaseline =
border=3D0></P>
<P><FONT face=3DArial size=3D2>But, hide one of the elements and you get =
a=20
hole:</FONT></P>
<P><FONT face=3DArial size=3D2>contents.add(c); c.setVisible(false); =
<IMG alt=3D""=20
hspace=3D0 src=3D"cid:004501c3142e$063a6fd0$0200a8c0@zen" =
align=3Dbaseline=20
border=3D0></FONT><FONT face=3DArial size=3D2><BR></FONT><FONT =
face=3DArial=20
size=3D2></FONT></P>
<P><FONT face=3DArial size=3D2>Is this a bug?</FONT></P>
<P><FONT face=3DArial size=3D2>...Richard</FONT></P>
<P><FONT face=3DArial size=3D2> </P></FONT></DIV></BODY></HTML>
------=_NextPart_001_004B_01C313F3.59DD1E70--
------=_NextPart_000_004A_01C313F3.59DD1E70
Content-Type: image/gif;
name="abcd.gif"
Content-Transfer-Encoding: base64
Content-ID: <004401c3142e$06345550$0200a8c0@zen>
R0lGODlhMgAWALMAAAAAAMzMzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAACwAAAAAMgAWAAAETDDISau9OOvNu/9gKI5kaZ5oqn6A2aYvGZ+zWHNA buX63lO8m6cWI2KK
oWAFCTxOhBnmc9q8SDvXQBaaxfGWX99NuSqbz+i0es0+RwAAOw==
------=_NextPart_000_004A_01C313F3.59DD1E70
Content-Type: image/gif;
name="abd.gif"
Content-Transfer-Encoding: base64
Content-ID: <004501c3142e$063a6fd0$0200a8c0@zen>
R0lGODlhMgAWALMAAAAAAMzMzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAACwAAAAAMgAWAAAERTDISau9OOvNu/9gKI5kaZ5oqn6A2aYvGZ+zWHNA buU6y8uV2A0jDPFq
xU7Ss5Q0Nc/NM0qcDKE/yhG0XXm/4LB4TC6DIwA7
------=_NextPart_000_004A_01C313F3.59DD1E70--
|
|
|
| Re: Layouts with (occasionally) hidden parts [message #78169 is a reply to message #78152] |
Tue, 06 May 2003 22:06   |
Eclipse User |
|
|
|
I think this is standard behavior. Even SWT's GridLayout does this.
Try the following...
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
public class LayoutVisibilityTest {
public static void main(String[] args) {
Shell shell = new Shell();
GridLayout layout = new GridLayout();
layout.numColumns = 3;
shell.setLayout(layout);
Button b1 = new Button(shell, SWT.PUSH);
b1.setText("First");
Button b2 = new Button(shell, SWT.PUSH);
b2.setText("Second");
b2.setVisible(false);
Button b3 = new Button(shell, SWT.PUSH);
b3.setText("Third");
shell.pack();
shell.open();
Display display = Display.getDefault();
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
display.dispose();
}
}
You'll notice the second button is not visible, but there is a space
there for it. Are you using GEF or just Draw2d? If you're using GEF,
you can filter your model based on their visibility. Consider this...
You have a container object in your model. (I'll call it Container
because I'm very unoriginal.)
You have child objects A, B, C, D -- just like you described. These
child models have methods isVisible() and setVisible(boolean).
Your container's edit part is ContainerEditPart (more unoriginality).
In ContainerEditPart.getModelChildren(), you return a list of only those
children that are visible.
Now, when the user clicks to make an element visible/invisible, you just
set that element's model to reflect the appropriate visibility and fire
a model change. The ContainerEditPart would listen to the model and
call refreshChildren() when that type of property change occurs.
Now, if you're using Draw2d, I just typed up this scenario for no
reason. ;) Either way, I hope this helps.
Eric
Richard Clark wrote:
> I have a need to show/hide certain graphical elements as the user
> clicks, and I would prefer to change their visibility instead of adding
> and removing elements. However, the ToolbarLayout (and, it appears, the
> other "gridded" layouts) don't seem to take visibility into account when
> computing a layout.
>
> If I create 4 elements in a row, all works fine. If I hide one of them,
> there's a "hole":
>
> Figure contents = new Figure();
> ToolbarLayout layout = new ToolbarLayout(ToolbarLayout.HORIZONTAL);
> layout.setStretchMinorAxis(true);
> layout.setSpacing(3);
> contents.setLayoutManager(layout);
> Label a = new Label("a");
> Label b = new Label("b");
> Label c = new Label("c");
> Label d = new Label("d");
> contents.add(a);
> contents.add(b);
> contents.add(c);
> contents.add(d);
>
> This does what you want:
>
> But, hide one of the elements and you get a hole:
>
> contents.add(c); c.setVisible(false);
>
> Is this a bug?
>
> ...Richard
>
>
>
|
|
|
| Re: Layouts with (occasionally) hidden parts [message #78184 is a reply to message #78152] |
Tue, 06 May 2003 23:15   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
This is a multi-part message in MIME format.
------=_NextPart_000_00B8_01C31425.56CF0860
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_00B9_01C31425.56CF0860"
------=_NextPart_001_00B9_01C31425.56CF0860
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
The behavior is undefined. If you want the behavior changed, please =
open a bugzilla, preferably with a patch to the layoutmanager you need =
changed :-)
"Richard Clark" <rdclark@nextquestion.net> wrote in message =
news:b99j9b$3rp$1@rogue.oti.com...
I have a need to show/hide certain graphical elements as the user =
clicks, and I would prefer to change their visibility instead of adding =
and removing elements. However, the ToolbarLayout (and, it appears, the =
other "gridded" layouts) don't seem to take visibility into account when =
computing a layout.
If I create 4 elements in a row, all works fine. If I hide one of =
them, there's a "hole":
Figure contents =3D new Figure();
ToolbarLayout layout =3D new ToolbarLayout(ToolbarLayout.HORIZONTAL);
layout.setStretchMinorAxis(true);
layout.setSpacing(3);
contents.setLayoutManager(layout);
Label a =3D new Label("a");
Label b =3D new Label("b");
Label c =3D new Label("c");
Label d =3D new Label("d");
contents.add(a);
contents.add(b);
contents.add(c);
contents.add(d);
This does what you want:=20
But, hide one of the elements and you get a hole:
contents.add(c); c.setVisible(false);=20
Is this a bug?
...Richard
------=_NextPart_001_00B9_01C31425.56CF0860
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.2723.2500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>The behavior is undefined. If you =
want the=20
behavior changed, please open a bugzilla, preferably with a patch to the =
layoutmanager you need changed :-)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV>"Richard Clark" <<A=20
href=3D"mailto:rdclark@nextquestion.net">rdclark@nextquestion.net</A>>=
wrote in=20
message <A=20
href=3D"news:b99j9b$3rp$1@rogue.oti.com">news:b99j9b$3rp$1@rogue.oti.com<=
/A>...</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV><FONT face=3DArial size=3D2>I have a need to show/hide certain =
graphical=20
elements as the user clicks, and I would prefer to change their =
visibility=20
instead of adding and removing elements. However, the ToolbarLayout =
(and, it=20
appears, the other "gridded" layouts) don't seem to take visibility =
into=20
account when computing a layout.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>If I create 4 elements in a row, all =
works fine.=20
If I hide one of them, there's a "hole":</FONT></DIV>
<DIV>
<P><FONT face=3DArial size=3D2>Figure contents =3D new =
Figure();<BR>ToolbarLayout=20
layout =3D new=20
=
ToolbarLayout(ToolbarLayout.HORIZONTAL);<BR>layout.setStretchMinorAxis(tr=
ue);<BR>layout.setSpacing(3);<BR>contents.setLayoutManager(layout); <BR>La=
bel=20
a =3D new Label("a");<BR>Label b =3D new Label("b");<BR>Label c =3D =
new=20
Label("c");<BR>Label d =3D new=20
=
Label("d");<BR>contents.add(a);<BR>contents.add(b);<BR >contents.add(c);<B=
R>contents.add(d);</FONT></P>
<P><FONT face=3DArial size=3D2>This does what you want: </FONT><IMG =
alt=3D""=20
hspace=3D0 src=3D"cid:00b201c31446$ddab4080$6401a8c0@porrada" =
align=3Dbaseline=20
border=3D0></P>
<P><FONT face=3DArial size=3D2>But, hide one of the elements and you =
get a=20
hole:</FONT></P>
<P><FONT face=3DArial size=3D2>contents.add(c); c.setVisible(false); =
<IMG alt=3D""=20
hspace=3D0 src=3D"cid:00b301c31446$ddacc720$6401a8c0@porrada" =
align=3Dbaseline=20
border=3D0></FONT><FONT face=3DArial size=3D2><BR></FONT><FONT =
face=3DArial=20
size=3D2></FONT></P>
<P><FONT face=3DArial size=3D2>Is this a bug?</FONT></P>
<P><FONT face=3DArial size=3D2>...Richard</FONT></P>
<P><FONT face=3DArial =
size=3D2> </P></FONT></DIV></BLOCKQUOTE></BODY ></HTML>
------=_NextPart_001_00B9_01C31425.56CF0860--
------=_NextPart_000_00B8_01C31425.56CF0860
Content-Type: image/gif;
name="abcd.gif"
Content-Transfer-Encoding: base64
Content-ID: <00b201c31446$ddab4080$6401a8c0@porrada>
R0lGODlhMgAWALMAAAAAAMzMzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAACwAAAAAMgAWAAAETDDISau9OOvNu/9gKI5kaZ5oqn6A2aYvGZ+zWHNA buX63lO8m6cWI2KK
oWAFCTxOhBnmc9q8SDvXQBaaxfGWX99NuSqbz+i0es0+RwAAOw==
------=_NextPart_000_00B8_01C31425.56CF0860
Content-Type: image/gif;
name="abd.gif"
Content-Transfer-Encoding: base64
Content-ID: <00b301c31446$ddacc720$6401a8c0@porrada>
R0lGODlhMgAWALMAAAAAAMzMzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAA
AAAAACwAAAAAMgAWAAAERTDISau9OOvNu/9gKI5kaZ5oqn6A2aYvGZ+zWHNA buU6y8uV2A0jDPFq
xU7Ss5Q0Nc/NM0qcDKE/yhG0XXm/4LB4TC6DIwA7
------=_NextPart_000_00B8_01C31425.56CF0860--
|
|
| | |
| Re: Layouts with (occasionally) hidden parts [message #78338 is a reply to message #78198] |
Wed, 07 May 2003 11:40  |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
"Richard Clark" <rdclark@nextquestion.net> wrote in message
news:b99vdr$9g3$1@rogue.oti.com...
> I'm using GEF, so I could use a ContainerEditPart.
>
> I'm actually editing a form for a command with multiple parameters (some
> optional), and want to show the entry fields for all the parameters when
the
> part is selected and hide the unused optional parameters when it's
> deselected. Since there are a great many of these, and I was feeling
> concerned about the sheer number of EditParts floating around in memory, I
> was thinking of having one EditPart for the whole command (with its
> parameters) and doing the pieces in draw2d. But I'll give the
> ContainerEditPart approach a shot and look at the time/memory performance.
You are not the first to display a "node" with multiple "attributes". I'm
curious to know when GEF users decide to use an EditPart to display these
sub-attributes, versus just having a single EditPart that has multiple
figures in it, each displaying one of the sub-properties. I guess it boils
down to the extent to which the user can edit an "attribute". Can they
delete it? Can they drag it to another node? Is keyboard access a high
priority so you want to be able to move up/down among attributes?
If you don't use editparts, you can still use the mouse to direct edit the
individual properties, and you could still use F2 to invoke cell editing on
the first parameter, with maybe TAB key or DOWN_ARROW to switch to others?
> > GridLayout layout = new GridLayout();
> > layout.numColumns = 3;
> > shell.setLayout(layout);
>
> Re: The hole in a GridLayout -- it's a 2d layout so I could rationalize
this
> as "hiding the part in a row shouldn't remove a grid cell, as other
parallel
> rows could be affected" (and the same for columns). It's harder to say
what
> a 1-dimensional layout such as ToolbarLayout should do, but it feels
> intuitively right that an invisible cell (and the spacer immediately to
its
> left) should take up no space. The same principle applies to a menu --
> deleting a menu command pulls the following commands up to fill the space.
>
> I'll do as Randy suggested and file a bugzilla entry with a patch so the
> powers that be can see what seems right. :)
>
> Thanks for the answer, I'll run with the pure-GEF approach and see how it
> turns out.
>
> Regards,
>
> ...Richard
>
>
|
|
|
Goto Forum:
Current Time: Sat Nov 08 04:04:44 EST 2025
Powered by FUDForum. Page generated in 0.05250 seconds
|