organize imports, javadoc

This commit is contained in:
honfika
2014-06-18 20:53:19 +02:00
parent fb21f408cd
commit 52e6142fe5
88 changed files with 968 additions and 1005 deletions
@@ -1,230 +1,228 @@
/*
* 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/>.
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowStateListener;
import java.util.List;
import javax.swing.JFrame;
import org.pushingpixels.flamingo.api.ribbon.JRibbon;
import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationMenuButton;
/**
*
* @author JPEXS
*/
public final class MainFrameRibbon extends AppRibbonFrame implements MainFrame {
public MainPanel panel;
private MainFrameMenu mainMenu;
public MainFrameRibbon() {
super();
FlashPlayerPanel flashPanel = null;
try {
flashPanel = new FlashPlayerPanel(this);
} catch (FlashUnsupportedException fue) {
}
Container cnt = getContentPane();
cnt.setLayout(new BorderLayout());
JRibbon ribbon = getRibbon();
cnt.add(ribbon, BorderLayout.NORTH);
boolean externalFlashPlayerUnavailable = flashPanel == null;
mainMenu = new MainFrameRibbonMenu(this, ribbon, externalFlashPlayerUnavailable);
panel = new MainPanel(this, mainMenu, flashPanel);
panel.setBackground(Color.yellow);
cnt.add(panel, BorderLayout.CENTER);
int w = Configuration.guiWindowWidth.get();
int h = Configuration.guiWindowHeight.get();
Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
if (w > dim.width) {
w = dim.width;
}
if (h > dim.height) {
h = dim.height;
}
setSize(w, h);
boolean maximizedHorizontal = Configuration.guiWindowMaximizedHorizontal.get();
boolean maximizedVertical = Configuration.guiWindowMaximizedVertical.get();
int state = 0;
if (maximizedHorizontal) {
state |= JFrame.MAXIMIZED_HORIZ;
}
if (maximizedVertical) {
state |= JFrame.MAXIMIZED_VERT;
}
setExtendedState(state);
View.setWindowIcon(this);
addWindowStateListener(new WindowStateListener() {
@Override
public void windowStateChanged(WindowEvent e) {
int state = e.getNewState();
Configuration.guiWindowMaximizedHorizontal.set((state & JFrame.MAXIMIZED_HORIZ) == JFrame.MAXIMIZED_HORIZ);
Configuration.guiWindowMaximizedVertical.set((state & JFrame.MAXIMIZED_VERT) == JFrame.MAXIMIZED_VERT);
}
});
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
int state = getExtendedState();
if ((state & JFrame.MAXIMIZED_HORIZ) == 0) {
Configuration.guiWindowWidth.set(getWidth());
}
if ((state & JFrame.MAXIMIZED_VERT) == 0) {
Configuration.guiWindowHeight.set(getHeight());
}
}
});
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
Main.exit();
}
});
View.centerScreen(this);
}
private static void getApplicationMenuButtons(Component comp, List<JRibbonApplicationMenuButton> ret) {
if (comp instanceof JRibbonApplicationMenuButton) {
ret.add((JRibbonApplicationMenuButton) comp);
return;
}
if (comp instanceof java.awt.Container) {
java.awt.Container cont = (java.awt.Container) comp;
for (int i = 0; i < cont.getComponentCount(); i++) {
getApplicationMenuButtons(cont.getComponent(i), ret);
}
}
}
@Override
public void setVisible(boolean b) {
super.setVisible(b);
/* final MainFrameRibbon t = this;
//TODO: Handle this better. This is awful :-(
new Timer().schedule(new TimerTask() {
@Override
public void run() {
List<JRibbonApplicationMenuButton> mbuttons = new ArrayList<>();
getApplicationMenuButtons(t, mbuttons);
if (mbuttons.size() < 2) {
//return, task will run again
return;
}
for (final JRibbonApplicationMenuButton mbutton : mbuttons) {
mbutton.setIcon(View.getResizableIcon("buttonicon_256"));
mbutton.setDisplayState(new CommandButtonDisplayState(
"My Ribbon Application Menu Button", mbutton.getSize().width) {
@Override
public CommandButtonLayoutManager createLayoutManager(
AbstractCommandButton commandButton) {
return new CommandButtonLayoutManager() {
@Override
public int getPreferredIconSize() {
return mbutton.getSize().width;
}
@Override
public CommandButtonLayoutManager.CommandButtonLayoutInfo getLayoutInfo(
AbstractCommandButton commandButton, Graphics g) {
CommandButtonLayoutManager.CommandButtonLayoutInfo result = new CommandButtonLayoutManager.CommandButtonLayoutInfo();
result.actionClickArea = new Rectangle(0, 0, 0, 0);
result.popupClickArea = new Rectangle(0, 0, commandButton
.getWidth(), commandButton.getHeight());
result.popupActionRect = new Rectangle(0, 0, 0, 0);
ResizableIcon icon = commandButton.getIcon();
icon.setDimension(new Dimension(commandButton.getWidth(), commandButton.getHeight()));
result.iconRect = new Rectangle(
0,
0,
commandButton.getWidth(), commandButton.getHeight());
result.isTextInActionArea = false;
return result;
}
@Override
public Dimension getPreferredSize(
AbstractCommandButton commandButton) {
return new Dimension(40, 40);
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
}
@Override
public Point getKeyTipAnchorCenterPoint(
AbstractCommandButton commandButton) {
// dead center
return new Point(commandButton.getWidth() / 2,
commandButton.getHeight() / 2);
}
};
}
});
MyRibbonApplicationMenuButtonUI mui = (MyRibbonApplicationMenuButtonUI) mbutton.getUI();
mui.setHoverIcon(View.getResizableIcon("buttonicon_hover_256"));
mui.setNormalIcon(View.getResizableIcon("buttonicon_256"));
mui.setClickIcon(View.getResizableIcon("buttonicon_down_256"));
mbutton.repaint();
}
cancel(); //cancel task so it does not run again
}
}, 1, 50);*/
panel.setVisible(b);
}
@Override
public MainPanel getPanel() {
return panel;
}
@Override
public Window getWindow() {
return this;
}
}
/*
* 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/>.
*/
package com.jpexs.decompiler.flash.gui;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.gui.player.FlashPlayerPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Window;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowStateListener;
import java.util.List;
import javax.swing.JFrame;
import org.pushingpixels.flamingo.api.ribbon.JRibbon;
import org.pushingpixels.flamingo.internal.ui.ribbon.appmenu.JRibbonApplicationMenuButton;
/**
*
* @author JPEXS
*/
public final class MainFrameRibbon extends AppRibbonFrame implements MainFrame {
public MainPanel panel;
private MainFrameMenu mainMenu;
public MainFrameRibbon() {
super();
FlashPlayerPanel flashPanel = null;
try {
flashPanel = new FlashPlayerPanel(this);
} catch (FlashUnsupportedException fue) {
}
Container cnt = getContentPane();
cnt.setLayout(new BorderLayout());
JRibbon ribbon = getRibbon();
cnt.add(ribbon, BorderLayout.NORTH);
boolean externalFlashPlayerUnavailable = flashPanel == null;
mainMenu = new MainFrameRibbonMenu(this, ribbon, externalFlashPlayerUnavailable);
panel = new MainPanel(this, mainMenu, flashPanel);
panel.setBackground(Color.yellow);
cnt.add(panel, BorderLayout.CENTER);
int w = Configuration.guiWindowWidth.get();
int h = Configuration.guiWindowHeight.get();
Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
if (w > dim.width) {
w = dim.width;
}
if (h > dim.height) {
h = dim.height;
}
setSize(w, h);
boolean maximizedHorizontal = Configuration.guiWindowMaximizedHorizontal.get();
boolean maximizedVertical = Configuration.guiWindowMaximizedVertical.get();
int state = 0;
if (maximizedHorizontal) {
state |= JFrame.MAXIMIZED_HORIZ;
}
if (maximizedVertical) {
state |= JFrame.MAXIMIZED_VERT;
}
setExtendedState(state);
View.setWindowIcon(this);
addWindowStateListener(new WindowStateListener() {
@Override
public void windowStateChanged(WindowEvent e) {
int state = e.getNewState();
Configuration.guiWindowMaximizedHorizontal.set((state & JFrame.MAXIMIZED_HORIZ) == JFrame.MAXIMIZED_HORIZ);
Configuration.guiWindowMaximizedVertical.set((state & JFrame.MAXIMIZED_VERT) == JFrame.MAXIMIZED_VERT);
}
});
addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
int state = getExtendedState();
if ((state & JFrame.MAXIMIZED_HORIZ) == 0) {
Configuration.guiWindowWidth.set(getWidth());
}
if ((state & JFrame.MAXIMIZED_VERT) == 0) {
Configuration.guiWindowHeight.set(getHeight());
}
}
});
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
Main.exit();
}
});
View.centerScreen(this);
}
private static void getApplicationMenuButtons(Component comp, List<JRibbonApplicationMenuButton> ret) {
if (comp instanceof JRibbonApplicationMenuButton) {
ret.add((JRibbonApplicationMenuButton) comp);
return;
}
if (comp instanceof java.awt.Container) {
java.awt.Container cont = (java.awt.Container) comp;
for (int i = 0; i < cont.getComponentCount(); i++) {
getApplicationMenuButtons(cont.getComponent(i), ret);
}
}
}
@Override
public void setVisible(boolean b) {
super.setVisible(b);
/* final MainFrameRibbon t = this;
//TODO: Handle this better. This is awful :-(
new Timer().schedule(new TimerTask() {
@Override
public void run() {
List<JRibbonApplicationMenuButton> mbuttons = new ArrayList<>();
getApplicationMenuButtons(t, mbuttons);
if (mbuttons.size() < 2) {
//return, task will run again
return;
}
for (final JRibbonApplicationMenuButton mbutton : mbuttons) {
mbutton.setIcon(View.getResizableIcon("buttonicon_256"));
mbutton.setDisplayState(new CommandButtonDisplayState(
"My Ribbon Application Menu Button", mbutton.getSize().width) {
@Override
public CommandButtonLayoutManager createLayoutManager(
AbstractCommandButton commandButton) {
return new CommandButtonLayoutManager() {
@Override
public int getPreferredIconSize() {
return mbutton.getSize().width;
}
@Override
public CommandButtonLayoutManager.CommandButtonLayoutInfo getLayoutInfo(
AbstractCommandButton commandButton, Graphics g) {
CommandButtonLayoutManager.CommandButtonLayoutInfo result = new CommandButtonLayoutManager.CommandButtonLayoutInfo();
result.actionClickArea = new Rectangle(0, 0, 0, 0);
result.popupClickArea = new Rectangle(0, 0, commandButton
.getWidth(), commandButton.getHeight());
result.popupActionRect = new Rectangle(0, 0, 0, 0);
ResizableIcon icon = commandButton.getIcon();
icon.setDimension(new Dimension(commandButton.getWidth(), commandButton.getHeight()));
result.iconRect = new Rectangle(
0,
0,
commandButton.getWidth(), commandButton.getHeight());
result.isTextInActionArea = false;
return result;
}
@Override
public Dimension getPreferredSize(
AbstractCommandButton commandButton) {
return new Dimension(40, 40);
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
}
@Override
public Point getKeyTipAnchorCenterPoint(
AbstractCommandButton commandButton) {
// dead center
return new Point(commandButton.getWidth() / 2,
commandButton.getHeight() / 2);
}
};
}
});
MyRibbonApplicationMenuButtonUI mui = (MyRibbonApplicationMenuButtonUI) mbutton.getUI();
mui.setHoverIcon(View.getResizableIcon("buttonicon_hover_256"));
mui.setNormalIcon(View.getResizableIcon("buttonicon_256"));
mui.setClickIcon(View.getResizableIcon("buttonicon_down_256"));
mbutton.repaint();
}
cancel(); //cancel task so it does not run again
}
}, 1, 50);*/
panel.setVisible(b);
}
@Override
public MainPanel getPanel() {
return panel;
}
@Override
public Window getWindow() {
return this;
}
}
@@ -23,7 +23,6 @@ import com.jpexs.decompiler.flash.console.ContextMenuTools;
import com.jpexs.decompiler.flash.gui.helpers.CheckResources;
import com.jpexs.decompiler.flash.gui.treenodes.SWFNode;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import com.jpexs.decompiler.flash.tags.Tag;
import com.jpexs.helpers.Cache;
import com.jpexs.helpers.utf8.Utf8Helper;
import com.jpexs.process.ProcessTools;
@@ -45,7 +45,6 @@ import com.jpexs.decompiler.flash.tags.VideoFrameTag;
import com.jpexs.decompiler.flash.tags.base.AloneTag;
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
import com.jpexs.decompiler.flash.tags.base.Container;
import com.jpexs.decompiler.flash.tags.base.ContainerItem;
import com.jpexs.decompiler.flash.tags.base.FontTag;
import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
@@ -1,271 +1,259 @@
/*
* 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();
}*/
}
/*
* 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.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
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.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.JTextComponent;
import jsyntaxpane.actions.DocumentSearchData;
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();
}*/
}
@@ -1,122 +1,123 @@
/*
* 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.Window;
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(Window owner,String text,SearchListener<E> listener) {
super(owner);
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();
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());
}
});
}
}
}
/*
* 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.Window;
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
* @param <E>
*/
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(Window owner,String text,SearchListener<E> listener) {
super(owner);
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();
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());
}
});
}
}
}
@@ -43,7 +43,6 @@ 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;
@@ -94,24 +93,17 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ActionMap;
import javax.swing.BoxLayout;
import javax.swing.InputMap;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JToggleButton;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.border.BevelBorder;
@@ -121,13 +113,8 @@ import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.JTextComponent;
import javax.swing.tree.TreePath;
import jsyntaxpane.DefaultSyntaxKit;
import jsyntaxpane.actions.DocumentSearchData;
import jsyntaxpane.actions.QuickFindAction;
import jsyntaxpane.actions.SyntaxAction;
public class ABCPanel extends JPanel implements ItemListener, ActionListener, SearchListener<ABCPanelSearchResult>, Freed {
@@ -1,187 +1,186 @@
/*
* 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/>.
*/
package com.jpexs.decompiler.flash.gui.abc;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.usages.InsideClassMultinameUsage;
import com.jpexs.decompiler.flash.abc.usages.MethodMultinameUsage;
import com.jpexs.decompiler.flash.abc.usages.MultinameUsage;
import com.jpexs.decompiler.flash.abc.usages.TraitMultinameUsage;
import com.jpexs.decompiler.flash.gui.AppDialog;
import com.jpexs.decompiler.flash.gui.AppFrame;
import com.jpexs.decompiler.flash.gui.View;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
/**
*
* @author JPEXS
*/
public class UsageFrame extends AppDialog implements ActionListener, MouseListener {
static final String ACTION_GOTO = "GOTO";
static final String ACTION_CANCEL = "CANCEL";
private final JButton gotoButton = new JButton(translate("button.goto"));
private final JButton cancelButton = new JButton(translate("button.cancel"));
private final JList usageList;
private final UsageListModel usageListModel;
private final ABCPanel abcPanel;
public UsageFrame(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, ABCPanel abcPanel, boolean definitions) {
super(abcPanel.getMainPanel().getMainFrame().getWindow());
this.abcPanel = abcPanel;
List<MultinameUsage> usages = definitions?abc.findMultinameDefinition(abcTags,multinameIndex):abc.findMultinameUsage(abcTags,multinameIndex);
Multiname m = abc.constants.constant_multiname.get(multinameIndex);
if(m.namespace_index>0 && abc.constants.constant_namespace.get(m.namespace_index).kind != Namespace.KIND_PRIVATE)
{
for(ABCContainerTag at:abcTags){
ABC a = at.getABC();
if(a == abc){
continue;
}
int mid=a.constants.getMultinameId(m,false);
if(mid>0){
usages.addAll(definitions?a.findMultinameDefinition(abcTags, mid):a.findMultinameUsage(abcTags, mid));
}
}
}
usageListModel = new UsageListModel();
for (MultinameUsage u : usages) {
usageListModel.addElement(u);
}
usageList = new JList<>(usageListModel);
usageList.setBackground(Color.white);
gotoButton.setActionCommand(ACTION_GOTO);
gotoButton.addActionListener(this);
cancelButton.setActionCommand(ACTION_CANCEL);
cancelButton.addActionListener(this);
JPanel buttonsPanel = new JPanel();
buttonsPanel.setLayout(new FlowLayout());
buttonsPanel.add(gotoButton);
buttonsPanel.add(cancelButton);
usageList.addMouseListener(this);
Container cont = getContentPane();
cont.setLayout(new BorderLayout());
cont.add(new JScrollPane(usageList), BorderLayout.CENTER);
cont.add(buttonsPanel, BorderLayout.SOUTH);
setSize(400, 300);
setTitle((definitions?translate("dialog.title.declaration"):translate("dialog.title")) + abc.constants.getMultiname(multinameIndex).getNameWithNamespace(abc.constants));
View.centerScreen(this);
View.setWindowIcon(this);
}
public static void gotoUsage(final ABCPanel abcPanel,final MultinameUsage usage){
if (usage instanceof InsideClassMultinameUsage) {
final InsideClassMultinameUsage icu = (InsideClassMultinameUsage) usage;
Runnable settrait = new Runnable() {
@Override
public void run() {
abcPanel.decompiledTextArea.removeScriptListener(this);
abcPanel.decompiledTextArea.setClassIndex(icu.classIndex);
if (usage instanceof TraitMultinameUsage) {
TraitMultinameUsage tmu = (TraitMultinameUsage) usage;
int traitIndex;
if (tmu.parentTraitIndex > -1) {
traitIndex = tmu.parentTraitIndex;
} else {
traitIndex = tmu.traitIndex;
}
if (!tmu.isStatic) {
traitIndex += abcPanel.abc.class_info.get(tmu.classIndex).static_traits.traits.size();
}
if (tmu instanceof MethodMultinameUsage) {
MethodMultinameUsage mmu = (MethodMultinameUsage) usage;
if (mmu.isInitializer == true) {
traitIndex = abcPanel.abc.class_info.get(mmu.classIndex).static_traits.traits.size() + abcPanel.abc.instance_info.get(mmu.classIndex).instance_traits.traits.size() + (mmu.isStatic ? 1 : 0);
}
}
abcPanel.decompiledTextArea.gotoTrait(traitIndex);
}
}
};
if(abcPanel.decompiledTextArea.getClassIndex() == icu.classIndex && abcPanel.abc == icu.abc){
settrait.run();
}else{
abcPanel.decompiledTextArea.addScriptListener(settrait);
abcPanel.hilightScript(abcPanel.swf, abcPanel.abc.instance_info.get(icu.classIndex).getName(abcPanel.abc.constants).getNameWithNamespace(abcPanel.abc.constants));
}
}
}
private void gotoUsage() {
if (usageList.getSelectedIndex() != -1) {
MultinameUsage usage = usageListModel.getUsage(usageList.getSelectedIndex());
gotoUsage(abcPanel,usage);
}
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_GOTO:
gotoUsage();
setVisible(false);
break;
case ACTION_CANCEL:
setVisible(false);
break;
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
gotoUsage();
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
}
/*
* 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/>.
*/
package com.jpexs.decompiler.flash.gui.abc;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.types.Multiname;
import com.jpexs.decompiler.flash.abc.types.Namespace;
import com.jpexs.decompiler.flash.abc.usages.InsideClassMultinameUsage;
import com.jpexs.decompiler.flash.abc.usages.MethodMultinameUsage;
import com.jpexs.decompiler.flash.abc.usages.MultinameUsage;
import com.jpexs.decompiler.flash.abc.usages.TraitMultinameUsage;
import com.jpexs.decompiler.flash.gui.AppDialog;
import com.jpexs.decompiler.flash.gui.View;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
/**
*
* @author JPEXS
*/
public class UsageFrame extends AppDialog implements ActionListener, MouseListener {
static final String ACTION_GOTO = "GOTO";
static final String ACTION_CANCEL = "CANCEL";
private final JButton gotoButton = new JButton(translate("button.goto"));
private final JButton cancelButton = new JButton(translate("button.cancel"));
private final JList usageList;
private final UsageListModel usageListModel;
private final ABCPanel abcPanel;
public UsageFrame(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, ABCPanel abcPanel, boolean definitions) {
super(abcPanel.getMainPanel().getMainFrame().getWindow());
this.abcPanel = abcPanel;
List<MultinameUsage> usages = definitions?abc.findMultinameDefinition(abcTags,multinameIndex):abc.findMultinameUsage(abcTags,multinameIndex);
Multiname m = abc.constants.constant_multiname.get(multinameIndex);
if(m.namespace_index>0 && abc.constants.constant_namespace.get(m.namespace_index).kind != Namespace.KIND_PRIVATE)
{
for(ABCContainerTag at:abcTags){
ABC a = at.getABC();
if(a == abc){
continue;
}
int mid=a.constants.getMultinameId(m,false);
if(mid>0){
usages.addAll(definitions?a.findMultinameDefinition(abcTags, mid):a.findMultinameUsage(abcTags, mid));
}
}
}
usageListModel = new UsageListModel();
for (MultinameUsage u : usages) {
usageListModel.addElement(u);
}
usageList = new JList<>(usageListModel);
usageList.setBackground(Color.white);
gotoButton.setActionCommand(ACTION_GOTO);
gotoButton.addActionListener(this);
cancelButton.setActionCommand(ACTION_CANCEL);
cancelButton.addActionListener(this);
JPanel buttonsPanel = new JPanel();
buttonsPanel.setLayout(new FlowLayout());
buttonsPanel.add(gotoButton);
buttonsPanel.add(cancelButton);
usageList.addMouseListener(this);
Container cont = getContentPane();
cont.setLayout(new BorderLayout());
cont.add(new JScrollPane(usageList), BorderLayout.CENTER);
cont.add(buttonsPanel, BorderLayout.SOUTH);
setSize(400, 300);
setTitle((definitions?translate("dialog.title.declaration"):translate("dialog.title")) + abc.constants.getMultiname(multinameIndex).getNameWithNamespace(abc.constants));
View.centerScreen(this);
View.setWindowIcon(this);
}
public static void gotoUsage(final ABCPanel abcPanel,final MultinameUsage usage){
if (usage instanceof InsideClassMultinameUsage) {
final InsideClassMultinameUsage icu = (InsideClassMultinameUsage) usage;
Runnable settrait = new Runnable() {
@Override
public void run() {
abcPanel.decompiledTextArea.removeScriptListener(this);
abcPanel.decompiledTextArea.setClassIndex(icu.classIndex);
if (usage instanceof TraitMultinameUsage) {
TraitMultinameUsage tmu = (TraitMultinameUsage) usage;
int traitIndex;
if (tmu.parentTraitIndex > -1) {
traitIndex = tmu.parentTraitIndex;
} else {
traitIndex = tmu.traitIndex;
}
if (!tmu.isStatic) {
traitIndex += abcPanel.abc.class_info.get(tmu.classIndex).static_traits.traits.size();
}
if (tmu instanceof MethodMultinameUsage) {
MethodMultinameUsage mmu = (MethodMultinameUsage) usage;
if (mmu.isInitializer == true) {
traitIndex = abcPanel.abc.class_info.get(mmu.classIndex).static_traits.traits.size() + abcPanel.abc.instance_info.get(mmu.classIndex).instance_traits.traits.size() + (mmu.isStatic ? 1 : 0);
}
}
abcPanel.decompiledTextArea.gotoTrait(traitIndex);
}
}
};
if(abcPanel.decompiledTextArea.getClassIndex() == icu.classIndex && abcPanel.abc == icu.abc){
settrait.run();
}else{
abcPanel.decompiledTextArea.addScriptListener(settrait);
abcPanel.hilightScript(abcPanel.swf, abcPanel.abc.instance_info.get(icu.classIndex).getName(abcPanel.abc.constants).getNameWithNamespace(abcPanel.abc.constants));
}
}
}
private void gotoUsage() {
if (usageList.getSelectedIndex() != -1) {
MultinameUsage usage = usageListModel.getUsage(usageList.getSelectedIndex());
gotoUsage(abcPanel,usage);
}
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_GOTO:
gotoUsage();
setVisible(false);
break;
case ACTION_CANCEL:
setVisible(false);
break;
}
}
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
gotoUsage();
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
}
@@ -1,46 +1,41 @@
/*
* 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/>.
*/
package com.jpexs.decompiler.flash.gui.abc;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.abc.usages.MultinameUsage;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
/**
*
* @author JPEXS
*/
public class UsageListModel extends DefaultListModel<Object> {
@Override
public Object get(int index) {
return ((MultinameUsage) super.get(index)).toString();
}
@Override
public Object getElementAt(int index) {
return ((MultinameUsage) super.getElementAt(index)).toString();
}
public MultinameUsage getUsage(int index) {
return ((MultinameUsage) super.getElementAt(index));
}
}
/*
* 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/>.
*/
package com.jpexs.decompiler.flash.gui.abc;
import com.jpexs.decompiler.flash.abc.usages.MultinameUsage;
import javax.swing.DefaultListModel;
/**
*
* @author JPEXS
*/
public class UsageListModel extends DefaultListModel<Object> {
@Override
public Object get(int index) {
return ((MultinameUsage) super.get(index)).toString();
}
@Override
public Object getElementAt(int index) {
return ((MultinameUsage) super.getElementAt(index)).toString();
}
public MultinameUsage getUsage(int index) {
return ((MultinameUsage) super.getElementAt(index));
}
}