Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » A simple button with a simple ListViewer simply doesn't work
A simple button with a simple ListViewer simply doesn't work [message #494313] Fri, 30 October 2009 04:52 Go to next message
Ralf Heydenreich is currently offline Ralf Heydenreich
Messages: 106
Registered: July 2009
Senior Member
Hi all,
I get a very strange behaviour from my application. What I want is a
simple PushButton which opens a new Shell. This Shell should display a
List. There I've used a ListViewer. The first time I press the Button
all things are fine. But the second time the following message appears
in my browser window:

<begin_message>
Could not evaluate javascript response:

TypeError: w is undefined

org.eclipse.swt.EventUtil.suspendEventHandling();var req =
org.eclipse.swt.Request.getInstance();req.setRequestCounter( "24" );var
wm = org.eclipse.swt.WidgetManager.getInstance();var w =
wm.findWidgetById( "w103" );w.setBackgroundColor( "#cccccc" );var w =
wm.findWidgetById( "w26" );w.setSpace( 257, 94, -93, 94 );w.setActive(
true );var w = wm.newWidget( "w163", "w26", true, null,
"org.eclipse.swt.widgets.List" );w.init( true );w.addState( "rwt_BORDER"
);w.setOverflow( "auto" );w.setSpace( 0, 0, 0, 0 );w.setZIndex( 300
);w.setTabIndex( 1 );w.setChangeSelectionNotification( "action" );var w
= wm.findWidgetById( "w26" );w.setActiveControl( wm.findWidgetById(
"w163" ) );org.eclipse.swt.WidgetManager.getInstance().focus( "w163"
);qx.ui.core.Widget.flushGlobalQueues();org.eclipse.swt.Even tUtil.resumeEventHandling();


</begin_message>

Now some code fragments. In the constructor, I wrote:

/**
* @param parent the parent shell
* @param container the container in which the element should be placed
*/
public MySimpleListViewer(final Shell parent, Composite container) {
popupDialogShell = new Shell(parent, SWT.NONE);
init(container);
}


/**
* Initializes the PushButton
* @param container the container in which the PushButton should
be placed
*/
private void init(Composite container) {
button = new Button(container, SWT.PUSH);
button.setText("\u2026"); // only three dots
}

/**
* Appends a SelectionListener to the Button. At first the
ListViewer
* is build and initialized.
*/
public void activatePushButton() {
buildListViewer();
button.addSelectionListener(new SelectionAdapter(){

public void widgetSelected(SelectionEvent event) {

GridLayout gridLayout = new GridLayout(1, false);
popupDialogShell.setLayout(gridLayout);
if(listViewer.getContentProvider() == null)
buildListViewer();
popupDialogShell.pack();
popupDialogShell.open();
}
});
}

/**
* This method builds the ListViewer and initializes it with
* the right values.
*/
private void buildListViewer() {
GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
gridData.horizontalAlignment = GridData.FILL;
gridData.heightHint = 180;

listViewer = new ListViewer(popupDialogShell);
// field contentProvider is set before
listViewer.setContentProvider(contentProvider);
// field labelProvider is set before
listViewer.setLabelProvider(labelProvider);
// field customListInput is set before
listViewer.setInput(customListInput);
listViewer.getList().setLayoutData(gridData);
// String[] selectedItems are all items which are previously selected
//(first time empty)
listViewer.getList().setSelection(selectedItems);

listViewer.getList().addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
if (listViewer.getList().getSelectionCount() > 0) {
StringBuffer sb = new StringBuffer();
for(String s: listViewer.getList().getSelection()) {
if(sb.length() > 0) sb.append(";");
sb.append(s);
}
System.out.println(sb.toString());
selectedItems = listViewer.getList().getSelection();
} else {
System.out.println("nothing selected");
}
popupDialogShell.close();
}
});
}

The fields contentProvider, labelProvider and customListInput are set
via Setters for my class and aren't null (checked with Debugger). Is
there anything what I've overseen? Or is there a completely different
solution? I've build this example in SWT, too. There it works fine.

TIA,
Ralf.
Re: A simple button with a simple ListViewer simply doesn't work [message #494319 is a reply to message #494313] Fri, 30 October 2009 05:27 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan Furnadjiev
Messages: 1778
Registered: July 2009
Senior Member
Hi Ralf,

this is definitely a bug. Please file a bugzilla and attach a code to
reproduce it.

TIA,
Ivan

