My favorites | Sign in
Project Home Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
*
*/
package com.googlecode.pennybank.swing.controller.actions;

import com.googlecode.pennybank.model.account.entity.Account;
import com.googlecode.pennybank.swing.view.main.MainContentPanel;
import com.googlecode.pennybank.swing.view.main.MainNavigationPanel;
import com.googlecode.pennybank.swing.view.main.MainWindow;

/**
* Generic action implementation providing common behavior for all the actions.
* A template pattern is employed, so each action must override specific
* doExecute, doRedo, doUndo and doGetName methods. The execute, redo, undo and
* getName methods are marked as final, so the extending classes doesn't
* override them.
*
* @author spenap
*
*/
public abstract class GenericAction implements UIAction {

public final boolean execute() {
boolean value = doExecute();
update();
return value;
}

public final String getName() {
return doGetName();
}

public final void redo() {
doRedo();
update();
}

public final void undo() {
doUndo();
update();
}

private void update() {
Account selectedAccount = null;
MainNavigationPanel navigationPanel = null;
MainContentPanel contentPanel = null;

navigationPanel = MainWindow.getInstance().getNavigationPanel();
contentPanel = MainWindow.getInstance().getContentPanel();
selectedAccount = navigationPanel.getSelectedAccount();

navigationPanel.update();
if (selectedAccount != null)
contentPanel.showAccountOperations(selectedAccount);
}

protected abstract boolean doExecute();

protected abstract String doGetName();

protected abstract void doRedo();

protected abstract void doUndo();

}

Change log

r27 by bulfaiter on Apr 11, 2009   Diff
Adding, editing and removing account
operations works now. Deleting multiple
account operations at a time can be undone
in a single operation, too (without
reversing the deletion of every single
operation)

From the last commit log, the last
sentence still applies:

The actions must return an execution
result, which is still missing. Common
...
Go to: 
Project members, sign in to write a code review

Older revisions

r26 by bulfaiter on Apr 9, 2009   Diff
The menu bar is now completed. Every
action in the user interface is fully
accessible, whether from the main menu
bar or from the context menu. Besides,
the Edit Menu gets its "delete" menu
...
All revisions of this file

File info

Size: 1624 bytes, 65 lines

File properties

svn:mime-type
text/plain
Powered by Google Project Hosting