| | |
| | | |
| | | package org.opends.quicksetup.ui; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | |
| | | import org.opends.quicksetup.UserInteraction; |
| | | import org.opends.quicksetup.Constants; |
| | | import org.opends.quicksetup.i18n.ResourceProvider; |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | import javax.swing.*; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Object confirm(String summary, String details, |
| | | String title, MessageType type, String[] options, |
| | | String def) { |
| | | public Object confirm(Message summary, Message details, |
| | | Message title, MessageType type, Message[] options, |
| | | Message def) { |
| | | return confirm(summary, details, null, title, type, options, def, null); |
| | | } |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public Object confirm(String summary, String details, String fineDetails, |
| | | String title, MessageType type, String[] options, |
| | | String def, String viewDetailsOption) { |
| | | public Object confirm(Message summary, Message details, Message fineDetails, |
| | | Message title, MessageType type, Message[] options, |
| | | Message def, Message viewDetailsOption) { |
| | | int optionType; |
| | | if (options != null) { |
| | | if (options.length == 2) { |
| | |
| | | // characters per line functionality of the extends options |
| | | // pane does not affect message that are components so we |
| | | // have to format this ourselves. |
| | | StringBuilder sb = new StringBuilder(Constants.HTML_BOLD_OPEN); |
| | | MessageBuilder sb = new MessageBuilder(); |
| | | sb.append(Constants.HTML_BOLD_OPEN); |
| | | sb.append(Utils.breakHtmlString(summary, MAX_CHARS_PER_LINE)); |
| | | sb.append(Constants.HTML_BOLD_CLOSE); |
| | | sb.append(Constants.HTML_LINE_BREAK); |
| | | sb.append(Constants.HTML_LINE_BREAK); |
| | | |
| | | sb.append(Utils.breakHtmlString(details, MAX_CHARS_PER_LINE)); |
| | | JEditorPane ep = UIFactory.makeHtmlPane( |
| | | sb.toString(), |
| | | sb.toMessage(), |
| | | UIFactory.INSTRUCTIONS_FONT); |
| | | ep.setBorder(BorderFactory.createEmptyBorder(0, 0, 20, 0)); |
| | | op.setMessage(ep); |
| | |
| | | op.setMessageType(msgType); |
| | | op.setOptions(options); |
| | | op.setInitialValue(def); |
| | | JDialog dlg = op.createDialog(parent, title); |
| | | JDialog dlg = op.createDialog(parent, String.valueOf(title)); |
| | | dlg.setVisible(true); |
| | | return op.getValue(); |
| | | } |
| | |
| | | * dialog. |
| | | */ |
| | | public DetailsOptionPane(int maxCharactersPerLine, |
| | | String details) { |
| | | Message details) { |
| | | super(maxCharactersPerLine); |
| | | detailsComponent = createDetailsComponent(details); |
| | | } |
| | |
| | | detailsButtonsPanel.setLayout( |
| | | new BoxLayout(detailsButtonsPanel, |
| | | BoxLayout.LINE_AXIS)); |
| | | final String showDetailsLabel = getMsg("show-details-button-label"); |
| | | final String hideDetailsLabel = getMsg("hide-details-button-label"); |
| | | final JButton btnDetails = new JButton(showDetailsLabel); |
| | | final Message showDetailsLabel = INFO_SHOW_DETAILS_BUTTON_LABEL.get(); |
| | | final Message hideDetailsLabel = INFO_HIDE_DETAILS_BUTTON_LABEL.get(); |
| | | final JButton btnDetails = new JButton(showDetailsLabel.toString()); |
| | | btnDetails.addActionListener(new ActionListener() { |
| | | public void actionPerformed(ActionEvent e) { |
| | | Dimension current = dialog.getSize(); |
| | |
| | | // detailsComponent.setVisible(true); |
| | | dialog.setSize(current.width, |
| | | current.height + getExpansionHeight()); |
| | | btnDetails.setText(hideDetailsLabel); |
| | | btnDetails.setText(hideDetailsLabel.toString()); |
| | | } else { |
| | | // detailsComponent.setVisible(false); |
| | | dialog.setSize(current.width, |
| | | current.height - getExpansionHeight()); |
| | | btnDetails.setText(showDetailsLabel); |
| | | btnDetails.setText(showDetailsLabel.toString()); |
| | | } |
| | | detailsShowing = !detailsShowing; |
| | | } |
| | |
| | | return dialog; |
| | | } |
| | | |
| | | private Component createDetailsComponent(String details) { |
| | | private Component createDetailsComponent(Message details) { |
| | | JPanel detailsPanel = new JPanel(); |
| | | detailsPanel.setLayout(new GridBagLayout()); |
| | | GridBagConstraints gbc = new GridBagConstraints(); |
| | |
| | | gbc.insets = new Insets(15, 0, 0, 0); |
| | | gbc.fill = GridBagConstraints.HORIZONTAL; |
| | | detailsPanel.add(UIFactory.makeJLabel(null, |
| | | getMsg("details-label"), |
| | | INFO_DETAILS_LABEL.get(), |
| | | UIFactory.TextStyle.PRIMARY_FIELD_VALID), gbc); |
| | | |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | |
| | | gbc.fill = GridBagConstraints.BOTH; |
| | | |
| | | JEditorPane ep; |
| | | if (Utils.containsHtml(details)) { |
| | | if (Utils.containsHtml(String.valueOf(details))) { |
| | | ep = UIFactory.makeHtmlPane(details, UIFactory.INSTRUCTIONS_FONT); |
| | | } else { |
| | | ep = UIFactory.makeTextPane(details, UIFactory.TextStyle.INSTRUCTIONS); |
| | |
| | | |
| | | } |
| | | |
| | | private static String getMsg(String key) { |
| | | return ResourceProvider.getInstance().getMsg(key); |
| | | } |
| | | |
| | | // public static void main(String[] args) { |
| | | // new GuiUserInteraction(null).confirm( |
| | | // "Summary", |