How add OpenJavafx 11 GUI components on SWT part using OpenJDK 11 and Eclipse photon 2018-12 - swt

I am using OpenJDK 11 + OpenJavafx 11 environment in Eclipse Photon 2018-12 and created one plugin GUI project in eclipse. My aim is to add the OpenJavafx components(Button) on SWT Part.
These are steps I am following to render the javafx Button on top of SWT Part
Application e4xmi view:
There are two plugins using
1. com.rcp.main – Main RCP Application, there are two parts on part stack in main plugin.
Part 1 (Sample Part 1 : class URI bundleclass://com.rcp.main/com.rcp.main.parts.SamplePart) Rendered with pure SWT created from eclipse template figure below. It is working as expected.
Part 2 (Sample Part 2: class URI bundleclass://com.rcp.main/com.rcp.main.parts.SamplePart1) Rendered with open Javafx GUI components (Button) on SWT part. I am getting empty one exception from as figure below
2. com.rcp.feature – This feature included plugins with com.rcp.main and org.eclipse.fx.osgi
VM Arguments in Product file:
-Dorg.osgi.framework.bundle.parent=ext
-Dosgi.framework.extensions=org.eclipse.fx.osgi --module-path "C:\Program Files\Java\javafx-sdk-11.0.1\lib" --add-modules javafx.base,javafx.controls,javafx.graphics --add-modules ALL-MODULE-PATH
public class SamplePart {
private TableViewer tableViewer;
#Inject
private MPart part;
#PostConstruct
public void createComposite(Composite parent) {
parent.setLayout(new GridLayout(1, false));
Text txtInput = new Text(parent, SWT.BORDER);
txtInput.setMessage("Enter text to mark part as dirty");
txtInput.addModifyListener(e -> part.setDirty(true));
txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
tableViewer = new TableViewer(parent);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());
tableViewer.setInput(createInitialDataModel());
tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
}
#Focus
public void setFocus() {
tableViewer.getTable().setFocus();
}
#Persist
public void save() {
part.setDirty(false);
}
private List<String> createInitialDataModel() {
return Arrays.asList("Sample item 1", "Sample item 2", "Sample item 3", "Sample item 4", "Sample item 5");
}
}
public class SamplePart1 {
#Inject
private MPart part;
#PostConstruct
public void createComposite(Composite parent) {
final FXCanvas fxCanvas = new FXCanvas(parent, SWT.NONE);
fxCanvas.setLayout(new GridLayout(1, true));
try {
Button btn = new Button();
btn.setText("Say 'Hello World'");
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root);
fxCanvas.setScene(scene);
} catch (Exception e1) {
}
}
#PreDestroy
#Inject
private void disposeARView(MWindow window, EModelService modelService) {
}
#Focus
public void setFocus() {
}
#Persist
public void save() {
}
}
I am getting this exception when i click the Part 2 tab on part stack
Result:
Empty Screen in Part 2
!ENTRY org.eclipse.e4.ui.workbench 4 0 2019-02-05 09:55:46.956
!MESSAGE Unable to create class 'com.rcp.main.parts.SamplePart1' from bundle '82'
!STACK 0
org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Canvas
Caused by: java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Canvas
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1095)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Canvas
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)

Related

Eclipse e4 RCP SourceViewer syntax coloring

