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.hiveboard.util.Participant; |
21 | import net.sourceforge.hivegui.message.UserChoice; |
22 | |
23 | public class ParticipantCommands extends AbstractCommandHolder |
24 | { |
25 | @Action(enabledProperty = PARTICIPANT_TOKEN_SETTABLE, block = Task.BlockingScope.WINDOW) |
26 | public Task setParticipantWriter() |
27 | { |
28 | final Participant current = _guiContext.getParticipant(); |
29 | return new AbstractTask<Void, Void>(_application) |
30 | { |
31 | @Override protected Void doInBackground() throws Exception |
32 | { |
33 | _service.giveToken(current.getBoard().getId(), current.getAccount().getId()); |
34 | return null; |
35 | } |
36 | }; |
37 | } |
38 | |
39 | @Action(enabledProperty = PARTICIPANT_REMOVABLE, block = Task.BlockingScope.WINDOW) |
40 | public Task removeParticipant() |
41 | { |
42 | final Participant current = _guiContext.getParticipant(); |
43 | // Get initiator's confirmation if participant is currently present |
44 | if (current.isPresent()) |
45 | { |
46 | UserChoice choice = showMessage("confirm-remove-participant", |
47 | current.getAccount().getVisa(), |
48 | current.getBoard().getName()); |
49 | if (choice == UserChoice.CANCEL) |
50 | { |
51 | return null; |
52 | } |
53 | } |
54 | return new AbstractTask<Void, Void>(_application) |
55 | { |
56 | @Override protected Void doInBackground() throws Exception |
57 | { |
58 | _service.removeParticipant( current.getBoard().getId(), |
59 | current.getAccount().getId()); |
60 | return null; |
61 | } |
62 | }; |
63 | } |
64 | } |