diff --git a/.gitignore b/.gitignore index 9b40cc14a..bed0a9888 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ hs_err_pid*.log *.~* /revision.txt -/libsrc/gnujpdf/dist/ \ No newline at end of file +/libsrc/gnujpdf/dist/ +/libsrc/jsyntaxpane/jsyntaxpane/target/ \ No newline at end of file diff --git a/lib/jsyntaxpane-0.9.5.jar b/lib/jsyntaxpane-0.9.5.jar index 4bb581a71..fa79c09bf 100644 Binary files a/lib/jsyntaxpane-0.9.5.jar and b/lib/jsyntaxpane-0.9.5.jar differ diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/QuickFindHandler.java b/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/QuickFindHandler.java new file mode 100644 index 000000000..8126ff311 --- /dev/null +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/QuickFindHandler.java @@ -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); +} diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/gui/QuickFindDialog.form b/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/gui/QuickFindDialog.form index f8ffe9a55..0a4d582d2 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/gui/QuickFindDialog.form +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/gui/QuickFindDialog.form @@ -78,7 +78,7 @@ - + diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/gui/QuickFindDialog.java b/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/gui/QuickFindDialog.java index d27fce3d4..e25f26068 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/gui/QuickFindDialog.java +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/java/jsyntaxpane/actions/gui/QuickFindDialog.java @@ -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(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()); } diff --git a/libsrc/jsyntaxpane/jsyntaxpane/src/main/resources/META-INF/services/jsyntaxpane/scripts/insertdate.js b/libsrc/jsyntaxpane/jsyntaxpane/src/main/resources/META-INF/services/jsyntaxpane/scripts/insertdate.js index ea61d4d13..e69de29bb 100644 --- a/libsrc/jsyntaxpane/jsyntaxpane/src/main/resources/META-INF/services/jsyntaxpane/scripts/insertdate.js +++ b/libsrc/jsyntaxpane/jsyntaxpane/src/main/resources/META-INF/services/jsyntaxpane/scripts/insertdate.js @@ -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)); -} \ No newline at end of file diff --git a/src/com/jpexs/decompiler/flash/gui/QuickFindPanel.java b/src/com/jpexs/decompiler/flash/gui/QuickFindPanel.java new file mode 100644 index 000000000..08f918783 --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/QuickFindPanel.java @@ -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 . + */ + +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 target; + private WeakReference 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(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(); + }*/ + + + + +} diff --git a/src/com/jpexs/decompiler/flash/gui/SearchResultsDialog.java b/src/com/jpexs/decompiler/flash/gui/SearchResultsDialog.java new file mode 100644 index 000000000..be1f3fbca --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/SearchResultsDialog.java @@ -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 . + */ + +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 extends AppDialog implements ActionListener{ + private final JList resultsList; + private final DefaultListModel model; + private final SearchListener 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 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 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()); + } + + }); + } + } + +} diff --git a/src/com/jpexs/decompiler/flash/gui/TextPanel.java b/src/com/jpexs/decompiler/flash/gui/TextPanel.java index 1fdc928b1..eda739e73 100644 --- a/src/com/jpexs/decompiler/flash/gui/TextPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/TextPanel.java @@ -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 diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java index 6b2c42df0..06d1966a1 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanel.java @@ -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, 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 searchPanel; + public SearchPanel 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 sr=new SearchResultsDialog(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; diff --git a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanelSearchResult.java b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanelSearchResult.java index f87645cb7..8624cf623 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/ABCPanelSearchResult.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/ABCPanelSearchResult.java @@ -27,4 +27,11 @@ public class ABCPanelSearchResult { public ScriptPack scriptPack; public ClassPath classPath; + + @Override + public String toString() { + return classPath.toString(); + } + + } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java index dead716c7..a3fd4929c 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DecompiledEditorPane.java @@ -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 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); } diff --git a/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java b/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java index 55204b310..356098e84 100644 --- a/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/abc/DetailPanel.java @@ -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())); } } - } - 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())); - } } @Override diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java index d02475509..afeda3562 100644 --- a/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionPanel.java @@ -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 { +public class ActionPanel extends JPanel implements ActionListener, SearchListener { 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 searchPanel; + public SearchPanel searchPanel; private Cache 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 list = SWF.createASTagList(mainPanel.getCurrentSwf().tags, null); Map asms = new HashMap<>(); getASMs("", list, asms); - List found = new ArrayList<>(); + final List 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 sr=new SearchResultsDialog(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) { diff --git a/src/com/jpexs/decompiler/flash/gui/action/ActionSearchResult.java b/src/com/jpexs/decompiler/flash/gui/action/ActionSearchResult.java new file mode 100644 index 000000000..e2b846804 --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/action/ActionSearchResult.java @@ -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 . + */ + +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; + } + + +} diff --git a/src/com/jpexs/decompiler/flash/gui/locales/SearchResultsDialog.properties b/src/com/jpexs/decompiler/flash/gui/locales/SearchResultsDialog.properties new file mode 100644 index 000000000..0d6a85ac5 --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/locales/SearchResultsDialog.properties @@ -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 . + +button.goto = Go to +button.close = Close +dialog.title = Search results: %text% diff --git a/src/com/jpexs/decompiler/flash/gui/locales/SearchResultsDialog_cs.properties b/src/com/jpexs/decompiler/flash/gui/locales/SearchResultsDialog_cs.properties new file mode 100644 index 000000000..24bc64133 --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/locales/SearchResultsDialog_cs.properties @@ -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 . + +button.goto = P\u0159ej\u00edt na +button.close = Zav\u0159\u00edt +dialog.title = V\u00fdsledky hled\u00e1n\u00ed: %text%