Mercurial Hosting > junotu
annotate src/junotu/TabEdit.java @ 68:c6b1b4def7c1
Allowing to edit and create cards in a new window..
and adjusted search refreshes to work better with multiple windows.
To edit a card in a new window, click the card or the new card button while holding the SHIFT key.
author | Fox |
---|---|
date | Sat, 24 Dec 2022 01:49:57 +0100 |
parents | 4dd7d78e19a1 |
children | dfedca84c36b |
rev | line source |
---|---|
1 | 1 package junotu; |
2 | |
3 import java.awt.Dimension; | |
4 import java.awt.Font; | |
8 | 5 import java.awt.event.ActionEvent; |
6 import java.awt.event.ActionListener; | |
32 | 7 import java.awt.event.InputEvent; |
8 import java.awt.event.KeyEvent; | |
15 | 9 import java.awt.event.FocusEvent; |
10 import java.awt.event.FocusListener; | |
1 | 11 |
32 | 12 import javax.swing.KeyStroke; |
13 | 13 import javax.swing.SwingUtilities; |
9
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
14 import javax.swing.event.DocumentListener; |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
15 import javax.swing.event.DocumentEvent; |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
16 |
1 | 17 import javax.swing.JPanel; |
18 | |
19 import java.awt.BorderLayout; | |
15 | 20 import java.awt.FlowLayout; |
1 | 21 |
22 import javax.swing.Box; | |
23 import javax.swing.JButton; | |
24 import javax.swing.JTextField; | |
25 import javax.swing.JTextArea; | |
26 import javax.swing.JScrollPane; | |
13 | 27 import javax.swing.JScrollBar; |
1 | 28 |
8 | 29 import junotu.Main; |
30 import junotu.Database; | |
31 import junotu.Window.Tab; | |
15 | 32 import junotu.GUIToolbox; |
14 | 33 import junotu.Card; |
8 | 34 |
44 | 35 public class TabEdit extends JPanel implements ActionListener { |
8 | 36 |
44 | 37 private class TagWidget extends JButton implements ActionListener { |
15 | 38 |
39 public String tag; | |
40 public Object value; | |
41 | |
42 public TagWidget( String tag, Object value ) { | |
43 super(); | |
44 this.tag = tag; | |
45 this.value = value; | |
52 | 46 this.setToolTipText("Click to edit this tag. Use ':' to delimit name and value."); |
44 | 47 |
48 addActionListener(this); | |
15 | 49 |
50 update(); | |
51 } | |
52 | |
53 public void update() | |
54 { | |
55 if( value != null ) { | |
56 setText( tag+": "+value.toString() ); | |
57 } else { | |
58 setText( tag ); | |
59 } | |
60 } | |
44 | 61 |
62 public void actionPerformed( ActionEvent e ) | |
63 { | |
45 | 64 /* Not exactly sure how this works, but it does. */ |
44 | 65 tagEdit( this ); |
66 } | |
15 | 67 |
68 } | |
45 | 69 |
70 private final String KEY_ACTION_BACK = "back"; | |
71 private final String KEY_ACTION_SAVE = "save"; | |
15 | 72 |
73 private Card card = null; | |
8 | 74 private boolean newCard = true; |
15 | 75 |
76 private TagWidget editedTag = null; | |
77 private JTextField editedTagField; | |
8 | 78 |
13 | 79 private JScrollPane scroll; |
80 | |
8 | 81 private JTextField title; |
82 private JTextArea content; | |
15 | 83 private JPanel tags; |
84 private JButton addTag; | |
12 | 85 |
44 | 86 private JButton back; |
13 | 87 private JButton delete; |
59
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
88 private JButton editAsBoard; |
44 | 89 private JButton save; |
90 | |
8 | 91 |
1 | 92 public TabEdit() |
93 { | |
94 this.setLayout( new BorderLayout() ); | |
95 | |
20 | 96 JPanel scrollContent = new JPanel( new GUIToolbox.CardEditLayout() ); |
15 | 97 scroll = new JScrollPane( scrollContent ); |
98 title = new JTextField(); | |
99 content = new JTextArea(); | |
100 tags = new JPanel(); | |
101 editedTagField = new JTextField(); | |
102 addTag = new JButton("+"); | |
1 | 103 |
44 | 104 Box bottom = Box.createHorizontalBox(); |
59
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
105 back = new JButton("Cancel"); |
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
106 delete = new JButton("Delete"); |
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
107 editAsBoard = new JButton("As board"); |
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
108 save = new JButton("Save"); |
1 | 109 |
15 | 110 tags.setLayout( new FlowLayout() ); |
111 | |
1 | 112 title.setFont( new Font( "Monospaced", Font.PLAIN, 32 ) ); |
113 content.setFont( new Font( "Monospaced", Font.PLAIN, 16 ) ); | |
15 | 114 editedTagField.setFont( new Font( "Monospaced", Font.PLAIN, 12 ) ); |
1 | 115 |
116 scroll.getVerticalScrollBar().setUnitIncrement(16); | |
117 | |
15 | 118 title.setMaximumSize( new Dimension( Integer.MAX_VALUE, 64 ) ); |
119 //content.setMaximumSize( new Dimension( Integer.MAX_VALUE, Integer.MAX_VALUE ) ); | |
20 | 120 content.setLineWrap( true ); |
15 | 121 /* TODO: Figure out tags layout mess. */ |
24
b66fc08656c1
TabEdit: commented out lines that seem to have no effect
Fox
parents:
20
diff
changeset
|
122 //tags.setPreferredSize( new Dimension( 16, 256 ) ); |
b66fc08656c1
TabEdit: commented out lines that seem to have no effect
Fox
parents:
20
diff
changeset
|
123 //tags.setMaximumSize( new Dimension( Integer.MAX_VALUE, Integer.MAX_VALUE ) ); |
1 | 124 |
125 this.add( scroll, BorderLayout.CENTER ); | |
126 scrollContent.add( title ); | |
20 | 127 //scrollContent.add( Box.createVerticalStrut(10) ); |
1 | 128 scrollContent.add( content ); |
15 | 129 scrollContent.add( tags ); |
1 | 130 |
131 this.add( bottom, BorderLayout.SOUTH ); | |
132 bottom.add( back ); | |
133 bottom.add( Box.createHorizontalGlue() ); | |
12 | 134 bottom.add( delete ); |
59
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
135 bottom.add( editAsBoard ); |
1 | 136 bottom.add( save ); |
137 | |
138 //scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); | |
9
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
139 |
44 | 140 back.addActionListener(this); |
141 delete.addActionListener(this); | |
59
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
142 editAsBoard.addActionListener(this); |
44 | 143 save.addActionListener(this); |
144 addTag.addActionListener(this); | |
15 | 145 |
146 editedTagField.addFocusListener( | |
147 new FocusListener() | |
148 { | |
149 @Override | |
150 public void focusGained(FocusEvent e) | |
151 { | |
152 } | |
153 | |
154 @Override | |
155 public void focusLost(FocusEvent e) | |
156 { | |
157 tagCommit(); | |
158 } | |
159 } | |
160 ); | |
9
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
161 |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
162 title.getDocument().addDocumentListener( |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
163 new DocumentListener() |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
164 { |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
165 @Override |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
166 public void changedUpdate( DocumentEvent e ) |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
167 { |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
168 updateTitle(); |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
169 } |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
170 @Override |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
171 public void removeUpdate( DocumentEvent e ) |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
172 { |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
173 updateTitle(); |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
174 } |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
175 @Override |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
176 public void insertUpdate( DocumentEvent e ) |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
177 { |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
178 updateTitle(); |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
179 } |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
180 } |
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
181 ); |
32 | 182 |
45 | 183 registerKeyboardAction( this, KEY_ACTION_BACK, KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0 ), WHEN_IN_FOCUSED_WINDOW ); |
184 registerKeyboardAction( this, KEY_ACTION_SAVE, KeyStroke.getKeyStroke( KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK ), WHEN_IN_FOCUSED_WINDOW ); | |
52 | 185 |
186 title.setToolTipText("Card title."); | |
187 back.setToolTipText("Go back without saving. Can also use [ESC]."); | |
188 delete.setToolTipText("Delete the card. There is no confirmation, nor going back."); | |
59
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
189 editAsBoard.setToolTipText("Edit this card as board."); |
52 | 190 save.setToolTipText("Save and go back. Shift-click to save without exiting. Can also use [CTRL]+[S]."); |
191 | |
192 addTag.setToolTipText("Add new tag."); | |
1 | 193 |
194 } | |
8 | 195 |
13 | 196 private void scrollTop() |
197 { | |
198 JScrollBar scrollbar = scroll.getVerticalScrollBar(); | |
199 scrollbar.setValue(0); | |
200 } | |
201 | |
202 private void scrollBottom() | |
203 { | |
204 JScrollBar scrollbar = scroll.getVerticalScrollBar(); | |
205 int maximum = scrollbar.getMaximum()-scrollbar.getVisibleAmount(); | |
206 scrollbar.setValue(maximum); | |
207 } | |
208 | |
8 | 209 public void cardCreate() |
210 { | |
211 newCard = true; | |
15 | 212 card = new Card(); |
9
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
213 updateTitle(); |
12 | 214 delete.setVisible(false); |
15 | 215 updateTags(); |
8 | 216 } |
217 | |
218 public void cardEdit( Card card ) | |
219 { | |
220 newCard = false; | |
15 | 221 this.card = card; |
14 | 222 title.setText( card.titleGet() ); |
223 content.setText( card.contentGet() ); | |
9
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
224 updateTitle(); |
12 | 225 delete.setVisible(true); |
15 | 226 updateTags(); |
13 | 227 SwingUtilities.invokeLater( |
228 new Runnable() | |
229 { | |
230 public void run() | |
231 { | |
232 scrollTop(); | |
233 } | |
234 } | |
235 ); | |
8 | 236 } |
237 | |
15 | 238 private void reset() |
8 | 239 { |
240 title.setText(""); | |
241 content.setText(""); | |
15 | 242 card = null; |
243 } | |
244 | |
16 | 245 private void updateTitle() |
246 { | |
247 Window window = (Window)this.getTopLevelAncestor(); | |
248 | |
249 String text = title.getText(); | |
250 String action = newCard ? "Create" : "Edit"; | |
251 | |
252 if( text.length() > 0 ) { | |
253 window.setTitle( window.preferredTitle( action+": "+text ) ); | |
254 } else { | |
255 window.setTitle( window.preferredTitle( action ) ); | |
256 } | |
257 | |
258 } | |
259 | |
15 | 260 private void updateTags() |
261 { | |
262 tags.removeAll(); | |
263 for( String tag : card.tagNames() ) { | |
16 | 264 if( tag.startsWith("_") ) { |
265 continue; | |
266 } | |
15 | 267 for( Object value : card.tagValues( tag ) ) { |
268 tags.add( new TagWidget( tag, value ) ); | |
269 } | |
270 } | |
271 tags.add( addTag ); | |
272 tags.validate(); | |
273 tags.repaint(); | |
274 } | |
275 | |
276 private void tagAdd() | |
277 { | |
278 tags.add( editedTagField, GUIToolbox.componentGetIndex( addTag ) ); | |
279 editedTagField.setText( "" ); | |
280 editedTagField.setColumns(12); | |
281 editedTagField.grabFocus(); | |
282 tags.validate(); | |
283 tags.repaint(); | |
284 System.out.print( "Opened new tag for editing.\n" ); | |
285 } | |
286 | |
287 private void tagEdit( TagWidget tagWidget ) | |
288 { | |
289 editedTag = tagWidget; | |
290 tags.add( editedTagField, GUIToolbox.componentGetIndex( editedTag ) ); | |
291 if( editedTag.value != null ) { | |
292 editedTagField.setText( editedTag.tag+":"+editedTag.value.toString() ); | |
293 } else { | |
294 editedTagField.setText( editedTag.tag ); | |
295 } | |
296 editedTagField.setColumns(0); | |
297 editedTagField.grabFocus(); | |
298 editedTag.setVisible(false); | |
299 tags.validate(); | |
300 tags.repaint(); | |
301 System.out.print( "Opened existing tag for editing.\n" ); | |
302 } | |
303 | |
304 private void tagCommit() | |
305 { | |
306 | |
307 String newTag; | |
308 Object newValue; | |
309 | |
310 { | |
311 String[] split = editedTagField.getText().split( ":", 2 ); | |
312 newTag = split[0]; | |
313 newValue = split.length > 1 ? split[1] : null; | |
314 } | |
315 | |
316 /* Either editing tag, or adding a new one. */ | |
317 if( editedTag != null ) { | |
318 | |
319 String oldTag = editedTag.tag; | |
320 Object oldValue = editedTag.value; | |
321 | |
322 logTagChange( oldTag, oldValue, newTag, newValue ); | |
323 | |
324 if( oldTag.equals(newTag) ) { | |
325 card.tagValueReplace( oldTag, oldValue, newValue ); | |
326 editedTag.value = newValue; | |
327 editedTag.update(); | |
328 } else { /* Replace tag with another one. */ | |
329 | |
330 card.tagValueRemove( oldTag, oldValue ); | |
331 card.tagValueAdd( newTag, newValue ); | |
332 | |
333 if( !newTag.equals("") ) { | |
334 editedTag.tag = newTag; | |
335 editedTag.value = newValue; | |
336 editedTag.update(); | |
337 } else { | |
338 tags.remove( editedTag ); | |
339 } | |
340 | |
341 } | |
342 | |
343 editedTag.setVisible( true ); | |
344 | |
345 } else { /* Adding new tag (value). */ | |
346 if( !newTag.equals("") ) { | |
347 card.tagValueAdd( newTag, newValue ); | |
348 tags.add( new TagWidget( newTag, newValue ), GUIToolbox.componentGetIndex( addTag )-1 ); | |
349 logTagChange( "", null, newTag, newValue ); | |
350 } else { | |
351 logTagChange( "", null, "", null ); | |
352 } | |
353 } | |
354 | |
355 editedTagField.setText( "" ); | |
356 tags.remove( editedTagField ); | |
357 | |
358 editedTag = null; | |
359 | |
360 tags.validate(); | |
361 tags.repaint(); | |
362 | |
363 } | |
364 | |
365 private void logTagChange( String oldTag, Object oldValue, String newTag, Object newValue ) | |
366 { | |
367 System.out.print( "Comitted changes to tag: " ); | |
368 if( oldTag.equals("") ) { /* Creating tag. */ | |
369 if( !newTag.equals("") ) { | |
370 if( newValue == null ) { /* No value. */ | |
371 System.out.print( "Added tag '"+newTag+"' (with no value)\n" ); | |
372 } else { /* Has value. */ | |
373 System.out.print( "Added tag '"+newTag+"' with value '"+newValue.toString()+"'\n" ); | |
374 } | |
375 } else { | |
376 System.out.print( "No changes.\n" ); | |
377 } | |
378 } else { /* Editing tag. */ | |
379 if( oldTag.equals(newTag) ) { /* Same tag. */ | |
380 if( oldValue == null ) { | |
381 if( newValue == null ) { /* Clear before, clear now. */ | |
382 System.out.print( "No changes (tag '"+oldTag+"' with no value)\n" ); | |
383 } else { /* Assigned value. */ | |
384 System.out.print( "Assigned value of tag '"+oldTag+"' to '"+newValue.toString()+"'\n" ); | |
385 } | |
386 } else { | |
387 if( newValue == null ) { /* Clearing value. */ | |
388 System.out.print( "Cleared value of tag '"+oldTag+"' (was '" | |
389 +oldValue.toString()+"')\n" ); | |
390 } else if( oldValue.equals(newValue) ) { /* Value is the same. */ | |
391 System.out.print( "No changes (tag '"+oldTag+"' with value '"+oldValue+"')\n" ); | |
392 } else { /* Changing value. */ | |
393 System.out.print( "Changed value of tag '"+oldTag+"' from '" | |
394 +oldValue.toString()+"' to '"+newValue.toString()+"'\n" ); | |
395 } | |
396 } | |
397 } else { /* Replaced tag. */ | |
398 if( newTag.equals("") ) { /* Removing tag. */ | |
399 if( oldValue == null ) { | |
400 System.out.print( "Removed tag '"+oldTag+"' (with no value)\n" ); | |
401 } else { | |
402 System.out.print( "Removed tag '"+oldTag+"' with value '"+oldValue.toString()+"'\n" ); | |
403 } | |
404 } else { | |
405 if( oldValue == null ) { | |
406 if( newValue == null ) { | |
407 System.out.print( | |
408 "Renamed tag '"+oldTag+"' -> '" | |
409 +newTag+"'\n" ); | |
410 } else { | |
411 System.out.print( | |
412 "Changed tag '"+oldTag+"' -> '" | |
413 +newTag+"': '"+newValue.toString()+"'\n" ); | |
414 } | |
415 } else { | |
416 if( newValue == null ) { | |
417 System.out.print( | |
418 "Changed tag '"+oldTag+"': '"+oldValue.toString()+"' -> '" | |
419 +newTag+"'\n" ); | |
420 } else { | |
421 System.out.print( | |
422 "Changed tag '"+oldTag+"': '"+oldValue.toString()+"' -> '" | |
423 +newTag+"': '"+newValue.toString()+"'\n" ); | |
424 } | |
425 } | |
426 } | |
427 } | |
428 } | |
8 | 429 } |
9
dd51276f95a2
Dynamically change window title on card edit tab to reflect card title
Fox
parents:
8
diff
changeset
|
430 |
16 | 431 |
8 | 432 private void buttonClickedBack() |
433 { | |
11 | 434 Window window = (Window)this.getTopLevelAncestor(); |
15 | 435 reset(); |
436 window.tabSwitch( Tab.SEARCH ); | |
8 | 437 } |
12 | 438 |
439 private void buttonClickedDelete() | |
440 { | |
441 | |
442 if( newCard ) { | |
443 return; | |
444 } | |
445 | |
65 | 446 Main.database.cardDeleteByIdentifier( card.identifierGet() ); |
12 | 447 |
448 Window window = (Window)this.getTopLevelAncestor(); | |
68 | 449 Main.refreshSearches(); |
15 | 450 reset(); |
12 | 451 window.tabSwitch( Tab.SEARCH ); |
452 | |
453 } | |
59
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
454 |
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
455 private void buttonClickedEditAsBoard() |
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
456 { |
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
457 Window window = (Window)this.getTopLevelAncestor(); |
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
458 |
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
459 buttonClickedSave(true); |
60 | 460 window.tabBoard.boardEdit(card); |
59
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
461 reset(); |
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
462 window.tabSwitch( Tab.BOARD ); |
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
463 } |
8 | 464 |
31
fb49a356458a
Control + save button click to save card and stay in edit mode
Fox
parents:
24
diff
changeset
|
465 private void buttonClickedSave( boolean noSwitch ) |
8 | 466 { |
467 | |
14 | 468 card.titleSet( title.getText() ); |
469 card.contentSet( content.getText() ); | |
8 | 470 |
63 | 471 if( newCard ) { |
472 Main.database.cardAdd( card ); | |
473 } else { | |
474 Main.database.cardUpdate( card ); | |
8 | 475 } |
476 | |
68 | 477 Main.refreshSearches(); |
31
fb49a356458a
Control + save button click to save card and stay in edit mode
Fox
parents:
24
diff
changeset
|
478 |
fb49a356458a
Control + save button click to save card and stay in edit mode
Fox
parents:
24
diff
changeset
|
479 if( noSwitch ) { |
fb49a356458a
Control + save button click to save card and stay in edit mode
Fox
parents:
24
diff
changeset
|
480 if( newCard ) { |
fb49a356458a
Control + save button click to save card and stay in edit mode
Fox
parents:
24
diff
changeset
|
481 cardEdit( this.card ); |
fb49a356458a
Control + save button click to save card and stay in edit mode
Fox
parents:
24
diff
changeset
|
482 } |
fb49a356458a
Control + save button click to save card and stay in edit mode
Fox
parents:
24
diff
changeset
|
483 } else { |
68 | 484 Window window = (Window)this.getTopLevelAncestor(); |
31
fb49a356458a
Control + save button click to save card and stay in edit mode
Fox
parents:
24
diff
changeset
|
485 reset(); |
fb49a356458a
Control + save button click to save card and stay in edit mode
Fox
parents:
24
diff
changeset
|
486 window.tabSwitch( Tab.SEARCH ); |
fb49a356458a
Control + save button click to save card and stay in edit mode
Fox
parents:
24
diff
changeset
|
487 } |
8 | 488 } |
44 | 489 |
490 public void actionPerformed( ActionEvent e ) | |
491 { | |
492 Object source = e.getSource(); | |
45 | 493 if( source == this ) { |
494 switch( e.getActionCommand() ) { | |
495 | |
496 case KEY_ACTION_BACK: { | |
497 buttonClickedBack(); | |
498 break; | |
499 } | |
500 | |
501 case KEY_ACTION_SAVE: { | |
502 buttonClickedSave( true ); | |
63 | 503 Main.database.databaseCommit(); |
45 | 504 break; |
505 } | |
506 | |
507 } | |
508 } else if( source == back ) { | |
44 | 509 buttonClickedBack(); |
59
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
510 } else if( source == editAsBoard ) { |
a2696310fa8c
Default to TabSearch search, and added a way to get to TabBoard from TabEdit
Fox
parents:
52
diff
changeset
|
511 buttonClickedEditAsBoard(); |
44 | 512 } else if( source == delete ) { |
513 buttonClickedDelete(); | |
514 } else if( source == save ) { | |
515 boolean noSwitch = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0; | |
516 buttonClickedSave( noSwitch ); | |
517 } else if( source == addTag ) { | |
518 tagAdd(); | |
519 } | |
520 } | |
8 | 521 |
1 | 522 } |