R. Heydenreich wrote:
> Hi all,
> I get a very strange behaviour from my application. What I want is a
> simple PushButton which opens a new Shell. This Shell should display a
> List. There I've used a ListViewer. The first time I press the Button
> all things are fine. But the second time the following message appears
> in my browser window:
>
> <begin_message>
> Could not evaluate javascript response:
>
> TypeError: w is undefined
>
> org.eclipse.swt.EventUtil.suspendEventHandling();var req =
> org.eclipse.swt.Request.getInstance();req.setRequestCounter( "24" );var
> wm = org.eclipse.swt.WidgetManager.getInstance();var w =
> wm.findWidgetById( "w103" );w.setBackgroundColor( "#cccccc" );var w =
> wm.findWidgetById( "w26" );w.setSpace( 257, 94, -93, 94 );w.setActive(
> true );var w = wm.newWidget( "w163", "w26", true, null,
> "org.eclipse.swt.widgets.List" );w.init( true );w.addState( "rwt_BORDER"
> );w.setOverflow( "auto" );w.setSpace( 0, 0, 0, 0 );w.setZIndex( 300
> );w.setTabIndex( 1 );w.setChangeSelectionNotification( "action" );var w
> = wm.findWidgetById( "w26" );w.setActiveControl( wm.findWidgetById(
> "w163" ) );org.eclipse.swt.WidgetManager.getInstance().focus( "w163"
> );qx.ui.core.Widget.flushGlobalQueues();org.eclipse.swt.Even tUtil.resumeEventHandling();
>
>
> </begin_message>
>
> Now some code fragments. In the constructor, I wrote:
>
> /**
> * @param parent the parent shell
> * @param container the container in which the element should be placed
> */
> public MySimpleListViewer(final Shell parent, Composite container) {
> popupDialogShell = new Shell(parent, SWT.NONE);
> init(container);
> }
>
>
> /**
> * Initializes the PushButton
> * @param container the container in which the PushButton should
> be placed
> */
> private void init(Composite container) {
> button = new Button(container, SWT.PUSH);
> button.setText("\u2026"); // only three dots
> }
>
> /**
> * Appends a SelectionListener to the Button. At first the
> ListViewer
> * is build and initialized.
> */
> public void activatePushButton() {
> buildListViewer();
> button.addSelectionListener(new SelectionAdapter(){
>
> public void widgetSelected(SelectionEvent event) {
>
> GridLayout gridLayout = new GridLayout(1, false);
> popupDialogShell.setLayout(gridLayout);
> if(listViewer.getContentProvider() == null)
> buildListViewer();
> popupDialogShell.pack();
> popupDialogShell.open();
> }
> });
> }
>
> /**
> * This method builds the ListViewer and initializes it with
> * the right values.
> */
> private void buildListViewer() {
> GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_END);
> gridData.horizontalAlignment = GridData.FILL;
> gridData.heightHint = 180;
>
> listViewer = new ListViewer(popupDialogShell);
> // field contentProvider is set before
> listViewer.setContentProvider(contentProvider);
> // field labelProvider is set before
> listViewer.setLabelProvider(labelProvider);
> // field customListInput is set before
> listViewer.setInput(customListInput);
> listViewer.getList().setLayoutData(gridData);
> // String[] selectedItems are all items which are previously selected
> //(first time empty)
> listViewer.getList().setSelection(selectedItems);
>
> listViewer.getList().addFocusListener(new FocusAdapter() {
> public void focusLost(FocusEvent e) {
> if (listViewer.getList().getSelectionCount() > 0) {
> StringBuffer sb = new StringBuffer();
> for(String s: listViewer.getList().getSelection()) {
> if(sb.length() > 0) sb.append(";");
> sb.append(s);
> }
> System.out.println(sb.toString());
> selectedItems = listViewer.getList().getSelection();
> } else {
> System.out.println("nothing selected");
> }
> popupDialogShell.close();
> }
> });
> }
>
> The fields contentProvider, labelProvider and customListInput are set
> via Setters for my class and aren't null (checked with Debugger). Is
> there anything what I've overseen? Or is there a completely different
> solution? I've build this example in SWT, too. There it works fine.
>
> TIA,
> Ralf.
>
>
>
>
>
>
>
>
>
>
Re: A simple button with a simple ListViewer simply doesn't work [message #495245 is a reply to message #494319] Wed, 04 November 2009 05:32 Go to previous message
Ralf Heydenreich is currently offline Ralf Heydenreich
Messages: 106
Registered: July 2009
Senior Member
Ivan Furnadjiev schrieb:
> Hi Ralf,
>
> this is definitely a bug. Please file a bugzilla and attach a code to
> reproduce it.

Hi Ivan,
I've just opened a new bug. It was a little difficult to reproduce it
outside our complex application. But now I've got the same error in a
HelloWorld project. Please see Bug 294178. There I've attached a little
project for testing.

Regards,
Ralf.


