Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Alert$OptionSequence


    @Override
    public void install(Component component) {
        super.install(component);

        Alert alert = (Alert)component;
        alert.setPreferredWidth(320);
        alert.setMinimumWidth(160);

        alert.getAlertListeners().add(this);

        // Load the alert content
        BXMLSerializer bxmlSerializer = new BXMLSerializer();

        Component content;
        try {
            content = (Component)bxmlSerializer.readObject(TerraAlertSkin.class,
                "terra_alert_skin.bxml");
        } catch(Exception exception) {
            throw new RuntimeException(exception);
        }

        alert.setContent(content);

        typeImageView = (ImageView)bxmlSerializer.getNamespace().get("typeImageView");
        messageLabel = (Label)bxmlSerializer.getNamespace().get("messageLabel");
        messageBoxPane = (BoxPane)bxmlSerializer.getNamespace().get("messageBoxPane");
        optionButtonBoxPane = (BoxPane)bxmlSerializer.getNamespace().get("optionButtonBoxPane");

        for (Object option : alert.getOptions()) {
            PushButton optionButton = new PushButton(option);
            optionButton.setStyleName(TerraAlertSkin.class.getPackage().getName()
                + "." + TerraTheme.COMMAND_BUTTON_STYLE);
            optionButton.getButtonPressListeners().add(optionButtonPressListener);
View Full Code Here


    @Override
    public void windowOpened(Window window) {
        super.windowOpened(window);

        Alert alert = (Alert)window;
        int index = alert.getSelectedOptionIndex();

        if (index >= 0) {
            optionButtonBoxPane.get(index).requestFocus();
        } else {
            window.requestFocus();
View Full Code Here

    @Override
    public void install(Component component) {
        super.install(component);

        Alert alert = (Alert)component;
        alert.getAlertListeners().add(this);

        // Load the alert content
        WTKXSerializer wtkxSerializer = new WTKXSerializer();
        Component content = null;

        try {
            content = (Component)wtkxSerializer.readObject(this, "terra_alert_skin.wtkx");
        } catch(Exception exception) {
            throw new RuntimeException(exception);
        }

        alert.setContent(content);

        // Set the type image
        TerraTheme theme = (TerraTheme)Theme.getTheme();

        ImageView typeImageView = (ImageView)wtkxSerializer.get("typeImageView");
        typeImageView.setImage(theme.getMessageIcon(alert.getMessageType()));

        // Set the message
        Label messageLabel = (Label)wtkxSerializer.get("messageLabel");
        String message = alert.getMessage();
        messageLabel.setText(message);

        // Set the body
        BoxPane messageBoxPane = (BoxPane)wtkxSerializer.get("messageBoxPane");
        Component body = alert.getBody();
        if (body != null) {
            messageBoxPane.add(body);
        }

        // Add the option buttons
        BoxPane buttonBoxPane = (BoxPane)wtkxSerializer.get("buttonBoxPane");

        for (int i = 0, n = alert.getOptionCount(); i < n; i++) {
            Object option = alert.getOption(i);

            PushButton optionButton = new PushButton(option);
            optionButton.setStyles(commandButtonStyles);

            optionButton.getButtonPressListeners().add(new ButtonPressListener() {
                @Override
                public void buttonPressed(Button button) {
                    int optionIndex = optionButtons.indexOf(button);

                    if (optionIndex >= 0) {
                        Alert alert = (Alert)getComponent();
                        alert.setSelectedOption(optionIndex);
                        alert.close(true);
                    }
                }
            });

            buttonBoxPane.add(optionButton);
View Full Code Here

    @Override
    public void windowOpened(Window window) {
        super.windowOpened(window);

        Alert alert = (Alert)window;
        int index = alert.getSelectedOption();

        if (index >= 0) {
            optionButtons.get(index).requestFocus();
        } else {
            window.requestFocus();
View Full Code Here

        if (alert == null) {
            ArrayList<String> options = new ArrayList<String>();
            options.add("Yes");
            options.add("No");

            alert = new Alert(MessageType.QUESTION, "Cancel shutdown?", options);
            alert.open(display, new DialogCloseListener() {
                public void dialogClosed(Dialog dialog, boolean modal) {
                    Alert alert = (Alert)dialog;

                    if (alert.getResult()) {
                        if (alert.getSelectedOption() == 1) {
                            cancelShutdown = false;
                            DesktopApplicationContext.exit();
                        }
                    }
View Full Code Here

                                body = (Component)wtkxSerializer.readObject(this, "alert.wtkx");
                            } catch(Exception exception) {
                                System.err.println(exception);
                            }

                            Alert alert = new Alert(MessageType.QUESTION, "Please select your favorite icon:",
                                options, body);
                            alert.setTitle("Select Icon");
                            alert.setSelectedOption(0);
                            alert.getDecorators().update(0, new ReflectionDecorator());
                            alert.open(window);
                        } else {
                            String message = (String)userData.get("message");
                            Alert.alert(MessageType.valueOf(messageType.toUpperCase()), message, window);
                        }
                    }
View Full Code Here

                                body = (Component)serializer.readObject(KitchenSink.class, "alert.bxml");
                            } catch(Exception exception) {
                                System.err.println(exception);
                            }

                            Alert alert = new Alert(MessageType.QUESTION, "Please select your favorite icon:",
                                options, body);
                            alert.setTitle("Select Icon");
                            alert.setSelectedOptionIndex(0);
                            alert.getDecorators().update(0, new ReflectionDecorator());
                            alert.open(KitchenSink.this.window);
                        } else {
                            String message = (String)userData.get("message");
                            Alert.alert(MessageType.valueOf(messageType.toUpperCase()), message, KitchenSink.this.window);
                        }
                    }
View Full Code Here

        if (alert == null) {
            ArrayList<String> options = new ArrayList<String>();
            options.add("Yes");
            options.add("No");

            alert = new Alert(MessageType.QUESTION, "Cancel shutdown?", options);
            alert.setModal(false);
            alert.open(display, new DialogCloseListener() {
                @Override
                public void dialogClosed(Dialog dialog, boolean modal) {
                    if (!(dialog instanceof Alert)) {
                        return ;
                    }

                    Alert alertLocal = (Alert)dialog;
                    if (alertLocal.getResult()) {
                        if (alertLocal.getSelectedOptionIndex() == 1) {
                            cancelShutdown = false;
                            DesktopApplicationContext.exit();
                        }
                    }
View Full Code Here

        });

        Label alertBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
        alertBody.getStyles().put("wrapText", true);

        final Alert alert = new Alert(MessageType.INFO, "Alert", new ArrayList<String>("OK"), alertBody);
        alert.setTitle("Alert");

        BoxPane boxPane = new BoxPane();
        tablePane.getRows().get(1).add(boxPane);

        boxPane.getStyles().put("horizontalAlignment", HorizontalAlignment.RIGHT);
View Full Code Here

        if (alert == null) {
            ArrayList<String> options = new ArrayList<String>();
            options.add("Yes");
            options.add("No");

            alert = new Alert(MessageType.QUESTION, "Cancel shutdown?", options);
            alert.setModal(false);
            alert.open(display, new DialogCloseListener() {
                public void dialogClosed(Dialog dialog, boolean modal) {
                    if (!(dialog instanceof Alert)) {
                        return ;
                    }

                    Alert alert = (Alert)dialog;
                    if (alert.getResult()) {
                        if (alert.getSelectedOptionIndex() == 1) {
                            cancelShutdown = false;
                            DesktopApplicationContext.exit();
                        }
                    }
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.Alert$OptionSequence

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.