Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Prevent OK button being default in DataSetWizardPage
Paul A
Hi,<br />
<br />
I have a ODA Designer Plug-in which I have created via the wizard in Eclipse Indigo SDK (3.7).<br />
<br />
When I debug the report designer and double-click my Data Set to edit it shows the Edit Data Set dialog with the Query selected. If I press Enter, the wizard will close.<br />
<br />
The generated class in my code is CustomDataSetWizardPage which extends DataSetWizardPage. On this I have created a org.eclipse.swt.widgets.Text field where I want the user to enter a string to search in a Tree. I want to be able to press enter and perform the search - not leave the wizard page.<br />
<br />
I am guessing something is the default button - probably OK. The only place I can see a button default is in the Shell so I tried the following code which I thought might work:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
Shell shell = parent.getDisplay().getActiveShell();
shell.setDefaultButton(buttonNext); // throws exception
shell.setDefaultButton(null); // no effect
</pre>
<br />
Which throws up an exception.<br />
<br />
Is there any way to prevent the wizard from leaving the page in this instance and allow me to perform the search?<br />
<br />
Cheers<br />
<br />
Andez
Find more posts tagged with
Comments
Xiaoxiao
Hi Andez,<br />
<br />
I sugguest you should not change the default behavior of SWT components which may cause some other issue such as the exception you've met.<br />
<br />
Actually by default, if you press enter, it results that the default button of the dialog is pressed, generally the OK button or Cancel.<br />
<br />
If you want to perform the search by the input value of the Text, I think the best way is to add a search button besides the Text field. You can press the button by mouse to perform the search, or use the keyboard by TAB, which makes the button focused on, and then Space to achieve the same effect as directly pressing the button.<br />
<br />
Please try the way I recommended above. Any question or suggestion is welcomed.<br />
<br />
Thanks,<br />
Xiaoxiao<br />
<br />
<blockquote class='ipsBlockquote' data-author="'Paul A'" data-cid="81115" data-time="1312474123" data-date="04 August 2011 - 09:08 AM"><p>
Hi,<br />
<br />
I have a ODA Designer Plug-in which I have created via the wizard in Eclipse Indigo SDK (3.7).<br />
<br />
When I debug the report designer and double-click my Data Set to edit it shows the Edit Data Set dialog with the Query selected. If I press Enter, the wizard will close.<br />
<br />
The generated class in my code is CustomDataSetWizardPage which extends DataSetWizardPage. On this I have created a org.eclipse.swt.widgets.Text field where I want the user to enter a string to search in a Tree. I want to be able to press enter and perform the search - not leave the wizard page.<br />
<br />
I am guessing something is the default button - probably OK. The only place I can see a button default is in the Shell so I tried the following code which I thought might work:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
Shell shell = parent.getDisplay().getActiveShell();
shell.setDefaultButton(buttonNext); // throws exception
shell.setDefaultButton(null); // no effect
</pre>
<br />
Which throws up an exception.<br />
<br />
Is there any way to prevent the wizard from leaving the page in this instance and allow me to perform the search?<br />
<br />
Cheers<br />
<br />
Andez<br /></p></blockquote>
Paul A
Hi Xiaoxiao,
Thanks for that. I forgot to mention I have added Next and Previous buttons.
But the idea for being a quick search would be to type text then press enter after the user has typed some text - just like the search in say Internet Explorer and most desktop applications. I know wizards work differently in some instances but to me it would make sense to capture the Enter Keypress.
The other alternative is to do a search as you type - then if the user wanted they click on the Next button to goto the next matching item. I have added this functionality in a modifyText event on the text box. Again, when they have entered text and it matches on an item, I would like to capture the Enter press. I can see this being an issue with certain users.
Is it possible to do this?
Cheers,
Andez
Xiaoxiao
Hi Andez,
The SWT has its own framework, as you know, which is completely different from the IE mechanism. So even if you think the behavior makes sense for you, it may not be implemented under the restrictions of SWT framework.
As for the idea to do the search as you type, I think you can exactly add the logic of search in the modifyText event on the text box, which means whenever the user types a word or makes some modification the search logic will be executed. And if the matching item on the tree is found, you can make it highlighted or do some other jobs on the tree as you need.
The capture of Enter press, however, will still not work as you expect. I mean the default button on the dialog will be pressed as the result.
All that is restricted by the special mechanisms of SWT such as Listener, which cannot be controlled by our own.
Hope the suggestions above will give you some help.
Thanks,
Xiaoxiao