>
> TIA,
> Ivan
>
> R. Heydenreich wrote:
>> Hi all,
>> I get a very strange behaviour from my application. What I want is a
>> simple PushButton which opens a new Shell. This Shell should display a
>> List. There I've used a ListViewer. The first time I press the Button
>> all things are fine. But the second time the following message appears
>> in my browser window:
>>
>> <begin_message>
>> Could not evaluate javascript response:
>>
>> TypeError: w is undefined
>>
>> org.eclipse.swt.EventUtil.suspendEventHandling();var req =
>> org.eclipse.swt.Request.getInstance();req.setRequestCounter( "24" );var
>> wm = org.eclipse.swt.WidgetManager.getInstance();var w =
>> wm.findWidgetById( "w103" );w.setBackgroundColor( "#cccccc" );var w =
>> wm.findWidgetById( "w26" );w.setSpace( 257, 94, -93, 94 );w.setActive(
>> true );var w = wm.newWidget( "w163", "w26", true, null,
>> "org.eclipse.swt.widgets.List" );w.init( true );w.addState( "rwt_BORDER"
>> );w.setOverflow( "auto" );w.setSpace( 0, 0, 0, 0 );w.setZIndex( 300
>> );w.setTabIndex( 1 );w.setChangeSelectionNotification( "action" );var w
>> = wm.findWidgetById( "w26" );w.setActiveControl( wm.findWidgetById(
>> "w163" ) );org.eclipse.swt.WidgetManager.getInstance().focus( "w163"
>> );qx.ui.core.Widget.flushGlobalQueues();org.eclipse.swt.Even tUtil.resumeEventHandling();
>>
>>
>>
>> </begin_message>
>>
>> Now some code fragments. In the constructor, I wrote:
>>
>> /**
>> * @param parent the parent shell
>> * @param container the container in which the element should be placed
>> */
>> public MySimpleListViewer(final Shell parent, Composite container) {
>> popupDialogShell = new Shell(parent, SWT.NONE);
>> init(container);
>> }
>>
>>
>> /**
>> * Initializes the PushButton
>> * @param container the container in which the PushButton should
>> be placed
>> */
>> private void init(Composite container) {
>> button = new Button(container, SWT.PUSH);
>> button.setText("\u2026"); // only three dots
>> }
>>
>> /**
>> * Appends a SelectionListener to the Button. At first the
>> ListViewer
>> * is build and initialized.
>> */
>> public void activatePushButton() {
>> buildListViewer();
>> button.addSelectionListener(new SelectionAdapter(){
>>
>> public void widgetSelected(SelectionEvent event) {
>>
>> GridLayout gridLayout = new GridLayout(1, false);
>> popupDialogShell.setLayout(gridLayout);
>> if(listViewer.getContentProvider() == null)
>> buildListViewer();
>> popupDialogShell.pack();
>> popupDialogShell.open();
>> }
>> });
>> }
>>
>> /**
>> * This method builds the ListViewer and initializes it with
>> * the right values.
>> */
>> private void buildListViewer() {
>> GridData gridData = new
>> GridData(GridData.HORIZONTAL_ALIGN_END);
>> gridData.horizontalAlignment = GridData.FILL;
>> gridData.heightHint = 180;
>>
>> listViewer = new ListViewer(popupDialogShell);
>> // field contentProvider is set before
>> listViewer.setContentProvider(contentProvider);
>> // field labelProvider is set before
>> listViewer.setLabelProvider(labelProvider);
>> // field customListInput is set before
>> listViewer.setInput(customListInput);
>> listViewer.getList().setLayoutData(gridData);
>> // String[] selectedItems are all items which are previously selected
>> //(first time empty)
>> listViewer.getList().setSelection(selectedItems);
>>
>> listViewer.getList().addFocusListener(new FocusAdapter() {
>> public void focusLost(FocusEvent e) {
>> if (listViewer.getList().getSelectionCount() > 0) {
>> StringBuffer sb = new StringBuffer();
>> for(String s:
>> listViewer.getList().getSelection()) {
>> if(sb.length() > 0) sb.append(";");
>> sb.append(s);
>> }
>> System.out.println(sb.toString());
>> selectedItems =
>> listViewer.getList().getSelection();
>> } else {
>> System.out.println("nothing selected");
>> }
>> popupDialogShell.close();
>> }
>> });
>> }
>>
>> The fields contentProvider, labelProvider and customListInput are set
>> via Setters for my class and aren't null (checked with Debugger). Is
>> there anything what I've overseen? Or is there a completely different
>> solution? I've build this example in SWT, too. There it works fine.
>>
>> TIA,
>> Ralf.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
Previous Topic:Some toolbar items are missing when part size is too narrow
Next Topic:[Databinding]Binding multiple TreeViewers in different session to single model
Goto Forum:
  


Current Time: Mon Jul 28 18:37:42 EDT 2014

Powered by FUDForum. Page generated in 0.02183 seconds