diff --git a/src/main/java/info/augendre/caps_extractor/HelpAction.java b/src/main/java/info/augendre/caps_extractor/HelpAction.java new file mode 100644 index 0000000..c5c9603 --- /dev/null +++ b/src/main/java/info/augendre/caps_extractor/HelpAction.java @@ -0,0 +1,21 @@ +package info.augendre.caps_extractor; + +import javax.swing.*; +import java.awt.event.ActionEvent; + +/** + * Created by Gabriel. + */ +public class HelpAction extends AbstractAction { + public HelpAction() { + super(I18nSupport.translate("plain.help_title")); + } + + @Override + public void actionPerformed(ActionEvent e) { + JDialog help = new HelpDialog(); + help.pack(); + help.setLocationRelativeTo(null); + help.setVisible(true); + } +} diff --git a/src/main/java/info/augendre/caps_extractor/HelpDialog.form b/src/main/java/info/augendre/caps_extractor/HelpDialog.form new file mode 100644 index 0000000..67fa2e3 --- /dev/null +++ b/src/main/java/info/augendre/caps_extractor/HelpDialog.form @@ -0,0 +1,64 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/info/augendre/caps_extractor/HelpDialog.java b/src/main/java/info/augendre/caps_extractor/HelpDialog.java new file mode 100644 index 0000000..7adb1ff --- /dev/null +++ b/src/main/java/info/augendre/caps_extractor/HelpDialog.java @@ -0,0 +1,97 @@ +package info.augendre.caps_extractor; + +import com.intellij.uiDesigner.core.GridConstraints; +import com.intellij.uiDesigner.core.GridLayoutManager; +import com.intellij.uiDesigner.core.Spacer; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class HelpDialog extends JDialog { + private JPanel contentPane; + private JButton buttonOK; + private JLabel helpField; + + public HelpDialog() { + setContentPane(contentPane); + setModal(true); + getRootPane().setDefaultButton(buttonOK); + + this.setTitle(I18nSupport.translate("plain.help_title")); + + String helpText = "" + + "

" + + I18nSupport.translate("help.content") + + "

" + + ""; + + helpField.setText(helpText); + + buttonOK.addActionListener(e -> onOK()); + + buttonOK.addActionListener(e -> onOK()); + + // call onCancel() when cross is clicked + setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + onCancel(); + } + }); + + // call onCancel() on ESCAPE + contentPane.registerKeyboardAction(e -> onCancel(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + } + + private void onOK() { + dispose(); + } + + private void onCancel() { + dispose(); + } + + { +// GUI initializer generated by IntelliJ IDEA GUI Designer +// >>> IMPORTANT!! <<< +// DO NOT EDIT OR ADD ANY CODE HERE! + $$$setupUI$$$(); + } + + /** + * Method generated by IntelliJ IDEA GUI Designer + * >>> IMPORTANT!! <<< + * DO NOT edit this method OR call it in your code! + * + * @noinspection ALL + */ + private void $$$setupUI$$$() { + contentPane = new JPanel(); + contentPane.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1)); + final JPanel panel1 = new JPanel(); + panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null, null, 0, false)); + final Spacer spacer1 = new Spacer(); + panel1.add(spacer1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); + final JPanel panel2 = new JPanel(); + panel2.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + buttonOK = new JButton(); + buttonOK.setText("OK"); + panel2.add(buttonOK, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + final JPanel panel3 = new JPanel(); + panel3.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); + contentPane.add(panel3, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); + helpField = new JLabel(); + helpField.setText("Label"); + panel3.add(helpField, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); + } + + /** + * @noinspection ALL + */ + public JComponent $$$getRootComponent$$$() { + return contentPane; + } +} diff --git a/src/main/java/info/augendre/caps_extractor/MainWindow.java b/src/main/java/info/augendre/caps_extractor/MainWindow.java index babe6f6..3819bc9 100644 --- a/src/main/java/info/augendre/caps_extractor/MainWindow.java +++ b/src/main/java/info/augendre/caps_extractor/MainWindow.java @@ -16,6 +16,8 @@ public class MainWindow extends JFrame { JMenuBar menuBar = new JMenuBar(); JMenu help = new JMenu(I18nSupport.translate("menu.help")); menuBar.add(help); + JMenuItem helpItem = new JMenuItem(new HelpAction()); + help.add(helpItem); JMenuItem about = new JMenuItem(new AboutAction()); help.add(about); return menuBar; diff --git a/src/main/resources/info/augendre/caps_extractor/strings.properties b/src/main/resources/info/augendre/caps_extractor/strings.properties index 37c864f..e56bf5c 100644 --- a/src/main/resources/info/augendre/caps_extractor/strings.properties +++ b/src/main/resources/info/augendre/caps_extractor/strings.properties @@ -3,4 +3,7 @@ label.output=&Output\: plain.about_title=A propos plain.dev=Developer menu.help=Help -plain.title=Caps Extractor \ No newline at end of file +plain.title=Caps Extractor +help.content=Enter some text in the first box.
\ +All the upper case letters will be reflected in the latter box. +plain.help_title=Help \ No newline at end of file diff --git a/src/main/resources/info/augendre/caps_extractor/strings_fr.properties b/src/main/resources/info/augendre/caps_extractor/strings_fr.properties index 572f143..a680849 100644 --- a/src/main/resources/info/augendre/caps_extractor/strings_fr.properties +++ b/src/main/resources/info/augendre/caps_extractor/strings_fr.properties @@ -3,4 +3,7 @@ label.output=&Sortie \: plain.about_title=A propos plain.dev=D\u00E9veloppeur menu.help=Aide -plain.title=Extracteur de majuscules \ No newline at end of file +plain.title=Extracteur de majuscules +help.content=Entrez du texte dans le premier champ.
\ +Toutes les lettres majuscules seront r\u00E9p\u00E9t\u00E9es dans le second champ. +plain.help_title=Aide \ No newline at end of file