Search in sources :

Example 1 with UIRegistry

use of com.github.bordertech.wcomponents.registry.UIRegistry in project wcomponents by BorderTech.

the class PlainLauncher method createUI.

/**
 * Creates the UI which the launcher displays. If there is misconfiguration or error, a UI containing an error
 * message is returned.
 *
 * @return the UI which the launcher displays.
 */
protected WComponent createUI() {
    // Check if the parameter COMPONENT_TO_LAUNCH_PARAM_KEY has been
    // configured with the name of a component to launch.
    WComponent sharedApp;
    uiClassName = getComponentToLaunchClassName();
    if (uiClassName == null) {
        sharedApp = new WText("You need to set the class name of the WComponent you want to run.<br />" + "Do this by setting the parameter \"" + COMPONENT_TO_LAUNCH_PARAM_KEY + "\" in your \"local_app.properties\" file.<br />" + "Eg.  <code>" + COMPONENT_TO_LAUNCH_PARAM_KEY + "=com.github.bordertech.wcomponents.examples.picker.ExamplePicker</code>");
        ((WText) sharedApp).setEncodeText(false);
    } else {
        UIRegistry registry = UIRegistry.getInstance();
        sharedApp = registry.getUI(uiClassName);
        if (sharedApp == null) {
            sharedApp = new WText("Unable to load the component \"" + uiClassName + "\".<br />" + "Either the component does not exist as a resource in the classpath," + " or is not a WComponent.<br />" + "Check that the parameter \"" + COMPONENT_TO_LAUNCH_PARAM_KEY + "\" is set correctly.");
            ((WText) sharedApp).setEncodeText(false);
        }
    }
    return sharedApp;
}
Also used : WComponent(com.github.bordertech.wcomponents.WComponent) WText(com.github.bordertech.wcomponents.WText) UIRegistry(com.github.bordertech.wcomponents.registry.UIRegistry)

Aggregations

WComponent (com.github.bordertech.wcomponents.WComponent)1 WText (com.github.bordertech.wcomponents.WText)1 UIRegistry (com.github.bordertech.wcomponents.registry.UIRegistry)1