最古版。新版→https://osdn.jp/users/tacticsrealize/pf/ChlorophyllUploader/wiki/FrontPage
Revision | 6127ca0b64a1a3ba7af478c4d14ad15872614bb1 (tree) |
---|---|
Zeit | 2015-07-14 17:57:13 |
Autor | MirrgieRiana Kurilab |
Commiter | MirrgieRiana Kurilab |
FrameSelectPort: use NamedSlot
@@ -16,11 +16,12 @@ | ||
16 | 16 | |
17 | 17 | import jp.hishidama.swing.layout.GroupLayoutUtil; |
18 | 18 | import mirrg.ants.swing.FrameMirrg; |
19 | +import mirrg.ants.swing.NamedSlot; | |
19 | 20 | |
20 | 21 | public class FrameSelectPort extends FrameMirrg |
21 | 22 | { |
22 | 23 | |
23 | - private JList<Wrapper<CommPortIdentifier>> list; | |
24 | + private JList<NamedSlot<CommPortIdentifier>> list; | |
24 | 25 | private Consumer<CommPortIdentifier> consumer; |
25 | 26 | |
26 | 27 | public FrameSelectPort(Consumer<CommPortIdentifier> consumer) |
@@ -106,43 +107,23 @@ | ||
106 | 107 | |
107 | 108 | private void send() |
108 | 109 | { |
109 | - Wrapper<CommPortIdentifier> portIdentifier = list.getSelectedValue(); | |
110 | + NamedSlot<CommPortIdentifier> portIdentifier = list.getSelectedValue(); | |
110 | 111 | if (portIdentifier != null) { |
111 | - if (portIdentifier.x != null) { | |
112 | + if (portIdentifier.get() != null) { | |
112 | 113 | dispose(); |
113 | - consumer.accept(portIdentifier.x); | |
114 | + consumer.accept(portIdentifier.get()); | |
114 | 115 | } |
115 | 116 | } |
116 | 117 | } |
117 | 118 | |
118 | - public static class Wrapper<X> | |
119 | - { | |
120 | - | |
121 | - public X x; | |
122 | - public String name; | |
123 | - | |
124 | - public Wrapper(X x, String name) | |
125 | - { | |
126 | - this.x = x; | |
127 | - this.name = name; | |
128 | - } | |
129 | - | |
130 | - @Override | |
131 | - public String toString() | |
132 | - { | |
133 | - return name; | |
134 | - } | |
135 | - | |
136 | - } | |
137 | - | |
138 | - private static void redraw(JList<Wrapper<CommPortIdentifier>> list) | |
119 | + private static void redraw(JList<NamedSlot<CommPortIdentifier>> list) | |
139 | 120 | { |
140 | 121 | Enumeration<CommPortIdentifier> portIdentifiers = getPortIdentifiers(); |
141 | 122 | |
142 | - Vector<Wrapper<CommPortIdentifier>> vector = new Vector<>(); | |
123 | + Vector<NamedSlot<CommPortIdentifier>> vector = new Vector<>(); | |
143 | 124 | while (portIdentifiers.hasMoreElements()) { |
144 | 125 | CommPortIdentifier portIdentifier = portIdentifiers.nextElement(); |
145 | - vector.add(new Wrapper<>(portIdentifier, portIdentifier.getName())); | |
126 | + vector.add(new NamedSlot<>(portIdentifier, CommPortIdentifier::getName)); | |
146 | 127 | } |
147 | 128 | |
148 | 129 | list.setListData(vector); |