| 1 |
|
package net.oni2.aeinstaller.gui; |
| 2 |
|
|
| 3 |
|
import java.awt.BorderLayout; |
| 4 |
+ |
import java.awt.Component; |
| 5 |
|
import java.awt.Desktop; |
| 6 |
|
import java.awt.GridLayout; |
| 7 |
+ |
import java.awt.KeyEventDispatcher; |
| 8 |
+ |
import java.awt.KeyboardFocusManager; |
| 9 |
|
import java.awt.Toolkit; |
| 10 |
|
import java.awt.datatransfer.Clipboard; |
| 11 |
|
import java.awt.datatransfer.StringSelection; |
| 93 |
|
* @author Christian Illy |
| 94 |
|
*/ |
| 95 |
|
public class MainWin extends JFrame implements ApplicationListener, |
| 96 |
< |
ModInstallSelectionListener, ModSelectionListener { |
| 96 |
> |
ModInstallSelectionListener, ModSelectionListener, KeyEventDispatcher { |
| 97 |
|
private static final long serialVersionUID = -4027395051382659650L; |
| 98 |
|
|
| 99 |
|
private ResourceBundle bundle = UTF8ResourceBundleLoader |
| 183 |
|
tblMods.addModSelectionListener(this); |
| 184 |
|
tblMods.addDownloadSizeListener(this); |
| 185 |
|
|
| 186 |
+ |
KeyboardFocusManager.getCurrentKeyboardFocusManager() |
| 187 |
+ |
.addKeyEventDispatcher(this); |
| 188 |
+ |
|
| 189 |
|
setSize(SettingsManager.getInstance().get("win_main_width", 1050), |
| 190 |
|
SettingsManager.getInstance().get("win_main_height", 600)); |
| 191 |
|
setLocationRelativeTo(null); |
| 577 |
|
}); |
| 578 |
|
} |
| 579 |
|
|
| 574 |
– |
@SuppressWarnings("unused") |
| 580 |
|
private void refreshLocalMods() { |
| 581 |
|
PackageManager.getInstance().updateLocalData(); |
| 582 |
|
tblMods.reloadData(); |
| 1017 |
|
} |
| 1018 |
|
} |
| 1019 |
|
|
| 1020 |
+ |
private boolean componentBelongsToWindow(Component c) { |
| 1021 |
+ |
while (c != null) { |
| 1022 |
+ |
if (c == this) |
| 1023 |
+ |
return true; |
| 1024 |
+ |
c = c.getParent(); |
| 1025 |
+ |
} |
| 1026 |
+ |
return false; |
| 1027 |
+ |
} |
| 1028 |
+ |
|
| 1029 |
+ |
@Override |
| 1030 |
+ |
public boolean dispatchKeyEvent(KeyEvent e) { |
| 1031 |
+ |
if (e.getID() == KeyEvent.KEY_PRESSED) { |
| 1032 |
+ |
switch (e.getKeyCode()) { |
| 1033 |
+ |
case KeyEvent.VK_F5: |
| 1034 |
+ |
if (componentBelongsToWindow(e.getComponent())) |
| 1035 |
+ |
refreshLocalMods(); |
| 1036 |
+ |
return true; |
| 1037 |
+ |
} |
| 1038 |
+ |
} |
| 1039 |
+ |
return false; |
| 1040 |
+ |
} |
| 1041 |
+ |
|
| 1042 |
|
@Override |
| 1043 |
|
public void handleAbout(ApplicationEvent event) { |
| 1044 |
|
event.setHandled(true); |