To implement syntax coloring in an eclipse e4 RCP application, I have created a basic plugin project with a Part including a SourceViewer control.
public class SyntaxColoringTest {
/** The SourceViewer control to create the editor. */
public SourceViewer sv = null;
#Inject
public SyntaxColoringTest() {
}
#PostConstruct
public void postConstruct(Composite parent) {
IVerticalRuler verticalRuler = new VerticalRuler(10);
OverviewRuler overviewRuler = new OverviewRuler(null, 20, null);
sv = new SourceViewer(parent, verticalRuler, overviewRuler, true, SWT.MULTI | SWT.V_SCROLL |SWT.H_SCROLL);
sv.configure(new TestSourceViewerConf());
}
}
Being TestSourceViewerConf as follows:
public class TestSourceViewerConf extends SourceViewerConfiguration {
public ITokenScanner tokenScanner;
public IRule patternRule;
public IRule endOfLineRule;
public TestSourceViewerConf(){
tokenScanner = createTokenScanner();
}
public IPresentationReconciler getPresentationReconciler(ISourceViewer viewer) {
PresentationReconciler reconciler= new PresentationReconciler();
DefaultDamagerRepairer defDamagerRepairer= new DefaultDamagerRepairer(tokenScanner);
reconciler.setDamager(defDamagerRepairer, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(defDamagerRepairer, IDocument.DEFAULT_CONTENT_TYPE);
return reconciler;
}
private ITokenScanner createTokenScanner() {
RuleBasedScanner scanner= new RuleBasedScanner();
scanner.setRules(createRules());
return scanner;
}
private IRule[] createRules() {
Display display = Display.getCurrent();
Color blue = display.getSystemColor(SWT.COLOR_BLUE);
IToken tokenA= new Token(new TextAttribute(blue));
IToken tokenB= new Token(new TextAttribute(blue));
patternRule= new PatternRule("<", ">", tokenA, '\\', false);
endOfLineRule = new EndOfLineRule("++ ", tokenB);
return new IRule[] {patternRule, endOfLineRule};
}
}
When running the application nothing is colored when typing after "++ " or in between < >
Thanks
This code works for me testing in one of my own e4 editors.
What you haven't shown is any set up of the document for the source viewer. If you don't set a document my test shows the behavior you are seeing. Set the document with:
IDocument doc = new Document(contents);
sv.setDocument(doc);
where contents is the initial contents of the document.

How do I reset perspective for Eclipse e4 RCP application?

After building a perspective in application.e4xmi file, I am unable to reset perspective by calling IWorkbenchPage.resetPerspective().
I thought this may save others some time, as well as document it for myself.
The trick to being able to reset an e4 perspective is as follows (assumes a basic application.e4xmi with PerspectiveStack element):
In your application.e4xmi file, locate your PerspectiveStack under your Application/TrimmedWindow node. Record/set its ID.
In Eclipse 4 Model Editor, drag your Perspective(s) from underneath your PerspectiveStack to Application/Snippets. (This will cause your perspective IDs to register with IPerspectiveRegistry, and provide a pristine state).
Create new CopyPerspectiveSnippetProcessor. This will copy the perspectives in your snippets to your PerspectiveStack on startup. This makes it so you don't have to maintain two copies of each perspective element in your e4xmi file.
package com.example.application.processors;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
/**
* Copies all snippet perspectives to perspective stack called "MainPerspectiveStack" In order to register/reset perspective and not have to sync two copies in
* e4xmi.
*
*/
public class CopyPerspectiveSnippetProcessor {
private static final String MAIN_PERSPECTIVE_STACK_ID = "MainPerspectiveStack";
#Execute
public void execute(EModelService modelService, MApplication application) {
MPerspectiveStack perspectiveStack = (MPerspectiveStack) modelService.find(MAIN_PERSPECTIVE_STACK_ID, application);
// Only do this when no other children, or the restored workspace state will be overwritten.
if (!perspectiveStack.getChildren().isEmpty())
return;
// clone each snippet that is a perspective and add the cloned perspective into the main PerspectiveStack
boolean isFirst = true;
for (MUIElement snippet : application.getSnippets()) {
if (snippet instanceof MPerspective) {
MPerspective perspectiveClone = (MPerspective) modelService.cloneSnippet(application, snippet.getElementId(), null);
perspectiveStack.getChildren().add(perspectiveClone);
if (isFirst) {
perspectiveStack.setSelectedElement(perspectiveClone);
isFirst = false;
}
}
}
}
}
Register your CopyPerspectiveSnippetProcess into your plugin.xml file.
<extension id="MainAppModel" point="org.eclipse.e4.workbench.model">
<processor beforefragment="false" class="com.example.application.processors.CopyPerspectiveSnippetProcessor"/>
</extension>
Reset the perspective as normal. You will also want to set the perspective stack and the current perspective to visible, as these can sometimes be set to invisible. A sample handler might look like:
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspectiveStack;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.ui.PlatformUI;
public class ResetPerspectiveHandler {
private static final String MAIN_PERSPECTIVE_STACK_ID = "MainPerspectiveStack";
#Execute
public void execute(EModelService modelService, MApplication application) {
MPerspectiveStack perspectiveStack = (MPerspectiveStack) modelService.find(MAIN_PERSPECTIVE_STACK_ID, application);
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().resetPerspective();
perspectiveStack.getSelectedElement().setVisible(true);
perspectiveStack.setVisible(true);
}
}
Reset perspective (when you lunch e4 application without clearing work space, when you switch other perspective to your perceptive).
Step 1: Add a add-on in your model fragment at application level.
Step 2: Create Add-on class and implement EventHandler
Step 3: add following code in the class.
public class ResetPrespectiveAddOn implements EventHandler {
private static final String MY_PERSPECTIVE_ID = "myPrespectiveId";
#Inject
private IEventBroker broker;
#PostConstruct
public void loadPrespective() {
broker.subscribe(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT, this);
}
#SuppressWarnings("restriction")
#Override
public void handleEvent(Event event) {
//UIEvents.EventTags.ELEMENT is trigger for all UI activity
Object property = event.getProperty(UIEvents.EventTags.ELEMENT);
if (!(property instanceof PerspectiveStackImpl)) {
return;
}
// Reset perspective logic .
IEclipseContext serviceContext = E4Workbench.getServiceContext();
final IEclipseContext appContext = (IEclipseContext) serviceContext.getActiveChild();
EModelService modelService = appContext.get(EModelService.class);
MApplication application = serviceContext.get(MApplication.class);
MWindow mWindow = application.getChildren().get(0);
PerspectiveStackImpl perspectiveStack = (PerspectiveStackImpl) property;
List<MPerspective> children = perspectiveStack.getChildren();
for (MPerspective myPerspective : children) {
if (myPerspective.getElementId().equals(MY_PERSPECTIVE_ID)) {
//find active perspective
MPerspective activePerspective = modelService.getActivePerspective(mWindow);
if(activePerspective.getElementId().equals(MY_PERSPECTIVE_ID))
//Reseting perspective e3 way
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().resetPerspective();
// till now there is no direct e4 way to reset perspective
// but u can Add and remove e4 perspective with this code code
EPartService partService = serviceContext.get(EPartService.class);
MPerspectiveStack perspectiveStack = (MPerspectiveStack) (MElementContainer<?>) activePerspective.getParent();
int indexOf = perspectiveStack.getChildren().indexOf(activePerspective);
perspectiveStack.getChildren().remove(indexOf);
perspectiveStack.getChildren().add(myPerspective);
partService.switchPerspective(myPerspective);
}
}
}}

Generating check boxes dynamically, Netbeans

I am developing a desktop application in which I want Admin have option to delete users, for which I planned that whenever Admin clicks on 'delete users' button a new tab will open in which check boxes with the name of all existing users in my database should appear(so that he can delete multiple users simultaneously); so basically I need to generate dynamic check boxes as per my database.
I am using Netbeans 7.0.1, jdk 1.6, sqlite3.
After searching on google I got two links which match to my problem:
http://www.coderanch.com/t/345949/GUI/java/create-dynamic-checkboxes#2805277
Creating dcheckbox dynamically in Java-NetBeans
I have tried to follow the code from above first link but it does not working for me properly. What I does is just created new JFrame in netbeans and called a method inside constructor which create checkboxes as per needed, method's code is as below:
public class Work extends javax.swing.JFrame {
/** Creates new form Work */
public Work() {
initComponents();
checks = new java.util.ArrayList<>();
createCheckboxes();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
#SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void createCheckboxes(){
panel = new javax.swing.JPanel();
this.add(panel);
for(int i = 0; i<4; i++){
javax.swing.JCheckBox box = new javax.swing.JCheckBox("check"+i);
panel.add(box);
checks.add(box);
panel.revalidate();
panel.repaint();
}
panel.setVisible(true);
}
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Work.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Work.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Work.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Work.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Work().setVisible(true);
}
});
}
// Variables declaration - do not modify
// End of variables declaration
private java.util.ArrayList <javax.swing.JCheckBox> checks;
private javax.swing.JPanel panel;
}
The output is just a blank frame. Please help me to know where I am wrong!!
And yes this code is not connected to database yet, once it will work then I can modify it to work with database.
Also is their any other betterway to accomplish my task or am on right path?`
I think it might help if u call the following function whenever to wanna create a new checkbox..
public class CheckBox extends JFrame{
//private static final long serialVersionUID = 1L;
public CheckBox() {
// set flow layout for the frame
this.getContentPane().setLayout(new FlowLayout(FlowLayout.TRAILING, 50, 20)); //(default) centered alignment and a default 5-unit horizontal and vertical gap.
JCheckBox checkBox1 = new JCheckBox("Checkbox 1");
checkBox1.setSelected(true);
JCheckBox checkBox2 = new JCheckBox("Checkbox 2", true);
JCheckBox checkBox3 = new JCheckBox("Checkbox 3");
// add checkboxes to frame
add(checkBox1);
add(checkBox2);
add(checkBox3);
}
private static void createAndShowGUI() {
//Create and set up the window.
//JFrame frame = new CreateCheckedUncheckedJCheckBox();
CheckBox cb = new CheckBox();
//Display the window.
cb.pack();
cb.setVisible(true);
cb.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
createAndShowGUI();
}
});
}
}
You add the new checkboxes as if your frame was using some simple layout such as FlowLayout, but it is not - it is using GroupLayout - see the generated initComponents() method.
If you want to handle ALL components in the frame dynamically, you can do this (it is better to create an empty class file and then paste the code below; do not ask NB to create a JFrame as it would again create a form to be designed in the visual designer; if you still do it then r-click it and change the layout to something simpler):
public class Work extends javax.swing.JFrame {
private java.util.List <javax.swing.JCheckBox> checks = new java.util.ArrayList<>();;
public Work() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new java.awt.FlowLayout()); // simply put the components next to each other
createCheckboxes();
}
private void createCheckboxes(){
for(int i=0; i<4; i++) {
javax.swing.JCheckBox box = new javax.swing.JCheckBox("check"+i);
add(box);
checks.add(box);
}
pack(); // this will tell the JFrame's panel to layout all the components
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Work().setVisible(true);
}
});
}
}
Or you can design part of your frame with the visual designer and then add the checkboxes. In that case add an empty panel in the designer, set the panel's layout to something like flow or grid layout and then add the checkboxes to that panel from your code in the same way as above.
You validate needs to be called only if the panel/frame is already visible. Calling pack works even then, but might change the size of the frame. Also validating can be done after all components were added not after adding each one.
To add check boxes or any other component dynamically in Netbeans JFrame one need to manage Layout Managers, by default netbeans frames use Free Design Layout, follow steps below:
Create blank JFrame -->Add Jpanel to it-->right click to the panel, select setLayout and change it to GridLayout.
Now we are free to add ant components on this panel.
Also don't forgate to add revalidate() and repaint() methods.
This worked for me.

CoolBar (java SWT WindowBuilder) Composite doesn't appear in Application

I have a problem when I try to use a coolBar in a composite and then I embed this composite in an application. The coolBar simply doesn't appear. This problem doesn't occours with another tools, like toolBar and other composites. What can I doing wrong or forgetting?
Before following the code, I refer my system:
Win7
Eclipse:Version: Indigo Service Release 2 Build id: 20120216-1857
Google WindowBuilder 1.5.0 Google
Plugin 3.1.0
SWT Designer 1.5.0
Google Web Toolkit 2.4.0
Composite code:
package xx.xxx.xx.pcommJavaGUI.composites;
import org.eclipse.swt.widgets.Composite;
public class TestComposite extends Composite {
public TestComposite(Composite parent, int style) {
super(parent, style);
setLayout(new GridLayout(1, false));
CoolBar coolBar = new CoolBar(this, SWT.FLAT);
CoolItem coolItem = new CoolItem(coolBar, SWT.NONE);
Button btnTest = new Button(coolBar, SWT.NONE);
coolItem.setControl(btnTest);
btnTest.setText("Test");
Tree tree = new Tree(this, SWT.BORDER);
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
}
#Override
protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}
}
And the application Window code:
package xx.xxx.xx.pcommJavaGUI.composites;
import org.eclipse.swt.SWT;
public class TestApplication {
protected Shell shell;
public static void main(String[] args) {
try {
TestApplication window = new TestApplication();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}
public void open() {
Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
protected void createContents() {
shell = new Shell();
shell.setSize(450, 300);
shell.setText("SWT Application");
shell.setLayout(new GridLayout(1, false));
TestComposite tc = new TestComposite(shell, SWT.NONE);
GridData gd_tc = new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1);
tc.setLayoutData(gd_tc);
}
}
Thanks for helping.
You have to set the size of CoolItem manually.
First of all pack(); your Button to set it to it's default size.
Afterwards set the size of the CoolItem to the size of the Button.
The Button:
Button btnTest = new Button(coolBar, SWT.NONE);
coolItem.setControl(btnTest);
btnTest.setText("Test");
// If you do not call this, btnTest.getSize() will give you x=0,y=0.
btnTest.pack();
Set the size of CoolItem:
Point size = btnTest.getSize();
coolItem.setControl(btnTest);
coolItem.setSize(coolItem.computeSize(size.x, size.y));
Links:
CoolBar Examples
API: Control.pack();
It might be just because you aren't setting layout data for the coolbar. See this article to understand how layouts work.

Render view based on another view in Eclipse plugin

I am developing an Eclipse plug-in that has currently 2 views. In my first view I have a list of connections displayed in a TableViewer (name and connection status).In my second view I want to load the tables in a database (the connection). This loading will be done by clicking a menu item on a connection ("view details"). These tables will be displayed in a TreeViewer because they can also have children. I have tried to do it this way:
My View class:
public class DBTreeView extends ViewPart {
private TreeViewer treeViewer;
private Connection root = null;
public DBTreeView() {
Activator.getDefault().setDbTreeView(this);
}
public void createPartControl(Composite parent) {
treeViewer = new TreeViewer(parent);
treeViewer.setContentProvider(new DBTreeContentProvider());
treeViewer.setLabelProvider(new DBTreeLabelProvider());
}
public void setInput(Connection conn){
root = conn;
treeViewer.setInput(root);
treeViewer.refresh();
}
}
I made a setInput method that is called from the action registered with the menu item in the connections view with the currently selected connection as argument:
MViewContentsAction class:
public void run(){
selectedConnection = Activator.getDefault().getConnectionsView().getSelectedConnection();
Activator.getDefault().getDbTreeView().setInput(selectedConnection);
}
In my ContentProvider class:
public Object[] getChildren(Object arg0) {
if (arg0 instanceof Connection){
return ((Connection) arg0).getTables().toArray();
}
return EMPTY_ARRAY;
}
where EMPTY_ARRAY is an...empty array
The problem I'm facing is that when in debug mode, this piece of code is not executed somehow:
Activator.getDefault().getDbTreeView().setInput(selectedConnection);
And also nothing happens in the tree view when clicking the menu item. Any ideas?
Thank you
Huh. Ok, what you're doing here is.. not really the right way. What you should be doing is registering your TableViewer as a selection provider.
getSite().setSelectionProvider(tableViewer);
Then, define a selection listener and add it to the view with the tree viewer like this:
ISelectionListener listener = new ISelectionListener() {
public void selectionChanged(IWorkbenchPart part, ISelection sel) {
if (!(sel instanceof IStructuredSelection))
return;
IStructuredSelection ss = (IStructuredSelection) sel;
// rest of your code dealing with checking whether selection is what is
//expected and if it is, setting it as an input to
//your tree viewer
}
};
public void createPartControl(Composite parent) {
getSite().getPage().addSelectionListener(listener);
}
Now your tree viewer's input will be changed according to what is selected in the table viewer (btw, don't forget to call treeviewer.refresh() after you set new input).
See an example here.