Problem with multiline Label, the setTextWrap(true); does not work [message #482178] |
Tue, 25 August 2009 11:13  |
Eclipse User |
|
|
|
Hi everyone,
I want to implement a multiline label, as far as I read from previous
threads, it's
1. set the wappinglabel's setTextWrap(true);
2. then make the method annotated by @generated NOT
here is my code
/**
* @generated NOT
*/
private void createContents() {
fFigurePFMachineNameFigure = new WrappingLabel();
fFigurePFMachineNameFigure.setText("<...>");
fFigurePFMachineNameFigure.setTextWrap(true);
...
}
but the label still is only one line, The rectangle's defautlt size is
(100,62), and it resizes(longer) by the length of the label!!
I tried to set the maximunSize of the label but it also did not work.
I current use newest Eclipse Moddeling, and my GMF version is 2.2.0, any
idea about this?
BTW, how can I constrain the length of a label? the setMaximumSize()
function does not seem to be useful on label.
Kind Regards
Liu Bo
|
|
|
|
Re: Problem with multiline Label, the setTe xtWrap(true); does not work [message #482242 is a reply to message #482192] |
Tue, 25 August 2009 15:56  |
Eclipse User |
|
|
|
Hi Ivo,
Thanks a lot. Your code works!
And I think I found part of the reason for this:
there are some old version code in the TextDirectEditManager class:
public static Class getTextCellEditorClass(GraphicalEditPart source) {
IFigure figure = source.getFigure();
if (figure instanceof WrapLabel && ((WrapLabel)
figure).isTextWrapped())
return WrapTextCellEditor.class;
return TextCellEditorEx.class;
}
the return type is TextCellEditorEx.class; as the checking condition in if
is "instanceof WrapLabel", however, it should be "WrappingLabel". The
generated getManager method calls this method, so it never return the
right class. After I change it to WrapTextCellEditor.class, it works fine.
Actually I do expect the label change automatically to mutiline when it
arrives the bound of the node, it seems I have to use "ctrl + enter" to
enable it mannually.
Now I am going to customize the label's position and its width to make it
better looked...
Thanks again Ivo.
Kind Regards
Liu Bo
|
|
|
Powered by
FUDForum. Page generated in 0.03207 seconds