Package org.apache.pivot.util

Examples of org.apache.pivot.util.Resources


        String src = properties.get(SRC_KEY);
        if (src == null) {
            throw new IllegalArgumentException(SRC_KEY + " argument is required.");
        }

        Resources resources = null;
        if (properties.containsKey(RESOURCES_KEY)) {
            resources = new Resources(properties.get(RESOURCES_KEY));
        }

        WTKXSerializer wtkxSerializer = new WTKXSerializer(resources);

        ClassLoader classLoader = ThreadUtilities.getClassLoader();
View Full Code Here


            secure = Boolean.parseBoolean(properties.get(SECURE_KEY));
        } else {
            secure = origin.getProtocol().equals("HTTPS");
        }

        WTKXSerializer wtkxSerializer = new WTKXSerializer(new Resources(ExpensesWindow.class.getName()));
        expensesWindow = (ExpensesWindow)wtkxSerializer.readObject(this, "expenses_window.wtkx");
        expensesWindow.open(display);
    }
View Full Code Here

    public static final String CLASS_PROPERTY = "class";

    @Override
    public void startup(Display display, Map<String, String> properties)
        throws Exception {
        Resources resources = new Resources(getClass().getName());
        WTKXSerializer wtkxSerializer = new WTKXSerializer(resources);
        window = (Window)wtkxSerializer.readObject(this, "component_explorer.wtkx");

        splitPane = wtkxSerializer.getValue("splitPane");
        treeView = wtkxSerializer.getValue("treeView");
View Full Code Here

    @Override
    @SuppressWarnings("unchecked")
    public void initialize(Resources resources) {
        // Load the add/edit sheet
        try {
            WTKXSerializer wtkxSerializer = new WTKXSerializer(new Resources(ExpenseSheet.class.getName()));
            expenseSheet = (ExpenseSheet)wtkxSerializer.readObject(this, "expense_sheet.wtkx");
        } catch (IOException exception) {
            throw new RuntimeException(exception);
        } catch (SerializationException exception) {
            throw new RuntimeException(exception);
View Full Code Here

    @Override
    public void startup(Display display, Map<String, String> properties) throws Exception {
        String language = properties.get(LANGUAGE_KEY);
        Locale locale = (language == null) ? Locale.getDefault() : new Locale(language);
        Resources resources = new Resources(getClass().getName(), locale);

        Theme theme = Theme.getTheme();
        Font font = theme.getFont();

        // Search for a font that can support the sample string
        String sampleResource = resources.getString("firstName");
        if (font.canDisplayUpTo(sampleResource) != -1) {
            Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();

            for (int i = 0; i < fonts.length; i++) {
                if (fonts[i].canDisplayUpTo(sampleResource) == -1) {
View Full Code Here

    private Resources parent;
    private Resources main;

    @Before
    public void before() throws Exception {
        parent = new Resources(getClass().getName() + "Parent");
        assertNotNull("From parent", parent.getString("parentKeyString"));
        main = new Resources(parent, getClass().getName(), Locale.ENGLISH);
    }
View Full Code Here

    }

    @Test
    public void testConstructors() throws Exception {
        main = new Resources(parent, getClass().getName(), Charset.defaultCharset());
        testString();

        main = new Resources(parent, getClass().getName(), Charset.defaultCharset().name());
        testString();

        main = new Resources(parent, getClass().getName(), Locale.ENGLISH);
        testString();

        main = new Resources(parent, getClass().getName(), Locale.ENGLISH, Charset.defaultCharset());
        testString();

        main = new Resources(parent, getClass().getName(), Locale.ENGLISH,
            Charset.defaultCharset().name());
        testString();

    }
View Full Code Here

        if (language != null) {
            Locale.setDefault(new Locale(language));
        }

        // Load and bind to the WTKX source
        Resources resources = new Resources(getClass().getName(), "UTF-8");
        WTKXSerializer wtkxSerializer = new WTKXSerializer(resources);
        window = (Window)wtkxSerializer.readObject(this, "stocktracker.wtkx");
        wtkxSerializer.bind(this, StockTracker.class);

        // Wire up event handlers
View Full Code Here

public class ResolveTest implements Application {
    private Window window = null;

    @Override
    public void startup(Display display, Map<String, String> properties) throws Exception {
        Resources resources = new Resources(getClass().getName());
        WTKXSerializer wtkxSerializer = new WTKXSerializer(resources);
        window = (Window)wtkxSerializer.readObject(this, "resolve_test.wtkx");
        window.open(display);
    }
View Full Code Here

                                    if (element.type == Element.Type.INCLUDE) {
                                        // Process attributes looking for wtkx:id, src, resources, asynchronous,
                                        // and static property setters only
                                        String src = null;
                                        Resources resources = this.resources;

                                        for (Attribute attribute : element.attributes) {
                                            if (attribute.prefix != null
                                                && attribute.prefix.equals(WTKX_PREFIX)) {
                                                if (attribute.localName.equals(ID_ATTRIBUTE)) {
                                                    id = attribute.value;
                                                } else {
                                                    throw new SerializationException(WTKX_PREFIX + ":" + attribute.localName
                                                        + " is not a valid attribute.");
                                                }
                                            } else {
                                                if (attribute.localName.equals(INCLUDE_SRC_ATTRIBUTE)) {
                                                    src = attribute.value;
                                                } else if (attribute.localName.equals(INCLUDE_RESOURCES_ATTRIBUTE)) {
                                                    resources = new Resources(resources, attribute.value);
                                                } else if (attribute.localName.equals(INCLUDE_ASYNCHRONOUS_ATTRIBUTE)) {
                                                    // TODO
                                                    throw new UnsupportedOperationException("Asynchronous includes are not"
                                                        + " yet supported.");
                                                } else {
View Full Code Here

TOP

Related Classes of org.apache.pivot.util.Resources

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.