Mercurial > cgi-bin > hgweb.cgi > ClipMan
annotate src/name/blackcap/clipman/PasteboardQueue.kt @ 57:c6cccbe2f393
Port to OpenJDK 15 (mostly done).
author | David Barts <n5jrn@me.com> |
---|---|
date | Wed, 23 Mar 2022 23:56:29 -0700 |
parents | 19d9da731c43 |
children |
rev | line source |
---|---|
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
1 /* |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
2 * The queue of pasteboard items we manage. New stuff gets added to the |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
3 * tail, and old stuff truncated off the head. |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
4 */ |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
5 package name.blackcap.clipman |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
6 |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
7 import java.awt.Container |
1
fb224c3aebdf
Got it auto-scrolling to the bottom.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
8 import java.awt.Rectangle |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
9 import java.util.Collections |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
10 import java.util.LinkedList |
1
fb224c3aebdf
Got it auto-scrolling to the bottom.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
11 import java.util.logging.Level |
fb224c3aebdf
Got it auto-scrolling to the bottom.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
12 import java.util.logging.Logger |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
13 import javax.swing.* |
27
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
14 import javax.swing.text.DefaultHighlighter |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
15 |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
16 /** |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
17 * A queue that tracks the data we display and the widgets used to |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
18 * display them. We never explicitly remove stuff from the queue, |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
19 * though items will get silently discarded to prevent the queue from |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
20 * exceeding the specified maximum size. |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
21 */ |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
22 class PasteboardQueue(val parent: Container, maxSize: Int) { |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
23 private val queue = LinkedList<QueueItem>() |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
24 private var _maxSize = maxSize |
16
88703ca72fc3
Make an efficiency improvement: cache the scrollPane.
David Barts <n5jrn@me.com>
parents:
5
diff
changeset
|
25 private var scrollPane: JScrollPane? = null |
88703ca72fc3
Make an efficiency improvement: cache the scrollPane.
David Barts <n5jrn@me.com>
parents:
5
diff
changeset
|
26 init { |
88703ca72fc3
Make an efficiency improvement: cache the scrollPane.
David Barts <n5jrn@me.com>
parents:
5
diff
changeset
|
27 var sp: Container? = parent |
88703ca72fc3
Make an efficiency improvement: cache the scrollPane.
David Barts <n5jrn@me.com>
parents:
5
diff
changeset
|
28 while (sp != null) { |
88703ca72fc3
Make an efficiency improvement: cache the scrollPane.
David Barts <n5jrn@me.com>
parents:
5
diff
changeset
|
29 if (sp is JScrollPane) { |
88703ca72fc3
Make an efficiency improvement: cache the scrollPane.
David Barts <n5jrn@me.com>
parents:
5
diff
changeset
|
30 scrollPane = sp |
88703ca72fc3
Make an efficiency improvement: cache the scrollPane.
David Barts <n5jrn@me.com>
parents:
5
diff
changeset
|
31 break |
88703ca72fc3
Make an efficiency improvement: cache the scrollPane.
David Barts <n5jrn@me.com>
parents:
5
diff
changeset
|
32 } |
88703ca72fc3
Make an efficiency improvement: cache the scrollPane.
David Barts <n5jrn@me.com>
parents:
5
diff
changeset
|
33 sp = sp.parent |
88703ca72fc3
Make an efficiency improvement: cache the scrollPane.
David Barts <n5jrn@me.com>
parents:
5
diff
changeset
|
34 } |
88703ca72fc3
Make an efficiency improvement: cache the scrollPane.
David Barts <n5jrn@me.com>
parents:
5
diff
changeset
|
35 } |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
36 |
29
c4f53bc01732
Fix searching (and main display).
David Barts <n5jrn@me.com>
parents:
27
diff
changeset
|
37 data class Offset(val inQueue: Int, val inItem: Int) |
21 | 38 enum class Direction { FORWARDS, BACKWARDS } |
39 | |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
40 /** |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
41 * The maximum allowed size of this queue. Attempts to make the queue |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
42 * larger than this size, or specifying a size smaller than the current |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
43 * size, will result in the oldest item(s) being discarded. A size less |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
44 * than or equal to zero means an unlimited size. |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
45 */ |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
46 var maxSize: Int |
41
33fbe3a78d84
Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
40
diff
changeset
|
47 get() { return _maxSize } |
33fbe3a78d84
Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
40
diff
changeset
|
48 @Synchronized set(value) { |
33fbe3a78d84
Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
40
diff
changeset
|
49 _maxSize = value |
33fbe3a78d84
Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
40
diff
changeset
|
50 truncate() |
33fbe3a78d84
Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
40
diff
changeset
|
51 } |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
52 |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
53 /** |
1
fb224c3aebdf
Got it auto-scrolling to the bottom.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
54 * Add a QueueItem to the end of the queue. |
fb224c3aebdf
Got it auto-scrolling to the bottom.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
55 * @param item QueueItem to add |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
56 */ |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
57 @Synchronized fun add(item: QueueItem) { |
1
fb224c3aebdf
Got it auto-scrolling to the bottom.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
58 inSwingThread { |
27
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
59 parent.add(item.view.contents) |
46
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
60 validate() |
1
fb224c3aebdf
Got it auto-scrolling to the bottom.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
61 } |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
62 queue.addLast(item) |
5 | 63 truncate() |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
64 } |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
65 |
21 | 66 /** |
67 * Find and highlight the next occurrence of the specified string | |
68 * @param string to search | |
69 * @param whether to search backwards (default forwards) | |
70 * @param case-folding flag (default true) | |
71 * @param starting point (0, 0) for forwards, (m, n) for backwards | |
72 * @return position where start of string was found, or null | |
73 */ | |
74 fun find(needle: String, direction: Direction = Direction.FORWARDS, | |
75 foldCase: Boolean = true, origin: Offset? = null): Offset? | |
76 { | |
27
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
77 /* clean up any old highlights */ |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
78 queue.forEach { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
79 val hiliter = it.view.searchable.highlighter |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
80 hiliter.highlights.forEach { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
81 hiliter.removeHighlight(it) |
21 | 82 } |
27
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
83 } |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
84 |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
85 /* get starting item index */ |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
86 val qMax = queue.size |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
87 var norigin = origin ?: when (direction) { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
88 Direction.FORWARDS -> Offset(0, 0) |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
89 Direction.BACKWARDS -> Offset(qMax - 1, -1) |
21 | 90 } |
91 | |
27
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
92 /* loop initialization */ |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
93 val (start, incr, search) = if (direction == Direction.FORWARDS) { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
94 Triple( 0, 1, { n: String, h: String, o: Int -> h.indexOf(n, o, foldCase) }) |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
95 } else { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
96 Triple(-1, -1, { n: String, h: String, o: Int -> h.lastIndexOf(n, o, foldCase) }) |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
97 } |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
98 val painter = DefaultHighlighter.DefaultHighlightPainter(null); |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
99 var pos = -1 |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
100 |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
101 /* try and find it */ |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
102 while (norigin.inQueue >= 0 && norigin.inQueue < qMax) { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
103 val si = queue.get(norigin.inQueue).view.searchable |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
104 val doc = si.document |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
105 val text = doc.getText(0, doc.length) |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
106 pos = if (norigin.inItem >= 0) norigin.inItem else text.length - 1 |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
107 pos = search(needle, text, pos) |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
108 if (pos >= 0) { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
109 si.highlighter.addHighlight(pos, pos+needle.length, painter) |
40
c803a2c89ea0
Make the JScrollPane scroll properly to highlighted text.
David Barts <n5jrn@me.com>
parents:
31
diff
changeset
|
110 val r = si.modelToView(pos).apply { |
c803a2c89ea0
Make the JScrollPane scroll properly to highlighted text.
David Barts <n5jrn@me.com>
parents:
31
diff
changeset
|
111 add(si.modelToView(pos + needle.length - 1)) |
c803a2c89ea0
Make the JScrollPane scroll properly to highlighted text.
David Barts <n5jrn@me.com>
parents:
31
diff
changeset
|
112 } |
c803a2c89ea0
Make the JScrollPane scroll properly to highlighted text.
David Barts <n5jrn@me.com>
parents:
31
diff
changeset
|
113 si.scrollRectToVisible(r) |
27
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
114 break |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
115 } |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
116 norigin = Offset(norigin.inQueue + incr, start) |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
117 } |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
118 return if (pos >= 0) Offset(norigin.inQueue, pos) else null |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
119 } |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
120 |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
121 /** |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
122 * Ensure none of the searchables in this queue are selected. |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
123 */ |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
124 fun deselectAll() { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
125 queue.forEach { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
126 val s = it.view.searchable as? ClipText |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
127 if (s != null && s.selected) { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
128 s.selected = false |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
129 s.validate() |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
130 } |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
131 } |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
132 } |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
133 |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
134 /** |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
135 * Return the selected item, or null if nothing has been selected |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
136 */ |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
137 fun getSelected(): QueueItem? { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
138 queue.forEach { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
139 if ((it.view.searchable as? ClipText)?.selected ?: false) { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
140 return it |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
141 } |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
142 } |
21 | 143 return null |
144 } | |
145 | |
5 | 146 private fun truncate() { |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
147 if (_maxSize > 0) { |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
148 var size = queue.size |
5 | 149 var dirty = false |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
150 while (size > _maxSize) { |
27
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
151 var extra = queue.removeFirst().view |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
152 inSwingThread { |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
153 if (extra.searchable.selected) { |
47
19d9da731c43
Recoded; cleaned up root namespace, removed race conditions.
David Barts <n5jrn@me.com>
parents:
46
diff
changeset
|
154 Application.anyRequired.disable() |
19d9da731c43
Recoded; cleaned up root namespace, removed race conditions.
David Barts <n5jrn@me.com>
parents:
46
diff
changeset
|
155 Application.styledRequired.disable() |
27
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
156 } |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
157 parent.remove(extra.contents) |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
158 } |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
159 dirty = true |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
160 size -= 1 |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
161 } |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
162 if (dirty) { |
46
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
163 inSwingThread { validate() } |
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
164 } |
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
165 } |
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
166 } |
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
167 |
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
168 private fun validate() |
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
169 { |
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
170 if (scrollPane == null) { |
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
171 parent.validate() |
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
172 } else { |
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
173 scrollPane!!.run { |
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
174 validate() |
88066346f129
Fix display glitch when resizing queue truncates it.
David Barts <n5jrn@me.com>
parents:
41
diff
changeset
|
175 verticalScrollBar.run { value = maximum + 1 } |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
176 } |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
177 } |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
178 } |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
179 } |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
180 |
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
181 /** |
27
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
182 * An item in the above queue. Linking model to view here sorta violates |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
183 * MVC principles, but rules are sometimes best broken. Doing it this way |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
184 * makes it impossible for the view queue to fail to follow the data |
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
185 * queue. |
0
be282c48010a
Incomplete; checking it in as a backup.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
186 */ |
27
8aa2dfac27eb
Big reorg; compiled but untested.
David Barts <n5jrn@me.com>
parents:
21
diff
changeset
|
187 data class QueueItem(val contents: PasteboardItem, val view: PasteboardItemView) |