All pastes #2109385 Raw Edit

Untitled

public text v1 · immutable
#2109385 ·published 2012-02-03 15:14 UTC
rendered paste body
package ...e3ui.handler;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.commands.IHandlerListener;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;

import ...service.ISessionService;

public class OpenProductHandler
    implements IHandler
{
    
    public OpenProductHandler()
    {
        System.out.println("<init>");
    }
    
    @Override
    public void addHandlerListener( IHandlerListener handlerListener )
    {
        // empty
    }

    @Override
    public void removeHandlerListener( IHandlerListener handlerListener )
    {
        // empty
    }
    
    @Override
    public void dispose()
    {
        // empty
    }

    @Override
    public Object execute( ExecutionEvent event )
        throws ExecutionException
    {
        ServiceReference<ISessionService> sessionServiceReference = FrameworkUtil.getBundle(getClass()).getBundleContext().getServiceReference(ISessionService.class);
        ISessionService sessionService = FrameworkUtil.getBundle(getClass()).getBundleContext().getService( sessionServiceReference );
        
        if( sessionServiceReference != null )
        {
            System.out.println("not null");
        }
        
        Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        FileDialog fileDialog = new FileDialog( shell );
        fileDialog.setFilterExtensions( new String[] {"*.xml"} );
        fileDialog.setText( "Open Product" );
        
        //sessionService.openSession( fileDialog.open() ); 
        
        return null;
    }

    @Override
    public boolean isEnabled()
    {
        return true;
    }

    @Override
    public boolean isHandled()
    {
        return true;
    }

}