I'm trying to convert a drop down box widget into a SuggestionBox because the current drop down menu has 100+ choices. It seems like you can only add String suggestions to a SuggestOracle though. I need to be able to add a custom object that contains both a description and an ID that matches the record to the database though. Would I have to extend the SuggestOracle class?
Yes as i know you can not use pair of values i.e Id and Value. You have to add your strings in suggestion box perhaps you can use different solution other then suggestion box i.e. Create a List of values popup. And add as many fields as you like. display your data in flex table with pagination. update your form with the selected row by using selecition handler. for reference how to use FlexTable and handle events please see able Single Row Click Event
SuggestOracle is the parent class of MultiWordSuggestOracle which you are already yousing.
public class MultiWordSuggestOracle extends SuggestOracle
see MultiWordSuggestOracle
Related
I connected MySql database with Java app, I see data from two different columns (Items, Price) but I want to connect them somehow, for example, if choose in first combobox item "Desk" the other combobox should automatic find "Desk" price and display it in second combobox. Anyone have idea how to make that ?
You could write a changelistener for the first box, then have it go into another sql query which will populate the second box. Check out this guide, it'll explain to you how to do it
https://docs.oracle.com/javase/tutorial/uiswing/events/changelistener.html
First, I think that you don't want to ComboBoxes being correlated in such a way. There must be a better design for your gui.
Is your ComboBox from JFace? There are JFace Data Bindings. Normally, you use them to automatically update your model if someone changes values in the user interface. If your model contains an id from your database, both comboboxes can have a binding to this id.
I have a list of items that are pulled from a database, it combines the various fields with a rs.getString method to create a longer string of items, this is done in an action button method.
I would like to be able to click on an item in this list and have one of the fields display as text in a textbox, so this needs to be done through the list selection event method where I instruct the program to set the text to my desired value.
My problem is, I am not sure of the logic to follow in order to specify how to retrieve that fields information that will be corresponding to the item that is selected in the list, can you give me any ideas?
Rather the combining the fields into a single String, create a POJO (Plain Old Java Object), which provides getters (and possible setters) for the fields you want and these objects to the ListModel
Use a ListCellRenderer to customise the way which the JList renders the POJO the way you want to. See Writing a Custom Cell Renderer for more details.
When the user selects an item from the list, use JList#getSelectedValue and cast to the same class as your POJO. You can now use the POJO's getters to extract the properties you want to display.
The idea is to generate a self contained unit of work, which, based on what you want to do, you can customise how the object is displayed.
This concept is a corner stone to the separation of data (model) and the UI (view) behind the Model-View-Controller paradigm and OOP generally...
I want to create a webpage that looks like this one:
This is done using a table. Each row describes an object and I want to be able to select multiple of those objects. When one of the submit-buttons is clicked, I want to get the list of selected objects. I know there is the class CheckBoxMultipleChoice, but the generated output is not what I need.
I think I should use a ListView, but since the number of objects is dynamic, I do not know how to access the states of the checkboxes. Could you please tell me how I can achieve this layout?
You should use a CheckGroup with one Check component in each row.
I have a TableViewer where the values in one column should typically come from a dynamic list.
I'm currently using org.eclipse.jface.viewers.ComboBoxCellEditor , which is actually a Select-List: it stores the index of the selected value. If I change the underlying list (calling setItems(String[]), it's clumsy to keep the previous selected value... (specially if it's not included in the list anymore!) What I'd wish is actually a cell editor that stores, not the index from the list, but the string (perhaps letting the user edit it freely, perhaps not), where the list is just used as a suggestion at input time - like a "combobox" was supposed to work in the good old days... Is this possible?
I would suggest you to have your CellEditor to mimic the behavior that you are looking for. Extend ComboBoxViewerCellEditor and override doGetValue() method. Add modify listener on Combo control and also filter (which filters list items based on input text) to comboviewer.
You should look at :
org.eclipse.wst.xml.ui.internal.properties.StringComboBoxCellEditor This class comes from WTP project; It's an extended ComboBoxCellEditor that selects and returns Strings.
codemirror.eclipse.ui.xquery.viewers.StringComboBoxCellEditor It's the copy/paste of WTP StringComboBoxCellEditor; it adds the capability to add the item in the combo when it is not found.
I'm trying to convert a drop down box widget into a SuggestionBox because the current drop down menu has 100+ choices. It seems like you can only add String suggestions to a SuggestOracle though. I need to be able to add a custom object that contains both a description and an ID that matches the record to the database though. Would I have to extend the SuggestOracle class?
Yes as i know you can not use pair of values i.e Id and Value. You have to add your strings in suggestion box perhaps you can use different solution other then suggestion box i.e. Create a List of values popup. And add as many fields as you like. display your data in flex table with pagination. update your form with the selected row by using selecition handler. for reference how to use FlexTable and handle events please see able Single Row Click Event
SuggestOracle is the parent class of MultiWordSuggestOracle which you are already yousing.
public class MultiWordSuggestOracle extends SuggestOracle
see MultiWordSuggestOracle