1 | // Copyright 2004-2007 Jean-Francois Poilpret |
2 | // |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | // you may not use this file except in compliance with the License. |
5 | // You may obtain a copy of the License at |
6 | // |
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | // |
9 | // Unless required by applicable law or agreed to in writing, software |
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | // See the License for the specific language governing permissions and |
13 | // limitations under the License. |
14 | |
15 | package net.sourceforge.hiveboard.command; |
16 | |
17 | import org.jdesktop.application.Action; |
18 | import org.jdesktop.application.Task; |
19 | |
20 | import net.sourceforge.hivegui.message.UserChoice; |
21 | |
22 | public class AccountCommands extends AbstractCommandHolder |
23 | { |
24 | @Action(enabledProperty = SELF_ADMIN) |
25 | public void createAccount() |
26 | { |
27 | showDialog("create-account-panel"); |
28 | } |
29 | |
30 | @Action(enabledProperty = ACCOUNT_MODIFIABLE, block = Task.BlockingScope.WINDOW) |
31 | public Task destroyAccount() |
32 | { |
33 | if (showMessage("confirm-destroy-account", |
34 | _guiContext.getAccount().getVisa()) == UserChoice.YES) |
35 | { |
36 | final int id = _guiContext.getAccount().getId(); |
37 | return new AbstractTask<Void, Void>(_application) |
38 | { |
39 | @Override protected Void doInBackground() throws Exception |
40 | { |
41 | _service.removeAccount(id); |
42 | return null; |
43 | } |
44 | }; |
45 | } |
46 | else |
47 | { |
48 | return null; |
49 | } |
50 | } |
51 | |
52 | @Action(enabledProperty = ACCOUNT_MODIFIABLE) |
53 | public void modifyAccount() |
54 | { |
55 | showDialog("modify-account-panel", _guiContext.getAccount()); |
56 | } |
57 | |
58 | @Action(enabledProperty = ACCOUNT_MODIFIABLE) |
59 | public void changePassword() |
60 | { |
61 | showDialog("change-account-password-panel", _guiContext.getAccount()); |
62 | } |
63 | } |