Wicket: AutoCompleteTextField with "favourites" - java

I need to build an AutoCompleteTextField-like component where the user can mark some options as favourites (when he starts to write, some options show up and each option has a checkbox to mark it as favourite). The user can then check a checkbox outside the AutoCompleteTextField to choose whether only the favourites will be shown or on the contrary all the values no matter if they are favourites or not, will be all shown.
I have read Using panels instead of String in Autocompletetextfield and i think it could be done using IAutoCompleteRenderer...
Any ideas?

I would go with the solution provided by Robert in https://stackoverflow.com/a/15484348/461499.
Why?
If you have complete control over how the choices are rendered (by using plain Wicket Components instead of javscript), you can built a very rich component. Although I think it will take some extra javascript effort to make the choices-panel look and feel correct, it should be worth the investment.

Related

How to select multiple radios inside p:selectOneRadio

I'd like to display a web page that shows the results of a test containing numerous multiple choice type questions. I have the list of options, the candidate's answer and the correct answer to the questions.
For each question I'd like to display a set of disabled radio buttons where you see the correct answer and the candidate's answer. The problem is that when the two differs I have to display two checked radio buttons (background color would indicate the correct one) and it seems to me that primefaces selectOneRadio or the h:selectOneRadio component don't provide a standard way to do that.
Could you suggest something? Should I try to set it somehow from javascript, or is there a way to do this with standard components based on information acquired from the backing JSF bean?

Best way to implement a selection box from a large number of entries

