Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » TextCellEditor does not show edited content
TextCellEditor does not show edited content [message #1467760] Mon, 10 November 2014 09:35 Go to next message
Andrea Richiardi is currently offline Andrea RichiardiFriend
Messages: 64
Registered: August 2012
Member
My implementation of a TextCellEditor is the following, also adding a KeyListener:

fHoverTableViewerTextCellEditor = new TextCellEditor(fHoverTableViewer.getTable());
		fHoverTableViewerTextCellEditor.getControl().addKeyListener(new KeyListener() {
			
			private boolean isPressedKeyModifier = false;
			private boolean isStateKeyModifier = false;
			
			public void keyPressed(KeyEvent e) {
				isPressedKeyModifier = e.keyCode > 0 && e.character == 0 && (e.keyCode & SWT.MODIFIER_MASK) != 0;
				isStateKeyModifier = e.stateMask > 0 && (e.stateMask & SWT.MODIFIER_MASK) != 0;
				
				String insertString = null;
				
				String modifierString = Action.findModifierString(e.keyCode);
				String modifierMask = Action.findModifierString(e.stateMask);
								
				if (isPressedKeyModifier) {
					insertString = Action.findModifierString(e.keyCode);
					
					if (isStateKeyModifier) {
						insertString= java.text.MessageFormat.format(Messages.HoverPreferencePage_insertModifierAndDelimiterAndModifier,
								new Object[] { Action.findModifierString(e.keyCode), Action.findModifierString(e.stateMask) });
						
					}
					
					fHoverTableViewerTextCellEditor.setValue(insertString);
				}
			}


And then I bind:
fModifierTableViewerColumn.setEditingSupport(ObservableValueEditingSupport.create(fHoverTableViewer, context,
				fHoverTableViewerTextCellEditor,
				CellEditorProperties.control().value(WidgetProperties.text(SWT.Modify)),
				HoverViewModel.getEditingDomain()));


But when I press enter I cannot see my content, or better, if I click again on the Cell, it shows my content, but it dies not show it after the "Editing" context is over.

What am I missing?
Re: TextCellEditor does not show edited content [message #1467783 is a reply to message #1467760] Mon, 10 November 2014 09:56 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6416
Registered: July 2009
Senior Member
You need to call viewer.update(Object,null) after you modified the value.
On 10.11.14 10:35, Andrea Richiardi wrote:
> My implementation of a TextCellEditor is the following, also adding a
> KeyListener:
>
>
> fHoverTableViewerTextCellEditor = new
> TextCellEditor(fHoverTableViewer.getTable());
> fHoverTableViewerTextCellEditor.getControl().addKeyListener(new
> KeyListener() {
>
> private boolean isPressedKeyModifier = false;
> private boolean isStateKeyModifier = false;
>
> public void keyPressed(KeyEvent e) {
> isPressedKeyModifier = e.keyCode > 0 && e.character == 0
> && (e.keyCode & SWT.MODIFIER_MASK) != 0;
> isStateKeyModifier = e.stateMask > 0 && (e.stateMask &
> SWT.MODIFIER_MASK) != 0;
>
> String insertString = null;
>
> String modifierString =
> Action.findModifierString(e.keyCode);
> String modifierMask =
> Action.findModifierString(e.stateMask);
>
> if (isPressedKeyModifier) {
> insertString = Action.findModifierString(e.keyCode);
>
> if (isStateKeyModifier) {
> insertString=
> java.text.MessageFormat.format(Messages.HoverPreferencePage_insertModifierAndDelimiterAndModifier,
>
> new Object[] {
> Action.findModifierString(e.keyCode),
> Action.findModifierString(e.stateMask) });
>
> }
>
> fHoverTableViewerTextCellEditor.setValue(insertString);
> }
> }
>
>
> And then I bind:
> fModifierTableViewerColumn.setEditingSupport(ObservableValueEditingSupport.create(fHoverTableViewer,
> context,
> fHoverTableViewerTextCellEditor,
>
> CellEditorProperties.control().value(WidgetProperties.text(SWT.Modify)),
> HoverViewModel.getEditingDomain()));
>
> But when I press enter I cannot see my content, or better, if I click
> again on the Cell, it shows my content, but it dies not show it after
> the "Editing" context is over.
>
> What am I missing?
>
Re: TextCellEditor does not show edited content [message #1467842 is a reply to message #1467783] Mon, 10 November 2014 10:56 Go to previous messageGo to next message
Andrea Richiardi is currently offline Andrea RichiardiFriend
Messages: 64
Registered: August 2012
Member
Yes but I don't have the visibility of the row that was modified/my model Object (I guess, I am still a JFace rookie), don't I?
Re: TextCellEditor does not show edited content [message #1467852 is a reply to message #1467842] Mon, 10 November 2014 11:09 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6416
Registered: July 2009
Senior Member
Well it looks like use use JFace-Databinding for editing but not the
LabelProviders.

Tom

On 10.11.14 11:56, Andrea Richiardi wrote:
> Yes but I don't have the visibility of the row that was modified/my
> model Object (I guess, I am still a JFace rookie), don't I?
Re: TextCellEditor does not show edited content [message #1467910 is a reply to message #1467852] Mon, 10 November 2014 12:05 Go to previous messageGo to next message
Andrea Richiardi is currently offline Andrea RichiardiFriend
Messages: 64
Registered: August 2012
Member
Yes it is a little mixed because I don't know how to intercept the KeyPressed/KeyReleased method in another way. Probably I should just forse a notify from my:
ViewerSupport.bind(fHoverTableViewer, fViewModel.observableList, HoverViewModel.getDisplayDomain());			
Re: TextCellEditor does not show edited content [message #1468102 is a reply to message #1467910] Mon, 10 November 2014 15:21 Go to previous message
Andrea Richiardi is currently offline Andrea RichiardiFriend
Messages: 64
Registered: August 2012
Member
Ok, using
ObservableMapLabelProvider
solved the problem.
Previous Topic:How to make shell display when it is hidden
Next Topic:How to add readonly textbox in table Viewer.
Goto Forum:
  


Current Time: Thu Nov 15 03:44:36 GMT 2018

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

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

Back to the top