how to disable a list element in swt list eclipse - java

Is it possible to disable only certain elements of a swt list display.I want a list display with a certain clickable strings and a few disabled strings based on my conditions.Is it possible to this?

It is not possible with SWT List widget. you might need to come up with your own widget( may be Table with one Column)

If you really want it then add a selection listener that would detect if the selection is on the "disabled" item and then adjust up/down/clear selection depending on the list contents.
You may also use table with a single column - then you should be able to custom-draw disabled items (e.g. to use lighter font or a different background).

Related

Vaadin - adding components as elements of another components

I've been using a ComboBox to store some values and make a selection from those values, but the problem is, ComboBox, as it is, only allows one selection at the time and I need multiple selections, ie checkboxes, but that cannot be done via Vaadin. I figured if I could present checkboxes as the elements of the ComboBox, that would solve the issue, except adding components to a component that is not a layout doesn't seem to be possible.
I've done this tutorial https://vaadin.com/docs/-/part/framework/components/components-customcomponent.html
Basically it combines two Vaadin components into one panel and displays them together, but that's not what I need, as I need certain components to be placed inside a parent component.
So what are my options if I'm to do this?
This is not an answer to the question that you are asking (component within a component), but rather the underlying problem that you present. In other words, I believe your question is an example of an XY problem.
I think you want to use a Grid with multi-select turned on. In this mode, check boxes are automatically added to each row and there is a checkbox in the header to allow toggling all on/off, ability to filter, ability to sort columns, etc. See the documentation for more details.

Filtering a ListView in wicket using 2 drop down boxes

I am trying to filter a list that is placed into a listview through the use of 2 drop down boxes.
The first dropdown box is titled price and the second is owner.
I want to be able to select a value in one or more of these drop down boxes and then have the List view re-render with the filtered results.
The trouble is I do not know how to begin this task, would someone be so kind as to enlighten me :D
Thanks in advance!
Your best starting point is probably this example: (Source code also available on this page, ChoicePage.java is the name)
First of all, you have to use a dynamic model in your ListView that generates the list of items depending on what you had selected in the dropdown boxes.
Then the basic idea is that you add an AjaxFormComponentUpdatingBehavior to the components that control the updates (your two dropdown boxes in your case), and in the onUpdate() method of this behaviour you should add the component you want to update to that AjaxRequestTarget passed.

wrapping the contents of List in SWT

I have created fixed size List. If the list has one item which is bigger than the List size it self, then the item should be wrapped to multiple lines.
SWT.WRAP can't be used as it supports only Label and Text controls.
For item customization of List you need to create your own widget.
Check e.g. http://www.snip2code.com/Snippet/11489/Custom-SWT-List-Box
In this way you will have full control on the rendering of the different items
If you want to have multiple lines in labels per item in a list, then you use a table instead. See the SWT snippet "draw multiple lines in a table item" for the relevant code.
The bad news is that all items must have the same height...

JFace ComboViewer with a header entry?

I'm interested in populating a ComboViewer with a list of objects.
I know JFace has some nice features that support that, but what if I want to make the first entry in the ComboViewer something like
<Select Connection>
or some other dummy entry that doesn't have an object associated to it? Is there any simple generic solution to it?
You could do this with the TableCombo widget from the Nebula project. You can a create TableComboViewer with input, selection listeners etc. but also set the text of the combo independently from the current selection.
TableComboViewer viewer = ...
...
viewer.getTableCombo().setText("...");
I use this in a current project. However the TableCombo is in alpha state, but in my application it works quite fine.
AFAIK you can't do it out of the box. You can write you own LabelProvider to do this, or you may want to switch to something like a ListViewer in a popup window, and use the List's headers to display your special first element.

JCheckBox to display and perform functionality in JList

I am trying to get a JCheckBox to display on a line that is in the multiple select JList and still perform its functionality.
Right now if I add the JCheckBox as an element it just prints its toString format.
Help/ideas?
If you haven't already done so, you'll need to write a custom ListCellRenderer, as discussed in Writing a Custom Cell Renderer.
Addendum: Because you'll also need an editor to handle the checkbox state, you may find it easier to use a one column JTable, as discussed in How to Use Tables. Note that a data column having the type Boolean will be automatically rendered with a check box.

Categories