Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Problem with multiline Label, the setTextWrap(true); does not work
Problem with multiline Label, the setTextWrap(true); does not work [message #482178] Tue, 25 August 2009 15:13 Go to next message
Bo Liu is currently offline Bo LiuFriend
Messages: 9
Registered: July 2009
Junior Member
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 setTextWrap(true); does not work [message #482192 is a reply to message #482178] Tue, 25 August 2009 16:28 Go to previous messageGo to next message
Ivo Petkov is currently offline Ivo PetkovFriend
Messages: 14
Registered: August 2009
Junior Member
Hi Lui,

Try this:
in the EditPart of the label change the getManager like this:
	/**
	 * @generated NOT
	 */
	protected DirectEditManager getManager() {
		if (manager == null) {
			setManager(new TextDirectEditManager(this,
					WrapTextCellEditor.class, TTTEditPartFactory
							.getTextCellEditorLocator(this)));
		}
		return manager;
	}

The essential is passing directly WrapTextCellEditor.class

To have a new line when you edit the text, press Ctrl + Enter


Regards,
Ivo

[Updated on: Tue, 25 August 2009 16:29]

Report message to a moderator

Re: Problem with multiline Label, the setTe xtWrap(true); does not work [message #482242 is a reply to message #482192] Tue, 25 August 2009 19:56 Go to previous message
Bo Liu is currently offline Bo LiuFriend
Messages: 9
Registered: July 2009
Junior Member
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
Previous Topic:Cannot change the link line from straight line to another path.
Next Topic:org.eclipse.gmf.formtk deprecated?
Goto Forum:
  


Current Time: Fri Apr 26 11:30:40 GMT 2024

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

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

Back to the top