Java SWT TreeViewer with one column that needs to be StyledText - java

I have a TreeViewer used in an eclipse plugin that uses a content provider and a label provider that implements all of (ITableLabelProvider, IFontProvider, IColorProvider).
But I need one of the columns of the table it creates to hold "links" - underlined blue text that when clicked causes some popup to open. I guess what I want to do is cause that single column to hold styled text and not just text, and attach a listener to the items in that column of the tree, but I couldn't figure out how to do it.

Use a separate label provider for each column using TreeViewerColumn:
TreeViewer viewer = new TreeViewer(.....);
TreeViewerColumn col1 = new TreeViewerColumn(viewer, SWT.LEAD);
col1.setLabelProvider(col1 label provider);
... repeat for other columns
For columns that require styling use DelegatingStyledCellLabelProvider as the column label provider as described here
Note: Do not call viewer.setLabelProvider when using column label providers.

Related

Zkoss-8.5.1 Problem creating data binding programmatically

I'm creating a zk component for mount easy grid from view database. One of its powerful features is the automatic generation of filters by column. These filters appear automatically on the top column inside the auxheader tag and all are generated programmatically in java with the column info. Example of database view TIMESTAMP column (sorry not css right now):
https://prnt.sc/ZK9nMws2l68p
My problem now is that I don't know how to bind these datebox generated programmatically in java with the view for recovering the filter values.
I was searching inside the zkoss wiki and only found this:
create data binding programmatically,
where you can find how bind zk components of the zul, or how bind components generated programatically if the parent has an item render option.
But i need generate N datebox, numberbox, textbox depending on the number and type of the columns and recover the values of it.
Anyone knows how do it?
The component has a loot of code and scrap, but more or less the idea is:
https://pastebin.com/Q5VX472L
cols.setParent(gridDatatable);
// create filters inside AuxHeads
Auxhead auxhead1 = new Auxhead();
// create a line with the same number of AuxHeaders as Columns we have
for (int indexColumn = 0; indexColumn < columnsList
.size(); indexColumn++) {
if (columnsList.get(indexColumn).getVisible()) {
// i have definned the diferent Auxheader with a patron factory
Auxheader auxheader = gridDatatableFilterFactory.generateFilter(
columnsList.get(indexColumn).getTerms().getType(),
columnsList.get(indexColumn).getTerms().getKey());
auxheader.setParent(auxhead1);
}
}
// set the Auxhead line between col names and rows
auxhead1.setParent(gridDatatable);
// we add the rowrender for print the rows
gridDatatable.setRowRenderer(
new DatatableRowRender(columnsList, gridDatatableCellFactory));
search();
Thank you in advance, regards.

How to add colum JTable to Jcombobox in Java Eclipse

I add the column value of JTable to JComBoBox full of null notifications
I tried passing the sub-variable and then adding jcombobox but it was not
I have test two ways but failed
1.TableColumn testColumn = tbclass.getColumnModel().getColumn(1);
testColumn.setCellEditor(new DefaultCellEditor(jcombobox));
2.tbclass.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(jcombobox));
The error is
java.lang.NullPointerExceptionat

Jbutton selection criteria

I am designing a Java project which contains a Radio button group having 15 jRadio buttons. Each Radio button have names like "Master", "Front_desk", "Accounts" etc. and this text name is defined in MySQL table. In MySQL table I have defined whether to enable or disable particular radio button. I use following code to get Radio button name from MySQL table
String Btn_name = Rs.getString("Module_name");
after get Btn_name I tried to enable or disable the radio button state by using follwing command
Btn_name.setEnabled(true);
or
Btn_name.setEnabled(false);
but I am getting following error
can not find symbol
symbol : method setEnabled(boolean)
location : variable Btn_name of type String
You need to create a jradiobutton in a standard way,
JRadioButton btn = new JRadioButton().
btn.setText(Btn_name);
btn.setEnabled(true/false);
And create as many jradiobutton you need in a loop over the resultSet.

How to create a complex header in vaadin 7?

I was using setColumnHeader(Object, String) to set a simple string as a column header. I want to create a complex header. I would like to know if there is any way to build a similar table as shown in the below figure in Vaadin 7. http://i.stack.imgur.com/u5dIw.gif
Now it is possible using Grid:
// Group headers by joining the cells
HeaderRow groupingHeader = grid.prependHeaderRow();
HeaderCell namesCell = groupingHeader.join(
groupingHeader.getCell("firstname"),
groupingHeader.getCell("lastname"));
HeaderCell yearsCell = groupingHeader.join(
groupingHeader.getCell("born"),
groupingHeader.getCell("died"),
groupingHeader.getCell("lived"));
This example is taken from Vaadin Book. Just to show that new Vaadin 7.5 (and above) can build table with complex header (joined columns). Another good resource is in Vaadin Wiki.
As you notice such grouping is also possible for footer row.
Not at the moment.
It is scheduled for vaadin 7.4, which is currently in alpha stage.

SmartGWT ListGrid - exclude field from selection

I would like to ask for your help to solve the following problem.
I have a SmartGwt ListGrid wich has multiple rows in it.
This ListGrid has a SelectionChangedHandler which works just fine.
I added a special column (ListGridField) to this ListGrid, on which basically I want to prevent the selectionChangeEvent to trigger when clicked.
This special column has its own recordclickHandler.
I only want to EXCLUDE this column form changing the selected record in the ListGrid.
Is there any way to do so in your knowledge?
Thanks in advance.
Since the event for row selection doesn't tell you which cell you clicked on, hence no way of telling which column, I think you'll need to make cells selectable, and ignore the event if the cell is in the excluded column.
myGrid.setCanSelectCells(true);
myGrid.addCellSelectionChangedHandler(new CellSelectionChangedHandler() {
public void onCellSelectionChanged(CellSelectionChangedEvent event) {
CellSelection selection = countryGrid.getCellSelection();
//use to determine if excluded column is clicked:
int[][] selectedCells = selection.getSelectedCells();
//use to get selected row:
ListGridRecord record = selection.getSelectedRecord();
//etc...
}
}

Categories