annotate src/name/blackcap/exifwasher/HelpDialog.kt @ 50:fb407182ba76

Add help menu item, UNTESTED.
author David Barts <davidb@stashtea.com>
date Thu, 07 May 2020 08:29:58 -0700
parents
children 39895d44a287
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
1 /*
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
2 * The dialog that displays the Exif data in a single file (display only,
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
3 * no changing). We do this after washing.
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
4 */
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
5 package name.blackcap.exifwasher
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
6
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
7 import java.awt.Color
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
8 import java.awt.Dimension
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
9 import java.awt.event.ActionEvent
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
10 import java.awt.event.ActionListener
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
11 import java.io.File
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
12 import java.io.IOException
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
13 import java.io.BufferedReader
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
14 import java.io.InputStream
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
15 import java.io.InputStreamReader
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
16 import java.util.logging.Level
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
17 import java.util.logging.Logger
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
18 import javax.swing.*
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
19 import javax.swing.table.DefaultTableModel
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
20 import javax.swing.table.TableColumn
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
21 import javax.swing.table.TableColumnModel
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
22
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
23 import name.blackcap.exifwasher.exiv2.*
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
24
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
25 class HelpDialog : JDialog(Application.mainFrame) {
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
26 private val BW = 9
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
27 private val BW2 = BW * 2
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
28 private val WIDTH = 640
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
29 private val HEIGHT = 480
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
30
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
31 private val dismissButton = JButton("Dismiss").also {
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
32 it.addActionListener(ActionListener { setVisible(false) })
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
33 }
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
34
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
35 private val helpPane = JTextPane().also {
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
36 it.contentType = "text/html";
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
37 it.text = ::class.java.getResourceAsStream("help.html").bufferedReader().use { it.readText() }
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
38 }
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
39
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
40 init {
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
41 setVisible(false)
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
42 title = "Help"
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
43 contentPane.apply {
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
44 layout = BoxLayout(this, BoxLayout.Y_AXIS)
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
45 add(JScrollPane(helpPane).apply {
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
46 alignmentX = JScrollPane.CENTER_ALIGNMENT
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
47 border = BorderFactory.createEmptyBorder(BW2, BW2, BW, BW2)
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
48 verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
49 horizontalScrollBarPolicy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
50 preferredSize = Dimension(WIDTH, HEIGHT)
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
51 background = Application.mainFrame.background
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
52 })
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
53 add(Box(BoxLayout.X_AXIS).apply {
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
54 alignmentX = Box.CENTER_ALIGNMENT
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
55 border = BorderFactory.createEmptyBorder(BW, BW2, BW2, BW2)
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
56 add(Box.createHorizontalGlue())
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
57 add(dismissButton)
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
58 })
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
59 }
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
60 pack()
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
61 }
fb407182ba76 Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff changeset
62 }