Home » Eclipse Projects » Eclipse Platform » How to add dynamic Hyperlink in SWT shell with eclipse(Hyperlink in SWT TableViewer)
How to add dynamic Hyperlink in SWT shell with eclipse [message #1830400] |
Fri, 24 July 2020 21:44 |
Eric Zuo Messages: 14 Registered: October 2014 |
Junior Member |
|
|
Dear Experts,
I have SWT window, and it will launch another SWT shell with TableViewer containing a list of information from Oracle database, each row will have a hyperlink in TableColumn for details of this row.
The second shell is launched, The columns are correctly loaded with data from Oracle, but the link "https://..." does not clickable. I guess the https may be a issue.
I attached the function for the initialization..
One the web, all examples show link with hard coded URL, and actually those samples do not work for me either, links did not launch.
Could you please forward me example for dynamic composed hyperlink?
Thank you very much.
Eric
[Updated on: Fri, 24 July 2020 23:29] Report message to a moderator
|
|
| | |
Re: How to add dynamic Hyperlink in SWT shell with eclipse [message #1830544 is a reply to message #1830418] |
Tue, 28 July 2020 23:03 |
Eric Zuo Messages: 14 Registered: October 2014 |
Junior Member |
|
|
Thank Ed and Rolf for your response. For OOMPH, it is new environment, I installed it, will try late. The Snippets are good, I learned a lot from them. I modified the Snippet148 to my page displaying my web page. the problem is how to launch it.
The link still not reflect to click. I tried both in (TableItem) cell.getItem():
Link: link.addListener (SWT.Selection, event ->{
System.out.println(url); // url printed.
// sn148.open(); // does not work, crashed.
});
button: public void mouseDoubleClick(MouseEvent e) {
Snippet148 sn148 = new Snippet148();
sn148.setUrl(url);
sn148.open();
}
in both cases , it crashed. But Snippet148 runs well if I run it alone.
Experts please take a look, and kindly forward instruction.
My Eclipse : Oxygen.3a (4.7.3a), Window 64. Project: WindowBuilder/SWT Desiner/SWT/JFace Java Project
Thank you in advance.
Eric
public void initializeQui() {
TableViewer viewer = new TableViewer(HYSHOPWORKORDER);
viewer.getTable().setHeaderVisible(true);
viewer.getTable().setLinesVisible(true);
viewer.setContentProvider(new ArrayContentProvider());
loadWorkOrder lWO = new loadWorkOrder();
ArrayList<WorkOrder> workOrders = lWO.mxWorkOrderOf1Asset(carNo);
TableColumn column = null;
column = new TableColumn(viewer.getTable(), SWT.NONE);
column.setText("wonum");
column.setWidth(100);
TableViewerColumn Col1 = new TableViewerColumn(viewer, column);
Col1.setLabelProvider(new ColumnLabelProvider(){
String url= "";
String wonum ="";
@Override
public String getText(Object element) {
WorkOrder wo = (WorkOrder)element;
url=wo.getUrl();
wonum= wo.getWonum();
return wonum;
}
@Override
public void update(ViewerCell cell) {
TableItem item = (TableItem) cell.getItem();
Hyperlink hyperlink;
wonum = getText(cell.getElement());
Link link = new Link((Composite) cell.getControl(), SWT.NONE);
String text = "<a>" + wonum + "</a>";
link.setText(text);
Snippet148 sn148 = new Snippet148();
sn148.setUrl(url);
link.addListener (SWT.Selection, event ->{
System.out.println(url); // url printed.
// sn148.open(); // does not work, crashed.
}); // How to bring up Snippet148?
TableEditor editor = new TableEditor(item.getParent());
editor.grabHorizontal = true;
editor.grabVertical = true;
editor.setEditor(link , item, cell.getColumnIndex());
editor.layout();
}
});
// column2, colukmn3, column4
}
//Instead use Link, I used Button, still not worked:
Button aWorkOrder = new Button((Composite) cell.getControl(), SWT.NONE);
String text = wonum ;
aWorkOrder.setText(text);
aWorkOrder.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
Snippet148 sn148 = new Snippet148();
sn148.setUrl(url);
sn148.open(); // Does not work, crashed. How to bring up Snippet148?
}
});
|
|
| |
Goto Forum:
Current Time: Thu Dec 26 23:28:13 GMT 2024
Powered by FUDForum. Page generated in 0.03719 seconds
|