| 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.Account; | 
| 21 | import net.sourceforge.hiveboard.WhiteBoardUserService; | 
| 22 | import net.sourceforge.hivegui.application.HiveGuiApplicationMain; | 
| 23 |   | 
| 24 | /** | 
| 25 |  * This command is used from full screen mode by the popup menu item to set the | 
| 26 |  * writer of the current board. It is instantiated once for each participant of | 
| 27 |  * the board. | 
| 28 |  * | 
| 29 |  * @author Jean-Francois Poilpret | 
| 30 |  */ | 
| 31 | public class GeneralSetWriter | 
| 32 | { | 
| 33 |         static public javax.swing.Action        createAction(        HiveGuiApplicationMain        application, | 
| 34 |                                                                                                                 WhiteBoardUserService        service, | 
| 35 |                                                                                                                 Account                                        who, | 
| 36 |                                                                                                                 int                                                where) | 
| 37 |         { | 
| 38 |                 GeneralSetWriter target = new GeneralSetWriter(application, service, who, where); | 
| 39 |                 javax.swing.Action action; | 
| 40 |                 action = application.getContext().getActionMap(target).get("setWriter"); | 
| 41 |                 return action; | 
| 42 |         } | 
| 43 |   | 
| 44 |         public GeneralSetWriter(HiveGuiApplicationMain        application, | 
| 45 |                                                         WhiteBoardUserService        service, | 
| 46 |                                                         Account                                        who, | 
| 47 |                                                         int                                                where) | 
| 48 |         { | 
| 49 |                 _application = application; | 
| 50 |                 _service = service; | 
| 51 |                 _where = where; | 
| 52 |                 _who = who.getId(); | 
| 53 |         } | 
| 54 |   | 
| 55 |         @Action(block = Task.BlockingScope.WINDOW) | 
| 56 |         public Task setWriter() | 
| 57 |         { | 
| 58 |                 return new AbstractTask(_application) | 
| 59 |                 { | 
| 60 |                         @Override protected Void doInBackground() throws Exception | 
| 61 |                         { | 
| 62 |                                 _service.giveToken(_where, _who); | 
| 63 |                                 return null; | 
| 64 |                         } | 
| 65 |                 }; | 
| 66 |         } | 
| 67 |   | 
| 68 |         private final HiveGuiApplicationMain        _application; | 
| 69 |         private final WhiteBoardUserService                _service; | 
| 70 |         private final int                                                _who; | 
| 71 |         private final int                                                _where; | 
| 72 | } |