diff --git a/app/src/main/java/org/audiveris/omr/ui/AboutAction.java b/app/src/main/java/org/audiveris/omr/ui/AboutAction.java index 13efb0924..8ba966d51 100644 --- a/app/src/main/java/org/audiveris/omr/ui/AboutAction.java +++ b/app/src/main/java/org/audiveris/omr/ui/AboutAction.java @@ -41,10 +41,14 @@ import com.jgoodies.forms.layout.FormLayout; import java.awt.Color; +import java.awt.Component; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics; import java.awt.Image; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; import java.awt.event.ActionEvent; import java.net.MalformedURLException; import java.net.URI; @@ -73,8 +77,8 @@ public class AboutAction private static final Logger logger = LoggerFactory.getLogger(AboutAction.class); // Resource injection - private static final ResourceMap resources = Application.getInstance().getContext() - .getResourceMap(AboutAction.class); + private static final ResourceMap resources = + Application.getInstance().getContext().getResourceMap(AboutAction.class); //~ Instance fields ---------------------------------------------------------------------------- @@ -97,11 +101,36 @@ public void actionPerformed (ActionEvent e) aboutBox = createAboutBox(); } - JOptionPane.showMessageDialog( + final Object[] options = + { "OK", "Copy" }; + + final int choice = JOptionPane.showOptionDialog( OMR.gui.getFrame(), aboutBox, resources.getString("AboutDialog.title"), - JOptionPane.INFORMATION_MESSAGE); + JOptionPane.DEFAULT_OPTION, + JOptionPane.INFORMATION_MESSAGE, + null, + options, + options[0]); + System.out.println("choice: " + choice); + + if (choice == 1) { + copyToClipBoard(); + } + } + + //-----------------// + // copyToClipBoard // + //-----------------// + private void copyToClipBoard () + { + final String str = getContents(); + final Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); + final StringSelection strSel = new StringSelection(str); + clip.setContents(strSel, strSel); + JOptionPane + .showMessageDialog(OMR.gui.getFrame(), resources.getString("AboutDialog.copied")); } //----------------// @@ -201,21 +230,56 @@ private JPanel createAboutBox () ((JLabel) Topic.javaVersion.comp).setText(System.getProperty("java.version")); ((JLabel) Topic.javaRuntime.comp).setText( - System.getProperty("java.runtime.name") + " (build " + System.getProperty( - "java.runtime.version") + ")"); + System.getProperty("java.runtime.name") + " (build " + + System.getProperty("java.runtime.version") + ")"); ((JLabel) Topic.javaVm.comp).setText( - System.getProperty("java.vm.name") + " (build " + System.getProperty( - "java.vm.version") + ", " + System.getProperty("java.vm.info") + ")"); + System.getProperty("java.vm.name") + " (build " + + System.getProperty("java.vm.version") + ", " + + System.getProperty("java.vm.info") + ")"); - ((JLabel) Topic.os.comp).setText( - System.getProperty("os.name") + " " + System.getProperty("os.version")); + ((JLabel) Topic.os.comp) + .setText(System.getProperty("os.name") + " " + System.getProperty("os.version")); ((JLabel) Topic.osArch.comp).setText(System.getProperty("os.arch")); return panel; } + //-------------// + // getContents // + //-------------// + /** + * Build the textual content of the panel. + * + * @return the panel content as a single string with line breaks + */ + private String getContents () + { + final StringBuilder sb = new StringBuilder(); + + for (Component comp : aboutBox.getComponents()) { + switch (comp) { + case JLabel label -> { + final String text = label.getText(); + sb.append(text); + sb.append(text.endsWith(":") ? " " : WellKnowns.LINE_SEPARATOR); + } + case JEditorPane pane -> { + if (pane == Topic.home.comp) { + sb.append(resources.getString("Application.homepage")); + } else if (pane == Topic.project.comp) { + sb.append(resources.getString("Application.projectpage")); + } + sb.append(WellKnowns.LINE_SEPARATOR); + } + default -> {} + } + } + + return sb.toString(); + } + //~ Inner Classes ------------------------------------------------------------------------------ //-----------// @@ -225,15 +289,11 @@ private static class Constants extends ConstantSet { - private final Constant.Integer titleFontSize = new Constant.Integer( - "Points", - 14, - "Font size for title in about box"); + private final Constant.Integer titleFontSize = + new Constant.Integer("Points", 14, "Font size for title in about box"); - private final Constant.Integer urlFontSize = new Constant.Integer( - "Points", - 10, - "Font size for URL in about box"); + private final Constant.Integer urlFontSize = + new Constant.Integer("Points", 10, "Font size for URL in about box"); } //------------// diff --git a/app/src/main/java/org/audiveris/omr/ui/resources/AboutAction.properties b/app/src/main/java/org/audiveris/omr/ui/resources/AboutAction.properties index bcfa9fc04..ac390af9e 100644 --- a/app/src/main/java/org/audiveris/omr/ui/resources/AboutAction.properties +++ b/app/src/main/java/org/audiveris/omr/ui/resources/AboutAction.properties @@ -12,6 +12,7 @@ # ---------------------- AboutDialog.title = About ${Application.name} +AboutDialog.copied = Content copied to clipboard! aboutTitleLabel.text = ${Application.name} diff --git a/app/src/main/java/org/audiveris/omr/ui/resources/AboutAction_fr.properties b/app/src/main/java/org/audiveris/omr/ui/resources/AboutAction_fr.properties index d80e7d200..340933b28 100644 --- a/app/src/main/java/org/audiveris/omr/ui/resources/AboutAction_fr.properties +++ b/app/src/main/java/org/audiveris/omr/ui/resources/AboutAction_fr.properties @@ -12,9 +12,27 @@ # ---------------------- AboutDialog.title = A propos d'${Application.name} -homeLabel.text = Site Web: +AboutDialog.copied = Contenu copi\u00e9 dans le presse-papiers ! -licenseLabel.text = Licence: +descriptionLabel.text = R\u00f4le : -ocrLabel.text = Moteur OCR: -ocrFolder.text = Donn\u00e9es OCR: +versionLabel.text = Version : + +classesLabel.text = Conteneur: + +homeLabel.text = Site Web : + +projectLabel.text = Projet : + +licenseLabel.text = Licence du logiciel : + +ocrLabel.text = Moteur OCR : +ocrFolder.text = Donn\u00e9es OCR : + +javaVendorLabel.text = Fournisseur Java : +javaVersionLabel.text = Version Java : +javaRuntimeLabel.text = Runtime java : +javaVmLabel.text = Machine virtuelle Java : + +osLabel.text = Syst\u00e8me d'exploitation : +osArchLabel.text = Architecture :