Code Search for Developers
 
 
  

WindowFactory.java from Groovy Eclipse Monkey at Krugle


Show WindowFactory.java syntax highlighted

/*
 * Created on Feb 28, 2004
 */
package groovy.jface.factory;
import groovy.swt.InvalidParentException;
import groovy.swt.convertor.PointConverter;
import groovy.swt.factory.SwtFactory;
import groovy.swt.factory.WidgetFactory;
import java.util.List;
import java.util.Map;
import org.codehaus.groovy.GroovyException;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;

/**
 * @author <a href:ckl at dacelo.nl">Christiaan ten Klooster </a>
 * @version $Revision: 401 $
 */
public class WindowFactory 
extends WidgetFactory 
implements SwtFactory
{
    /**
     * @param beanClass
     */
    public WindowFactory( final Class<?> beanClass )
    {
        super( beanClass );
    }
    /*
     * @see groovy.swt.factory.AbstractSwtFactory#newInstance(java.util.Map,
     *      java.lang.Object)
     */
    @SuppressWarnings("unchecked")
    @Override
    public Object newInstance( final Map properties, Object parent ) 
    throws GroovyException
    {
        if( parent == null )
            parent = new Shell();
        if( !( parent instanceof Shell ) )
            throw new InvalidParentException( "shell" );
        final Window window = ( Window )createWidget( parent );
        if( window != null )
        {
            // set title of Window
            final String title = ( String )properties.remove( "title" );
            if( title != null )
                window.getShell().setText( title );
            // set size of Window
            final List size = ( List )properties.remove( "size" );
            if( size != null )
            {
                final Point point = PointConverter.getInstance().parse( size );
                window.getShell().setSize( point );
            }
            // set location of Window
            final List location = ( List )properties.remove( "location" );
            if( location != null )
            {
                final Point point = PointConverter.getInstance().parse( location );
                window.getShell().setLocation( point );
            }
        }
        setBeanProperties( window, properties );
        return window;
    }
}




See more files for this project here

Groovy Eclipse Monkey

Groovy Monkey is a Utility for Eclipse that enables you to create scripts in Groovy, Beanshell, Python or Ruby to run directly in Eclipse. This tool can be used to Eclipse API exploration, automation scripts, and rapid plugin prototyping.

Project homepage: http://sourceforge.net/projects/groovy-monkey
Programming language(s): Groovy,Java,XML
License: other

  ActionImpl.java
  ContributionManagerFactory.java
  DoubleClickListenerFactory.java
  MenuManagerFactory.java
  PreferencesDialogFactory.java
  PreferencesFieldEditorFactory.java
  PreferencesPageFactory.java
  SelectionChangedListenerFactory.java
  ToolBarManagerFactory.java
  ViewerFactory.java
  WindowFactory.java
  WizardDialogFactory.java
  WizardPageFactory.java