Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » status bar injected into DAO(inject RCP components into spring DAOs)
status bar injected into DAO [message #502630] Wed, 09 December 2009 08:50 Go to next message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
Hi,
in my project I'm using spring DAOs and I'd like them to update the status bar and progress bar of my RCP application while doing operations. However I don't want to programmatically couple the DAO and the statusbarmanager, so I'd like to know if there's a way to inject the status bar into the dao thru the spring configuration file.
Anybody has done something similar?
Re: status bar injected into DAO [message #502808 is a reply to message #502630] Wed, 09 December 2009 18:38 Go to previous messageGo to next message
Ralf Ebert is currently offline Ralf EbertFriend
Messages: 72
Registered: July 2009
Member
> in my project I'm using spring DAOs and I'd like them to update the
> status bar and progress bar of my RCP application while doing
> operations. However I don't want to programmatically couple the DAO and
> the statusbarmanager, so I'd like to know if there's a way to inject the
> status bar into the dao thru the spring configuration file.

Most certainly you don't want to create a dependency from the DAO layer to the
GUI layer (even not declaratively). It has to be done the other way around
because the UI is the layer on top. You could create a neutral interface like
IDataOperationListener and allow such a listener to be added to your DAO
components. The UI layer (for example the ApplicationWorkbenchWindowAdvisor)
could register such a listener implementation and update the workbench status
bar whenever a data operation occurs. Sorry, I don't have an example code for
this, you have to figure out the details yourself,

Greetings,
Ralf


--
http://www.ralfebert.de/blog/eclipsercp/
Re: status bar injected into DAO [message #503515 is a reply to message #502808] Mon, 14 December 2009 10:09 Go to previous messageGo to next message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
Thanks for your help,
I've created a generic StatusBar class that is a wrapper around a StatusBarManager and a ProgressMonitor has shown here:

public class StatusBar implements ProgressMonitor {

    
    /**
     * The status line manager of the eclipse application.
     */
    private IStatusLineManager statusLineManager = null;
    
    /**
     * The progress monitor of the rcp application.
     */
    private IProgressMonitor progressMonitor = null;
    
    /**
     * The instance of myself.
     */
    private static StatusBar mySelf = null;
    
 
    
    /**
     * Get the single instance of this status bar.
     * @return
     */
    public static synchronized StatusBar getInstance(){
	if( mySelf == null )
	    mySelf = new StatusBar();
	
	return mySelf;
    }
    


    /**
     * A method to set the value of the statusLineManager
     * field within this object instance.
     * @param statusLineManager the statusLineManager to set
     */
    public synchronized final void setStatusLineManager(
    	IStatusLineManager statusLineManager) {
        // set the value of the this.statusLineManager field
        this.statusLineManager = statusLineManager;
        this.progressMonitor = this.statusLineManager.getProgressMonitor();

    }


    
    
}



The code above shows that the StatusBar is a singleton, and when the statusbarmanager is set than the progress monitor is set also. Not shown, there are delegate methods to set the progress, the task name, the message and so on. So StatusBar is a full wrapper around a statusLineManager and a progressMonitor.

In my application window advisor I initialize the StatusBar as follows:

 public void preWindowOpen() {
	// get the window configurer object
        IWorkbenchWindowConfigurer configurer = this.getWindowConfigurer();
        
        // show the status bar
        configurer.setShowStatusLine( true );
        

	
	// set the status bar to share with the application components
	StatusBar statusBar = StatusBar.getInstance();
	statusBar.setStatusLineManager( configurer.getActionBarConfigurer().getStatusLineManager() );
	



So the StatusBar should be initialized with the window statusline manager and the progress monitor. However when I try to use the progress monitor (with a begin task) I got the following exception:

java.lang.NullPointerException
	at org.eclipse.jface.action.StatusLineManager$1.beginTask(StatusLineManager.java:157)
	at hrpm.rcp.gui.StatusBar.beginTask(StatusBar.java:59)


a NullPointerException?
The StatusBar.beginTask() method is the following:
    public void beginTask(String taskName, int maxUnitOfWork) {
	this.statusLineManager.setMessage(taskName);
	this.progressMonitor.beginTask(taskName, maxUnitOfWork);
    }


So what am I doing wrong?
Re: status bar injected into DAO [message #503768 is a reply to message #503515] Tue, 15 December 2009 16:59 Go to previous messageGo to next message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
I'm getting lost, even calling directly the getProgressMonitor().beginTask returns me a null pointer exception. it seems there is something wrong within the initialization of the statuslinemanager, but what?
Re: status bar injected into DAO [message #506086 is a reply to message #502630] Wed, 06 January 2010 03:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jccanova.gmail.com

Hi Luca.

For me is pretty simple, create a EventObject and configure it into you
app-context... retrieve the EventObject from your context into your
application and create a EventListener which will be responsible to update
the status bar.

Another way could be you create a content provider for the status label...
is this make any sense for you ?

I crancked my head last week checking how i could use Spring to configure
SWT = JFace components and concluded that i will write a lot of code
(delegates) since SWT as a lightweight framework and dont follow the
javabeans get-set methods (mainly layout), but it can be done.... like your
applicationWindow can be a BeanFactorAware and retrieve the controls from
the spring application context (i dont see any problem in it). But inject
the control directly into the DAO i dont see it as a good pratice...

Regards,

Jose

"Luca Ferrari" <fluca1978@infinito.it> wrote in message
news:hfnod1$qib$1@build.eclipse.org...
> Hi,
> in my project I'm using spring DAOs and I'd like them to update the status
> bar and progress bar of my RCP application while doing operations. However
> I don't want to programmatically couple the DAO and the statusbarmanager,
> so I'd like to know if there's a way to inject the status bar into the dao
> thru the spring configuration file.
> Anybody has done something similar?
Re: status bar injected into DAO [message #512007 is a reply to message #506086] Wed, 03 February 2010 16:24 Go to previous message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
I found that the status bar must be initialized in the postWindowOpen method, and that makes my status bar working:

   public void postWindowOpen() {
	// do the parent initialization
	super.postWindowOpen();
	
	// get the configurer object
	IWorkbenchWindowConfigurer configurer = this.getWindowConfigurer();
	
	// set the status bar to share with the application components
	StatusBar statusBar = StatusBar.getInstance();
	statusBar.setStatusLineManager( configurer.getActionBarConfigurer().getStatusLineManager() );
	statusBar.setMessage("Ready");
    }
Previous Topic:Creating a parameter controlled ViewerFilter for CommonNavigator
Next Topic:RCP Views
Goto Forum:
  


Current Time: Tue Mar 19 02:59:37 GMT 2024

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

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

Back to the top