diff -r b15deae0faf8 javafx-deploy/src/com/sun/deploy/uitoolkit/impl/fx/ui/DialogTemplate.java --- a/javafx-deploy/src/com/sun/deploy/uitoolkit/impl/fx/ui/DialogTemplate.java Thu Jul 12 10:46:22 2012 -0700 +++ b/javafx-deploy/src/com/sun/deploy/uitoolkit/impl/fx/ui/DialogTemplate.java Mon Jul 16 17:13:29 2012 +0200 @@ -26,6 +26,8 @@ import static com.sun.deploy.uitoolkit.impl.fx.ui.resources.ResourceManager.getString; import com.sun.deploy.ui.AppInfo; +import com.sun.javafx.applet.HostServicesImpl; +import com.sun.javafx.application.HostServicesDelegate; import java.security.cert.X509Certificate; @@ -121,6 +123,74 @@ } + void setSSVContent(String message, + String moreInfoText, + URL moreInfoURL, + String choiceText, + String choice1Label, + String choice2Label, + String btnOneLabel, + String btnTwoLabel) { + + try { + BorderPane content = new BorderPane(); + content.setId("ssv-content-panel"); + + // Set security warning dialogs type to TOOLKIT_MODAL and OnTop + //dialogInterface.setModalOnTop(true); + dialog.initModality(Modality.APPLICATION_MODAL); + + contentPane.getChildren().add(content); + content.setTop(createSSVTopPanel(topText, + appTitle, + "ainfo.getDisplayFrom()"/*ainfo.getDisplayFrom()*/)); + BorderPane riskPanel = + createSSVRiskPanel(message, moreInfoText, moreInfoURL); + final SSVChoicePanel choicePanel = + new SSVChoicePanel(choiceText, choice1Label, choice2Label); + BorderPane centerPanel = new BorderPane(); + centerPanel.setTop(riskPanel); + centerPanel.setBottom(choicePanel); + + content.setCenter(centerPanel); + + FlowPane buttonsPanel = new FlowPane(6, 0); + buttonsPanel.getStyleClass().add("button-bar"); + + // Create buttons from okBtnStr and cancelBtnStr strings. + okBtn = new Button(btnOneLabel); + okBtn.setOnAction(new EventHandler() { + public void handle(ActionEvent ae) { + if (choicePanel.getSelection() == 0) { + setUserAnswer(UIFactory.OK_LATEST_JRE); + } else { + setUserAnswer(UIFactory.OK_OLD_JRE); + } + setVisible(false); + } + }); + buttonsPanel.getChildren().add(okBtn); + + cancelBtn = new Button(btnTwoLabel); + cancelBtn.setOnAction(new EventHandler() { + public void handle(ActionEvent ae) { + cancelAction(); + } + }); + cancelBtn.setCancelButton(true); + + buttonsPanel.getChildren().add(cancelBtn); + okBtn.setDefaultButton(true); + + content.setBottom(buttonsPanel); + dialog.setResizable(false); + dialog.setIconifiable(false); + } catch (Throwable t) { + //Trace.ignored(t); + } + } + + void setSimpleContent(String contentString, boolean contentScroll, String infoString, String okBtnStr, String cancelBtnStr, boolean includeTop, @@ -891,6 +961,141 @@ } + private BorderPane createSSVTopPanel(String message, String name, String url) { + BorderPane top = new BorderPane(); + top.setPadding(new Insets(16, 0, 16, 16)); + + Label messageLabel = new Label(message); + + messageLabel.getStyleClass().add("ssv-big-bold-label"); + + top.setTop(messageLabel); + + Label nameLabel = new Label(getMessage("dialog.template.name")); + nameLabel.getStyleClass().add("ssv-small-bold-label"); + nameLabel.setId("ssv-top-panel-name-label"); + + Label fromLabel = new Label(getMessage("dialog.template.from")); + fromLabel.getStyleClass().add("ssv-small-bold-label"); + fromLabel.setId("ssv-top-panel-from-label"); + + nameInfo = new Label(name); + nameInfo.getStyleClass().add("ssv-big-bold-label"); + + Label fromInfo = new Label(url); + fromInfo.getStyleClass().add("ssv-small-label"); + + BorderPane[] parts = new BorderPane[4]; + for (int i = 0; i < 4; i++) { + parts[i] = new BorderPane(); + } + ImageView warningIcon = getIcon("warning48.image"); + + parts[2].setTop(nameLabel); + parts[2].setBottom(fromLabel); + // border compensates for fromLabel being 2 pt size larger text + parts[2].setPadding(new Insets(2, 0, 0, 0)); + parts[3].setTop(nameInfo); + parts[3].setBottom(fromInfo); + + parts[1].setLeft(parts[2]); + parts[1].setCenter(parts[3]); + + parts[1].setPadding(new Insets(12, 0, 12, 0)); + parts[0].setLeft(warningIcon); + parts[0].setRight(parts[1]); + parts[0].setPadding(new Insets(8, 0, 0, 32)); + + top.setBottom(parts[0]); + + return top; + } + + private BorderPane createSSVRiskPanel(String message, + String moreInfoText, + final URL moreInfoURL) { + BorderPane risk = new BorderPane(); + risk.setPadding(new Insets(8, 8, 0, 8)); + + int index = message.indexOf(" "); + if (index < message.length() - 2) { + String riskLabelText = message.substring(0, index); + String riskText = message.substring(index+1); + BorderPane left = new BorderPane(); + Label riskLabel = new Label(riskLabelText); + riskLabel.getStyleClass().add("ssv-small-bold-label"); + left.setTop(riskLabel); + left.setPadding(new Insets(0, 8, 0, 8)); + + BorderPane right = new BorderPane(); + Label riskTextLabel = new Label(riskText); + right.setLeft(riskTextLabel); + riskTextLabel.getStyleClass().add("ssv-small-label"); + Hyperlink link = new Hyperlink(moreInfoText); + link.setOnAction(new EventHandler() { + public void handle(ActionEvent e) { + HostServicesDelegate services = HostServicesImpl.getInstance(null); + if (services != null && moreInfoURL != null) { + services.showDocument(moreInfoURL.toExternalForm()); + } + } + }); + right.setRight(link); + + risk.setLeft(left); + risk.setCenter(right); + } + return risk; + } + + private class SSVChoicePanel extends BorderPane { + + ToggleGroup group; + RadioButton button1, button2; + + public SSVChoicePanel(String choiceText, + String choice1Label, + String choice2Label) { + setPadding(new Insets(8, 16, 0, 16)); + + BorderPane top = new BorderPane(); + VBox bot = new VBox(); + bot.setSpacing(4); + + Label textLabel = new Label(choiceText); + textLabel.getStyleClass().add("ssv-small-bold-label"); + top.setCenter(textLabel); + + button1 = new RadioButton(choice1Label); + button1.getStyleClass().add("ssv-small-label"); + button2 = new RadioButton(choice2Label); + button2.getStyleClass().add("ssv-small-label"); + + group = new ToggleGroup(); + button1.setToggleGroup(group); + button2.setToggleGroup(group); + + button1.setSelected(true); + + bot.getChildren().addAll(button1, button2); + bot.setPadding(new Insets(0, 16, 0, 32)); + + setTop(top); + setBottom(bot); + + button1.requestFocus(); + } + + public int getSelection() { + if (button2.isSelected()) { + return 1; + } + return 0; + } + } + + + /* * Create panel with the following info: * - Text area with description of what the password is for diff -r b15deae0faf8 javafx-deploy/src/com/sun/deploy/uitoolkit/impl/fx/ui/FXUIFactory.java --- a/javafx-deploy/src/com/sun/deploy/uitoolkit/impl/fx/ui/FXUIFactory.java Thu Jul 12 10:46:22 2012 -0700 +++ b/javafx-deploy/src/com/sun/deploy/uitoolkit/impl/fx/ui/FXUIFactory.java Mon Jul 16 17:13:29 2012 +0200 @@ -904,6 +904,30 @@ } } + /** + * Show SSV dialog with 2 checkboxes (radio style) and two buttons + * + * This can return either: + * 0 - OK_OLD_JRE - user allowed to run with insecure JRE + * 1 - CANCEL - do not run + * 2 - OK_LATEST_JRE - user allowed to run with latest JRE only + */ + @Override public int showSSVDialog(final Object owner, AppInfo ainfo, + String title, + String masthead, + String message, + String moreInfoText, URL moreInfoURL, + String choiceText, + String choice1Label, String choice2Label, + String btnOneLabel, String btnTwoLabel) { + + return showSSVDialog0(owner, ainfo, title, masthead, message, + moreInfoText, moreInfoURL, choiceText, + choice1Label, choice2Label, btnOneLabel, btnTwoLabel); + + } + + // should add Object parent as param public File[] showFileChooser(String initDir, String[] extensions, final int mode, boolean showMultiple) { @@ -1062,6 +1086,50 @@ return (String []) al.toArray(list); } + + public static int showSSVDialog0(final Object owner, + final AppInfo ainfo, + final String title, + final String masthead, + final String message, + final String moreInfoText, + final URL moreInfoURL, + final String choiceText, + final String choice1Label, + final String choice2Label, + final String btnOneLabel, + final String btnTwoLabel) { + + final Stage fOwner = beforeDialog((Stage)owner); + + try { + // create the dialog template on FX Application thread... + return FXPluginToolkit.callAndWait(new Callable() { + public Integer call() { + DialogTemplate template = + new DialogTemplate(ainfo, fOwner, title, masthead/*//FXPORT , true*/); + + template.setSSVContent(message, moreInfoText, + moreInfoURL, choiceText, choice1Label, + choice2Label, btnOneLabel, btnTwoLabel); + + placeWindow(template.getDialog()); + template.setVisible(true); + + int userAnswer = template.getUserAnswer(); + return new Integer(userAnswer); + } + }); + } catch (Throwable e) { + //Trace.ignored(e); + return ERROR; + } finally { + afterDialog(); + } + } + + + /** * placeWindow * diff -r b15deae0faf8 javafx-deploy/src/com/sun/deploy/uitoolkit/impl/fx/ui/deploydialogs.css --- a/javafx-deploy/src/com/sun/deploy/uitoolkit/impl/fx/ui/deploydialogs.css Thu Jul 12 10:46:22 2012 -0700 +++ b/javafx-deploy/src/com/sun/deploy/uitoolkit/impl/fx/ui/deploydialogs.css Mon Jul 16 17:13:29 2012 +0200 @@ -133,6 +133,21 @@ -fx-cursor: se_resize; } + +.ssv-small-label { + -fx-font-size: 0.833333em; /* Two px less than default */ +} + +.ssv-small-bold-label { + -fx-font-size: 0.833333em; /* Two px less than default */ + -fx-font-weight: bold; +} + +.ssv-big-bold-label { + -fx-font-size: 1.166667em; /* Two px more than default */ + -fx-font-weight: bold; +} + #content-pane { -fx-background-color: #eeeeee; -fx-text-fill: #292929; @@ -348,3 +363,11 @@ #info-panel { -fx-padding: 20 12 20 12; } + +#ssv-top-panel-name-label { + -fx-padding: 0 16 0 16; +} + +#ssv-top-panel-from-label { + -fx-padding: 0 16 0 16; +}