mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-29 07:25:42 +00:00
Issue #337 quickfind visibility improved
AS Search Results dialog instead of panel with prev/next
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -22,4 +22,5 @@
|
||||
hs_err_pid*.log
|
||||
*.~*
|
||||
/revision.txt
|
||||
/libsrc/gnujpdf/dist/
|
||||
/libsrc/gnujpdf/dist/
|
||||
/libsrc/jsyntaxpane/jsyntaxpane/target/
|
||||
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
package jsyntaxpane.actions;
|
||||
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface QuickFindHandler {
|
||||
public void showQuickFind(final JTextComponent target, DocumentSearchData dsd);
|
||||
}
|
||||
@@ -78,7 +78,7 @@
|
||||
<Dimension value="[200, 24]"/>
|
||||
</Property>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[60, 24]"/>
|
||||
<Dimension value="[200, 24]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JRootPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
@@ -79,15 +80,16 @@ public class QuickFindDialog extends javax.swing.JDialog
|
||||
initComponents();
|
||||
SwingUtils.addEscapeListener(this);
|
||||
dsd = new WeakReference<DocumentSearchData>(data);
|
||||
getRootPane().setWindowDecorationStyle(JRootPane.NONE);
|
||||
|
||||
}
|
||||
|
||||
public void showFor(final JTextComponent target) {
|
||||
oldCaretPosition = target.getCaretPosition();
|
||||
Container view = target.getParent();
|
||||
Dimension wd = getSize();
|
||||
//JPEXS fix:
|
||||
Dimension wd = getPreferredSize();
|
||||
//wd.width = target.getVisibleRect().width;
|
||||
Point loc = new Point(0, view.getHeight()-getHeight()/*JPEXS fix*/);
|
||||
Point loc = new Point(0, view.getHeight());
|
||||
setSize(wd);
|
||||
setLocationRelativeTo(view);
|
||||
SwingUtilities.convertPointToScreen(loc, view);
|
||||
@@ -149,8 +151,8 @@ public class QuickFindDialog extends javax.swing.JDialog
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setBackground(java.awt.Color.darkGray);
|
||||
setName("QuickFindDialog"); // NOI18N
|
||||
setResizable(false);
|
||||
setUndecorated(true);
|
||||
setResizable(false);
|
||||
|
||||
jToolBar1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
|
||||
jToolBar1.setFloatable(false);
|
||||
@@ -166,7 +168,7 @@ public class QuickFindDialog extends javax.swing.JDialog
|
||||
jTxtFind.setColumns(30);
|
||||
jTxtFind.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
jTxtFind.setMaximumSize(new java.awt.Dimension(200, 24));
|
||||
jTxtFind.setMinimumSize(new java.awt.Dimension(60, 24));
|
||||
jTxtFind.setMinimumSize(new java.awt.Dimension(200, 24));
|
||||
jToolBar1.add(jTxtFind);
|
||||
jToolBar1.add(jSeparator3);
|
||||
|
||||
@@ -306,8 +308,10 @@ public class QuickFindDialog extends javax.swing.JDialog
|
||||
if (!d.doFindNext(t)) {
|
||||
jLblStatus.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
|
||||
} else {
|
||||
jLblStatus.setText(null);
|
||||
jLblStatus.setText(null);
|
||||
}
|
||||
setSize(getPreferredSize());
|
||||
pack();
|
||||
} catch (PatternSyntaxException e) {
|
||||
jLblStatus.setText(e.getDescription());
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// Import the needed java packages and classes
|
||||
importPackage(java.util);
|
||||
importClass(javax.swing.JOptionPane)
|
||||
|
||||
function putDate() {
|
||||
TARGET.replaceSelection("This is a dummy proc that inserts the Current Date:\n" + new Date());
|
||||
TARGET.replaceSelection("\nTab Size of doc = " + AU.getTabSize(TARGET));
|
||||
}
|
||||
271
src/com/jpexs/decompiler/flash/gui/QuickFindPanel.java
Normal file
271
src/com/jpexs/decompiler/flash/gui/QuickFindPanel.java
Normal file
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
* Copyright (C) 2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Event;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.JTextComponent;
|
||||
import jsyntaxpane.actions.DocumentSearchData;
|
||||
import jsyntaxpane.actions.gui.QuickFindDialog;
|
||||
import jsyntaxpane.components.Markers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class QuickFindPanel extends JPanel implements ActionListener, jsyntaxpane.actions.QuickFindHandler {
|
||||
public JTextField findTextField;
|
||||
public JButton prevButton,nextButton;
|
||||
public JCheckBox ignoreCaseCheckbox,regExpCheckbox,wrapCheckbox;
|
||||
public JLabel statusLabel;
|
||||
|
||||
private Markers.SimpleMarker marker = new Markers.SimpleMarker(Color.PINK);
|
||||
private WeakReference<JTextComponent> target;
|
||||
private WeakReference<DocumentSearchData> dsd;
|
||||
private int oldCaretPosition;
|
||||
|
||||
public QuickFindPanel(){
|
||||
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||
|
||||
|
||||
setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
|
||||
|
||||
JPanel pan1 = new JPanel(new WrapLayout());
|
||||
JPanel pan2 = new JPanel(new WrapLayout());
|
||||
pan1.setAlignmentX(0);
|
||||
pan2.setAlignmentX(0);
|
||||
pan1.setAlignmentY(0);
|
||||
pan2.setAlignmentY(0);
|
||||
|
||||
|
||||
JLabel jLabel1 = new javax.swing.JLabel();
|
||||
findTextField = new javax.swing.JTextField();
|
||||
prevButton = new javax.swing.JButton();
|
||||
nextButton = new javax.swing.JButton();
|
||||
ignoreCaseCheckbox = new javax.swing.JCheckBox();
|
||||
regExpCheckbox = new javax.swing.JCheckBox();
|
||||
wrapCheckbox = new javax.swing.JCheckBox();
|
||||
statusLabel = new javax.swing.JLabel();
|
||||
|
||||
setName("QuickFindDialog"); // NOI18N
|
||||
|
||||
|
||||
jLabel1.setLabelFor(findTextField);
|
||||
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle"); // NOI18N
|
||||
jLabel1.setText(bundle.getString("QuickFindDialog.jLabel1.text")); // NOI18N
|
||||
pan1.add(jLabel1);
|
||||
|
||||
findTextField.setColumns(30);
|
||||
findTextField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
findTextField.setMaximumSize(new java.awt.Dimension(200, 24));
|
||||
findTextField.setMinimumSize(new java.awt.Dimension(60, 24));
|
||||
pan1.add(findTextField);
|
||||
|
||||
prevButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/go-up.png"))); // NOI18N
|
||||
prevButton.setFocusable(false);
|
||||
prevButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
prevButton.setOpaque(false);
|
||||
prevButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
prevButton.setActionCommand("PREVIOUS");
|
||||
prevButton.addActionListener(this);
|
||||
pan1.add(prevButton);
|
||||
|
||||
nextButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/go-down.png"))); // NOI18N
|
||||
nextButton.setFocusable(false);
|
||||
nextButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
nextButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
|
||||
nextButton.setOpaque(false);
|
||||
nextButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
nextButton.setActionCommand("NEXT");
|
||||
nextButton.addActionListener(this);
|
||||
pan1.add(nextButton);
|
||||
|
||||
ignoreCaseCheckbox.setMnemonic('C');
|
||||
ignoreCaseCheckbox.setText(bundle.getString("QuickFindDialog.jChkIgnoreCase.text")); // NOI18N
|
||||
ignoreCaseCheckbox.setFocusable(false);
|
||||
ignoreCaseCheckbox.setOpaque(false);
|
||||
ignoreCaseCheckbox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
pan2.add(ignoreCaseCheckbox);
|
||||
ignoreCaseCheckbox.addActionListener(this);
|
||||
|
||||
regExpCheckbox.setMnemonic('R');
|
||||
regExpCheckbox.setText(bundle.getString("QuickFindDialog.jChkRegExp.text")); // NOI18N
|
||||
regExpCheckbox.setFocusable(false);
|
||||
regExpCheckbox.setOpaque(false);
|
||||
regExpCheckbox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
pan2.add(regExpCheckbox);
|
||||
regExpCheckbox.addActionListener(this);
|
||||
|
||||
wrapCheckbox.setMnemonic('W');
|
||||
wrapCheckbox.setText(bundle.getString("QuickFindDialog.jChkWrap.text")); // NOI18N
|
||||
wrapCheckbox.setFocusable(false);
|
||||
wrapCheckbox.setOpaque(false);
|
||||
wrapCheckbox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
pan2.add(wrapCheckbox);
|
||||
wrapCheckbox.addActionListener(this);
|
||||
|
||||
|
||||
statusLabel.setFont(statusLabel.getFont().deriveFont(statusLabel.getFont().getStyle() | java.awt.Font.BOLD, statusLabel.getFont().getSize()-2));
|
||||
statusLabel.setForeground(java.awt.Color.red);
|
||||
pan2.add(statusLabel);
|
||||
|
||||
add(pan1);
|
||||
add(pan2);
|
||||
setPreferredSize(getMinimumSize());
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch(e.getActionCommand()){
|
||||
case "PREVIOUS":
|
||||
if (dsd.get().doFindPrev(target.get())) {
|
||||
statusLabel.setText(null);
|
||||
} else {
|
||||
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
|
||||
}
|
||||
break;
|
||||
case "NEXT":
|
||||
if (dsd.get().doFindNext(target.get())) {
|
||||
statusLabel.setText(null);
|
||||
} else {
|
||||
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void showQuickFind(final JTextComponent t,DocumentSearchData ds) {
|
||||
dsd = new WeakReference<DocumentSearchData>(ds);
|
||||
oldCaretPosition = t.getCaretPosition();
|
||||
Container view = t.getParent();
|
||||
Dimension wd = getSize();
|
||||
wd.width = t.getVisibleRect().width;
|
||||
Point loc = new Point(0, view.getHeight());
|
||||
setSize(wd);
|
||||
SwingUtilities.convertPointToScreen(loc, view);
|
||||
setLocation(loc);
|
||||
findTextField.setFont(t.getFont());
|
||||
final DocumentListener dl;
|
||||
findTextField.getDocument().addDocumentListener(dl = new DocumentListener() {
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
updateFind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
updateFind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
updateFind();
|
||||
}
|
||||
|
||||
private void updateFind() {
|
||||
JTextComponent t = target.get();
|
||||
DocumentSearchData d = dsd.get();
|
||||
String toFind = findTextField.getText();
|
||||
if (toFind == null || toFind.isEmpty()) {
|
||||
statusLabel.setText(null);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
d.setWrap(wrapCheckbox.isSelected());
|
||||
d.setPattern(toFind,
|
||||
regExpCheckbox.isSelected(),
|
||||
ignoreCaseCheckbox.isSelected());
|
||||
// The dsd doFindNext will always find from current pos,
|
||||
// so we need to relocate to our saved pos before we call doFindNext
|
||||
statusLabel.setText(null);
|
||||
t.setCaretPosition(oldCaretPosition);
|
||||
if (!d.doFindNext(t)) {
|
||||
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
|
||||
} else {
|
||||
statusLabel.setText(null);
|
||||
}
|
||||
} catch (PatternSyntaxException e) {
|
||||
statusLabel.setText(e.getDescription());
|
||||
}
|
||||
}
|
||||
});
|
||||
this.target = new WeakReference<>(t);
|
||||
Pattern p = dsd.get().getPattern();
|
||||
if (p != null) {
|
||||
findTextField.setText(p.pattern());
|
||||
}
|
||||
wrapCheckbox.setSelected(dsd.get().isWrap());
|
||||
|
||||
|
||||
setVisible(true);
|
||||
getParent().revalidate();
|
||||
getParent().repaint();
|
||||
findTextField.requestFocusInWindow();
|
||||
}
|
||||
/*
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
removeFocusListener(this);
|
||||
setVisible(false);
|
||||
getParent().revalidate();
|
||||
getParent().repaint();
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
121
src/com/jpexs/decompiler/flash/gui/SearchResultsDialog.java
Normal file
121
src/com/jpexs/decompiler/flash/gui/SearchResultsDialog.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (C) 2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.List;
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class SearchResultsDialog<E> extends AppDialog implements ActionListener{
|
||||
private final JList<E> resultsList;
|
||||
private final DefaultListModel<E> model;
|
||||
private final SearchListener<E> listener;
|
||||
|
||||
static final String ACTION_GOTO = "GOTO";
|
||||
static final String ACTION_CANCEL = "CLOSE";
|
||||
|
||||
private final JButton gotoButton = new JButton(translate("button.goto"));
|
||||
private final JButton closeButton = new JButton(translate("button.close"));
|
||||
|
||||
public SearchResultsDialog(String text,SearchListener<E> listener) {
|
||||
setTitle(translate("dialog.title").replace("%text%", text));
|
||||
Container cnt=getContentPane();
|
||||
model = new DefaultListModel<>();
|
||||
resultsList = new JList<>(model);
|
||||
this.listener = listener;
|
||||
|
||||
gotoButton.setActionCommand(ACTION_GOTO);
|
||||
gotoButton.addActionListener(this);
|
||||
closeButton.setActionCommand(ACTION_CANCEL);
|
||||
closeButton.addActionListener(this);
|
||||
JPanel buttonsPanel = new JPanel();
|
||||
buttonsPanel.setLayout(new FlowLayout());
|
||||
buttonsPanel.add(gotoButton);
|
||||
buttonsPanel.add(closeButton);
|
||||
resultsList.addMouseListener(new MouseAdapter() {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getClickCount() == 2) {
|
||||
gotoElement();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
cnt.setLayout(new BorderLayout());
|
||||
JScrollPane sp = new JScrollPane(resultsList);
|
||||
sp.setPreferredSize(new Dimension(300,300));
|
||||
cnt.add(sp,BorderLayout.CENTER);
|
||||
cnt.add(buttonsPanel,BorderLayout.SOUTH);
|
||||
pack();
|
||||
setAlwaysOnTop(true);
|
||||
View.centerScreen(this);
|
||||
View.setWindowIcon(this);
|
||||
}
|
||||
|
||||
public void setResults(List<E> results){
|
||||
model.clear();
|
||||
for(E e:results){
|
||||
model.addElement(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case ACTION_GOTO:
|
||||
gotoElement();
|
||||
setVisible(false);
|
||||
break;
|
||||
case ACTION_CANCEL:
|
||||
setVisible(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void gotoElement(){
|
||||
if (resultsList.getSelectedIndex() != -1) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
listener.updateSearchPos(resultsList.getSelectedValue());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -104,7 +104,13 @@ public class TextPanel extends JPanel implements ActionListener {
|
||||
|
||||
public void updateSearchPos() {
|
||||
textValue.setCaretPosition(0);
|
||||
textSearchPanel.showQuickFindDialog(textValue);
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
textSearchPanel.showQuickFindDialog(textValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,8 +42,10 @@ import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.gui.HeaderLabel;
|
||||
import com.jpexs.decompiler.flash.gui.Main;
|
||||
import com.jpexs.decompiler.flash.gui.MainPanel;
|
||||
import com.jpexs.decompiler.flash.gui.QuickFindPanel;
|
||||
import com.jpexs.decompiler.flash.gui.SearchListener;
|
||||
import com.jpexs.decompiler.flash.gui.SearchPanel;
|
||||
import com.jpexs.decompiler.flash.gui.SearchResultsDialog;
|
||||
import com.jpexs.decompiler.flash.gui.TagTreeModel;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.gui.abc.tablemodels.DecimalTableModel;
|
||||
@@ -107,6 +109,8 @@ import javax.swing.table.TableColumn;
|
||||
import javax.swing.table.TableModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
import jsyntaxpane.DefaultSyntaxKit;
|
||||
import jsyntaxpane.actions.DocumentSearchData;
|
||||
import jsyntaxpane.actions.QuickFindAction;
|
||||
|
||||
public class ABCPanel extends JPanel implements ItemListener, ActionListener, SearchListener<ABCPanelSearchResult>, Freed {
|
||||
|
||||
@@ -128,7 +132,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
public DetailPanel detailPanel;
|
||||
public JPanel navPanel;
|
||||
public JTabbedPane tabbedPane;
|
||||
public SearchPanel<ABCPanelSearchResult> searchPanel;
|
||||
public SearchPanel<ABCPanelSearchResult> searchPanel;
|
||||
private NewTraitDialog newTraitDialog;
|
||||
public JLabel scriptNameLabel;
|
||||
|
||||
@@ -143,7 +147,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
|
||||
static final String ACTION_ADD_TRAIT = "ADDTRAIT";
|
||||
|
||||
public boolean search(String txt, boolean ignoreCase, boolean regexp) {
|
||||
public boolean search(final String txt, boolean ignoreCase, boolean regexp) {
|
||||
if ((txt != null) && (!txt.isEmpty())) {
|
||||
searchPanel.setOptions(ignoreCase, regexp);
|
||||
TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel();
|
||||
@@ -192,8 +196,25 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
|
||||
System.gc();
|
||||
Main.stopWork();
|
||||
|
||||
searchPanel.setSearchText(txt);
|
||||
return searchPanel.setResults(found);
|
||||
|
||||
final ABCPanel that=this;
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SearchResultsDialog<ABCPanelSearchResult> sr=new SearchResultsDialog<ABCPanelSearchResult>(txt,that);
|
||||
sr.setResults(found);
|
||||
sr.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
//return searchPanel.setResults(found);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -379,7 +400,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
iconDecPanel.add(scriptNameLabel);
|
||||
iconDecPanel.add(iconsPanel);
|
||||
iconDecPanel.add(decompiledScrollPane);
|
||||
|
||||
|
||||
JPanel decButtonsPan = new JPanel(new FlowLayout());
|
||||
decButtonsPan.setBorder(new BevelBorder(BevelBorder.RAISED));
|
||||
decButtonsPan.add(editDecompiledButton);
|
||||
@@ -583,7 +604,14 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
hilightScript(pack);
|
||||
decompiledTextArea.setCaretPosition(0);
|
||||
|
||||
searchPanel.showQuickFindDialog(decompiledTextArea);
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
searchPanel.showQuickFindDialog(decompiledTextArea);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public String lastDecompiled = null;
|
||||
|
||||
@@ -27,4 +27,11 @@ public class ABCPanelSearchResult {
|
||||
|
||||
public ScriptPack scriptPack;
|
||||
public ClassPath classPath;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return classPath.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
return isStatic;
|
||||
}
|
||||
|
||||
public void setNoTrait() {
|
||||
public void setNoTrait() {
|
||||
abcPanel.detailPanel.showCard(DetailPanel.UNSUPPORTED_TRAIT_CARD, null);
|
||||
}
|
||||
|
||||
@@ -424,10 +424,11 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
}
|
||||
|
||||
public DecompiledEditorPane(ABCPanel abcPanel) {
|
||||
super();
|
||||
setEditable(false);
|
||||
getCaret().setVisible(true);
|
||||
addCaretListener(this);
|
||||
this.abcPanel = abcPanel;
|
||||
this.abcPanel = abcPanel;
|
||||
}
|
||||
private List<ABCContainerTag> abcList;
|
||||
|
||||
@@ -513,7 +514,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String t) {
|
||||
public void setText(String t) {
|
||||
super.setText(t);
|
||||
setCaretPosition(0);
|
||||
}
|
||||
|
||||
@@ -138,35 +138,42 @@ public class DetailPanel extends JPanel implements ActionListener {
|
||||
}
|
||||
}
|
||||
|
||||
public void showCard(String name, Trait trait) {
|
||||
CardLayout layout = (CardLayout) innerPanel.getLayout();
|
||||
layout.show(innerPanel, name);
|
||||
boolean b = cardMap.get(name) instanceof TraitDetail;
|
||||
buttonsPanel.setVisible(b);
|
||||
public void showCard(final String name, final Trait trait) {
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
|
||||
TraitDetail newDetail = null;
|
||||
if (b) {
|
||||
newDetail = (TraitDetail) cardMap.get(name);
|
||||
}
|
||||
for (JComponent v : cardMap.values()) {
|
||||
if (v instanceof TraitDetail) {
|
||||
if (v != newDetail) {
|
||||
TraitDetail oldDetail = (TraitDetail) v;
|
||||
oldDetail.setActive(false);
|
||||
@Override
|
||||
public void run() {
|
||||
CardLayout layout = (CardLayout) innerPanel.getLayout();
|
||||
layout.show(innerPanel, name);
|
||||
boolean b = cardMap.get(name) instanceof TraitDetail;
|
||||
buttonsPanel.setVisible(b);
|
||||
|
||||
TraitDetail newDetail = null;
|
||||
if (b) {
|
||||
newDetail = (TraitDetail) cardMap.get(name);
|
||||
}
|
||||
for (JComponent v : cardMap.values()) {
|
||||
if (v instanceof TraitDetail) {
|
||||
if (v != newDetail) {
|
||||
TraitDetail oldDetail = (TraitDetail) v;
|
||||
oldDetail.setActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newDetail != null) {
|
||||
newDetail.setActive(true);
|
||||
}
|
||||
|
||||
selectedCard = name;
|
||||
selectedLabel.setText(selectedCard);
|
||||
if (trait == null) {
|
||||
traitNameLabel.setText("-");
|
||||
} else {
|
||||
traitNameLabel.setText(trait.getName(abcPanel.abc).getName(abcPanel.abc.constants, new ArrayList<String>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newDetail != null) {
|
||||
newDetail.setActive(true);
|
||||
}
|
||||
});
|
||||
|
||||
selectedCard = name;
|
||||
selectedLabel.setText(selectedCard);
|
||||
if (trait == null) {
|
||||
traitNameLabel.setText("-");
|
||||
} else {
|
||||
traitNameLabel.setText(trait.getName(abcPanel.abc).getName(abcPanel.abc.constants, new ArrayList<String>()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.jpexs.decompiler.flash.gui.Main;
|
||||
import com.jpexs.decompiler.flash.gui.MainPanel;
|
||||
import com.jpexs.decompiler.flash.gui.SearchListener;
|
||||
import com.jpexs.decompiler.flash.gui.SearchPanel;
|
||||
import com.jpexs.decompiler.flash.gui.SearchResultsDialog;
|
||||
import com.jpexs.decompiler.flash.gui.TagTreeModel;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane;
|
||||
@@ -79,7 +80,7 @@ import javax.swing.event.CaretListener;
|
||||
import javax.swing.tree.TreePath;
|
||||
import jsyntaxpane.DefaultSyntaxKit;
|
||||
|
||||
public class ActionPanel extends JPanel implements ActionListener, SearchListener<ASMSource> {
|
||||
public class ActionPanel extends JPanel implements ActionListener, SearchListener<ActionSearchResult> {
|
||||
|
||||
static final String ACTION_GRAPH = "GRAPH";
|
||||
static final String ACTION_HEX = "HEX";
|
||||
@@ -119,7 +120,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
|
||||
private HilightedText srcHexOnly;
|
||||
private String lastDecompiled = "";
|
||||
private ASMSource lastASM;
|
||||
public SearchPanel<ASMSource> searchPanel;
|
||||
public SearchPanel<ActionSearchResult> searchPanel;
|
||||
private Cache<CachedScript> cache = Cache.getInstance(true);
|
||||
private CancellableWorker setSourceWorker;
|
||||
|
||||
@@ -216,13 +217,13 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
|
||||
}
|
||||
}
|
||||
|
||||
public boolean search(String txt, boolean ignoreCase, boolean regexp) {
|
||||
public boolean search(final String txt, boolean ignoreCase, boolean regexp) {
|
||||
if ((txt != null) && (!txt.isEmpty())) {
|
||||
searchPanel.setOptions(ignoreCase, regexp);
|
||||
List<TreeNode> list = SWF.createASTagList(mainPanel.getCurrentSwf().tags, null);
|
||||
Map<String, ASMSource> asms = new HashMap<>();
|
||||
getASMs("", list, asms);
|
||||
List<ASMSource> found = new ArrayList<>();
|
||||
final List<ActionSearchResult> found = new ArrayList<>();
|
||||
Pattern pat = null;
|
||||
if (regexp) {
|
||||
pat = Pattern.compile(txt, ignoreCase ? Pattern.CASE_INSENSITIVE : 0);
|
||||
@@ -244,13 +245,24 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
|
||||
break;
|
||||
}
|
||||
if (pat.matcher(getCached(item.getValue()).text).find()) {
|
||||
found.add(item.getValue());
|
||||
found.add(new ActionSearchResult(item.getValue(),item.getKey()));
|
||||
}
|
||||
}
|
||||
|
||||
Main.stopWork();
|
||||
searchPanel.setSearchText(txt);
|
||||
return searchPanel.setResults(found);
|
||||
final ActionPanel that=this;
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SearchResultsDialog<ActionSearchResult> sr=new SearchResultsDialog<ActionSearchResult>(txt,that);
|
||||
sr.setResults(found);
|
||||
sr.setVisible(true);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
//return searchPanel.setResults(found);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -524,7 +536,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
|
||||
|
||||
JPanel decPanel = new JPanel(new BorderLayout());
|
||||
decPanel.add(new JScrollPane(decompiledEditor), BorderLayout.CENTER);
|
||||
decPanel.add(searchPanel, BorderLayout.NORTH);
|
||||
//decPanel.add(searchPanel, BorderLayout.NORTH);
|
||||
|
||||
JPanel panA = new JPanel();
|
||||
panA.setLayout(new BorderLayout());
|
||||
@@ -773,14 +785,20 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSearchPos(ASMSource item) {
|
||||
public void updateSearchPos(ActionSearchResult item) {
|
||||
TagTreeModel ttm = (TagTreeModel) mainPanel.tagTree.getModel();
|
||||
TreePath tp = ttm.getTagPath(item);
|
||||
TreePath tp = ttm.getTagPath(item.src);
|
||||
mainPanel.tagTree.setSelectionPath(tp);
|
||||
mainPanel.tagTree.scrollPathToVisible(tp);
|
||||
decompiledEditor.setCaretPosition(0);
|
||||
|
||||
searchPanel.showQuickFindDialog(decompiledEditor);
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
searchPanel.showQuickFindDialog(decompiledEditor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void uncache(ASMSource pack) {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.jpexs.decompiler.flash.gui.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ActionSearchResult {
|
||||
public ASMSource src;
|
||||
public String path;
|
||||
|
||||
public ActionSearchResult(ASMSource src, String path) {
|
||||
this.src = src;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2010-2014 JPEXS
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
button.goto = Go to
|
||||
button.close = Close
|
||||
dialog.title = Search results: %text%
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2010-2014 JPEXS
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
button.goto = P\u0159ej\u00edt na
|
||||
button.close = Zav\u0159\u00edt
|
||||
dialog.title = V\u00fdsledky hled\u00e1n\u00ed: %text%
|
||||
Reference in New Issue
Block a user