Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH . All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: s IT Solutions AT Spardat GmbH - initial API and implementation /
/*
 * @(#) $Id: ComponentHelper.java 2084 2007-11-27 14:53:31Z s3460 $
 */
package at.spardat.xma.boot.component;
import  org.eclipse.swt.widgets.Display;


This class is deployed in the same classloader as SWT and IComponent. It encapsulates the code of the bootruntime which is dependend on SWT.

Author(s):
s2877
public class ComponentHelper implements IComponentHelper {
    private static Display display;
    private static boolean display_created=false;

    
Just casts the given object to IComponent.

Returns:
the unchanged component
Throws:
ClassCastException if the given object is not an IComponent
    public IComponent castToIComponent(Object component) {
        return (IComponentcomponent;
    }

    
Calls IComponent.getRTSession() on the given component.

Returns:
the client side session the given component belongs to.
Throws:
ClassCastException if the given object is not an IComponent
    public IRtXMASessionClient getRTSession(Object component) {
        return ((IComponent)component).getRTSession();
    }

    
Launches the given component. The input properties are passed to the component, then the component is invoked. Finally the component is disposed.

Returns:
the output properties of the given component
Throws:
ClassCastException if the given object is not an IComponent
    public Properties launch(Object componentProperties input) {
        IComponent rtc = (IComponentcomponent;
        try {
            rtc.setProperties(input);
            rtc.invoke(null);
            return rtc.getProperties();
        } finally {
            rtc.dispose();
        }
    }

    
Creates a Display in SWT if none allready exists.

Returns:
the preexisting or created Display.
    public Object initSWTDisplay() {
         = Display.getCurrent();
        if(==null) {
             = true;
             = Display.getDefault();
        }
        return ;
    }

    
Disposes the display created by initSWTDisplay() of this ComponentHelper. If no display was created by initSWTDisplay(), it does nothing.
    public void cleanupSWTDisplay() {
        if(!=null && ) {
            .dispose();
             = false;
        }
    }
New to GrepCode? Check out our FAQ X