Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » How to access the data provider instance created in the Activator of my plug-in
How to access the data provider instance created in the Activator of my plug-in [message #1491857] Sat, 29 November 2014 09:51
Alexander Fülleborn is currently offline Alexander FüllebornFriend
Messages: 132
Registered: April 2013
Senior Member
Hello community,

I use data bindig with ViewerSupport. To provide data for my Viewer before I invoke the bind method I Need to Access the instance of my data Provider model class. I instantiated this in the Activator of my plug-in. The question for me is how I can get Access to this instance within the Viewer class.

Here is the instantiation of the data Provider class in the Activator with the getter method (both in bold):

package de.uni.due.swe.propman.propret;


import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;


import de.uni.due.swe.propman.propret.model.ProPRetRetrievalResultList;


/**
 * The activator class controls the plug-in life cycle
 */
public class Activator extends AbstractUIPlugin {
 private ProPRetRetrievalResultList retResList;
 // The plug-in ID
 public static final String PLUGIN_ID = "de.uni.due.swe.propman.propret"; //$NON-NLS-1$


 // The shared instance
 private static Activator plugin;
 
 /**
  * The constructor
  */
 public Activator() {
[b]  this.retResList = new ProPRetRetrievalResultList();[/b]
 }
[b] public ProPRetRetrievalResultList getRetResList(){
  return this.retResList;
 }[/b]
 /*
  * (non-Javadoc)
  * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
  */
 public void start(BundleContext context) throws Exception {
  super.start(context);
  plugin = this;
 }


 /*
  * (non-Javadoc)
  * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
  */
 public void stop(BundleContext context) throws Exception {
  plugin = null;
  super.stop(context);
 }


 /**
  * Returns the shared instance
  *
  * @return the shared instance
  */
 public static Activator getDefault() {
  return plugin;
 }
}



And here the code snippet of my Viewer class where I Need the Access to the instance of the data Provider class created in the Activator, see remark and code in bold :


[...]
public class ProPRetResultListTableViewer extends ViewPart{


 private TableViewer proPRetResultListTableViewer; 
 private WritableList input;
 
 public ProPRetResultListTableViewer() {
  super();
 }
 public void createPartControl( Composite parent ) {
  GridLayout layout = new GridLayout( 5, false );
     parent.setLayout( layout );
     createViewer( parent );
 }
 private void createViewer( Composite parent ) {
  // TODO Auto-generated method stub
  this.proPRetResultListTableViewer =
    new TableViewer( parent ,
               SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL |
               SWT.FULL_SELECTION | SWT.BORDER);
 
  TableViewerColumn column = new TableViewerColumn(
    this.proPRetResultListTableViewer, SWT.NONE);
     column.getColumn().setWidth(100);
     column.getColumn().setText("Rank");
     column = new TableViewerColumn(
       this.proPRetResultListTableViewer,
       SWT.NONE);
     column.getColumn().setWidth(100);
     column.getColumn().setText("Score (Graph Edit Similarity)");
     column = new TableViewerColumn(
       this.proPRetResultListTableViewer, SWT.NONE);
     column.getColumn().setWidth(100);
     column.getColumn().setText("Problem-context pattern");
     column = new TableViewerColumn(
       this.proPRetResultListTableViewer, SWT.NONE);    
     column.getColumn().setWidth(100);
     column.getColumn().setText("Solution pattern");
     column = new TableViewerColumn(
        this.proPRetResultListTableViewer, SWT.NONE);
     column.getColumn().setWidth(100);
     column.getColumn().setText("Solution pattern instance preview");    
     
     this.proPRetResultListTableViewer.getTable().setHeaderVisible(true);
     this.proPRetResultListTableViewer.getTable().setLinesVisible( true );
     
[b]//  Here I Need the instance from the Activator instead of a new instance that is 
// created at the moment:     
ProPRetRetrievalResultList retResList = new ProPRetRetrievalResultList();[/b]
[b]     input = new WritableList(
       retResList.getRetrievalResults(),
       ProPRetRetrievalResult.class);[/b]
     ViewerSupport.bind(
      this.proPRetResultListTableViewer,
         input,
         BeanProperties.values( new String[] {
              "rank",
                          "score",
                          "pcpName",
                          "spName",
                          "spInstPreview"
         }));



Thanks a lot in advance for any appreciated Support.


Kind regards, Alexander
Previous Topic:How to add readonly textbox in table Viewer.
Next Topic:can Jface table cell have selection event
Goto Forum:
  


Current Time: Thu Apr 25 20:13:30 GMT 2024

Powered by FUDForum. Page generated in 0.03400 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top