Make part of Label editable? [message #23912] |
Fri, 04 October 2002 19:40  |
Eclipse User |
|
|
|
Hi,
I am trying to make part of the Label editable, for example, I have a label
with text "[only editable part]" but only text within [] is editable.
So in my LabelEditManager I strip the "[" and "]" when i initialize teh cell
editor. It does display the text which are editable.
But how can I surround the text that user put with "[]"?
There are 2 cases need to consider:
- user clicks the label, cell editor pops up, and he enters a new value
- user clicks the label, cell editor pops up, he clicks something else, so
he never change the value of the label
How i inital the cell editor:
String labelText =
((Label)((GraphicalEditPart)getEditPart()).getFigure()).getT ext();
getCellEditor().setValue(labelText.substring(1, labelText.length - 1));
Another approach I can think of is have 1 non-editable label for "[" , 1
non-editable label for "]" and 1 editable labe for the editable part. But I
am trying to reduce the number of objects as much as I can.
Thanks in advance for any help.
|
|
|
Re: Make part of Label editable? [message #24058 is a reply to message #23912] |
Sat, 05 October 2002 01:36   |
Eclipse User |
|
|
|
If you're already stripping out the brackets when you initialize the cell
editor, you can change LabelDirectEditPolicy.getDirectEditCommand(...) so that
it creates a new LogicLabelCommand with the brackets surrounding the text.
protected Command getDirectEditCommand(DirectEditRequest edit) {
String labelText = (String)edit.getCellEditor().getValue();
LogicLabelEditPart label = (LogicLabelEditPart)getHost();
LogicLabelCommand command = new
LogicLabelCommand((LogicLabel)label.getModel(), "["+labelText+"]");
return command;
}
Eric
Hal wrote:
> Hi,
>
> I am trying to make part of the Label editable, for example, I have a label
> with text "[only editable part]" but only text within [] is editable.
> So in my LabelEditManager I strip the "[" and "]" when i initialize teh cell
> editor. It does display the text which are editable.
>
> But how can I surround the text that user put with "[]"?
> There are 2 cases need to consider:
> - user clicks the label, cell editor pops up, and he enters a new value
> - user clicks the label, cell editor pops up, he clicks something else, so
> he never change the value of the label
>
> How i inital the cell editor:
> String labelText =
> ((Label)((GraphicalEditPart)getEditPart()).getFigure()).getT ext();
>
> getCellEditor().setValue(labelText.substring(1, labelText.length - 1));
>
> Another approach I can think of is have 1 non-editable label for "[" , 1
> non-editable label for "]" and 1 editable labe for the editable part. But I
> am trying to reduce the number of objects as much as I can.
>
> Thanks in advance for any help.
>
>
>
>
>
|
|
|
Re: Make part of Label editable? [message #24157 is a reply to message #23912] |
Sat, 05 October 2002 16:38  |
Eclipse User |
|
|
|
Originally posted by: hudsonr.us.eye-bee-em.com
Text control has a validateEdit callback. There is a way to prevent the
user from editing parts of the Text, but I think that sounds real strange.
Just surround the text with brackets when you display it in the label
figure, and everywhere else there are no brakets
"Hal" <otaconss2@hotmail.com> wrote in message
news:anl7it$v84$1@rogue.oti.com...
> Hi,
>
> I am trying to make part of the Label editable, for example, I have a
label
> with text "[only editable part]" but only text within [] is editable.
> So in my LabelEditManager I strip the "[" and "]" when i initialize teh
cell
> editor. It does display the text which are editable.
>
> But how can I surround the text that user put with "[]"?
> There are 2 cases need to consider:
> - user clicks the label, cell editor pops up, and he enters a new value
> - user clicks the label, cell editor pops up, he clicks something else, so
> he never change the value of the label
>
> How i inital the cell editor:
> String labelText =
> ((Label)((GraphicalEditPart)getEditPart()).getFigure()).getT ext();
>
> getCellEditor().setValue(labelText.substring(1, labelText.length - 1));
>
> Another approach I can think of is have 1 non-editable label for "[" , 1
> non-editable label for "]" and 1 editable labe for the editable part. But
I
> am trying to reduce the number of objects as much as I can.
>
> Thanks in advance for any help.
>
>
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 1.05561 seconds