jaroslav@268
|
1 |
/**
|
jaroslav@268
|
2 |
* Quoridor server and related libraries
|
jaroslav@268
|
3 |
* Copyright (C) 2009-2010 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
|
jaroslav@268
|
4 |
*
|
jaroslav@268
|
5 |
* This program is free software: you can redistribute it and/or modify
|
jaroslav@268
|
6 |
* it under the terms of the GNU General Public License as published by
|
jaroslav@268
|
7 |
* the Free Software Foundation, either version 3 of the License.
|
jaroslav@268
|
8 |
*
|
jaroslav@268
|
9 |
* This program is distributed in the hope that it will be useful,
|
jaroslav@268
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
jaroslav@268
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
jaroslav@268
|
12 |
* GNU General Public License for more details.
|
jaroslav@268
|
13 |
*
|
jaroslav@268
|
14 |
* You should have received a copy of the GNU General Public License
|
jaroslav@268
|
15 |
* along with this program. Look for COPYING file in the top folder.
|
jaroslav@268
|
16 |
* If not, see http://www.gnu.org/licenses/.
|
jaroslav@263
|
17 |
*/
|
jaroslav@268
|
18 |
|
jaroslav@263
|
19 |
package cz.xelfi.quoridor.desktop.sample;
|
jaroslav@263
|
20 |
|
jaroslav@263
|
21 |
import java.awt.event.ActionEvent;
|
jaroslav@263
|
22 |
import java.awt.event.ActionListener;
|
jaroslav@263
|
23 |
import org.openide.DialogDisplayer;
|
jaroslav@263
|
24 |
import org.openide.NotifyDescriptor;
|
jaroslav@263
|
25 |
import org.openide.util.NbBundle;
|
jaroslav@263
|
26 |
|
jaroslav@263
|
27 |
public final class LoginAction implements ActionListener {
|
jaroslav@263
|
28 |
|
jaroslav@263
|
29 |
@Override
|
jaroslav@263
|
30 |
public void actionPerformed(ActionEvent e) {
|
jaroslav@263
|
31 |
LoginPanel lp = new LoginPanel();
|
jaroslav@263
|
32 |
NotifyDescriptor nd = new NotifyDescriptor(
|
jaroslav@263
|
33 |
lp,
|
jaroslav@263
|
34 |
NbBundle.getMessage(LoginAction.class, "LoginAction.title"),
|
jaroslav@263
|
35 |
NotifyDescriptor.OK_CANCEL_OPTION,
|
jaroslav@263
|
36 |
NotifyDescriptor.QUESTION_MESSAGE, null, null
|
jaroslav@263
|
37 |
);
|
jaroslav@263
|
38 |
Object res = DialogDisplayer.getDefault().notify(nd);
|
jaroslav@263
|
39 |
if (res == NotifyDescriptor.OK_OPTION) {
|
jaroslav@263
|
40 |
if (!Quoridor.getDefault().login(lp.getLogin(), lp.getPassword())) {
|
jaroslav@263
|
41 |
nd = new NotifyDescriptor.Message(
|
jaroslav@263
|
42 |
NbBundle.getMessage(LoginAction.class, "LoginAction.fail")
|
jaroslav@263
|
43 |
);
|
jaroslav@263
|
44 |
DialogDisplayer.getDefault().notify(nd);
|
jaroslav@263
|
45 |
}
|
jaroslav@263
|
46 |
}
|
jaroslav@263
|
47 |
}
|
jaroslav@263
|
48 |
}
|