Package pivot.wtk

Examples of pivot.wtk.Button


                    sheet = (Sheet)sheetSerializer.readObject("pivot/tools/net/setAuthentication.wtkx");
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }

                Button okButton = (Button)sheetSerializer.getObjectByID("okButton");
                okButton.getButtonPressListeners().add(new ButtonPressListener() {
                    public void buttonPressed(Button button) {
                        sheet.close(true);
                    }
                });

                Button cancelButton = (Button)sheetSerializer.getObjectByID("cancelButton");
                cancelButton.getButtonPressListeners().add(new ButtonPressListener() {
                    public void buttonPressed(Button button) {
                        sheet.close(false);
                    }
                });

                if (credentials != null) {
                    TextInput usernameTextInput = (TextInput)sheetSerializer.getObjectByID("username");
                    TextInput passwordTextInput = (TextInput)sheetSerializer.getObjectByID("password");
                    usernameTextInput.setText(credentials.getUsername());
                    passwordTextInput.setText(credentials.getPassword());
                }

                sheet.getSheetStateListeners().add(new SheetStateListener() {
                    public Vote previewSheetClose(Sheet sheet, boolean result) {
                        return Vote.APPROVE;
                    }

                    public void sheetCloseVetoed(Sheet sheet, Vote reaso) {
                        // No-op
                    }

                    public void sheetClosed(Sheet sheet) {
                        if (sheet.getResult()) {
                            TextInput usernameTextInput = (TextInput)
                                sheetSerializer.getObjectByID("username");
                            TextInput passwordTextInput = (TextInput)
                                sheetSerializer.getObjectByID("password");

                            String username = usernameTextInput.getText();
                            String password = passwordTextInput.getText();

                            if (username.length() == 0 && password.length() == 0) {
                                credentials = null;
                            } else {
                                credentials = new Credentials(username, password);
                            }
                        }
                    }
                });

                sheet.open(window);
            }
        };

        new Action("toggleHostnameVerificationAction") {
            public String getDescription() {
                return "Toggles lenient hostname verification";
            }

            public void perform() {
                lenientHostnameVerification = !lenientHostnameVerification;
            }
        };

        new Action("setKeystoreAction") {
            private String keystorePath = null;
            private String keystorePassword = null;

            public String getDescription() {
                return "Sets a trusted keystore";
            }

            public void perform() {
                final WTKXSerializer sheetSerializer = new WTKXSerializer();
                final Sheet sheet;

                try {
                    sheet = (Sheet)sheetSerializer.readObject("pivot/tools/net/setKeystore.wtkx");
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }

                Button okButton = (Button)sheetSerializer.getObjectByID("okButton");
                okButton.getButtonPressListeners().add(new ButtonPressListener() {
                    public void buttonPressed(Button button) {
                        sheet.close(true);
                    }
                });

                Button cancelButton = (Button)sheetSerializer.getObjectByID("cancelButton");
                cancelButton.getButtonPressListeners().add(new ButtonPressListener() {
                    public void buttonPressed(Button button) {
                        sheet.close(false);
                    }
                });
View Full Code Here


                rollup.setContent(component);

                alertButton.getButtonPressListeners().add(new ButtonPressListener() {
                    public void buttonPressed(Button button) {
                        Button.Group messageTypeGroup = Button.getGroup("messageType");
                        Button selection = messageTypeGroup.getSelection();

                        Map<String, ?> userData =
                            JSONSerializer.parseMap((String)selection.getUserData().get("messageInfo"));
                        String messageType = (String)userData.get("type");

                        if (messageType.equals("custom")) {
                            ArrayList<String> options = new ArrayList<String>();
                            options.add("OK");
                            options.add("Cancel");

                            Component body = null;
                            WTKXSerializer wtkxSerializer = new WTKXSerializer();
                            try {
                                body = (Component)wtkxSerializer.readObject("pivot/tutorials/alert.wtkx");
                            } catch(Exception exception) {
                                System.out.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.decode(messageType), message, window);
                        }
                    }
                });

                promptButton.getButtonPressListeners().add(new ButtonPressListener() {
                    public void buttonPressed(Button button) {
                        Button.Group messageTypeGroup = Button.getGroup("messageType");
                        Button selection = messageTypeGroup.getSelection();

                        Map<String, ?> userData =
                            JSONSerializer.parseMap((String)selection.getUserData().get("messageInfo"));
                        String messageType = (String)userData.get("type");

                        if (messageType.equals("custom")) {
                            ArrayList<String> options = new ArrayList<String>();
                            options.add("OK");
View Full Code Here

                return "Select Image Action";
            }

            public void perform() {
                Button.Group imageMenuGroup = Button.getGroup("imageMenuGroup");
                Button selectedItem = imageMenuGroup.getSelection();

                String imageName = (String)selectedItem.getUserData();

                ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
                URL imageURL = classLoader.getResource(imageName);

                // If the image has not been added to the resource cache yet,
View Full Code Here

    @SuppressWarnings("unchecked")
    private void initializeAlertButtons() {
        alertButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                Button.Group messageTypeGroup = Button.getGroup("messageType");
                Button selection = messageTypeGroup.getSelection();

                Map<String, ?> userData = JSONSerializer.parseMap((String)selection.getUserData());
                String messageType = (String)userData.get("type");

                if (messageType.equals("custom")) {
                    ArrayList<String> options = new ArrayList<String>();
                    options.add("OK");
                    options.add("Cancel");

                    Component body = null;
                    WTKXSerializer wtkxSerializer = new WTKXSerializer();
                    try {
                        body = (Component)wtkxSerializer.readObject("pivot/tutorials/alert.wtkx");
                    } catch(Exception exception) {
                        System.out.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.decode(messageType), message, window);
                }
            }
        });

        promptButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                Button.Group messageTypeGroup = Button.getGroup("messageType");
                Button selection = messageTypeGroup.getSelection();

                Map<String, ?> userData = JSONSerializer.parseMap((String)selection.getUserData());
                String messageType = (String)userData.get("type");

                if (messageType.equals("custom")) {
                    ArrayList<String> options = new ArrayList<String>();
                    options.add("OK");
View Full Code Here

        dateButtonGroup = new Button.Group();
        dateButtonGroup.getGroupListeners().add(new Button.GroupListener() {
            public void selectionChanged(Group group, Button previousSelection) {
                Calendar calendar = (Calendar)getComponent();

                Button selection = group.getSelection();
                if (selection == null) {
                    CalendarDate selectedDate = calendar.getSelectedDate();

                    // If no date was selected, or the selection changed as a
                    // result of the user toggling the date button (as opposed
                    // to changing the month or year), clear the selection
                    if (selectedDate == null
                        || (selectedDate.getYear() == yearSpinner.getSelectedIndex()
                            && selectedDate.getMonth() == monthSpinner.getSelectedIndex())) {
                        calendar.setSelectedDate((CalendarDate)null);
                    }
                } else {
                    calendar.setSelectedDate((CalendarDate)selection.getButtonData());
                }
            }
        });

        for (int j = 0; j < 6; j++) {
View Full Code Here

        today = new CalendarDate();
    }

    private void updateSelection(CalendarDate selectedDate) {
        Calendar calendar = (Calendar)getComponent();
        Button selection = dateButtonGroup.getSelection();

        if (selectedDate == null) {
            if (selection != null) {
                selection.setSelected(false);
            }
        } else {
            int year = selectedDate.getYear();
            int month = selectedDate.getMonth();

            if (year == calendar.getYear()
                && month == calendar.getMonth()) {
                int day = selectedDate.getDay();

                // Update the button group
                int cellIndex = getCellIndex(year, month, day);
                int rowIndex = cellIndex / 7;
                int columnIndex = cellIndex % 7;

                TablePane.Row row = tablePane.getRows().get(rowIndex + 2);
                DateButton dateButton = (DateButton)row.get(columnIndex);
                dateButton.setSelected(true);
            } else {
                if (selection != null) {
                    selection.setSelected(false);
                }
            }
        }
    }
View Full Code Here

        updateButtonData(component);
    }

    // Button group events
    public void selectionChanged(Group group, Button previousSelection) {
        Button button = tabButtonGroup.getSelection();
        int index = (button == null) ? -1 : buttonFlowPane.indexOf(button);

        TabPane tabPane = (TabPane)getComponent();
        tabPane.setSelectedIndex(index);
    }
View Full Code Here

  public void selectedIndexChanged(Accordion accordion, int previousSelectedIndex) {
        int selectedIndex = accordion.getSelectedIndex();

        if (selectedIndex == -1) {
            Button button = panelHeaderGroup.getSelection();
            if (button != null) {
                button.setSelected(false);
            }
        } else {
            Button button = (Button)panelHeaders.get(selectedIndex);
            button.setSelected(true);
        }

        invalidateComponent();
    }
View Full Code Here

        updateButtonData(component);
    }

    // Button group events
    public void selectionChanged(Group group, Button previousSelection) {
        Button button = panelHeaderGroup.getSelection();
        int index = (button == null) ? -1 : panelHeaders.indexOf((PanelHeader)button);

        Accordion accordion = (Accordion)getComponent();
        accordion.setSelectedIndex(index);
    }
View Full Code Here

  public void selectedIndexChanged(TabPane tabPane, int previousSelectedIndex) {
        int selectedIndex = tabPane.getSelectedIndex();

        if (selectedIndex == -1) {
            Button button = tabButtonGroup.getSelection();
            if (button != null) {
                button.setSelected(false);
            }
        } else {
            Button button = (Button)buttonFlowPane.get(selectedIndex);
            button.setSelected(true);

            if (previousSelectedIndex == -1) {
                if (tabPane.isShowing()) {
                    expandTransition = new ExpandTransition(false, EXPAND_DURATION, EXPAND_RATE);
View Full Code Here

TOP

Related Classes of pivot.wtk.Button

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.