Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Resize node figure as textflow content changes
Resize node figure as textflow content changes [message #228622] Wed, 03 January 2007 16:54 Go to next message
Eclipse UserFriend
Originally posted by: ben.vitale.precipia.com

I noticed in the Logic example that as text is entered into the Label
textflow, the figure resizes to "best fit" the new text. Can someone
point me to where in the code this is being accomplished?
Re: Resize node figure as textflow content changes [message #228634 is a reply to message #228622] Wed, 03 January 2007 20:20 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
I think this is being done by the layout manager installed on the sticky
note figure - by the StackLayout. In general, resizing of parent figures
to fit their children is done by layout managers.
Re: Resize node figure as textflow content changes [message #228641 is a reply to message #228634] Wed, 03 January 2007 21:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ben.vitale.precipia.com

That makes sense. I copied the logic example to create my node figure,
which is very similar in appearance. But even with the StackLayout code
from logic editor, I'm not seeing the behavior.

Is there an edit policy I should check for that might be preventing the
resize from happening? The parent figure (the node) is in fact
resizable by the user.

Alex Boyko wrote:
> I think this is being done by the layout manager installed on the sticky
> note figure - by the StackLayout. In general, resizing of parent figures
> to fit their children is done by layout managers.
>
Re: Resize node figure as textflow content changes [message #228648 is a reply to message #228641] Wed, 03 January 2007 23:15 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi,

Yes, there is such an edit policy. Look at
LabelDirectEditPolicy#showCurrentEditValue().
This method sets the new text to text flow figure, which will eventually
revalidate the parent figure (the StickyNoteFigure), which with the help
of the layout manager will be assigned the proper bounds to fit the text
flow.
Hope this helps.

Cheer,
Alex
Re: Resize node figure as textflow content changes [message #228703 is a reply to message #228648] Thu, 04 January 2007 22:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ben.vitale.precipia.com

OK that also makes sense. My DirectEditPolicy looks just like the
example.. But it doesn't seem to cause the expected behavior. Even
while I am typing text into the flow, it simply scrolls to accommodate
more text, instead of resizing.

Figure code here:

public ScenarioNodeFigure()
{
setBorder(new LineBorder(2));

flowPage = new FlowPage();
flowPage.setOpaque(true);
flowPage.setBackgroundColor(ColorConstants.white);
flowPage.setBorder(new MarginBorder(3));

textFlow = new TextFlow();
textFlow.setLayoutManager(new ParagraphTextLayout(textFlow,
ParagraphTextLayout.WORD_WRAP_SOFT));
textFlow.setOpaque(false);
flowPage.add(textFlow);
flowPage.setBackgroundColor(ColorConstants.white);

setLayoutManager(new StackLayout());
add(flowPage);

incomingConnectionAnchor = new ScenarioLinkAnchor(this,true);
outgoingConnectionAnchor = new ScenarioLinkAnchor(this,false);
}

....

public void setText(String newText) {
textFlow.setText(newText);
}


Alex Boyko wrote:
> Hi,
>
> Yes, there is such an edit policy. Look at
> LabelDirectEditPolicy#showCurrentEditValue().
> This method sets the new text to text flow figure, which will eventually
> revalidate the parent figure (the StickyNoteFigure), which with the help
> of the layout manager will be assigned the proper bounds to fit the text
> flow.
> Hope this helps.
>
> Cheer,
> Alex
>
Re: Resize node figure as textflow content changes [message #228913 is a reply to message #228703] Thu, 11 January 2007 14:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ben.vitale.precipia.com

Does anyone else have any further suggestions or help regarding this
question?

Ben Vitale wrote:
> OK that also makes sense. My DirectEditPolicy looks just like the
> example.. But it doesn't seem to cause the expected behavior. Even
> while I am typing text into the flow, it simply scrolls to accommodate
> more text, instead of resizing.
>
> Figure code here:
>
> public ScenarioNodeFigure()
> {
> setBorder(new LineBorder(2));
>
> flowPage = new FlowPage();
> flowPage.setOpaque(true);
> flowPage.setBackgroundColor(ColorConstants.white);
> flowPage.setBorder(new MarginBorder(3));
>
> textFlow = new TextFlow();
> textFlow.setLayoutManager(new ParagraphTextLayout(textFlow,
> ParagraphTextLayout.WORD_WRAP_SOFT));
> textFlow.setOpaque(false);
> flowPage.add(textFlow);
> flowPage.setBackgroundColor(ColorConstants.white);
>
> setLayoutManager(new StackLayout());
> add(flowPage);
>
> incomingConnectionAnchor = new ScenarioLinkAnchor(this,true);
> outgoingConnectionAnchor = new ScenarioLinkAnchor(this,false);
> }
>
> ...
>
> public void setText(String newText) {
> textFlow.setText(newText);
> }
>
>
> Alex Boyko wrote:
>> Hi,
>>
>> Yes, there is such an edit policy. Look at
>> LabelDirectEditPolicy#showCurrentEditValue().
>> This method sets the new text to text flow figure, which will
>> eventually revalidate the parent figure (the StickyNoteFigure), which
>> with the help of the layout manager will be assigned the proper bounds
>> to fit the text flow.
>> Hope this helps.
>>
>> Cheer,
>> Alex
>>
Re: Resize node figure as textflow content changes [message #228949 is a reply to message #228913] Fri, 12 January 2007 03:10 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi Ben,

I'm out of ideas, so can only suggest debugging your
LabelDirectEditPolicy#showCurrentEditValue(Request) method. The line:
getHostFigure().getUpdateManager().performUpdate();
should validate your ScenarioNodeFigure, so figure's layout manager should
be called which will resize the ScenarioNodeFigure's bounds to fit the
text flow.
You could try this for now.

Cheers,
Alex
Re: Resize node figure as textflow content changes [message #228957 is a reply to message #228913] Fri, 12 January 2007 03:17 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi Ben,

You could also check if StackLayout#layout() is getting called when you're
entering text.

Cheers,
Alex
Re: Resize node figure as textflow content changes [message #229081 is a reply to message #228957] Mon, 15 January 2007 20:22 Go to previous message
Eclipse UserFriend
Originally posted by: ben.vitale.precipia.com

Thanks for the help Alex. Turns out I was looking in the wrong place.

In refreshVisuals for the node edit part, I was setting a layout
constraint on the node figure based on the dimensions stored in the
node's model object. Removing this constraint allowed my figure to
resize at will.

Alex Boyko wrote:
> Hi Ben,
>
> You could also check if StackLayout#layout() is getting called when
> you're entering text.
>
> Cheers,
> Alex
>
Previous Topic:How to start a GEF project in Eclispe
Next Topic:PolyLine.setBounds fails
Goto Forum:
  


Current Time: Fri Apr 19 23:29:30 GMT 2024

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

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

Back to the top