This is probably a trivial question for most but here goes...
I am using SWT and want to show a table inside a CTabItem (or a TabItem if it's easier).
I tried to create the table and use the CTabItem as the parent when doing so, however it doesnt accept this as a parameter (asking me to change CTabItem to Composite).
I figured there must be a way of showing a table inside a tab, I'm just not sure how to do it, can anyone point me in the right direction?
You have to use the (C)TabFolder as parent instead. And on the (C)TabItem you have to call tabItem.setControl(yourTable).
Howto put controls onto a tab see this snippet, use this as base and modify and replace a control with your table.
Related
I'm developing an eclipse RCP/RAP application. I have several GUI-classes that use the JFace TableViewer (internal org.eclipse.swt.widgets.Table).
Some of my clients mentioned that it is a little confusing wether the "database-select failed" or there are just no elements.
So here's my question. Is there any way to display a "greyed out" text saying "No elements". There is something similar for the org.eclipse.swt.widgets.Text:
edtTest.setMessage("Please enter something");
Couldn't find anything like that.
Thank you in advance.
There isn't any simple support for this.
You could simulate this by adding a dummy row to the table and making your label provider implement IColorProvider so you can set the color of the row (or use one of the label providers based on StyledCellLabelProvider.
Alternatively use a separate label control and use StackLayout to make either the table of the label the visible control.
I have developed an Eclipse plugin, when I clicked the button a table appears on the view. However, this table does not refresh itself, when I click it again or when I a run operations on the table (such as deletion).
While I was implementing my table, I used TableColumn to create my columns and "TableItem" for the rows and values. Therefore, the "TableViewer"s refresh or remove functions does not work.
My table is able to appear, when I click the button and I call this function in the handler, such as;
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView("ViewID");
However, still I am not able refresh it. Any help would be nice.
Thanks!
Basically, you need to call viewer.update() whenever you want to refresh or update the table. SWT tables and JFace viewers does not have a way to monitor the data model.
Alternatively, you can use Eclipse Data Binding to bind the model and the controls/viewers together. Have a look at this entry level tutorial to get you started.
Hello im making a program and using TableModel. I have 6 column filed with string's. I want the sixth column string make it look like URL. When i mean look like URL , i mean turn it into blue and be underlined. Is it possible to do that?
You need to write custom TableCellRenderer for your jtable. See this link.This may be helpful for you.
Sun had a very good tutorial (http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#modelchange) on cerating jtable. just go through it before you start. hope this tutorial will help you.
But below is my suggestion.
("<html><b><u>link</u></html>");
<html><b>bold</b></html>
a similar kind of thing
However, I wouldn't recommend altering the data in your model just to effect display. Instead I would create a custom cell renderer which accomplishes this effect and set it on the table. You could either wrap your text in the HTML or manually set font color and style properties on the renderer to mimic html.
Now even if you were to include the url in the html you still can't click on it. There is no component in the table. You don't really want to go into edit mode when clicking on a url. You just want to open that link. To accomplish this you would add a mouse listener to the table itself. When you receive a click event, you would then programatically determine which cell it was over, go back to your model and get the url, and finally use other Java API calls to open that url.
I'm pretty sure you can simply create a string containing
<html>...</html>
and it will work. Just code your link inside the html tags as you would in html. You'll just have to add extra code if you want it to appear blue. I think:
<font color='blue'>
would do it
I'm programming a GUI in Java using the Vaadin framework having a question about adjusting the behaviour of a drop down list.
What is the correct property action to make a drop down list of the type Select none-writeable. That is, when selected I don't want the "write-marker" to flash in the list expecting input but rather have the drop down list expand on such an action.
I've tried with searchDropDown.setReadOnly(true); but that turned off the drop down behaviour completely...
Anyone have any ideas...? =)
Thanks!
Try using a NativeSelect instead of ComboBox?
My current application uses a JList and everything is well (the only customization I did was to set the italic font on some of the rows).
Now I want to "upgrade" the user interface and instead of just labels in the List, I want a checkbox and a text field to be able to update the entry.
I started changing the code and adding a custom cell renderer and a custom cell model. My current problem is that the JPanel that the cell renderer is returning is not using the whole width of the container, so several list items are actually shown on the same line.
But now, I am wondering whether I should just change the whole thing to use JTable. I still need to add / remove items in the list though...
Any suggestion which one is better ? and if going with the JList, how should I go about fixing my current problem ?
In my experience using JTable is usually easier as it allows more complex data and functionality out-of-the-box. Usually when I try to do something the JList can't do, I just switch to JTable without a second thought. What you want sounds like something that should be pretty trivial to implement in a table. I suggest you try it out with some mock data to see if you can make it look and work the way you like (especially in case you want it to look like a list).
Try calling setLayoutOrientation(JList.VERTICAL) on your JList. That will restrict JList to a single column.