1 | |
package org.jtheque.core.managers.view; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
import org.jtheque.core.managers.Managers; |
20 | |
import org.jtheque.core.managers.language.ILanguageManager; |
21 | |
import org.jtheque.core.managers.view.able.IViewManager; |
22 | |
|
23 | |
import javax.swing.JTabbedPane; |
24 | |
import javax.swing.event.ChangeEvent; |
25 | |
import javax.swing.event.ChangeListener; |
26 | |
import java.awt.event.WindowAdapter; |
27 | |
import java.awt.event.WindowEvent; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | public final class MainController extends WindowAdapter implements ChangeListener { |
35 | |
@Override |
36 | |
public void stateChanged(ChangeEvent event) { |
37 | 0 | JTabbedPane tabbedPane = (JTabbedPane) event.getSource(); |
38 | |
|
39 | 0 | int index = tabbedPane.getSelectedIndex(); |
40 | |
|
41 | 0 | if (index == -1) { |
42 | 0 | Managers.getCore().getLifeCycleManager().setCurrentFunction(""); |
43 | |
} else { |
44 | 0 | Managers.getCore().getLifeCycleManager().setCurrentFunction(tabbedPane.getTitleAt(index)); |
45 | |
} |
46 | 0 | } |
47 | |
|
48 | |
@Override |
49 | |
public void windowClosing(WindowEvent e) { |
50 | 0 | boolean yes = Managers.getManager(IViewManager.class).askUserForConfirmation( |
51 | |
Managers.getManager(ILanguageManager.class).getMessage("dialogs.confirm.exit", |
52 | |
Managers.getCore().getApplication().getName()), |
53 | |
Managers.getManager(ILanguageManager.class).getMessage("dialogs.confirm.exit.title", |
54 | |
Managers.getCore().getApplication().getName())); |
55 | |
|
56 | 0 | if (yes) { |
57 | 0 | Managers.getCore().getLifeCycleManager().exit(); |
58 | |
} |
59 | 0 | } |
60 | |
} |