Ctrl + G shortcut for tag list view

This commit is contained in:
Jindra Petřík
2022-12-28 21:47:04 +01:00
parent f5bee6b8d9
commit 71da5e9bc9
2 changed files with 36 additions and 33 deletions

View File

@@ -591,7 +591,40 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
if (items.isEmpty()) {
return;
}
}
if ((e.getKeyCode() == 'G') && (e.isControlDown())) {
Openable openable = items.get(0).getOpenable();
SWF swf = null;
if (openable instanceof SWF) {
swf = (SWF) openable;
}
if (swf != null) {
String val = "";
boolean valid;
int characterId = -1;
do {
val = ViewMessages.showInputDialog(MainPanel.this, translate("message.input.gotoCharacter"), translate("message.input.gotoCharacter.title"), val);
if (val == null) {
break;
}
try {
characterId = Integer.parseInt(val);
} catch (NumberFormatException nfe) {
characterId = -1;
}
} while (characterId <= 0);
if (characterId > 0) {
CharacterTag tag = swf.getCharacter(characterId);
if (tag == null) {
ViewMessages.showMessageDialog(MainPanel.this, translate("message.character.notfound").replace("%characterid%", "" + characterId), translate("error"), JOptionPane.ERROR_MESSAGE);
} else {
setTagTreeSelectedNode(getCurrentTree(), tag);
}
}
}
return;
}
if ((e.getKeyCode() == 'F') && (e.isControlDown())) {
AbstractTagTree tree = getCurrentTree();
@@ -1175,38 +1208,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
@Override
public void keyPressed(KeyEvent e) {
handleKeyPressed(e);
if ((e.getKeyCode() == 'G') && (e.isControlDown())) {
SWF swf = getCurrentSwf();
if (swf != null) {
String val = "";
boolean valid;
int characterId = -1;
do {
val = ViewMessages.showInputDialog(MainPanel.this, translate("message.input.gotoCharacter"), translate("message.input.gotoCharacter.title"), val);
if (val == null) {
break;
}
try {
characterId = Integer.parseInt(val);
} catch (NumberFormatException nfe) {
characterId = -1;
}
} while (characterId <= 0);
if (characterId > 0) {
CharacterTag tag = swf.getCharacter(characterId);
if (tag == null) {
ViewMessages.showMessageDialog(MainPanel.this, translate("message.character.notfound").replace("%characterid%", "" + characterId), translate("error"), JOptionPane.ERROR_MESSAGE);
} else {
TreePath path = tagTree.getFullModel().getTreePath(tag);
if (path != null) {
tagTree.setSelectionPath(path);
}
}
}
}
}
handleKeyPressed(e);
}
});
tagListTree.addKeyListener(new KeyAdapter() {