Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » RAP 2.3 - keeping selected value on ComboViewer
RAP 2.3 - keeping selected value on ComboViewer [message #1421372] Thu, 11 September 2014 09:21 Go to next message
Christian Wrobel is currently offline Christian WrobelFriend
Messages: 5
Registered: July 2013
Junior Member
Hello everyone,

i have an problem with eclipse rap 2.3 and comboviewer.
When a value is selected in my combobox and the content of these combo is changed i like to keep the old selection if the new values contains the old selected item.

here my example code:

i create an combo:

final ComboViewer viewer = new ComboViewer(parent, SWT.NONE);
viewer.setContentProvider(new ArrayContentProvider());


for demonstrating this example i created two buttons:

Button btnObj = new Button(parent, SWT.NONE);
btnObj.setText("change input");
btnObj.addSelectionListener(new SelectionAdapter() {
	@Override
	public void widgetSelected(SelectionEvent e) {
		String[] itemsArr = new String[] {"a", "b", "c", "d", "e" };
		String oldValue = viewer.getCombo().getText();
		
		viewer.setInput(Arrays.asList(itemsArr));
		for(String strObj : viewer.getCombo().getItems()) {
			if(strObj.equals(oldValue)) {
				viewer.getCombo().setText(oldValue);
			}
		}
		System.out.println("viewer.getCombo().getSelectionIndex() " + viewer.getCombo().getSelectionIndex());
		System.out.println("viewer.getCombo().getText() " + viewer.getCombo().getText());
		
	}

});

Button btn2Obj = new Button(parent, SWT.NONE);
btn2Obj.setText("change input 2");
btn2Obj.addSelectionListener(new SelectionAdapter() {
	@Override
	public void widgetSelected(SelectionEvent e) {
		String[] itemsArr = new String[] {"a", "b", "c", "d", "e", "f" };
		String oldValue = viewer.getCombo().getText();
		
		viewer.setInput(Arrays.asList(itemsArr));
		for(String strObj : viewer.getCombo().getItems()) {
			if(strObj.equals(oldValue)) {
				viewer.getCombo().setText(oldValue);
			}
		}
		
		System.out.println("viewer.getCombo().getSelectionIndex() " + viewer.getCombo().getSelectionIndex());
		System.out.println("viewer.getCombo().getText() " + viewer.getCombo().getText());	
		
	}

});


now when i run this code and push button 'change input' it fills my combo with that list of data. After when i select one item, for example 'c', and press this button again the value in my combo is 'c'.

Now when i push the second button 'change input 2' it fills the second list in my combo, but there is no item selected. The console prints the following:

viewer.getCombo().getSelectionIndex() -1
viewer.getCombo().getText()
viewer.getCombo().getSelectionIndex() 2
viewer.getCombo().getText() c
viewer.getCombo().getSelectionIndex() 2
viewer.getCombo().getText() c

so it seems that the value 'c' is still selected, but in the ui there ist nothing selected. This problem only occurs when the content lengt of the combo list changes. For example when the second buttons loads the items "e", "d", "c", "b", "a" into the combo it works, that means when i select for example 'b' and press both buttons it keeps that selection in the ui.

Can anybody tell my what's wrong with my code?

Best regards
Christian Wrobel


Re: RAP 2.3 - keeping selected value on ComboViewer [message #1424038 is a reply to message #1421372] Mon, 15 September 2014 11:10 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2334
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Christian,
does your code work in RCP (SWT/JFace)? If yes, please file a bugzilla
and we will find what is causing the difference.
Best,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: RAP 2.3 - keeping selected value on ComboViewer [message #1435466 is a reply to message #1424038] Wed, 01 October 2014 14:34 Go to previous messageGo to next message
Christian Wrobel is currently offline Christian WrobelFriend
Messages: 5
Registered: July 2013
Junior Member
Hi Ivan,

thanks for your reply.

i was testing my code snippet with RCP, here it's working so i think that there is an bug with RAP. I watched bugzilla and saw that there is an similar bug (Bug 444128) which is already fixed, so i think that my issue should be solved, too.

So i would be happy to use this solution with RAP, based on version 2.3. Are there any patch releases planned in future (before RAP 3.0) ?

Best Regards
Christian Wrobel

[Updated on: Wed, 01 October 2014 14:35]

Report message to a moderator

Re: RAP 2.3 - keeping selected value on ComboViewer [message #1435480 is a reply to message #1435466] Wed, 01 October 2014 14:55 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2334
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Christian,
we will consider if the fix for bug 444128 is safe for back porting to
RAP 2.3 SR2 (scheduled for end of February).
Best,
Ivan

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:FileDialog
Next Topic:Enable text selection in a custom widget
Goto Forum:
  


Current Time: Mon Feb 24 16:13:46 GMT 2020

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

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

Back to the top