mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 04:50:46 +00:00
Find declaration menuItem,
AS Highlighter - forward declarations
This commit is contained in:
@@ -711,16 +711,42 @@ public class View {
|
||||
a.putValue(Action.ACCELERATOR_KEY, ks);
|
||||
a.putValue(Action.NAME, name);
|
||||
|
||||
String actionName = key;
|
||||
ActionMap amap = editor.getActionMap();
|
||||
InputMap imap = editor.getInputMap(JTextComponent.WHEN_FOCUSED);
|
||||
imap.put(ks, actionName);
|
||||
amap.put(actionName, a);
|
||||
imap.put(ks, key);
|
||||
amap.put(key, a);
|
||||
|
||||
JPopupMenu pmenu = editor.getComponentPopupMenu();
|
||||
JMenuItem findUsagesMenu = new JMenuItem(a);
|
||||
pmenu.add(findUsagesMenu);
|
||||
}
|
||||
|
||||
public static void removeEditorAction(JEditorPane editor, String key) {
|
||||
ActionMap amap = editor.getActionMap();
|
||||
InputMap imap = editor.getInputMap(JTextComponent.WHEN_FOCUSED);
|
||||
for (KeyStroke ks : imap.keys()) {
|
||||
if (key.equals(imap.get(ks))) {
|
||||
imap.remove(ks);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Action a = amap.get(key);
|
||||
if (a == null) {
|
||||
return;
|
||||
}
|
||||
amap.remove(key);
|
||||
JPopupMenu menu = editor.getComponentPopupMenu();
|
||||
for (int i = 0; i < menu.getComponentCount(); i++) {
|
||||
Component c = menu.getComponent(i);
|
||||
if (c instanceof JMenuItem) {
|
||||
JMenuItem mi = (JMenuItem) c;
|
||||
if (mi.getAction() == a) {
|
||||
menu.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean navigateUrl(String url) {
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
|
||||
@@ -1171,14 +1171,7 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
|
||||
usageFrame.setVisible(true);
|
||||
}
|
||||
}
|
||||
}, "find-usages", AppStrings.translate("abc.action.find-usages"), "control U");
|
||||
|
||||
View.addEditorAction(decompiledTextArea, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gotoDeclaration(decompiledTextArea.getCaretPosition());
|
||||
}
|
||||
}, "find-declaration", AppStrings.translate("abc.action.find-declaration"), "control B");
|
||||
}, "find-usages", AppStrings.translate("abc.action.find-usages"), "control U");
|
||||
|
||||
CtrlClickHandler cch = new CtrlClickHandler();
|
||||
decompiledTextArea.addKeyListener(cch);
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui.editor;
|
||||
|
||||
import com.jpexs.decompiler.flash.gui.AppStrings;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.simpleparser.SimpleParseException;
|
||||
import com.jpexs.decompiler.flash.simpleparser.SimpleParser;
|
||||
import java.awt.BorderLayout;
|
||||
@@ -24,6 +26,7 @@ import java.awt.Cursor;
|
||||
import java.awt.KeyEventPostProcessor;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
@@ -42,6 +45,7 @@ import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.JEditorPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollBar;
|
||||
@@ -356,6 +360,17 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
};
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventPostProcessor(kevEventPostProcessor);
|
||||
|
||||
View.addEditorAction(pane, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
SyntaxDocument doc = ActionUtils.getSyntaxDocument(pane);
|
||||
int pos = pane.getCaretPosition();
|
||||
Token token = getIdentifierTokenAt(doc, pos);
|
||||
handleLink(token);
|
||||
}
|
||||
}, "find-declaration", AppStrings.translate("abc.action.find-declaration"), "control B");
|
||||
|
||||
|
||||
documentUpdated();
|
||||
markTokenAt(editor.getCaretPosition());
|
||||
status = Status.INSTALLING;
|
||||
@@ -389,6 +404,9 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
}
|
||||
|
||||
private void update() {
|
||||
if (lastCursorPos == null) {
|
||||
return;
|
||||
}
|
||||
if (ctrlDown) {
|
||||
Token t = ((LineMarkedEditorPane) pane).tokenAtPos(lastCursorPos);
|
||||
|
||||
@@ -493,6 +511,7 @@ public class VariableMarker implements SyntaxComponent, CaretListener, PropertyC
|
||||
tim.cancel();
|
||||
errorsTimer = null;
|
||||
}
|
||||
View.removeEditorAction(pane, "find-declaration");
|
||||
pane.removePropertyChangeListener(this);
|
||||
pane.getDocument().removeDocumentListener(this);
|
||||
pane.removeCaretListener(this);
|
||||
|
||||
Reference in New Issue
Block a user