Skip to content

Commit

Permalink
Merge a0708ab into b2f41e9
Browse files Browse the repository at this point in the history
  • Loading branch information
bjzhou committed Aug 24, 2016
2 parents b2f41e9 + a0708ab commit 0666e94
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 66 deletions.
10 changes: 4 additions & 6 deletions jadx-gui/src/main/java/jadx/gui/ui/CodePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
import jadx.gui.treemodel.JNode;
import jadx.gui.utils.Utils;

import javax.swing.AbstractAction;
import javax.swing.JScrollPane;
import javax.swing.KeyStroke;
import java.awt.BorderLayout;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;

class CodePanel extends ContentPanel {
Expand All @@ -32,7 +29,8 @@ class CodePanel extends ContentPanel {
add(searchBar, BorderLayout.NORTH);
add(scrollPane);

KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK);
int shortcut = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_F, shortcut);
Utils.addKeyBinding(codeArea, key, "SearchAction", new SearchAction());
}

Expand Down
78 changes: 20 additions & 58 deletions jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,66 +15,27 @@
import jadx.gui.update.JadxUpdate;
import jadx.gui.update.JadxUpdate.IUpdateCallback;
import jadx.gui.update.data.Release;
import jadx.gui.utils.CacheObject;
import jadx.gui.utils.Link;
import jadx.gui.utils.NLS;
import jadx.gui.utils.Position;
import jadx.gui.utils.Utils;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JToggleButton;
import javax.swing.JToolBar;
import javax.swing.JTree;
import javax.swing.ProgressMonitor;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import jadx.gui.utils.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.swing.*;
import javax.swing.event.MenuEvent;
import javax.swing.event.MenuListener;
import javax.swing.event.TreeExpansionEvent;
import javax.swing.event.TreeWillExpandListener;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.ExpandVetoException;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.DisplayMode;
import java.awt.Font;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.DropTarget;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.*;
import java.io.File;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.Timer;
import java.util.TimerTask;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static javax.swing.KeyStroke.getKeyStroke;

@SuppressWarnings("serial")
Expand Down Expand Up @@ -346,14 +307,15 @@ private void syncWithEditor() {
}

private void initMenuAndToolbar() {
int shortcut = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
Action openAction = new AbstractAction(NLS.str("file.open"), ICON_OPEN) {
@Override
public void actionPerformed(ActionEvent e) {
openFile();
}
};
openAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.open"));
openAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK));
openAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_O, shortcut));

Action saveAllAction = new AbstractAction(NLS.str("file.save_all"), ICON_SAVE_ALL) {
@Override
Expand All @@ -362,7 +324,7 @@ public void actionPerformed(ActionEvent e) {
}
};
saveAllAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.save_all"));
saveAllAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK));
saveAllAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_S, shortcut));

Action exportAction = new AbstractAction(NLS.str("file.export_gradle"), ICON_EXPORT) {
@Override
Expand All @@ -371,7 +333,7 @@ public void actionPerformed(ActionEvent e) {
}
};
exportAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.export_gradle"));
exportAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_DOWN_MASK));
exportAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_E, shortcut));

JMenu recentFiles = new JMenu(NLS.str("menu.recent_files"));
recentFiles.addMenuListener(new RecentFilesMenuListener(recentFiles));
Expand All @@ -384,7 +346,7 @@ public void actionPerformed(ActionEvent e) {
};
prefsAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.preferences"));
prefsAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_P,
KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
shortcut | KeyEvent.SHIFT_DOWN_MASK));

Action exitAction = new AbstractAction(NLS.str("file.exit"), ICON_CLOSE) {
@Override
Expand All @@ -404,7 +366,7 @@ public void actionPerformed(ActionEvent e) {
}
};
syncAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.sync"));
syncAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_DOWN_MASK));
syncAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_T, shortcut));

Action textSearchAction = new AbstractAction(NLS.str("menu.text_search"), ICON_SEARCH) {
@Override
Expand All @@ -414,7 +376,7 @@ public void actionPerformed(ActionEvent e) {
};
textSearchAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.text_search"));
textSearchAction.putValue(Action.ACCELERATOR_KEY,
getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
getKeyStroke(KeyEvent.VK_F, shortcut | KeyEvent.SHIFT_DOWN_MASK));

Action clsSearchAction = new AbstractAction(NLS.str("menu.class_search"), ICON_FIND) {
@Override
Expand All @@ -423,7 +385,7 @@ public void actionPerformed(ActionEvent e) {
}
};
clsSearchAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.class_search"));
clsSearchAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK));
clsSearchAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_N, shortcut));

Action deobfAction = new AbstractAction(NLS.str("preferences.deobfuscation"), ICON_DEOBF) {
@Override
Expand All @@ -433,7 +395,7 @@ public void actionPerformed(ActionEvent e) {
};
deobfAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("preferences.deobfuscation"));
deobfAction.putValue(Action.ACCELERATOR_KEY,
getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
getKeyStroke(KeyEvent.VK_D, shortcut | KeyEvent.ALT_DOWN_MASK));

deobfToggleBtn = new JToggleButton(deobfAction);
deobfToggleBtn.setSelected(settings.isDeobfuscationOn());
Expand All @@ -450,7 +412,7 @@ public void actionPerformed(ActionEvent e) {
};
logAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.log"));
logAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_L,
KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
shortcut | KeyEvent.SHIFT_DOWN_MASK));

Action aboutAction = new AbstractAction(NLS.str("menu.about")) {
@Override
Expand All @@ -467,7 +429,7 @@ public void actionPerformed(ActionEvent e) {
};
backAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("nav.back"));
backAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_LEFT,
KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
shortcut | KeyEvent.ALT_DOWN_MASK));

Action forwardAction = new AbstractAction(NLS.str("nav.forward"), ICON_FORWARD) {
@Override
Expand All @@ -477,7 +439,7 @@ public void actionPerformed(ActionEvent e) {
};
forwardAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("nav.forward"));
forwardAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_RIGHT,
KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
shortcut | KeyEvent.ALT_DOWN_MASK));

JMenu file = new JMenu(NLS.str("menu.file"));
file.setMnemonic(KeyEvent.VK_F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ void addPopupItems() {
}

private void addKeyActions() {
KeyStroke undoKey = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK);
int shortcut = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
KeyStroke undoKey = KeyStroke.getKeyStroke(KeyEvent.VK_Z, shortcut);
textComponent.getInputMap().put(undoKey, undoAction);
KeyStroke redoKey = KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_MASK);
KeyStroke redoKey = KeyStroke.getKeyStroke(KeyEvent.VK_R, shortcut);
textComponent.getInputMap().put(redoKey, redoAction);
}

Expand Down

0 comments on commit 0666e94

Please sign in to comment.