Package pivot.wtk

Examples of pivot.wtk.Sheet


                return "Specifies authentication credentials";
            }

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

                try {
                    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);
                    }
                });

                if (keystorePath != null) {
                    TextInput pathTextInput = (TextInput)sheetSerializer.getObjectByID("path");
                    pathTextInput.setText(keystorePath);
                }

                if (keystorePassword != null) {
                    TextInput passwdTextInput = (TextInput)sheetSerializer.getObjectByID("passwd");
                    passwdTextInput.setText(keystorePassword);
                }

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

                        if (result) {
                            TextInput pathTextInput = (TextInput)sheetSerializer.getObjectByID("path");
                            TextInput passwdTextInput = (TextInput)sheetSerializer.getObjectByID("passwd");

                            keystorePath = pathTextInput.getText();
                            keystorePassword = passwdTextInput.getText();

                            File file = new File(keystorePath);
                            if (!file.exists()
                                || !file.isFile()) {
                                vote = Vote.DENY;
                            } else if (!file.canRead()) {
                                vote = Vote.DENY;
                            }
                        }

                        return vote;
                    }

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

                    public void sheetClosed(Sheet sheet) {
                        if (sheet.getResult()) {
                            System.setProperty("javax.net.ssl.trustStore", keystorePath);
                            System.setProperty("javax.net.ssl.keyStorePassword", keystorePassword);
                        }
                    }
                });

                sheet.open(window);
            }
        };

        // Load the main app window
        serializer = new WTKXSerializer();
View Full Code Here


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

        Sheet sheet = (Sheet)component;
        sheet.getSheetStateListeners().add(this);

        // Attach the drop-shadow decorator
        dropShadowDecorator = new DropShadowDecorator(3, 3, 3);
        sheet.getDecorators().add(dropShadowDecorator);
    }
View Full Code Here

        sheet.getDecorators().add(dropShadowDecorator);
    }

    @Override
    public void uninstall() {
        Sheet sheet = (Sheet)getComponent();
        sheet.getSheetStateListeners().remove(this);

        // Detach the drop shadow decorator
        sheet.getDecorators().remove(dropShadowDecorator);
        dropShadowDecorator = null;

        super.uninstall();
    }
View Full Code Here

    @Override
    public int getPreferredWidth(int height) {
        int preferredWidth = 0;

        Sheet sheet = (Sheet)getComponent();
        Component content = sheet.getContent();

        if (content != null
            && content.isDisplayable()) {
            if (height != -1) {
                height = Math.max(height - (padding.top + padding.bottom + 2), 0);
View Full Code Here

    @Override
    public int getPreferredHeight(int width) {
        int preferredHeight = 0;

        Sheet sheet = (Sheet)getComponent();
        Component content = sheet.getContent();

        if (content != null
            && content.isDisplayable()) {
            if (width != -1) {
                width = Math.max(width - (padding.left + padding.right + 2), 0);
View Full Code Here

    @Override
    public Dimensions getPreferredSize() {
        int preferredWidth = 0;
        int preferredHeight = 0;

        Sheet sheet = (Sheet)getComponent();
        Component content = sheet.getContent();

        if (content != null
            && content.isDisplayable()) {
            Dimensions preferredContentSize = content.getPreferredSize();
            preferredWidth = preferredContentSize.width;
View Full Code Here

    public void layout() {
        int width = getWidth();
        int height = getHeight();

        Sheet sheet = (Sheet)getComponent();
        Component content = sheet.getContent();

        if (content != null) {
            if (content.isDisplayable()) {
                content.setVisible(true);
View Full Code Here

    @Override
    public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
        boolean consumed = false;

        Sheet sheet = (Sheet)getComponent();

        if (keyCode == Keyboard.KeyCode.ENTER) {
            sheet.close(true);
            consumed = true;
        } else if (keyCode == Keyboard.KeyCode.ESCAPE) {
            sheet.close(false);
            consumed = true;
        } else {
            consumed = super.keyPressed(component, keyCode, keyLocation);
        }
View Full Code Here

                return "Specifies authentication credentials";
            }

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

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

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

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

                if (credentials != null) {
                    TextInput usernameTextInput = (TextInput)sheetSerializer.getObjectByName("username");
                    TextInput passwordTextInput = (TextInput)sheetSerializer.getObjectByName("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.getObjectByName("username");
                            TextInput passwordTextInput = (TextInput)
                                sheetSerializer.getObjectByName("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.getObjectByName("okButton");
                okButton.getButtonPressListeners().add(new ButtonPressListener() {
                    public void buttonPressed(Button button) {
                        sheet.close(true);
                    }
                });

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

                if (keystorePath != null) {
                    TextInput pathTextInput = (TextInput)sheetSerializer.getObjectByName("path");
                    pathTextInput.setText(keystorePath);
                }

                if (keystorePassword != null) {
                    TextInput passwdTextInput = (TextInput)sheetSerializer.getObjectByName("passwd");
                    passwdTextInput.setText(keystorePassword);
                }

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

                        if (result) {
                            TextInput pathTextInput = (TextInput)sheetSerializer.getObjectByName("path");
                            TextInput passwdTextInput = (TextInput)sheetSerializer.getObjectByName("passwd");

                            keystorePath = pathTextInput.getText();
                            keystorePassword = passwdTextInput.getText();

                            File file = new File(keystorePath);
                            if (!file.exists()
                                || !file.isFile()) {
                                vote = Vote.DENY;
                            } else if (!file.canRead()) {
                                vote = Vote.DENY;
                            }
                        }

                        return vote;
                    }

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

                    public void sheetClosed(Sheet sheet) {
                        if (sheet.getResult()) {
                            System.setProperty("javax.net.ssl.trustStore", keystorePath);
                            System.setProperty("javax.net.ssl.keyStorePassword", keystorePassword);
                        }
                    }
                });

                sheet.open(window);
            }
        };

        // Load the main app window
        serializer = new WTKXSerializer();
View Full Code Here

      frame.setTitle("Card Pane Test");
      frame.setPreferredSize(800, 600);
      frame.setLocation(20, 20);

        WTKXSerializer wtkxSerializer = new WTKXSerializer();
        sheet = new Sheet((Component)wtkxSerializer.readObject(getClass().getResource("card_pane_test.wtkx")));

        cardPane = (CardPane)wtkxSerializer.getObjectByName("cardPane");

        Button.Group sizeGroup = Button.getGroup("sizeGroup");
        sizeGroup.getGroupListeners().add(new Button.GroupListener() {
View Full Code Here

TOP

Related Classes of pivot.wtk.Sheet

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.