comparison src/name/blackcap/clipman/Menus.kt @ 39:2a5808156f99

Remove more deadwood, add non-Mac About dialog.
author David Barts <n5jrn@me.com>
date Fri, 31 Jan 2020 00:06:59 -0800
parents fcf82e3b7e31
children 33fbe3a78d84
comparison
equal deleted inserted replaced
38:08eaae2aaf76 39:2a5808156f99
20 "File.Quit" -> System.exit(0) 20 "File.Quit" -> System.exit(0)
21 "Edit.Clone" -> onlyIfSelected { PasteboardItem.write(it.contents) } 21 "Edit.Clone" -> onlyIfSelected { PasteboardItem.write(it.contents) }
22 "Edit.Coerce" -> onlyIfSelected { coerceDialog.setVisible(true) } 22 "Edit.Coerce" -> onlyIfSelected { coerceDialog.setVisible(true) }
23 "Edit.Find" -> searchDialog.setVisible(true) 23 "Edit.Find" -> searchDialog.setVisible(true)
24 "Edit.FindAgain" -> searchDialog.find() 24 "Edit.FindAgain" -> searchDialog.find()
25 "Help.About" -> JOptionPane.showMessageDialog(frame.v,
26 "ClipMan, a clipboard manager.\n"
27 + "© MMXX, David W. Barts",
28 "About ClipMan",
29 JOptionPane.PLAIN_MESSAGE)
25 else -> throw RuntimeException("unexpected actionCommand!") 30 else -> throw RuntimeException("unexpected actionCommand!")
26 } 31 }
27 } 32 }
28 33
29 private fun onlyIfSelected(block: (QueueItem) -> Unit) { 34 private fun onlyIfSelected(block: (QueueItem) -> Unit) {
33 "No item selected.", 38 "No item selected.",
34 "Error", 39 "Error",
35 JOptionPane.ERROR_MESSAGE) 40 JOptionPane.ERROR_MESSAGE)
36 } else { 41 } else {
37 block(selected) 42 block(selected)
38 }
39 }
40
41 private fun clone(contents: PasteboardItem) {
42 val (plain, html) = when(contents) {
43 is PasteboardItem.Plain -> Pair(contents.plain, null)
44 is PasteboardItem.HTML -> Pair(contents.plain, contents.html)
45 is PasteboardItem.RTF -> Pair(contents.plain, contents.html)
46 }
47 if (html == null) {
48 PasteboardItem.write(PasteboardItem.Plain(plain))
49 } else {
50 PasteboardItem.write(PasteboardItem.HTML(plain, scrub(html)))
51 } 43 }
52 } 44 }
53 } 45 }
54 46
55 val menuItemListener = MenuItemListener() 47 val menuItemListener = MenuItemListener()