I have a large set of data from which the user has to select one. I'm thinking of a way to implement it (of course, in a GUI). I have a few ideas. But just thought of posting here as there may be better alternatives..
Say, user has to select a name from a large set of user base. If I simply put a text field for user to enter the name, then there can be issues like entering same name in different formats, misspelling etc...
I see two options here
Using a combo box
Using a list (Actually i'm thinking of something like a tool tip. As I cant show the whole list always due to space issues)
But combo box won't be much user friendly i guess. As the user will have to scroll around the whole list to select an entry. If the number of entries are too large, this will be
Which means, now I'm left only one option. A popping up list, which will change the content according the text user is entering in the text field. So he can type first few letters and the list will show all the entries starting from the entered text. Got my point, right?
Are there any other better to achieve this kind of need?
If I'm going to implement above, what will be the best way to follow. I'm thinking of extending the JTextField to add required functionality. Well, I'll put some method to set the popup list entries. And I'll add some actionListner to watch the text field, and control the popup list accordingly...
Autocomplete is what you are probably looking for. Google for "java swing jcombobox autocomplete" and limit results for the last couple of years to get relevant results. There will be a lot of examples and ideas on how to implement this with custom code.
I believe there is also some custom libraries like "swingx" that provide at least partial or full implementations to save time.
http://swingx.java.net/
They have released code as recently as the beginning of this years so it appears active and might have what you need.
You could take a look at SwingLab's autocomplete feature, it allows you to attach it to a JCombBox, JList or JTextComponent
use AutoComplete JComboBox/JTextField
based on Standard Java Classes
no issue with larger sets of data
no issue with Focus, BackSpace Key, Caret
for better performance to required sort the array before use
simple workaround for setStrict(true/false), restrict input to array

Selecting nested subexpressions in a Swing GUI

As a part of a GUI design that I'm implementing in Java swing, I need the user to be able to select parts or subparts of a tree like structure represented as a string.
For example, if I were to display the following expression, ((a|b)|(c|d))
The user would need to be able to select any of the following
(a|b), (c|d) or the entire thing ((a|b)|(c|d)).
Ideally I'd like them to be able to navigate via the keyboard arrows, moving up and down though the nested subexpressions, and hit enter when they come to the subexpression they want. However if its only possible to do this on mouse click, thats also acceptable.
The main issue that I'm having with this is the nesting component. I could easily make the entire expression selectable, but I don't know how to allow subexpressions to be selectable using SWING components. Based on my research Swing doesn't allow nesting of labels of text areas in the manner that I need so I'm looking for any alternatives.
Any help or suggestions would be much appreciated.
You could use a Highlighter and a DocumentListener on the read-only JTextField suggested by Joop in the comment above, following http://docs.oracle.com/javase/tutorial/uiswing/components/textfield.html in the section about JTextFieldDemo. That way you can highlight your (partial) string and listen to what (sub)string is selected, and compare it to the original string to check for matches.

Best way to implement refusing a value change by the user in Swing?

I have a JCheckBox that should not be checked by the user when a certain other field is empty.
So now I want to have an error popup and then reset the checkbox (I've considered disabling the checkbox, but the connection to the other field is non-obvious, and a tooltip text IMO not visible enough).
What's the correct way to do that in Swing? Through a PropertyVetoException? Where do I throw it and where do I catch it? My first (probably ugly) idea would be to add a ChangeListener that itself shows the popup and resets the value.
Edit: The question is about Nikki (screenshot below), an app I am developing which geotags images and exports them to Google Earth's KMZ format. The checkbox is used to select the images to include in the export. But this requires the images to be gotagged first (which in turn requires either a timestamp, or manual assignment). I don't think this requirement can be made obvious through the UI layout.
(source: brazzy.de)
I would simply disable the check box and add a message explaining why the option is not available. A nice way to show the message is to display a mini exclamation mark next to the check box and put the message in a tooltip.
Poping up an exception often feels wrong because users don't read error messages. For most users an error message popup means that the application did something wrong, in your case it's the normal behavior.
Edit if you insist on letting the check box enabled, another way to show the user that some info is missing would be to flash the missing data. Eg. if latitude and longitude are missing and the user clicks on export, set a red background onto these fields for a just a second. This will clearly show the user what's missing.
In this screen, don't you want to put the mouse over the red circle to understand what's going on?
validation http://www.vogella.de/articles/EclipseDataBinding/images/validation10.gif
I don't think the Export JCheckBox should be disabled at all. Instead, the Export JButton itself should examine the current export list and display any anomalous entries in a way that allows navigation to a chosen photograph. If all entries are correct, Export would proceed as usual.
Addendum: It think you are right to keep the interface as non-modal as possible. My model for this would be unsaved files when exiting an editor or uncommitted changes when closing a project in an IDE.
If that's a status line at the bottom of the window, you might indicate the number of photographs currently selected for export, adding a count if any still need geocoding.
The field should simply be allowed to disable the checkbox. If the coupling is unintuitive then the GUI layout may have to be reconsidered.
EDIT: I ran it from your page, and I believe the issue here is that you actually have a third and fourth step in addition to select folder, select images. The third step is validate image, and fourth is select images for export. I think your problem is that this is not clearly conveyed in the current layout, and that reflects in your question.
I would suggest that you create a separate column containing the checkbox for each image, and that THAT checkbox is disabled until the image passes validation (step 3). Perhaps with an explanatory text in the column about why the image hasn't passed yet.

In an Eclipse RCP editor, what is the best way to handle missing mandatory fields?

On an Eclipse RCP application, I'm building an Editor in which some fields are mandatory.
If the user saves the editor with theses fields not filled, what is the best way/practice to handle this ?
(my first guess is to show an error dialog if theses fields are empty in doSave() method but I'm not sure it's the "eclipse" way to deal with this kind of problem)
If you consider some dialog box like "Create a New Java Project",
you simply cannot do any action (like "Next" or "Finish" until you fill the one mandatory field ("Project name")
So it is different than checking on the doSave() event.
If that field is invalid (like if the project name already exist), a warning is displayed in the zone at the top.
If the field is correctly filled, then you can save.
(Note: I know this is not an Editor, but it can give you an idea about the mandatory fields management in eclipse)
alt text http://ds.informatik.uni-marburg.de/MAGE/gdt/images/tutorial/NewJavaProject.png
I agree with VonC and would disable the "Save" button, as long as the user has filed all the important fields.
Showig a warning which fields the user has to fill would help a lot.
EDIT:
Create a component which added himself as change listener. When someone changes the component, you can check whether the input is correct.
Create a window whith all the self-checking components and add the window as listener to all the components.
When somebody change a compounent you can directly check if the input is valid and the user can step to the next page or save the page.
In RCP (Example FieldEditorPreferencePage) a lot of components have the doSave() and isValid() methods.
In isValid() you can check all the components you can find in the window and in doSave(), you sould check the isValid() state, when it is not done automatically, and do some additional save actions.
You could use FieldDecorations to mark the mandatory fields and provide visual feedback if the content of a field is incorrect.

Categories