mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 04:20:45 +00:00
Issue #85 - AS3 Text search
This commit is contained in:
@@ -18,15 +18,18 @@ package com.jpexs.decompiler.flash.abc.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.Main;
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
import com.jpexs.decompiler.flash.abc.gui.tablemodels.*;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Font;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -36,6 +39,7 @@ import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.table.*;
|
||||
import jsyntaxpane.DefaultSyntaxKit;
|
||||
import jsyntaxpane.actions.DocumentSearchData;
|
||||
|
||||
public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
|
||||
@@ -58,6 +62,36 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
public JTextField filterField = new JTextField("");
|
||||
public JPanel navPanel;
|
||||
public JTabbedPane tabbedPane;
|
||||
public JPanel searchPanel;
|
||||
public JLabel searchPos;
|
||||
private List<ScriptPack> found = new ArrayList<ScriptPack>();
|
||||
private int foundPos = 0;
|
||||
private JLabel searchForLabel;
|
||||
private String searchFor;
|
||||
|
||||
public boolean search(String txt) {
|
||||
if ((txt != null) && (!txt.equals(""))) {
|
||||
ClassesListTreeModel clModel = (ClassesListTreeModel) classTree.getModel();
|
||||
HashMap<String, ScriptPack> allpacks = clModel.getList();
|
||||
for (ScriptPack p : allpacks.values()) {
|
||||
decompiledTextArea.cacheScriptPack(p, list);
|
||||
}
|
||||
found = decompiledTextArea.searchCache(txt);
|
||||
if (found.isEmpty()) {
|
||||
searchPanel.setVisible(false);
|
||||
return false;
|
||||
} else {
|
||||
foundPos = 0;
|
||||
decompiledTextArea.setScript(found.get(foundPos), list);
|
||||
searchPanel.setVisible(true);
|
||||
searchFor = txt;
|
||||
updateSearchPos();
|
||||
searchForLabel.setText("Search for \"" + txt + "\" : ");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private JTable autoResizeColWidth(JTable table, TableModel model) {
|
||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||
@@ -189,11 +223,19 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
|
||||
|
||||
decompiledTextArea = new DecompiledEditorPane(this);
|
||||
|
||||
|
||||
searchPanel = new JPanel(new FlowLayout());
|
||||
|
||||
decompiledScrollPane = new JScrollPane(decompiledTextArea);
|
||||
|
||||
JPanel decPanel = new JPanel(new BorderLayout());
|
||||
decPanel.add(searchPanel, BorderLayout.NORTH);
|
||||
decPanel.add(decompiledScrollPane, BorderLayout.CENTER);
|
||||
detailPanel = new DetailPanel(this);
|
||||
JPanel panB = new JPanel();
|
||||
panB.setLayout(new BorderLayout());
|
||||
panB.add(decompiledScrollPane, BorderLayout.CENTER);
|
||||
panB.add(decPanel, BorderLayout.CENTER);
|
||||
panB.add(decLabel, BorderLayout.NORTH);
|
||||
decLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
decLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
|
||||
@@ -259,12 +301,36 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
JPanel treePanel = new JPanel();
|
||||
treePanel.setLayout(new BorderLayout());
|
||||
treePanel.add(new JScrollPane(classTree = new ClassesListTree(list, this)), BorderLayout.CENTER);
|
||||
JPanel searchPanel = new JPanel();
|
||||
searchPanel.setLayout(new BorderLayout());
|
||||
searchPanel.add(filterField, BorderLayout.CENTER);
|
||||
JPanel filterPanel = new JPanel();
|
||||
filterPanel.setLayout(new BorderLayout());
|
||||
filterPanel.add(filterField, BorderLayout.CENTER);
|
||||
JButton prevSearchButton = new JButton(View.getIcon("prev16"));
|
||||
prevSearchButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
prevSearchButton.addActionListener(this);
|
||||
prevSearchButton.setActionCommand("SEARCHPREV");
|
||||
JButton nextSearchButton = new JButton(View.getIcon("next16"));
|
||||
nextSearchButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
nextSearchButton.addActionListener(this);
|
||||
nextSearchButton.setActionCommand("SEARCHNEXT");
|
||||
JButton cancelSearchButton = new JButton(View.getIcon("cancel16"));
|
||||
cancelSearchButton.setMargin(new Insets(3, 3, 3, 3));
|
||||
cancelSearchButton.addActionListener(this);
|
||||
cancelSearchButton.setActionCommand("SEARCHCANCEL");
|
||||
searchPos = new JLabel("0/0");
|
||||
searchForLabel = new JLabel("Search for \"\": ");
|
||||
searchPanel.add(searchForLabel);
|
||||
searchPanel.add(prevSearchButton);
|
||||
searchPanel.add(new JLabel("Script "));
|
||||
searchPanel.add(searchPos);
|
||||
searchPanel.add(nextSearchButton);
|
||||
searchPanel.add(cancelSearchButton);
|
||||
|
||||
|
||||
|
||||
searchPanel.setVisible(false);
|
||||
JLabel picLabel = new JLabel(View.getIcon("search16"));
|
||||
searchPanel.add(picLabel, BorderLayout.EAST);
|
||||
treePanel.add(searchPanel, BorderLayout.NORTH);
|
||||
filterPanel.add(picLabel, BorderLayout.EAST);
|
||||
treePanel.add(filterPanel, BorderLayout.NORTH);
|
||||
|
||||
splitPaneTreeVSNavigator = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
|
||||
treePanel,
|
||||
@@ -360,10 +426,36 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener {
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
public void updateSearchPos() {
|
||||
searchPos.setText((foundPos + 1) + "/" + found.size());
|
||||
decompiledTextArea.setScript(found.get(foundPos), list);
|
||||
decompiledTextArea.setCaretPosition(0);
|
||||
DocumentSearchData dsd = DocumentSearchData.getFromEditor(decompiledTextArea);
|
||||
dsd.setPattern(searchFor, false, false);
|
||||
dsd.showQuickFindDialog(decompiledTextArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals("FILTERSCRIPT")) {
|
||||
doFilter();
|
||||
}
|
||||
if (e.getActionCommand().equals("SEARCHCANCEL")) {
|
||||
foundPos = 0;
|
||||
searchPanel.setVisible(false);
|
||||
found = new ArrayList<ScriptPack>();
|
||||
searchFor = null;
|
||||
}
|
||||
if (e.getActionCommand().equals("SEARCHPREV")) {
|
||||
foundPos--;
|
||||
if (foundPos < 0) {
|
||||
foundPos += found.size();
|
||||
}
|
||||
updateSearchPos();
|
||||
}
|
||||
if (e.getActionCommand().equals("SEARCHNEXT")) {
|
||||
foundPos = (foundPos + 1) % found.size();
|
||||
updateSearchPos();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user