| .. | .. |
|---|
| 20 | 20 | import java.net.URL; |
|---|
| 21 | 21 | import java.util.*; |
|---|
| 22 | 22 | |
|---|
| 23 | | -public class ListView extends AbstractView { |
|---|
| 23 | +public class ListView extends AbstractView |
|---|
| 24 | +{ |
|---|
| 25 | + private JEditorPane listDisplay; |
|---|
| 26 | + private JComboBox sortMenu = new JComboBox(); |
|---|
| 27 | + private ActComparator sort;//=ActComparator.byTime(); |
|---|
| 28 | + private int maxPerPage = 50; |
|---|
| 29 | + private int pageStart = 0; |
|---|
| 30 | + private int lastSize = 0; |
|---|
| 31 | + private ActList acts; |
|---|
| 32 | + private Field sortField; |
|---|
| 33 | + private JLabel pageLabel = new JLabel("Page", JLabel.LEFT); |
|---|
| 34 | + private JComboBox pageMenu = new JComboBox(); |
|---|
| 35 | + private boolean changing = false; |
|---|
| 36 | + private JPanel controls; |
|---|
| 24 | 37 | |
|---|
| 25 | | - private JEditorPane listDisplay; |
|---|
| 26 | | - private JComboBox sortMenu=new JComboBox(); |
|---|
| 27 | | - private ActComparator sort;//=ActComparator.byTime(); |
|---|
| 28 | | - private int maxPerPage=50; |
|---|
| 29 | | - private int pageStart=0; |
|---|
| 30 | | - private int lastSize=0; |
|---|
| 31 | | - private ActList acts; |
|---|
| 32 | | - private Field sortField; |
|---|
| 33 | | - |
|---|
| 34 | | - private JLabel pageLabel=new JLabel("Page", JLabel.LEFT); |
|---|
| 35 | | - private JComboBox pageMenu=new JComboBox(); |
|---|
| 36 | | - private boolean changing=false; |
|---|
| 37 | | - |
|---|
| 38 | | - private JPanel controls; |
|---|
| 39 | | - |
|---|
| 40 | | - public ListView(TFModel model) |
|---|
| 41 | | - { |
|---|
| 42 | | - super(model); |
|---|
| 43 | | - |
|---|
| 44 | | - listDisplay=HtmlDisplay.create(); |
|---|
| 45 | | - listDisplay.addHyperlinkListener(new LinkIt()); |
|---|
| 46 | | - JScrollPane scrollPane = new JScrollPane(listDisplay); |
|---|
| 47 | | - setLayout(new BorderLayout()); |
|---|
| 48 | | - add(scrollPane, BorderLayout.CENTER); |
|---|
| 49 | | - |
|---|
| 50 | | - |
|---|
| 51 | | - controls=new JPanel(); |
|---|
| 52 | | - controls.setLayout(null); |
|---|
| 53 | | - controls.setBackground(Color.white); |
|---|
| 54 | | - |
|---|
| 55 | | - int x=10, y=10; |
|---|
| 56 | | - int ch=25, pad=5, cw=160; |
|---|
| 57 | | - JLabel sortLabel=new JLabel("Sort Order", JLabel.LEFT); |
|---|
| 58 | | - controls.add(sortLabel); |
|---|
| 59 | | - sortLabel.setBounds(x,y,cw,ch); |
|---|
| 60 | | - y+=ch+pad; |
|---|
| 61 | | - |
|---|
| 62 | | - controls.add(sortMenu); |
|---|
| 63 | | - sortMenu.setBounds(x,y,cw,ch); |
|---|
| 64 | | - y+=ch+3*pad; |
|---|
| 65 | | - |
|---|
| 66 | | - controls.add(pageLabel); |
|---|
| 67 | | - pageLabel.setBounds(x,y,cw,ch); |
|---|
| 68 | | - y+=ch+pad; |
|---|
| 69 | | - controls.add(pageMenu); |
|---|
| 70 | | - pageMenu.setBounds(x,y,cw,ch); |
|---|
| 71 | | - |
|---|
| 72 | | - showPageMenu(false); |
|---|
| 73 | | - pageMenu.addActionListener(pageListener); |
|---|
| 74 | | - sortMenu.addActionListener(sortListener); |
|---|
| 75 | | - } |
|---|
| 76 | | - |
|---|
| 77 | | - protected JComponent _getControls() |
|---|
| 78 | | - { |
|---|
| 79 | | - return controls; |
|---|
| 80 | | - } |
|---|
| 81 | | - |
|---|
| 82 | | - ActionListener sortListener=new ActionListener() { |
|---|
| 83 | | - @Override |
|---|
| 84 | | - public void actionPerformed(ActionEvent e) { |
|---|
| 85 | | - if (changing || sortMenu.getItemCount()<=0) // this means the action was fired after all items removed. |
|---|
| 86 | | - return; |
|---|
| 87 | | - sortField=getModel().getDB().getField((String)sortMenu.getSelectedItem()); |
|---|
| 88 | | - sort=sortField==null ? null : ActComparator.by(sortField); |
|---|
| 89 | | - setToFirstPage(); |
|---|
| 90 | | - makeList(); |
|---|
| 91 | | - }}; |
|---|
| 92 | | - |
|---|
| 93 | | - ActionListener pageListener=new ActionListener() { |
|---|
| 94 | | - @Override |
|---|
| 95 | | - public void actionPerformed(ActionEvent e) { |
|---|
| 96 | | - if (changing) |
|---|
| 97 | | - return; |
|---|
| 98 | | - pageStart=maxPerPage*pageMenu.getSelectedIndex(); |
|---|
| 99 | | - System.out.println(e.getActionCommand()); |
|---|
| 100 | | - makeList(); |
|---|
| 101 | | - }}; |
|---|
| 102 | | - |
|---|
| 103 | | - @Override |
|---|
| 104 | | - protected void onscreen(boolean majorChange) |
|---|
| 105 | | - { |
|---|
| 106 | | - _note(null); |
|---|
| 107 | | - } |
|---|
| 108 | | - |
|---|
| 109 | | - public void _note(TFEvent e) { |
|---|
| 110 | | - changing=true; |
|---|
| 111 | | - if (e==null || e.affectsSchema() || e.affectsRowSet()) |
|---|
| 112 | | - { |
|---|
| 113 | | - sortMenu.removeActionListener(sortListener); |
|---|
| 114 | | - sortMenu.removeAllItems(); |
|---|
| 115 | | - pageStart=0; |
|---|
| 116 | | - java.util.List<Field> fields=getModel().getDB().getFields(); |
|---|
| 117 | | - Field firstField=null; |
|---|
| 118 | | - if (fields.size()>0) |
|---|
| 119 | | - firstField=fields.get(0); |
|---|
| 120 | | - for (Field f: fields) |
|---|
| 121 | | - { |
|---|
| 122 | | - sortMenu.addItem(f.getName()); |
|---|
| 123 | | - } |
|---|
| 124 | | - sortField=getModel().getDB().getField(VirtualField.START); |
|---|
| 125 | | - if (sortField!=null) |
|---|
| 126 | | - sortMenu.setSelectedItem(sortField.getName()); |
|---|
| 127 | | - else |
|---|
| 128 | | - sortField=firstField; |
|---|
| 129 | | - sortMenu.addActionListener(sortListener); |
|---|
| 130 | | - sort=null; |
|---|
| 131 | | - } |
|---|
| 132 | | - if (e!=null && e.affectsData()) |
|---|
| 133 | | - { |
|---|
| 134 | | - setToFirstPage(); |
|---|
| 135 | | - } |
|---|
| 136 | | - changing=false; |
|---|
| 137 | | - makeList(); |
|---|
| 138 | | - } |
|---|
| 139 | | - |
|---|
| 140 | | - private void setToFirstPage() |
|---|
| 141 | | - { |
|---|
| 142 | | - pageStart=0; |
|---|
| 143 | | - if (pageMenu.isVisible()) |
|---|
| 144 | | - { |
|---|
| 145 | | - pageMenu.removeActionListener(pageListener); |
|---|
| 146 | | - pageMenu.setSelectedIndex(0); |
|---|
| 147 | | - pageMenu.addActionListener(pageListener); |
|---|
| 148 | | - } |
|---|
| 149 | | - } |
|---|
| 150 | | - |
|---|
| 151 | | - void showPageMenu(boolean visible) |
|---|
| 152 | | - { |
|---|
| 153 | | - pageLabel.setVisible(visible); |
|---|
| 154 | | - pageMenu.setVisible(visible); |
|---|
| 155 | | - if (visible) |
|---|
| 156 | | - { |
|---|
| 157 | | - pageMenu.removeActionListener(pageListener); |
|---|
| 158 | | - pageMenu.setSelectedIndex(pageStart/maxPerPage); |
|---|
| 159 | | - pageMenu.addActionListener(pageListener); |
|---|
| 160 | | - } |
|---|
| 161 | | - } |
|---|
| 162 | | - |
|---|
| 163 | | - |
|---|
| 164 | | - void makeList() |
|---|
| 165 | | - { |
|---|
| 166 | | - HtmlFormat html=new HtmlFormat(); |
|---|
| 167 | | - html.setModel(getModel()); |
|---|
| 168 | | - StringBuffer page=new StringBuffer(); |
|---|
| 169 | | - |
|---|
| 170 | | - page.append(html.makeHeader()); |
|---|
| 171 | | - |
|---|
| 172 | | - |
|---|
| 173 | | - ActList as=getModel().getActs(); |
|---|
| 174 | | - if (as==null || as.size()==0 && getModel().getDB().size()==0) |
|---|
| 175 | | - { |
|---|
| 176 | | - page.append("<tr><td><h1><font color=#003399>Empty Database</font></h1></td></tr>"); |
|---|
| 177 | | - showPageMenu(false); |
|---|
| 178 | | - } |
|---|
| 179 | | - else |
|---|
| 180 | | - { |
|---|
| 181 | | - |
|---|
| 182 | | - if (sort==null) |
|---|
| 183 | | - { |
|---|
| 184 | | - Field timeField=getModel().getDB().getField(VirtualField.START); |
|---|
| 185 | | - if (timeField!=null) |
|---|
| 186 | | - sort=ActComparator.by(timeField); |
|---|
| 187 | | - } |
|---|
| 38 | + public ListView(TimeflowModel model) |
|---|
| 39 | + { |
|---|
| 40 | + super(model); |
|---|
| 188 | 41 | |
|---|
| 189 | | - acts=as.copy(); |
|---|
| 190 | | - if (sort!=null) |
|---|
| 191 | | - Collections.sort(acts, sort); |
|---|
| 192 | | - |
|---|
| 193 | | - boolean pages=acts.size()>maxPerPage; |
|---|
| 194 | | - int last=Math.min(acts.size(), pageStart+maxPerPage); |
|---|
| 195 | | - if (pages) |
|---|
| 196 | | - { |
|---|
| 197 | | - int n=acts.size(); |
|---|
| 198 | | - if (lastSize!=n) |
|---|
| 199 | | - { |
|---|
| 200 | | - pageMenu.removeActionListener(pageListener); |
|---|
| 201 | | - pageMenu.removeAllItems(); |
|---|
| 202 | | - for (int i=0; i*maxPerPage<n;i++) |
|---|
| 203 | | - { |
|---|
| 204 | | - pageMenu.addItem("Items "+((i*maxPerPage)+1)+" to "+ |
|---|
| 205 | | - Math.min(n, (i+1)*maxPerPage)); |
|---|
| 206 | | - } |
|---|
| 207 | | - pageMenu.addActionListener(pageListener); |
|---|
| 208 | | - lastSize=n; |
|---|
| 209 | | - } |
|---|
| 210 | | - } |
|---|
| 211 | | - showPageMenu(pages); |
|---|
| 212 | | - |
|---|
| 213 | | - page.append("<tr><td><h1><font color=#003399>"+(pages? (pageStart+1)+"-"+(last) +" of ": "")+acts.size()+" Events</font></h1>"); |
|---|
| 214 | | - page.append("<br><br></td></tr>"); |
|---|
| 42 | + listDisplay = HtmlDisplay.create(); |
|---|
| 43 | + listDisplay.addHyperlinkListener(new LinkIt()); |
|---|
| 44 | + JScrollPane scrollPane = new JScrollPane(listDisplay); |
|---|
| 45 | + setLayout(new BorderLayout()); |
|---|
| 46 | + add(scrollPane, BorderLayout.CENTER); |
|---|
| 215 | 47 | |
|---|
| 216 | | - for (int i=pageStart; i<last; i++) |
|---|
| 217 | | - { |
|---|
| 218 | | - Act a=acts.get(i); |
|---|
| 219 | | - page.append(html.makeItem(a,i)); |
|---|
| 220 | | - } |
|---|
| 221 | | - } |
|---|
| 222 | | - page.append(html.makeFooter()); |
|---|
| 223 | | - listDisplay.setText(page.toString()); |
|---|
| 224 | | - listDisplay.setCaretPosition(0); |
|---|
| 225 | | - repaint(); |
|---|
| 226 | | - } |
|---|
| 227 | | - |
|---|
| 228 | | - |
|---|
| 229 | | - |
|---|
| 230 | | - |
|---|
| 231 | | - @Override |
|---|
| 232 | | - public String getName() { |
|---|
| 233 | | - return "List"; |
|---|
| 234 | | - } |
|---|
| 235 | | - |
|---|
| 236 | | - static class ArrayRenderer extends DefaultTableCellRenderer { |
|---|
| 237 | | - public void setValue(Object value) { |
|---|
| 238 | | - setText(Display.arrayToString((Object[])value)); |
|---|
| 239 | | - } |
|---|
| 240 | | - } |
|---|
| 241 | | - |
|---|
| 242 | | - public class LinkIt implements HyperlinkListener |
|---|
| 243 | | - { |
|---|
| 244 | | - public void hyperlinkUpdate(HyperlinkEvent e) |
|---|
| 245 | | - { |
|---|
| 246 | | - if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) |
|---|
| 247 | | - return; |
|---|
| 248 | | - |
|---|
| 249 | | - String s=e.getDescription(); |
|---|
| 250 | | - System.out.println(s); |
|---|
| 251 | | - if (s.length()>0) |
|---|
| 252 | | - { |
|---|
| 253 | | - char c=s.charAt(0); |
|---|
| 254 | | - if (c=='e') // code for "edit" |
|---|
| 255 | | - { |
|---|
| 256 | | - int i=Integer.parseInt(s.substring(1)); |
|---|
| 257 | | - EditRecordPanel.edit(getModel(), acts.get(i)); |
|---|
| 258 | | - return; |
|---|
| 259 | | - } |
|---|
| 260 | | - |
|---|
| 261 | | - } |
|---|
| 262 | | - Display.launchBrowser(e.getURL().toString()); |
|---|
| 263 | | - |
|---|
| 264 | | - } |
|---|
| 265 | | - } |
|---|
| 48 | + |
|---|
| 49 | + controls = new JPanel(); |
|---|
| 50 | + controls.setLayout(null); |
|---|
| 51 | + controls.setBackground(Color.white); |
|---|
| 52 | + |
|---|
| 53 | + int x = 10, y = 10; |
|---|
| 54 | + int ch = 25, pad = 5, cw = 160; |
|---|
| 55 | + JLabel sortLabel = new JLabel("Sort Order", JLabel.LEFT); |
|---|
| 56 | + controls.add(sortLabel); |
|---|
| 57 | + sortLabel.setBounds(x, y, cw, ch); |
|---|
| 58 | + y += ch + pad; |
|---|
| 59 | + |
|---|
| 60 | + controls.add(sortMenu); |
|---|
| 61 | + sortMenu.setBounds(x, y, cw, ch); |
|---|
| 62 | + y += ch + 3 * pad; |
|---|
| 63 | + |
|---|
| 64 | + controls.add(pageLabel); |
|---|
| 65 | + pageLabel.setBounds(x, y, cw, ch); |
|---|
| 66 | + y += ch + pad; |
|---|
| 67 | + controls.add(pageMenu); |
|---|
| 68 | + pageMenu.setBounds(x, y, cw, ch); |
|---|
| 69 | + |
|---|
| 70 | + showPageMenu(false); |
|---|
| 71 | + pageMenu.addActionListener(pageListener); |
|---|
| 72 | + sortMenu.addActionListener(sortListener); |
|---|
| 73 | + } |
|---|
| 74 | + |
|---|
| 75 | + protected JComponent _getControls() |
|---|
| 76 | + { |
|---|
| 77 | + return controls; |
|---|
| 78 | + } |
|---|
| 79 | + ActionListener sortListener = new ActionListener() |
|---|
| 80 | + { |
|---|
| 81 | + |
|---|
| 82 | + @Override |
|---|
| 83 | + public void actionPerformed(ActionEvent e) |
|---|
| 84 | + { |
|---|
| 85 | + if (changing || sortMenu.getItemCount() <= 0) // this means the action was fired after all items removed. |
|---|
| 86 | + { |
|---|
| 87 | + return; |
|---|
| 88 | + } |
|---|
| 89 | + sortField = getModel().getDB().getField((String) sortMenu.getSelectedItem()); |
|---|
| 90 | + sort = sortField == null ? null : ActComparator.by(sortField); |
|---|
| 91 | + setToFirstPage(); |
|---|
| 92 | + makeList(); |
|---|
| 93 | + } |
|---|
| 94 | + }; |
|---|
| 95 | + ActionListener pageListener = new ActionListener() |
|---|
| 96 | + { |
|---|
| 97 | + |
|---|
| 98 | + @Override |
|---|
| 99 | + public void actionPerformed(ActionEvent e) |
|---|
| 100 | + { |
|---|
| 101 | + if (changing) |
|---|
| 102 | + { |
|---|
| 103 | + return; |
|---|
| 104 | + } |
|---|
| 105 | + pageStart = maxPerPage * pageMenu.getSelectedIndex(); |
|---|
| 106 | + System.out.println(e.getActionCommand()); |
|---|
| 107 | + makeList(); |
|---|
| 108 | + } |
|---|
| 109 | + }; |
|---|
| 110 | + |
|---|
| 111 | + @Override |
|---|
| 112 | + protected void onscreen(boolean majorChange) |
|---|
| 113 | + { |
|---|
| 114 | + _note(null); |
|---|
| 115 | + } |
|---|
| 116 | + |
|---|
| 117 | + public void _note(TFEvent e) |
|---|
| 118 | + { |
|---|
| 119 | + changing = true; |
|---|
| 120 | + if (e == null || e.affectsSchema() || e.affectsRowSet()) |
|---|
| 121 | + { |
|---|
| 122 | + sortMenu.removeActionListener(sortListener); |
|---|
| 123 | + sortMenu.removeAllItems(); |
|---|
| 124 | + pageStart = 0; |
|---|
| 125 | + java.util.List<Field> fields = getModel().getDB().getFields(); |
|---|
| 126 | + Field firstField = null; |
|---|
| 127 | + if (fields.size() > 0) |
|---|
| 128 | + { |
|---|
| 129 | + firstField = fields.get(0); |
|---|
| 130 | + } |
|---|
| 131 | + for (Field f : fields) |
|---|
| 132 | + { |
|---|
| 133 | + sortMenu.addItem(f.getName()); |
|---|
| 134 | + } |
|---|
| 135 | + sortField = getModel().getDB().getField(VirtualField.START); |
|---|
| 136 | + if (sortField != null) |
|---|
| 137 | + { |
|---|
| 138 | + sortMenu.setSelectedItem(sortField.getName()); |
|---|
| 139 | + } else |
|---|
| 140 | + { |
|---|
| 141 | + sortField = firstField; |
|---|
| 142 | + } |
|---|
| 143 | + sortMenu.addActionListener(sortListener); |
|---|
| 144 | + sort = null; |
|---|
| 145 | + } |
|---|
| 146 | + if (e != null && e.affectsData()) |
|---|
| 147 | + { |
|---|
| 148 | + setToFirstPage(); |
|---|
| 149 | + } |
|---|
| 150 | + changing = false; |
|---|
| 151 | + makeList(); |
|---|
| 152 | + } |
|---|
| 153 | + |
|---|
| 154 | + private void setToFirstPage() |
|---|
| 155 | + { |
|---|
| 156 | + pageStart = 0; |
|---|
| 157 | + if (pageMenu.isVisible()) |
|---|
| 158 | + { |
|---|
| 159 | + pageMenu.removeActionListener(pageListener); |
|---|
| 160 | + pageMenu.setSelectedIndex(0); |
|---|
| 161 | + pageMenu.addActionListener(pageListener); |
|---|
| 162 | + } |
|---|
| 163 | + } |
|---|
| 164 | + |
|---|
| 165 | + void showPageMenu(boolean visible) |
|---|
| 166 | + { |
|---|
| 167 | + pageLabel.setVisible(visible); |
|---|
| 168 | + pageMenu.setVisible(visible); |
|---|
| 169 | + if (visible) |
|---|
| 170 | + { |
|---|
| 171 | + pageMenu.removeActionListener(pageListener); |
|---|
| 172 | + pageMenu.setSelectedIndex(pageStart / maxPerPage); |
|---|
| 173 | + pageMenu.addActionListener(pageListener); |
|---|
| 174 | + } |
|---|
| 175 | + } |
|---|
| 176 | + |
|---|
| 177 | + void makeList() |
|---|
| 178 | + { |
|---|
| 179 | + HtmlFormat html = new HtmlFormat(); |
|---|
| 180 | + html.setModel(getModel()); |
|---|
| 181 | + StringBuffer page = new StringBuffer(); |
|---|
| 182 | + |
|---|
| 183 | + page.append(html.makeHeader()); |
|---|
| 184 | + |
|---|
| 185 | + ActList as = getModel().getActs(); |
|---|
| 186 | + if (as == null || as.size() == 0 && getModel().getDB().size() == 0) |
|---|
| 187 | + { |
|---|
| 188 | + page.append("<tr><td><h1><font color=#003399>Empty Database</font></h1></td></tr>"); |
|---|
| 189 | + showPageMenu(false); |
|---|
| 190 | + } else |
|---|
| 191 | + { |
|---|
| 192 | + |
|---|
| 193 | + if (sort == null) |
|---|
| 194 | + { |
|---|
| 195 | + Field timeField = getModel().getDB().getField(VirtualField.START); |
|---|
| 196 | + if (timeField != null) |
|---|
| 197 | + { |
|---|
| 198 | + sort = ActComparator.by(timeField); |
|---|
| 199 | + } |
|---|
| 200 | + } |
|---|
| 201 | + |
|---|
| 202 | + acts = as.copy(); |
|---|
| 203 | + if (sort != null) |
|---|
| 204 | + { |
|---|
| 205 | + Collections.sort(acts, sort); |
|---|
| 206 | + } |
|---|
| 207 | + |
|---|
| 208 | + boolean pages = acts.size() > maxPerPage; |
|---|
| 209 | + int last = Math.min(acts.size(), pageStart + maxPerPage); |
|---|
| 210 | + if (pages) |
|---|
| 211 | + { |
|---|
| 212 | + int n = acts.size(); |
|---|
| 213 | + if (lastSize != n) |
|---|
| 214 | + { |
|---|
| 215 | + pageMenu.removeActionListener(pageListener); |
|---|
| 216 | + pageMenu.removeAllItems(); |
|---|
| 217 | + for (int i = 0; i * maxPerPage < n; i++) |
|---|
| 218 | + { |
|---|
| 219 | + pageMenu.addItem("Items " + ((i * maxPerPage) + 1) + " to " |
|---|
| 220 | + + Math.min(n, (i + 1) * maxPerPage)); |
|---|
| 221 | + } |
|---|
| 222 | + pageMenu.addActionListener(pageListener); |
|---|
| 223 | + lastSize = n; |
|---|
| 224 | + } |
|---|
| 225 | + } |
|---|
| 226 | + showPageMenu(pages); |
|---|
| 227 | + |
|---|
| 228 | + page.append("<tr><td><h1><font color=#003399>" + (pages ? (pageStart + 1) + "-" + (last) + " of " : "") + acts.size() + " Events</font></h1>"); |
|---|
| 229 | + page.append("<br><br></td></tr>"); |
|---|
| 230 | + |
|---|
| 231 | + for (int i = pageStart; i < last; i++) |
|---|
| 232 | + { |
|---|
| 233 | + Act a = acts.get(i); |
|---|
| 234 | + page.append(html.makeItem(a, i)); |
|---|
| 235 | + } |
|---|
| 236 | + } |
|---|
| 237 | + page.append(html.makeFooter()); |
|---|
| 238 | + listDisplay.setText(page.toString()); |
|---|
| 239 | + listDisplay.setCaretPosition(0); |
|---|
| 240 | + repaint(); |
|---|
| 241 | + } |
|---|
| 242 | + |
|---|
| 243 | + @Override |
|---|
| 244 | + public String getName() |
|---|
| 245 | + { |
|---|
| 246 | + return "List"; |
|---|
| 247 | + } |
|---|
| 248 | + |
|---|
| 249 | + static class ArrayRenderer extends DefaultTableCellRenderer |
|---|
| 250 | + { |
|---|
| 251 | + |
|---|
| 252 | + public void setValue(Object value) |
|---|
| 253 | + { |
|---|
| 254 | + setText(Display.arrayToString((Object[]) value)); |
|---|
| 255 | + } |
|---|
| 256 | + } |
|---|
| 257 | + |
|---|
| 258 | + public class LinkIt implements HyperlinkListener |
|---|
| 259 | + { |
|---|
| 260 | + |
|---|
| 261 | + public void hyperlinkUpdate(HyperlinkEvent e) |
|---|
| 262 | + { |
|---|
| 263 | + if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) |
|---|
| 264 | + { |
|---|
| 265 | + return; |
|---|
| 266 | + } |
|---|
| 267 | + |
|---|
| 268 | + String s = e.getDescription(); |
|---|
| 269 | + System.out.println(s); |
|---|
| 270 | + if (s.length() > 0) |
|---|
| 271 | + { |
|---|
| 272 | + char c = s.charAt(0); |
|---|
| 273 | + if (c == 'e') // code for "edit" |
|---|
| 274 | + { |
|---|
| 275 | + int i = Integer.parseInt(s.substring(1)); |
|---|
| 276 | + EditRecordPanel.edit(getModel(), acts.get(i)); |
|---|
| 277 | + return; |
|---|
| 278 | + } |
|---|
| 279 | + |
|---|
| 280 | + } |
|---|
| 281 | + Display.launchBrowser(e.getURL().toString()); |
|---|
| 282 | + |
|---|
| 283 | + } |
|---|
| 284 | + } |
|---|
| 266 | 285 | } |
|---|