action lsiteners converted to java 8 member references 1

This commit is contained in:
honfika@gmail.com
2015-05-01 23:58:36 +02:00
parent 0750a000c6
commit e7ce5e46a0
38 changed files with 1312 additions and 1636 deletions

View File

@@ -30,7 +30,6 @@ import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.text.ParseException;
@@ -68,10 +67,16 @@ import org.pushingpixels.substance.api.skin.SkinInfo;
*
* @author JPEXS
*/
public class AdvancedSettingsDialog extends AppDialog implements ActionListener {
public class AdvancedSettingsDialog extends AppDialog {
private final Map<String, Component> componentsMap = new HashMap<>();
private JButton cancelButton;
private JButton okButton;
private JButton resetButton;
/**
* Creates new form AdvancedSettingsDialog
*/
@@ -145,16 +150,13 @@ public class AdvancedSettingsDialog extends AppDialog implements ActionListener
setPreferredSize(new java.awt.Dimension(800, 500));
okButton.setText(AppStrings.translate("button.ok"));
okButton.addActionListener(this);
okButton.setActionCommand("OK");
okButton.addActionListener(this::okButtonActionPerformed);
cancelButton.setText(AppStrings.translate("button.cancel"));
cancelButton.addActionListener(this);
cancelButton.setActionCommand("CANCEL");
cancelButton.addActionListener(this::cancelButtonActionPerformed);
resetButton.setText(AppStrings.translate("button.reset"));
resetButton.addActionListener(this);
resetButton.setActionCommand("RESET");
resetButton.addActionListener(this::resetButtonActionPerformed);
Container cnt = getContentPane();
cnt.setLayout(new BorderLayout());
@@ -376,120 +378,109 @@ public class AdvancedSettingsDialog extends AppDialog implements ActionListener
}
}
private JButton cancelButton;
private JButton okButton;
private JButton resetButton;
//private EachRowRendererEditor configurationTable;
@Override
@SuppressWarnings("unchecked")
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case "OK":
boolean modified = false;
Map<String, Field> fields = Configuration.getConfigurationFields();
Map<String, Object> values = new HashMap<>();
for (String name : fields.keySet()) {
Component c = componentsMap.get(name);
Object value = null;
private void okButtonActionPerformed(ActionEvent evt) {
boolean modified = false;
Map<String, Field> fields = Configuration.getConfigurationFields();
Map<String, Object> values = new HashMap<>();
for (String name : fields.keySet()) {
Component c = componentsMap.get(name);
Object value = null;
ParameterizedType listType = (ParameterizedType) fields.get(name).getGenericType();
Class itemType = (Class<?>) listType.getActualTypeArguments()[0];
if (name.equals("gui.skin")) {
value = ((SkinSelect) ((JComboBox<SkinSelect>) c).getSelectedItem()).className;
} else if (itemType == String.class) {
value = ((JTextField) c).getText();
}
if (itemType == Boolean.class) {
value = ((JCheckBox) c).isSelected();
}
ParameterizedType listType = (ParameterizedType) fields.get(name).getGenericType();
Class itemType = (Class<?>) listType.getActualTypeArguments()[0];
if (name.equals("gui.skin")) {
value = ((SkinSelect) ((JComboBox<SkinSelect>) c).getSelectedItem()).className;
} else if (itemType == String.class) {
value = ((JTextField) c).getText();
}
if (itemType == Boolean.class) {
value = ((JCheckBox) c).isSelected();
}
if (itemType == Calendar.class) {
Calendar cal = Calendar.getInstance();
try {
cal.setTime(new SimpleDateFormat().parse(((JTextField) c).getText()));
} catch (ParseException ex) {
c.requestFocusInWindow();
return;
}
value = cal;
}
if (itemType.isEnum()) {
String stringValue = (String) ((JComboBox<String>) c).getSelectedItem();
value = Enum.valueOf(itemType, stringValue);
}
try {
if (itemType == Integer.class) {
value = Integer.parseInt(((JTextField) c).getText());
}
if (itemType == Long.class) {
value = Long.parseLong(((JTextField) c).getText());
}
if (itemType == Double.class) {
value = Double.parseDouble(((JTextField) c).getText());
}
if (itemType == Float.class) {
value = Float.parseFloat(((JTextField) c).getText());
}
} catch (NumberFormatException nfe) {
if (!((JTextField) c).getText().isEmpty()) {
c.requestFocusInWindow();
return;
} // else null
}
values.put(name, value);
if (itemType == Calendar.class) {
Calendar cal = Calendar.getInstance();
try {
cal.setTime(new SimpleDateFormat().parse(((JTextField) c).getText()));
} catch (ParseException ex) {
c.requestFocusInWindow();
return;
}
value = cal;
}
for (String name : fields.keySet()) {
Component c = componentsMap.get(name);
Object value = values.get(name);
if (itemType.isEnum()) {
String stringValue = (String) ((JComboBox<String>) c).getSelectedItem();
value = Enum.valueOf(itemType, stringValue);
}
Field field = fields.get(name);
ConfigurationItem item = null;
try {
item = (ConfigurationItem) field.get(null);
} catch (IllegalArgumentException | IllegalAccessException ex) {
// Reflection exceptions. This should never happen
throw new Error(ex.getMessage());
}
if (item.get() == null || !item.get().equals(value)) {
if (item.hasValue() || value != null) {
item.set(value);
modified = true;
}
}
try {
if (itemType == Integer.class) {
value = Integer.parseInt(((JTextField) c).getText());
}
Configuration.saveConfig();
setVisible(false);
if (modified) {
showRestartConfirmDialod();
if (itemType == Long.class) {
value = Long.parseLong(((JTextField) c).getText());
}
break;
case "CANCEL":
setVisible(false);
break;
case "RESET":
if (itemType == Double.class) {
value = Double.parseDouble(((JTextField) c).getText());
}
if (itemType == Float.class) {
value = Float.parseFloat(((JTextField) c).getText());
}
} catch (NumberFormatException nfe) {
if (!((JTextField) c).getText().isEmpty()) {
c.requestFocusInWindow();
return;
} // else null
}
values.put(name, value);
}
Map<String, Field> rfields = Configuration.getConfigurationFields();
for (Entry<String, Field> entry : rfields.entrySet()) {
String name = entry.getKey();
Field field = entry.getValue();
try {
ConfigurationItem item = (ConfigurationItem) field.get(null);
item.unset();
} catch (IllegalArgumentException | IllegalAccessException ex) {
// Reflection exceptions. This should never happen
throw new Error(ex.getMessage());
}
for (String name : fields.keySet()) {
Component c = componentsMap.get(name);
Object value = values.get(name);
Field field = fields.get(name);
ConfigurationItem item = null;
try {
item = (ConfigurationItem) field.get(null);
} catch (IllegalArgumentException | IllegalAccessException ex) {
// Reflection exceptions. This should never happen
throw new Error(ex.getMessage());
}
if (item.get() == null || !item.get().equals(value)) {
if (item.hasValue() || value != null) {
item.set(value);
modified = true;
}
Configuration.saveConfig();
setVisible(false);
showRestartConfirmDialod();
break;
}
}
Configuration.saveConfig();
setVisible(false);
if (modified) {
showRestartConfirmDialod();
}
}
private void cancelButtonActionPerformed(ActionEvent evt) {
setVisible(false);
}
private void resetButtonActionPerformed(ActionEvent evt) {
Map<String, Field> rfields = Configuration.getConfigurationFields();
for (Entry<String, Field> entry : rfields.entrySet()) {
String name = entry.getKey();
Field field = entry.getValue();
try {
ConfigurationItem item = (ConfigurationItem) field.get(null);
item.unset();
} catch (IllegalArgumentException | IllegalAccessException ex) {
// Reflection exceptions. This should never happen
throw new Error(ex.getMessage());
}
}
Configuration.saveConfig();
setVisible(false);
showRestartConfirmDialod();
}
}

View File

@@ -24,7 +24,6 @@ import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
@@ -36,14 +35,10 @@ import javax.swing.text.Document;
*
* @author JPEXS
*/
public class DebugLogDialog extends AppDialog implements ActionListener {
public class DebugLogDialog extends AppDialog {
private final JTextArea logTextArea = new JTextArea();
private final String ACTION_CLOSE = "CLOSE";
private final String ACTION_CLEAR = "CLEAR";
private final Debugger debug;
public DebugLogDialog(Debugger debug) {
@@ -73,12 +68,10 @@ public class DebugLogDialog extends AppDialog implements ActionListener {
JPanel buttonsPanel = new JPanel(new FlowLayout());
JButton clearButton = new JButton(translate("button.clear"));
clearButton.setActionCommand(ACTION_CLEAR);
clearButton.addActionListener(this);
clearButton.addActionListener(this::clearButtonActionPerformed);
JButton closeButton = new JButton(translate("button.close"));
closeButton.setActionCommand(ACTION_CLOSE);
closeButton.addActionListener(this);
closeButton.addActionListener(this::closeButtonActionPerformed);
buttonsPanel.add(clearButton);
buttonsPanel.add(closeButton);
@@ -96,15 +89,11 @@ public class DebugLogDialog extends AppDialog implements ActionListener {
}
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_CLEAR:
logTextArea.setText("");
break;
case ACTION_CLOSE:
setVisible(false);
break;
}
private void clearButtonActionPerformed(ActionEvent evt) {
logTextArea.setText("");
}
private void closeButtonActionPerformed(ActionEvent evt) {
setVisible(false);
}
}

View File

@@ -30,6 +30,8 @@ import com.jpexs.decompiler.flash.exporters.modes.ShapeExportMode;
import com.jpexs.decompiler.flash.exporters.modes.SoundExportMode;
import com.jpexs.decompiler.flash.exporters.modes.SymbolClassExportMode;
import com.jpexs.decompiler.flash.exporters.modes.TextExportMode;
import static com.jpexs.decompiler.flash.gui.AppDialog.CANCEL_OPTION;
import static com.jpexs.decompiler.flash.gui.AppDialog.OK_OPTION;
import com.jpexs.decompiler.flash.gui.tagtree.TagTreeModel;
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
import com.jpexs.decompiler.flash.tags.DefineVideoStreamTag;
@@ -49,8 +51,6 @@ import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Arrays;
import java.util.List;
import javax.swing.JButton;
@@ -67,7 +67,7 @@ import javax.swing.JTextField;
*/
public class ExportDialog extends AppDialog {
boolean cancelled = false;
private int result = ERROR_OPTION;
String[] optionNames = {
TagTreeModel.FOLDER_SHAPES,
@@ -126,7 +126,7 @@ public class ExportDialog extends AppDialog {
private final JComboBox[] combos;
private final JCheckBox[] checkBoxes;
private final JCheckBox selectAllCheckBox;
private JTextField zoomTextField = new JTextField();
@@ -138,7 +138,7 @@ public class ExportDialog extends AppDialog {
return values[combos[i].getSelectedIndex()];
}
}
return null;
}
@@ -148,7 +148,7 @@ public class ExportDialog extends AppDialog {
return checkBoxes[i].isSelected();
}
}
return false;
}
@@ -168,7 +168,7 @@ public class ExportDialog extends AppDialog {
}
cfg += key;
}
Configuration.lastSelectedExportZoom.set(Double.parseDouble(zoomTextField.getText()) / 100);
Configuration.lastSelectedExportFormats.set(cfg);
}
@@ -176,12 +176,6 @@ public class ExportDialog extends AppDialog {
public ExportDialog(List<TreeItem> exportables) {
setTitle(translate("dialog.title"));
setResizable(false);
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
cancelled = true;
}
});
Container cnt = getContentPane();
cnt.setLayout(new BorderLayout());
@@ -201,24 +195,24 @@ public class ExportDialog extends AppDialog {
}
}
}
if (!exportableExists) {
continue;
}
exportableExistsArray[i] = true;
JLabel label = new JLabel(translate(optionNames[i]));
if (label.getPreferredSize().width > labWidth) {
labWidth = label.getPreferredSize().width;
}
}
String exportFormatsStr = Configuration.lastSelectedExportFormats.get();
if ("".equals(exportFormatsStr)) {
exportFormatsStr = null;
}
String exportFormatsArr[] = new String[0];
if (exportFormatsStr != null) {
if (exportFormatsStr.contains(",")) {
@@ -228,7 +222,7 @@ public class ExportDialog extends AppDialog {
}
}
int comboWidth = 200;
int checkBoxWidth;
int top = 10;
@@ -243,14 +237,14 @@ public class ExportDialog extends AppDialog {
selectAllCheckBox.addActionListener((ActionEvent e) -> {
boolean selected = selectAllCheckBox.isSelected();
for (JCheckBox checkBox : checkBoxes) {
if (checkBox != null){
if (checkBox != null) {
checkBox.setSelected(selected);
}
}
});
comboPanel.add(selectAllCheckBox);
top += selectAllCheckBox.getHeight();
boolean zoomable = false;
for (int i = 0; i < optionNames.length; i++) {
Class c = optionClasses[i];
@@ -270,7 +264,7 @@ public class ExportDialog extends AppDialog {
if (itemIndex > -1) {
combos[i].setSelectedIndex(itemIndex);
}
combos[i].setBounds(10 + labWidth + 10, top, comboWidth, combos[i].getPreferredSize().height);
checkBoxes[i] = new JCheckBox();
@@ -284,7 +278,7 @@ public class ExportDialog extends AppDialog {
if (Arrays.asList(zoomClasses).contains(c)) {
zoomable = true;
}
JLabel lab = new JLabel(translate(optionNames[i]));
lab.setBounds(10, top, lab.getPreferredSize().width, lab.getPreferredSize().height);
comboPanel.add(lab);
@@ -292,7 +286,7 @@ public class ExportDialog extends AppDialog {
comboPanel.add(combos[i]);
top += combos[i].getHeight();
}
int zoomWidth = 50;
if (zoomable) {
top += 2;
@@ -315,23 +309,10 @@ public class ExportDialog extends AppDialog {
JPanel buttonsPanel = new JPanel(new FlowLayout());
JButton okButton = new JButton(translate("button.ok"));
okButton.addActionListener((ActionEvent e) -> {
try {
saveConfig();
} catch (NumberFormatException nfe) {
JOptionPane.showMessageDialog(ExportDialog.this, translate("zoom.invalid"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
zoomTextField.requestFocusInWindow();
return;
}
setVisible(false);
});
okButton.addActionListener(this::okButtonActionPerformed);
JButton cancelButton = new JButton(translate("button.cancel"));
cancelButton.addActionListener((ActionEvent e) -> {
cancelled = true;
setVisible(false);
});
cancelButton.addActionListener(this::cancelButtonActionPerformed);
buttonsPanel.add(okButton);
buttonsPanel.add(cancelButton);
@@ -346,15 +327,38 @@ public class ExportDialog extends AppDialog {
if (pct.endsWith(".0")) {
pct = pct.substring(0, pct.length() - 2);
}
zoomTextField.setText(pct);
}
@Override
public void setVisible(boolean b) {
if (b) {
cancelled = false;
result = ERROR_OPTION;
}
super.setVisible(b);
}
private void okButtonActionPerformed(ActionEvent evt) {
result = OK_OPTION;
try {
saveConfig();
} catch (NumberFormatException nfe) {
JOptionPane.showMessageDialog(ExportDialog.this, translate("zoom.invalid"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
zoomTextField.requestFocusInWindow();
return;
}
setVisible(false);
}
private void cancelButtonActionPerformed(ActionEvent evt) {
result = CANCEL_OPTION;
setVisible(false);
}
public int showExportDialog() {
setVisible(true);
return result;
}
}

View File

@@ -26,7 +26,6 @@ import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyAdapter;
@@ -56,13 +55,7 @@ import javax.swing.filechooser.FileFilter;
*
* @author JPEXS
*/
public class FontEmbedDialog extends AppDialog implements ActionListener {
private static final String ACTION_OK = "OK";
private static final String ACTION_CANCEL = "CANCEL";
private static final String ACTION_LOAD_FROM_DISK = "LOAD_FROM_DISK";
public class FontEmbedDialog extends AppDialog {
private static final int SAMPLE_MAX_LENGTH = 50;
@@ -78,7 +71,7 @@ public class FontEmbedDialog extends AppDialog implements ActionListener {
private final JTextField individualCharsField;
private boolean result = false;
private int result = ERROR_OPTION;
private JLabel individialSample;
@@ -167,8 +160,7 @@ public class FontEmbedDialog extends AppDialog implements ActionListener {
faceSelection.setSelectedItem(selectedFace);
JButton loadFromDiskButton = new JButton(View.getIcon("open16"));
loadFromDiskButton.setToolTipText(translate("button.loadfont"));
loadFromDiskButton.addActionListener(this);
loadFromDiskButton.setActionCommand(ACTION_LOAD_FROM_DISK);
loadFromDiskButton.addActionListener(this::loadFromDiscButtonActionPerformed);
selFontPanel.add(installedRadio);
selFontPanel.add(familyNamesSelection);
selFontPanel.add(faceSelection);
@@ -268,11 +260,9 @@ public class FontEmbedDialog extends AppDialog implements ActionListener {
JPanel buttonsPanel = new JPanel(new FlowLayout());
JButton okButton = new JButton(AppStrings.translate("button.ok"));
okButton.setActionCommand(ACTION_OK);
okButton.addActionListener(this);
okButton.addActionListener(this::okButtonActionPerformed);
JButton cancelButton = new JButton(AppStrings.translate("button.cancel"));
cancelButton.setActionCommand(ACTION_CANCEL);
cancelButton.addActionListener(this);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
buttonsPanel.add(okButton);
buttonsPanel.add(cancelButton);
cnt.add(buttonsPanel);
@@ -345,25 +335,32 @@ public class FontEmbedDialog extends AppDialog implements ActionListener {
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_OK:
result = true;
setVisible(false);
break;
case ACTION_CANCEL:
result = false;
setVisible(false);
break;
case ACTION_LOAD_FROM_DISK:
if (customFont != null) {
if (loadFromDisk()) {
updateCheckboxes();
}
}
ttfFileRadio.setSelected(true);
break;
public void setVisible(boolean b) {
if (b) {
result = ERROR_OPTION;
}
super.setVisible(b);
}
private void okButtonActionPerformed(ActionEvent evt) {
result = OK_OPTION;
setVisible(false);
}
private void cancelButtonActionPerformed(ActionEvent evt) {
result = CANCEL_OPTION;
setVisible(false);
}
private void loadFromDiscButtonActionPerformed(ActionEvent evt) {
if (customFont != null) {
if (loadFromDisk()) {
updateCheckboxes();
}
}
ttfFileRadio.setSelected(true);
}
private boolean loadFromDisk() {
@@ -401,8 +398,7 @@ public class FontEmbedDialog extends AppDialog implements ActionListener {
return false;
}
public boolean display() {
result = false;
public int showDialog() {
setVisible(true);
return result;
}

View File

@@ -286,7 +286,7 @@ public class FontPanel extends JPanel {
contentPanel = new JPanel();
contentScrollPane.setBorder(null);
contentScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
TableLayout tlFontParamsPanel;
fontParamsPanel.setLayout(tlFontParamsPanel = new TableLayout(new double[][]{
{TableLayout.PREFERRED, TableLayout.FILL},
@@ -475,7 +475,7 @@ public class FontPanel extends JPanel {
contentPanel.add(buttonsPanel, "0,1");
contentPanel.add(addCharsPanel, "0,2");
contentScrollPane.setViewportView(contentPanel);
setLayout(new BorderLayout());
add(contentScrollPane, BorderLayout.CENTER);
@@ -504,7 +504,7 @@ public class FontPanel extends JPanel {
if (item instanceof FontTag) {
FontTag ft = (FontTag) item;
FontEmbedDialog fed = new FontEmbedDialog((FontFace) fontFaceSelection.getSelectedItem(), fontAddCharactersField.getText());
if (fed.display()) {
if (fed.showDialog() == AppDialog.OK_OPTION) {
Set<Integer> selChars = fed.getSelectedChars();
if (!selChars.isEmpty()) {
Font selFont = fed.getSelectedFont();

View File

@@ -47,8 +47,6 @@ import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
@@ -70,7 +68,7 @@ import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.JLabel;
import javax.swing.JPanel;
public final class ImagePanel extends JPanel implements ActionListener, MediaDisplay {
public final class ImagePanel extends JPanel implements MediaDisplay {
private final List<MediaDisplayListener> listeners = new ArrayList<>();
@@ -462,15 +460,15 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
}
private synchronized void redraw() {
if (!isPlaying()){
if (!isPlaying()) {
counter++;
}
if (timer == null) {
startTimer(counter, timelined.getTimeline(), false);
}
}
@Override
public synchronized void zoom(Zoom zoom) {
boolean modified = this.zoom.value != zoom.value || this.zoom.fit != zoom.fit;
@@ -485,11 +483,6 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
}
}
@Override
public void actionPerformed(ActionEvent e) {
}
@Override
public synchronized BufferedImage printScreen() {
return iconPanel.getLastImage();
@@ -955,7 +948,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
if (!stillFrame && frame == timeline.getFrameCount() - 1) {
frame = 0;
}
startTimer(counter, timeline, true);
}
}
@@ -987,7 +980,7 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
timer = null;
}
}
fireMediaDisplayStateChanged();
} else {
nextFrame(taskCounter);
@@ -1017,11 +1010,11 @@ public final class ImagePanel extends JPanel implements ActionListener, MediaDis
if (timelined == null) {
return false;
}
if (stillFrame) {
return false;
}
return (timelined.getTimeline().getFrameCount() <= 1) || (timer != null);
}

View File

@@ -28,7 +28,6 @@ import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
@@ -55,13 +54,7 @@ import javax.swing.filechooser.FileFilter;
*
* @author JPEXS
*/
public class LoadFromCacheFrame extends AppFrame implements ActionListener {
private static final String ACTION_OPEN = "OPEN";
private static final String ACTION_SAVE = "SAVE";
private static final String ACTION_REFRESH = "REFRESH";
public class LoadFromCacheFrame extends AppFrame {
private final JList<CacheEntry> list;
@@ -120,18 +113,15 @@ public class LoadFromCacheFrame extends AppFrame implements ActionListener {
JPanel buttonsPanel = new JPanel(new FlowLayout());
openButton = new JButton(translate("button.open"));
openButton.setActionCommand(ACTION_OPEN);
openButton.addActionListener(this);
openButton.addActionListener(this::openButtonActionPerformed);
buttonsPanel.add(openButton);
saveButton = new JButton(translate("button.save"));
saveButton.setActionCommand(ACTION_SAVE);
saveButton.addActionListener(this);
saveButton.addActionListener(this::saveButtonActionPerformed);
buttonsPanel.add(saveButton);
refreshButton = new JButton(translate("button.refresh"));
refreshButton.setActionCommand(ACTION_REFRESH);
refreshButton.addActionListener(this);
refreshButton.addActionListener(this::refreshButtonActionPerformed);
buttonsPanel.add(refreshButton);
JPanel browsersPanel = new JPanel(new FlowLayout());
@@ -243,56 +233,53 @@ public class LoadFromCacheFrame extends AppFrame implements ActionListener {
}
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_REFRESH:
refresh();
break;
case ACTION_OPEN:
openSWF();
break;
case ACTION_SAVE:
List<CacheEntry> selected = list.getSelectedValuesList();
if (!selected.isEmpty()) {
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File(Configuration.lastSaveDir.get()));
if (selected.size() > 1) {
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
} else {
fc.setSelectedFile(new File(Configuration.lastSaveDir.get(), entryToFileName(selected.get(0))));
fc.setFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
return (f.getName().endsWith(".swf")) || (f.isDirectory());
}
private void refreshButtonActionPerformed(ActionEvent evt) {
refresh();
}
@Override
public String getDescription() {
return AppStrings.translate("filter.swf");
}
});
private void openButtonActionPerformed(ActionEvent evt) {
openSWF();
}
private void saveButtonActionPerformed(ActionEvent evt) {
List<CacheEntry> selected = list.getSelectedValuesList();
if (!selected.isEmpty()) {
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File(Configuration.lastSaveDir.get()));
if (selected.size() > 1) {
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
} else {
fc.setSelectedFile(new File(Configuration.lastSaveDir.get(), entryToFileName(selected.get(0))));
fc.setFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
return (f.getName().endsWith(".swf")) || (f.isDirectory());
}
fc.setAcceptAllFileFilterUsed(false);
JFrame f = new JFrame();
View.setWindowIcon(f);
if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
File file = Helper.fixDialogFile(fc.getSelectedFile());
try {
if (selected.size() == 1) {
Helper.saveStream(selected.get(0).getResponseDataStream(), file);
} else {
for (CacheEntry sel : selected) {
Helper.saveStream(sel.getResponseDataStream(), new File(file, entryToFileName(sel)));
}
}
Configuration.lastSaveDir.set(file.getParentFile().getAbsolutePath());
} catch (IOException ex) {
View.showMessageDialog(null, translate("error.file.write"));
@Override
public String getDescription() {
return AppStrings.translate("filter.swf");
}
});
}
fc.setAcceptAllFileFilterUsed(false);
JFrame f = new JFrame();
View.setWindowIcon(f);
if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
File file = Helper.fixDialogFile(fc.getSelectedFile());
try {
if (selected.size() == 1) {
Helper.saveStream(selected.get(0).getResponseDataStream(), file);
} else {
for (CacheEntry sel : selected) {
Helper.saveStream(sel.getResponseDataStream(), new File(file, entryToFileName(sel)));
}
}
Configuration.lastSaveDir.set(file.getParentFile().getAbsolutePath());
} catch (IOException ex) {
View.showMessageDialog(null, translate("error.file.write"));
}
break;
}
}
}
}

View File

@@ -32,7 +32,6 @@ import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
@@ -75,15 +74,7 @@ import javax.swing.table.TableRowSorter;
*
* @author JPEXS
*/
public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
private static final String ACTION_SELECT_PROCESS = "SELECTPROCESS";
private static final String ACTION_REFRESH_PROCESS_LIST = "REFRESHPROCESSLIST";
private static final String ACTION_OPEN_SWF = "OPENSWF";
private static final String ACTION_SAVE = "SAVE";
public class LoadFromMemoryFrame extends AppFrame {
private MainFrame mainFrame;
@@ -191,7 +182,7 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
}
}
private void openSWF() {
private void openSwf() {
if (foundIs == null) {
return;
}
@@ -324,7 +315,7 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() > 1) {
openSWF();
openSwf();
}
}
});
@@ -332,7 +323,7 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == 10) { //Enter pressed
openSWF();
openSwf();
}
}
});
@@ -362,11 +353,9 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
leftPanel.add(new JScrollPane(list), BorderLayout.CENTER);
JPanel leftButtonsPanel = new JPanel(new FlowLayout());
JButton selectButton = new JButton(translate("button.select"));
selectButton.setActionCommand(ACTION_SELECT_PROCESS);
selectButton.addActionListener(this);
selectButton.addActionListener(this::selectProcessButtonActionPerformed);
JButton refreshButton = new JButton(translate("button.refresh"));
refreshButton.setActionCommand(ACTION_REFRESH_PROCESS_LIST);
refreshButton.addActionListener(this);
refreshButton.addActionListener(this::refreshProcessListButtonActionPerformed);
leftButtonsPanel.add(selectButton);
leftButtonsPanel.add(refreshButton);
leftPanel.add(leftButtonsPanel, BorderLayout.SOUTH);
@@ -375,12 +364,10 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
rightPanel.add(new JScrollPane(tableRes), BorderLayout.CENTER);
JPanel rightButtonsPanel = new JPanel(new FlowLayout());
JButton openButton = new JButton(translate("button.open"));
openButton.setActionCommand(ACTION_OPEN_SWF);
openButton.addActionListener(this);
openButton.addActionListener(this::openSwfButtonActionPerformed);
JButton saveButton = new JButton(translate("button.save"));
saveButton.setActionCommand(ACTION_SAVE);
saveButton.addActionListener(this);
saveButton.addActionListener(this::saveButtonActionPerformed);
rightButtonsPanel.add(openButton);
rightButtonsPanel.add(saveButton);
@@ -405,68 +392,67 @@ public class LoadFromMemoryFrame extends AppFrame implements ActionListener {
setIconImages(images);
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_SELECT_PROCESS:
selectProcess();
break;
case ACTION_OPEN_SWF:
openSWF();
break;
case ACTION_REFRESH_PROCESS_LIST:
refreshList();
break;
case ACTION_SAVE:
if (foundIs == null) {
return;
}
int[] selected = tableRes.getSelectedRows();
if (selected.length > 0) {
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File(Configuration.lastSaveDir.get()));
if (selected.length > 1) {
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
} else {
fc.setSelectedFile(new File(Configuration.lastSaveDir.get(), "movie.swf"));
fc.setFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
return (f.getName().endsWith(".swf")) || (f.isDirectory());
}
private void selectProcessButtonActionPerformed(ActionEvent evt) {
selectProcess();
}
@Override
public String getDescription() {
return AppStrings.translate("filter.swf");
}
});
private void openSwfButtonActionPerformed(ActionEvent evt) {
openSwf();
}
private void refreshProcessListButtonActionPerformed(ActionEvent evt) {
refreshList();
}
private void saveButtonActionPerformed(ActionEvent evt) {
if (foundIs == null) {
return;
}
int[] selected = tableRes.getSelectedRows();
if (selected.length > 0) {
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File(Configuration.lastSaveDir.get()));
if (selected.length > 1) {
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
} else {
fc.setSelectedFile(new File(Configuration.lastSaveDir.get(), "movie.swf"));
fc.setFileFilter(new FileFilter() {
@Override
public boolean accept(File f) {
return (f.getName().endsWith(".swf")) || (f.isDirectory());
}
fc.setAcceptAllFileFilterUsed(false);
JFrame f = new JFrame();
View.setWindowIcon(f);
if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
File file = Helper.fixDialogFile(fc.getSelectedFile());
try {
if (selected.length == 1) {
SwfInMemory swf = foundIs.get(tableRes.getRowSorter().convertRowIndexToModel(selected[0]));
ReReadableInputStream bis = swf.is;
bis.seek(0);
Helper.saveStream(bis, file);
} else {
for (int sel : selected) {
SwfInMemory swf = foundIs.get(tableRes.getRowSorter().convertRowIndexToModel(sel));
ReReadableInputStream bis = swf.is;
bis.seek(0);
Helper.saveStream(bis, new File(file, "movie" + sel + ".swf"));
}
}
Configuration.lastSaveDir.set(file.getParentFile().getAbsolutePath());
} catch (IOException ex) {
View.showMessageDialog(null, translate("error.file.write"));
@Override
public String getDescription() {
return AppStrings.translate("filter.swf");
}
});
}
fc.setAcceptAllFileFilterUsed(false);
JFrame f = new JFrame();
View.setWindowIcon(f);
if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
File file = Helper.fixDialogFile(fc.getSelectedFile());
try {
if (selected.length == 1) {
SwfInMemory swf = foundIs.get(tableRes.getRowSorter().convertRowIndexToModel(selected[0]));
ReReadableInputStream bis = swf.is;
bis.seek(0);
Helper.saveStream(bis, file);
} else {
for (int sel : selected) {
SwfInMemory swf = foundIs.get(tableRes.getRowSorter().convertRowIndexToModel(sel));
ReReadableInputStream bis = swf.is;
bis.seek(0);
Helper.saveStream(bis, new File(file, "movie" + sel + ".swf"));
}
}
Configuration.lastSaveDir.set(file.getParentFile().getAbsolutePath());
} catch (IOException ex) {
View.showMessageDialog(null, translate("error.file.write"));
}
break;
}
}
}
}

View File

@@ -406,16 +406,16 @@ public class MainFrameClassicMenu extends MainFrameMenu implements ActionListene
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_RELOAD:
reload();
reload(null);
break;
case ACTION_ADVANCED_SETTINGS:
advancedSettings();
advancedSettings(null);
break;
case ACTION_LOAD_MEMORY:
loadFromMemory();
loadFromMemory(null);
break;
case ACTION_LOAD_CACHE:
loadFromCache();
loadFromCache(null);
break;
case ACTION_GOTO_DOCUMENT_CLASS_ON_STARTUP:
Configuration.gotoMainClassOnStartup.set(miGotoMainClassOnStartup.isSelected());

View File

@@ -30,6 +30,7 @@ import java.awt.Dimension;
import java.awt.KeyEventDispatcher;
import java.awt.KeyboardFocusManager;
import java.awt.ScrollPane;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.WindowEvent;
import java.io.ByteArrayInputStream;
@@ -308,7 +309,7 @@ public abstract class MainFrameMenu {
Main.about();
}
protected boolean reload() {
protected boolean reload(ActionEvent evt) {
if (swf != null) {
if (View.showConfirmDialog(null, translate("message.confirm.reload"), translate("message.warning"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
Main.reloadApp();
@@ -320,18 +321,23 @@ public abstract class MainFrameMenu {
return false;
}
protected void advancedSettings() {
protected void advancedSettings(ActionEvent evt) {
Main.advancedSettings();
}
protected void loadFromMemory() {
protected void loadFromMemory(ActionEvent evt) {
Main.loadFromMemory();
}
protected void loadFromCache() {
protected void loadFromCache(ActionEvent evt) {
Main.loadFromCache();
}
protected void gotoDucumentClassOnStartup(ActionEvent evt) {
boolean selected = true; // todo: honfika: get from evt.getSource()
Configuration.gotoMainClassOnStartup.set(selected);
}
protected void setLanguage() {
new SelectLanguageDialog().display();
}
@@ -367,7 +373,7 @@ public abstract class MainFrameMenu {
case KeyEvent.VK_T:
return search(true);
case KeyEvent.VK_R:
return reload();
return reload(null);
case KeyEvent.VK_X:
return closeAll();
case KeyEvent.VK_D:

View File

@@ -840,16 +840,16 @@ public class MainFrameRibbonMenu extends MainFrameMenu implements ActionListener
}
break;
case ACTION_RELOAD:
reload();
reload(null);
break;
case ACTION_ADVANCED_SETTINGS:
advancedSettings();
advancedSettings(null);
break;
case ACTION_LOAD_MEMORY:
loadFromMemory();
loadFromMemory(null);
break;
case ACTION_LOAD_CACHE:
loadFromCache();
loadFromCache(null);
break;
case ACTION_GOTO_DOCUMENT_CLASS_ON_STARTUP:
Configuration.gotoMainClassOnStartup.set(miGotoMainClassOnStartup.isSelected());

View File

@@ -36,9 +36,7 @@ import javax.swing.border.BevelBorder;
*
* @author JPEXS
*/
public class MainFrameStatusPanel extends JPanel implements ActionListener {
private static final String ACTION_SHOW_ERROR_LOG = "SHOWERRORLOG";
public class MainFrameStatusPanel extends JPanel {
private final MainPanel mainPanel;
@@ -96,8 +94,7 @@ public class MainFrameStatusPanel extends JPanel implements ActionListener {
errorNotificationButton.setContentAreaFilled(false);
errorNotificationButton.setMargin(new Insets(2, 2, 2, 2));
errorNotificationButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
errorNotificationButton.setActionCommand(ACTION_SHOW_ERROR_LOG);
errorNotificationButton.addActionListener(this);
errorNotificationButton.addActionListener(this::showErrorLogButtonActionPerformed);
errorNotificationButton.setToolTipText(translate("errors.none"));
add(errorNotificationButton, BorderLayout.EAST);
@@ -105,13 +102,8 @@ public class MainFrameStatusPanel extends JPanel implements ActionListener {
cancelButton.setVisible(false);
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_SHOW_ERROR_LOG:
Main.displayErrorFrame();
break;
}
private void showErrorLogButtonActionPerformed(ActionEvent evt) {
Main.displayErrorFrame();
}
private String translate(String key) {

View File

@@ -151,7 +151,6 @@ import java.awt.dnd.DragSourceListener;
import java.awt.dnd.DropTarget;
import java.awt.dnd.DropTargetDropEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
@@ -208,7 +207,7 @@ import javax.swing.tree.TreePath;
*
* @author JPEXS
*/
public final class MainPanel extends JPanel implements ActionListener, TreeSelectionListener, SearchListener<TextTag>, Freed {
public final class MainPanel extends JPanel implements TreeSelectionListener, SearchListener<TextTag>, Freed {
private final MainFrame mainFrame;
@@ -228,8 +227,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
private final JProgressBar progressBar = new JProgressBar(0, 100);
private DeobfuscationDialog deobfuscationDialog;
public TagTree tagTree;
public DumpTree dumpTree;
@@ -294,14 +291,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
public TreeItem oldItem;
private SearchDialog searchDialog;
private SearchDialog replaceDialog;
public static final String ACTION_SELECT_BKCOLOR = "SELECTCOLOR";
public static final String ACTION_REPLACE = "REPLACE";
// play morph shape in 2 second(s)
public static final int MORPH_SHAPE_ANIMATION_LENGTH = 2;
@@ -545,8 +534,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
treePanel = new JPanel(new BorderLayout());
treePanel.add(searchPanel, BorderLayout.SOUTH);
filterField.addActionListener(this);
searchPanel.setVisible(false);
filterField.getDocument().addDocumentListener(new DocumentListener() {
@@ -1354,10 +1341,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
}
public void searchInActionScriptOrText(Boolean searchInText) {
if (searchDialog == null) {
searchDialog = new SearchDialog(getMainFrame().getWindow(), false);
}
SearchDialog searchDialog = new SearchDialog(getMainFrame().getWindow(), false);
if (searchInText != null) {
if (searchInText) {
searchDialog.searchInTextsRadioButton.setSelected(true);
@@ -1366,8 +1350,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
}
}
searchDialog.setVisible(true);
if (searchDialog.result) {
if (searchDialog.showDialog() == AppDialog.OK_OPTION) {
final String txt = searchDialog.searchField.getText();
if (!txt.isEmpty()) {
final SWF swf = getCurrentSwf();
@@ -1411,12 +1394,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
}
public void replaceText() {
if (replaceDialog == null) {
replaceDialog = new SearchDialog(getMainFrame().getWindow(), true);
}
replaceDialog.setVisible(true);
if (replaceDialog.result) {
SearchDialog replaceDialog = new SearchDialog(getMainFrame().getWindow(), true);
if (replaceDialog.showDialog() == AppDialog.OK_OPTION) {
final String txt = replaceDialog.searchField.getText();
if (!txt.isEmpty()) {
final SWF swf = getCurrentSwf();
@@ -1818,8 +1797,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
}
}
final ExportDialog export = new ExportDialog(sel);
export.setVisible(true);
if (!export.cancelled) {
if (export.showExportDialog() == AppDialog.OK_OPTION) {
final String selFile = selectExportDir();
if (selFile != null) {
final long timeBefore = System.currentTimeMillis();
@@ -2004,11 +1982,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
}
public void deobfuscate() {
if (deobfuscationDialog == null) {
deobfuscationDialog = new DeobfuscationDialog();
}
deobfuscationDialog.setVisible(true);
if (deobfuscationDialog.ok) {
DeobfuscationDialog deobfuscationDialog = new DeobfuscationDialog();
if (deobfuscationDialog.showDialog() == AppDialog.OK_OPTION) {
Main.startWork(translate("work.deobfuscating") + "...");
new CancellableWorker() {
@Override
@@ -2221,121 +2196,129 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
return false;
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_SELECT_BKCOLOR:
Color newColor = JColorChooser.showDialog(null, AppStrings.translate("dialog.selectbkcolor.title"), View.getSwfBackgroundColor());
if (newColor != null) {
View.setSwfBackgroundColor(newColor);
public void selectBkColorButtonActionPerformed(ActionEvent evt) {
Color newColor = JColorChooser.showDialog(null, AppStrings.translate("dialog.selectbkcolor.title"), View.getSwfBackgroundColor());
if (newColor != null) {
View.setSwfBackgroundColor(newColor);
reload(true);
}
}
public void replaceButtonActionPerformed(ActionEvent evt) {
TreeItem item = tagTree.getCurrentTreeItem();
if (item == null) {
return;
}
if (item instanceof DefineSoundTag) {
File selectedFile = showImportFileChooser("filter.sounds|*.mp3;*.wav|filter.sounds.mp3|*.mp3|filter.sounds.wav|*.wav");
if (selectedFile != null) {
File selfile = Helper.fixDialogFile(selectedFile);
DefineSoundTag ds = (DefineSoundTag) item;
int soundFormat = SoundFormat.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN;
if (selfile.getName().toLowerCase().endsWith(".mp3")) {
soundFormat = SoundFormat.FORMAT_MP3;
}
boolean ok = false;
try {
ok = ds.setSound(new FileInputStream(selfile), soundFormat);
} catch (IOException ex) {
//ignore
}
if (!ok) {
View.showMessageDialog(null, translate("error.sound.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE);
} else {
reload(true);
}
break;
case ACTION_REPLACE: {
TreeItem item = tagTree.getCurrentTreeItem();
if (item == null) {
return;
}
if (item instanceof DefineSoundTag) {
File selectedFile = showImportFileChooser("filter.sounds|*.mp3;*.wav|filter.sounds.mp3|*.mp3|filter.sounds.wav|*.wav");
if (selectedFile != null) {
File selfile = Helper.fixDialogFile(selectedFile);
DefineSoundTag ds = (DefineSoundTag) item;
int soundFormat = SoundFormat.FORMAT_UNCOMPRESSED_LITTLE_ENDIAN;
if (selfile.getName().toLowerCase().endsWith(".mp3")) {
soundFormat = SoundFormat.FORMAT_MP3;
}
boolean ok = false;
try {
ok = ds.setSound(new FileInputStream(selfile), soundFormat);
} catch (IOException ex) {
//ignore
}
if (!ok) {
View.showMessageDialog(null, translate("error.sound.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE);
} else {
reload(true);
}
}
if (item instanceof ImageTag) {
ImageTag it = (ImageTag) item;
if (it.importSupported()) {
File selectedFile = showImportFileChooser("filter.images|*.jpg;*.jpeg;*.gif;*.png;*.bmp");
if (selectedFile != null) {
File selfile = Helper.fixDialogFile(selectedFile);
byte[] data = Helper.readFile(selfile.getAbsolutePath());
try {
Tag newTag = new ImageImporter().importImage(it, data);
SWF swf = it.getSwf();
if (newTag != null) {
refreshTree(swf);
setTagTreeSelectedNode(newTag);
}
swf.clearImageCache();
} catch (IOException ex) {
logger.log(Level.SEVERE, "Invalid image", ex);
View.showMessageDialog(null, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE);
}
}
if (item instanceof ImageTag) {
ImageTag it = (ImageTag) item;
if (it.importSupported()) {
File selectedFile = showImportFileChooser("filter.images|*.jpg;*.jpeg;*.gif;*.png;*.bmp");
if (selectedFile != null) {
File selfile = Helper.fixDialogFile(selectedFile);
byte[] data = Helper.readFile(selfile.getAbsolutePath());
try {
Tag newTag = new ImageImporter().importImage(it, data);
SWF swf = it.getSwf();
if (newTag != null) {
refreshTree(swf);
setTagTreeSelectedNode(newTag);
}
swf.clearImageCache();
} catch (IOException ex) {
logger.log(Level.SEVERE, "Invalid image", ex);
View.showMessageDialog(null, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE);
}
reload(true);
}
}
}
if (item instanceof ShapeTag) {
ShapeTag st = (ShapeTag) item;
File selectedFile = showImportFileChooser("filter.images|*.jpg;*.jpeg;*.gif;*.png;*.bmp");
if (selectedFile != null) {
File selfile = Helper.fixDialogFile(selectedFile);
byte[] data = Helper.readFile(selfile.getAbsolutePath());
try {
Tag newTag = new ShapeImporter().importImage(st, data);
SWF swf = st.getSwf();
if (newTag != null) {
refreshTree(swf);
setTagTreeSelectedNode(newTag);
}
swf.clearImageCache();
} catch (IOException ex) {
logger.log(Level.SEVERE, "Invalid image", ex);
View.showMessageDialog(null, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE);
}
reload(true);
}
}
if (item instanceof DefineBinaryDataTag) {
DefineBinaryDataTag bt = (DefineBinaryDataTag) item;
File selectedFile = showImportFileChooser("");
if (selectedFile != null) {
File selfile = Helper.fixDialogFile(selectedFile);
byte[] data = Helper.readFile(selfile.getAbsolutePath());
new BinaryDataImporter().importData(bt, data);
refreshTree(bt.getSwf());
reload(true);
}
reload(true);
}
}
break;
}
if (item instanceof ShapeTag) {
ShapeTag st = (ShapeTag) item;
File selectedFile = showImportFileChooser("filter.images|*.jpg;*.jpeg;*.gif;*.png;*.bmp");
if (selectedFile != null) {
File selfile = Helper.fixDialogFile(selectedFile);
byte[] data = Helper.readFile(selfile.getAbsolutePath());
try {
Tag newTag = new ShapeImporter().importImage(st, data);
SWF swf = st.getSwf();
if (newTag != null) {
refreshTree(swf);
setTagTreeSelectedNode(newTag);
}
swf.clearImageCache();
} catch (IOException ex) {
logger.log(Level.SEVERE, "Invalid image", ex);
View.showMessageDialog(null, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE);
}
reload(true);
}
}
if (item instanceof DefineBinaryDataTag) {
DefineBinaryDataTag bt = (DefineBinaryDataTag) item;
File selectedFile = showImportFileChooser("");
if (selectedFile != null) {
File selfile = Helper.fixDialogFile(selectedFile);
byte[] data = Helper.readFile(selfile.getAbsolutePath());
new BinaryDataImporter().importData(bt, data);
refreshTree(bt.getSwf());
reload(true);
}
}
}
public void exportJavaSourceActionPerformed(ActionEvent evt) {
if (Main.isWorking()) {
return;
}
switch (e.getActionCommand()) {
exportJavaSource();
}
case MainFrameRibbonMenu.ACTION_EXPORT_JAVA_SOURCE:
exportJavaSource();
break;
case MainFrameRibbonMenu.ACTION_EXPORT_SWF_XML:
exportSwfXml();
break;
case MainFrameRibbonMenu.ACTION_IMPORT_SWF_XML:
importSwfXml();
break;
case MainFrameRibbonMenu.ACTION_EXPORT_SEL:
export(true);
break;
public void exportSwfXmlActionPerformed(ActionEvent evt) {
if (Main.isWorking()) {
return;
}
exportSwfXml();
}
public void importSwfXmlActionPerformed(ActionEvent evt) {
if (Main.isWorking()) {
return;
}
importSwfXml();
}
public void exportSelectionActionPerformed(ActionEvent evt) {
if (Main.isWorking()) {
return;
}
export(true);
}
private File showImportFileChooser(String filter) {

View File

@@ -20,7 +20,6 @@ import com.jpexs.decompiler.flash.ApplicationInfo;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
@@ -31,13 +30,7 @@ import javax.swing.JLabel;
*
* @author JPEXS
*/
public class ModeFrame extends AppFrame implements ActionListener {
private static final String ACTION_OPEN = "OPEN";
private static final String ACTION_PROXY = "PROXY";
private static final String ACTION_EXIT = "EXIT";
public class ModeFrame extends AppFrame {
private final JButton openButton = new JButton(translate("button.open"));
@@ -50,14 +43,11 @@ public class ModeFrame extends AppFrame implements ActionListener {
*/
public ModeFrame() {
setSize(350, 200);
openButton.addActionListener(this);
openButton.setActionCommand(ACTION_OPEN);
openButton.addActionListener(this::openButtonActionPerformed);
openButton.setIcon(View.getIcon("open32"));
proxyButton.addActionListener(this);
proxyButton.setActionCommand(ACTION_PROXY);
proxyButton.addActionListener(this::proxyButtonActionPerformed);
proxyButton.setIcon(View.getIcon("proxy32"));
exitButton.addActionListener(this);
exitButton.setActionCommand(ACTION_EXIT);
exitButton.addActionListener(this::exitButtonActionPerformed);
exitButton.setIcon(View.getIcon("exit32"));
setResizable(false);
Container cont = getContentPane();
@@ -79,28 +69,20 @@ public class ModeFrame extends AppFrame implements ActionListener {
});
}
/**
* Method handling actions from buttons
*
* @param e event
*/
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_OPEN:
setVisible(false);
if (!Main.openFileDialog()) {
setVisible(true);
}
break;
case ACTION_PROXY:
setVisible(false);
Main.showProxy();
break;
case ACTION_EXIT:
setVisible(false);
Main.exit();
break;
private void openButtonActionPerformed(ActionEvent evt) {
setVisible(false);
if (!Main.openFileDialog()) {
setVisible(true);
}
}
private void proxyButtonActionPerformed(ActionEvent evt) {
setVisible(false);
Main.showProxy();
}
private void exitButtonActionPerformed(ActionEvent evt) {
setVisible(false);
Main.exit();
}
}

View File

@@ -22,7 +22,6 @@ import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -44,11 +43,7 @@ import javax.swing.UIManager;
*
* @author JPEXS
*/
public class NewVersionDialog extends AppDialog implements ActionListener {
private static final String ACTION_OK = "OK";
private static final String ACTION_CANCEL = "CANCEL";
public class NewVersionDialog extends AppDialog {
private Version latestVersion;
@@ -116,12 +111,10 @@ public class NewVersionDialog extends AppDialog implements ActionListener {
cnt.add(span);
JPanel buttonsPanel = new JPanel(new FlowLayout());
JButton buttonOk = new JButton(translate("button.ok"));
buttonOk.setActionCommand(ACTION_OK);
buttonOk.addActionListener(this);
buttonOk.addActionListener(this::okButtonActionPerformed);
JButton buttonCancel = new JButton(translate("button.cancel"));
buttonCancel.setActionCommand(ACTION_CANCEL);
buttonCancel.addActionListener(this);
buttonCancel.addActionListener(this::cancelButtonActionPerformed);
buttonsPanel.add(buttonOk);
buttonsPanel.add(buttonCancel);
@@ -141,21 +134,23 @@ public class NewVersionDialog extends AppDialog implements ActionListener {
View.setWindowIcon(this);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(ACTION_OK)) {
String url;
if (latestVersion.updateLink != null) {
url = latestVersion.updateLink;
} else {
url = ApplicationInfo.updateUrl;
}
if (View.navigateUrl(url)) {
Main.exit();
} else {
View.showMessageDialog(null, translate("newvermessage").replace("%oldAppName%", ApplicationInfo.SHORT_APPLICATION_NAME).replace("%newAppName%", latestVersion.appName).replace("%projectPage%", ApplicationInfo.PROJECT_PAGE), translate("newversion"), JOptionPane.INFORMATION_MESSAGE);
}
private void okButtonActionPerformed(ActionEvent evt) {
String url;
if (latestVersion.updateLink != null) {
url = latestVersion.updateLink;
} else {
url = ApplicationInfo.updateUrl;
}
if (View.navigateUrl(url)) {
Main.exit();
} else {
View.showMessageDialog(null, translate("newvermessage").replace("%oldAppName%", ApplicationInfo.SHORT_APPLICATION_NAME).replace("%newAppName%", latestVersion.appName).replace("%projectPage%", ApplicationInfo.PROJECT_PAGE), translate("newversion"), JOptionPane.INFORMATION_MESSAGE);
}
setVisible(false);
}
private void cancelButtonActionPerformed(ActionEvent evt) {
setVisible(false);
}
}

View File

@@ -74,7 +74,6 @@ import java.awt.Component;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.BufferedOutputStream;
@@ -115,7 +114,7 @@ import jsyntaxpane.DefaultSyntaxKit;
*
* @author JPEXS
*/
public class PreviewPanel extends JSplitPane implements ActionListener {
public class PreviewPanel extends JSplitPane {
private static final String FLASH_VIEWER_CARD = "FLASHVIEWER";
@@ -131,22 +130,6 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
private static final String CARDFONTPANEL = "Font card";
private static final String ACTION_EDIT_GENERIC_TAG = "EDITGENERICTAG";
private static final String ACTION_SAVE_GENERIC_TAG = "SAVEGENERICTAG";
private static final String ACTION_CANCEL_GENERIC_TAG = "CANCELGENERICTAG";
private static final String ACTION_PREV_FONTS = "PREVFONTS";
private static final String ACTION_NEXT_FONTS = "NEXTFONTS";
private static final String ACTION_EDIT_METADATA_TAG = "EDITMETADATATAG";
private static final String ACTION_SAVE_METADATA_TAG = "SAVEMETADATATAG";
private static final String ACTION_CANCEL_METADATA_TAG = "CANCELMETADATATAG";
private final MainPanel mainPanel;
private final JPanel viewerCards;
@@ -271,20 +254,17 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
private JPanel createImageButtonsPanel() {
replaceImageButton = new JButton(mainPanel.translate("button.replace"), View.getIcon("edit16"));
replaceImageButton.setMargin(new Insets(3, 3, 3, 10));
replaceImageButton.setActionCommand(MainPanel.ACTION_REPLACE);
replaceImageButton.addActionListener(mainPanel);
replaceImageButton.addActionListener(mainPanel::replaceButtonActionPerformed);
replaceImageButton.setVisible(false);
prevFontsButton = new JButton(mainPanel.translate("button.prev"), View.getIcon("prev16"));
prevFontsButton.setMargin(new Insets(3, 3, 3, 10));
prevFontsButton.setActionCommand(ACTION_PREV_FONTS);
prevFontsButton.addActionListener(this);
prevFontsButton.addActionListener(this::prevFontsButtonActionPerformed);
prevFontsButton.setVisible(false);
nextFontsButton = new JButton(mainPanel.translate("button.next"), View.getIcon("next16"));
nextFontsButton.setMargin(new Insets(3, 3, 3, 10));
nextFontsButton.setActionCommand(ACTION_NEXT_FONTS);
nextFontsButton.addActionListener(this);
nextFontsButton.addActionListener(this::nextFontsButtonActionPerformed);
nextFontsButton.setVisible(false);
ButtonsPanel imageButtonsPanel = new ButtonsPanel();
@@ -297,8 +277,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
private JPanel createBinaryButtonsPanel() {
replaceBinaryButton = new JButton(mainPanel.translate("button.replace"), View.getIcon("edit16"));
replaceBinaryButton.setMargin(new Insets(3, 3, 3, 10));
replaceBinaryButton.setActionCommand(MainPanel.ACTION_REPLACE);
replaceBinaryButton.addActionListener(mainPanel);
replaceBinaryButton.addActionListener(mainPanel::replaceButtonActionPerformed);
ButtonsPanel binaryButtonsPanel = new ButtonsPanel();
binaryButtonsPanel.add(replaceBinaryButton);
@@ -308,17 +287,14 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
private JPanel createGenericTagButtonsPanel() {
genericEditButton = new JButton(mainPanel.translate("button.edit"), View.getIcon("edit16"));
genericEditButton.setMargin(new Insets(3, 3, 3, 10));
genericEditButton.setActionCommand(ACTION_EDIT_GENERIC_TAG);
genericEditButton.addActionListener(this);
genericEditButton.addActionListener(this::editGenericTagButtonActionPerformed);
genericSaveButton = new JButton(mainPanel.translate("button.save"), View.getIcon("save16"));
genericSaveButton.setMargin(new Insets(3, 3, 3, 10));
genericSaveButton.setActionCommand(ACTION_SAVE_GENERIC_TAG);
genericSaveButton.addActionListener(this);
genericSaveButton.addActionListener(this::saveGenericTagButtonActionPerformed);
genericSaveButton.setVisible(false);
genericCancelButton = new JButton(mainPanel.translate("button.cancel"), View.getIcon("cancel16"));
genericCancelButton.setMargin(new Insets(3, 3, 3, 10));
genericCancelButton.setActionCommand(ACTION_CANCEL_GENERIC_TAG);
genericCancelButton.addActionListener(this);
genericCancelButton.addActionListener(this::cancelGenericTagButtonActionPerformed);
genericCancelButton.setVisible(false);
ButtonsPanel genericTagButtonsPanel = new ButtonsPanel();
@@ -331,17 +307,14 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
private JPanel createMetadataButtonsPanel() {
metadataEditButton = new JButton(mainPanel.translate("button.edit"), View.getIcon("edit16"));
metadataEditButton.setMargin(new Insets(3, 3, 3, 10));
metadataEditButton.setActionCommand(ACTION_EDIT_METADATA_TAG);
metadataEditButton.addActionListener(this);
metadataEditButton.addActionListener(this::editMetadataButtonActionPerformed);
metadataSaveButton = new JButton(mainPanel.translate("button.save"), View.getIcon("save16"));
metadataSaveButton.setMargin(new Insets(3, 3, 3, 10));
metadataSaveButton.setActionCommand(ACTION_SAVE_METADATA_TAG);
metadataSaveButton.addActionListener(this);
metadataSaveButton.addActionListener(this::saveMetadataButtonActionPerformed);
metadataSaveButton.setVisible(false);
metadataCancelButton = new JButton(mainPanel.translate("button.cancel"), View.getIcon("cancel16"));
metadataCancelButton.setMargin(new Insets(3, 3, 3, 10));
metadataCancelButton.setActionCommand(ACTION_CANCEL_METADATA_TAG);
metadataCancelButton.addActionListener(this);
metadataCancelButton.addActionListener(this::cancelMetadataButtonActionPerformed);
metadataCancelButton.setVisible(false);
ButtonsPanel metadataTagButtonsPanel = new ButtonsPanel();
@@ -1135,95 +1108,86 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
}
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_EDIT_METADATA_TAG: {
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
if (item == null) {
return;
}
private void editMetadataButtonActionPerformed(ActionEvent evt) {
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
if (item == null) {
return;
}
if (item instanceof MetadataTag) {
metadataEditor.setEditable(true);
updateMetadataButtonsVisibility();
}
}
break;
case ACTION_SAVE_METADATA_TAG: {
metadataTag.xmlMetadata = metadataEditor.getText().replaceAll(">\r?\n<", "> <");
metadataTag.setModified(true);
metadataEditor.setEditable(Configuration.editorMode.get());
metadataModified = false;
updateMetadataButtonsVisibility();
mainPanel.repaintTree();
}
break;
if (item instanceof MetadataTag) {
metadataEditor.setEditable(true);
updateMetadataButtonsVisibility();
}
}
case ACTION_CANCEL_METADATA_TAG: {
metadataEditor.setEditable(false);
metadataEditor.setText(formatMetadata(metadataTag.xmlMetadata, 4));
metadataEditor.setEditable(Configuration.editorMode.get());
metadataModified = false;
updateMetadataButtonsVisibility();
}
break;
private void saveMetadataButtonActionPerformed(ActionEvent evt) {
metadataTag.xmlMetadata = metadataEditor.getText().replaceAll(">\r?\n<", "> <");
metadataTag.setModified(true);
metadataEditor.setEditable(Configuration.editorMode.get());
metadataModified = false;
updateMetadataButtonsVisibility();
mainPanel.repaintTree();
}
case ACTION_EDIT_GENERIC_TAG: {
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
if (item == null) {
return;
}
private void cancelMetadataButtonActionPerformed(ActionEvent evt) {
metadataEditor.setEditable(false);
metadataEditor.setText(formatMetadata(metadataTag.xmlMetadata, 4));
metadataEditor.setEditable(Configuration.editorMode.get());
metadataModified = false;
updateMetadataButtonsVisibility();
}
if (item instanceof Tag) {
genericEditButton.setVisible(false);
genericSaveButton.setVisible(true);
genericCancelButton.setVisible(true);
genericTagPanel.setEditMode(true, (Tag) item);
}
}
break;
private void editGenericTagButtonActionPerformed(ActionEvent evt) {
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
if (item == null) {
return;
}
case ACTION_SAVE_GENERIC_TAG: {
genericTagPanel.save();
Tag tag = genericTagPanel.getTag();
SWF swf = tag.getSwf();
swf.clearImageCache();
swf.updateCharacters();
tag.getTimelined().resetTimeline();
mainPanel.repaintTree();
mainPanel.setTagTreeSelectedNode(tag);
genericEditButton.setVisible(true);
genericSaveButton.setVisible(false);
genericCancelButton.setVisible(false);
genericTagPanel.setEditMode(false, null);
}
break;
case ACTION_CANCEL_GENERIC_TAG: {
genericEditButton.setVisible(true);
genericSaveButton.setVisible(false);
genericCancelButton.setVisible(false);
genericTagPanel.setEditMode(false, null);
}
break;
case ACTION_PREV_FONTS: {
FontTag fontTag = fontPanel.getFontTag();
int pageCount = getFontPageCount(fontTag);
fontPageNum = (fontPageNum + pageCount - 1) % pageCount;
if (mainPanel.isInternalFlashViewerSelected() /*|| ft instanceof GFxDefineCompactedFont*/) {
imagePanel.setTimelined(MainPanel.makeTimelined(fontTag, fontPageNum), fontTag.getSwf(), 0);
}
}
break;
case ACTION_NEXT_FONTS: {
FontTag fontTag = fontPanel.getFontTag();
int pageCount = getFontPageCount(fontTag);
fontPageNum = (fontPageNum + 1) % pageCount;
if (mainPanel.isInternalFlashViewerSelected() /*|| ft instanceof GFxDefineCompactedFont*/) {
imagePanel.setTimelined(MainPanel.makeTimelined(fontTag, fontPageNum), fontTag.getSwf(), 0);
}
}
break;
if (item instanceof Tag) {
genericEditButton.setVisible(false);
genericSaveButton.setVisible(true);
genericCancelButton.setVisible(true);
genericTagPanel.setEditMode(true, (Tag) item);
}
}
private void saveGenericTagButtonActionPerformed(ActionEvent evt) {
genericTagPanel.save();
Tag tag = genericTagPanel.getTag();
SWF swf = tag.getSwf();
swf.clearImageCache();
swf.updateCharacters();
tag.getTimelined().resetTimeline();
mainPanel.repaintTree();
mainPanel.setTagTreeSelectedNode(tag);
genericEditButton.setVisible(true);
genericSaveButton.setVisible(false);
genericCancelButton.setVisible(false);
genericTagPanel.setEditMode(false, null);
}
private void cancelGenericTagButtonActionPerformed(ActionEvent evt) {
genericEditButton.setVisible(true);
genericSaveButton.setVisible(false);
genericCancelButton.setVisible(false);
genericTagPanel.setEditMode(false, null);
}
private void prevFontsButtonActionPerformed(ActionEvent evt) {
FontTag fontTag = fontPanel.getFontTag();
int pageCount = getFontPageCount(fontTag);
fontPageNum = (fontPageNum + pageCount - 1) % pageCount;
if (mainPanel.isInternalFlashViewerSelected() /*|| ft instanceof GFxDefineCompactedFont*/) {
imagePanel.setTimelined(MainPanel.makeTimelined(fontTag, fontPageNum), fontTag.getSwf(), 0);
}
}
private void nextFontsButtonActionPerformed(ActionEvent evt) {
FontTag fontTag = fontPanel.getFontTag();
int pageCount = getFontPageCount(fontTag);
fontPageNum = (fontPageNum + 1) % pageCount;
if (mainPanel.isInternalFlashViewerSelected() /*|| ft instanceof GFxDefineCompactedFont*/) {
imagePanel.setTimelined(MainPanel.makeTimelined(fontTag, fontPageNum), fontTag.getSwf(), 0);
}
}
}

View File

@@ -21,7 +21,6 @@ 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.ResourceBundle;
import java.util.regex.Pattern;
@@ -45,7 +44,7 @@ import jsyntaxpane.components.Markers;
*
* @author JPEXS
*/
public class QuickFindPanel extends JPanel implements ActionListener {
public class QuickFindPanel extends JPanel {
public JTextField findTextField;
@@ -102,8 +101,7 @@ public class QuickFindPanel extends JPanel implements ActionListener {
prevButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
prevButton.setOpaque(false);
prevButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
prevButton.setActionCommand("PREVIOUS");
prevButton.addActionListener(this);
prevButton.addActionListener(this::previousButtonActionPerformed);
pan1.add(prevButton);
nextButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/go-down.png")));
@@ -112,8 +110,7 @@ public class QuickFindPanel extends JPanel implements ActionListener {
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);
nextButton.addActionListener(this::nextButtonActionPerformed);
pan1.add(nextButton);
ignoreCaseCheckbox.setMnemonic('C');
@@ -122,7 +119,7 @@ public class QuickFindPanel extends JPanel implements ActionListener {
ignoreCaseCheckbox.setOpaque(false);
ignoreCaseCheckbox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
pan2.add(ignoreCaseCheckbox);
ignoreCaseCheckbox.addActionListener(this);
//ignoreCaseCheckbox.addActionListener(this);
regExpCheckbox.setMnemonic('R');
regExpCheckbox.setText(bundle.getString("QuickFindDialog.jChkRegExp.text"));
@@ -130,7 +127,7 @@ public class QuickFindPanel extends JPanel implements ActionListener {
regExpCheckbox.setOpaque(false);
regExpCheckbox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
pan2.add(regExpCheckbox);
regExpCheckbox.addActionListener(this);
//regExpCheckbox.addActionListener(this);
wrapCheckbox.setMnemonic('W');
wrapCheckbox.setText(bundle.getString("QuickFindDialog.jChkWrap.text"));
@@ -138,7 +135,7 @@ public class QuickFindPanel extends JPanel implements ActionListener {
wrapCheckbox.setOpaque(false);
wrapCheckbox.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
pan2.add(wrapCheckbox);
wrapCheckbox.addActionListener(this);
//wrapCheckbox.addActionListener(this);
statusLabel.setFont(statusLabel.getFont().deriveFont(statusLabel.getFont().getStyle() | java.awt.Font.BOLD, statusLabel.getFont().getSize() - 2));
statusLabel.setForeground(Color.red);
@@ -150,23 +147,19 @@ public class QuickFindPanel extends JPanel implements ActionListener {
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;
private void previousButtonActionPerformed(ActionEvent evt) {
if (dsd.get().doFindPrev(target.get())) {
statusLabel.setText(null);
} else {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
}
}
private void nextButtonActionPerformed(ActionEvent evt) {
if (dsd.get().doFindNext(target.get())) {
statusLabel.setText(null);
} else {
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
}
}

View File

@@ -20,7 +20,6 @@ import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
@@ -87,31 +86,9 @@ public class ReplaceTraceDialog extends AppDialog {
JPanel buttonsPanel = new JPanel(new FlowLayout());
JButton okButton = new JButton(AppStrings.translate("button.ok"));
okButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (debugAlertRadio.isSelected()) {
value = "debugAlert";
}
if (debugConsoleRadio.isSelected()) {
value = "debugConsole";
}
if (debugSocketRadio.isSelected()) {
value = "debugSocket";
}
setVisible(false);
}
});
okButton.addActionListener(this::okButtonActionPerformed);
JButton cancelButton = new JButton(AppStrings.translate("button.cancel"));
cancelButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
value = null;
setVisible(false);
}
});
cancelButton.addActionListener(this::cancelButtonActionPerformed);
buttonsPanel.add(okButton);
buttonsPanel.add(cancelButton);
buttonsPanel.setAlignmentX(0);
@@ -122,4 +99,23 @@ public class ReplaceTraceDialog extends AppDialog {
View.centerScreen(this);
setValue(defaultVal);
}
private void okButtonActionPerformed(ActionEvent evt) {
if (debugAlertRadio.isSelected()) {
value = "debugAlert";
}
if (debugConsoleRadio.isSelected()) {
value = "debugConsole";
}
if (debugSocketRadio.isSelected()) {
value = "debugSocket";
}
setVisible(false);
}
private void cancelButtonActionPerformed(ActionEvent evt) {
value = null;
setVisible(false);
}
}

View File

@@ -22,7 +22,6 @@ import java.awt.FlowLayout;
import java.awt.Image;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
@@ -42,11 +41,7 @@ import javax.swing.JTextField;
*
* @author JPEXS
*/
public class SearchDialog extends AppDialog implements ActionListener {
private static final String ACTION_OK = "OK";
private static final String ACTION_CANCEL = "CANCEL";
public class SearchDialog extends AppDialog {
public JTextField searchField = new MyTextField();
@@ -62,7 +57,7 @@ public class SearchDialog extends AppDialog implements ActionListener {
public JRadioButton searchInTextsRadioButton = new JRadioButton(translate("checkbox.searchText"));
public boolean result = false;
private int result = ERROR_OPTION;
public SearchDialog(Window owner, boolean replace) {
super(owner);
@@ -73,11 +68,9 @@ public class SearchDialog extends AppDialog implements ActionListener {
cnt.setLayout(new BoxLayout(cnt, BoxLayout.PAGE_AXIS));
JPanel panButtons = new JPanel(new FlowLayout());
JButton okButton = new JButton(translate("button.ok"));
okButton.setActionCommand(ACTION_OK);
okButton.addActionListener(this);
okButton.addActionListener(this::okButtonActionPerformed);
JButton cancelButton = new JButton(translate("button.cancel"));
cancelButton.setActionCommand(ACTION_CANCEL);
cancelButton.addActionListener(this);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
panButtons.add(okButton);
panButtons.add(cancelButton);
JPanel panField = new JPanel(new FlowLayout());
@@ -133,27 +126,34 @@ public class SearchDialog extends AppDialog implements ActionListener {
@Override
public void setVisible(boolean b) {
if (b) {
result = false;
result = ERROR_OPTION;
searchField.requestFocusInWindow();
}
super.setVisible(b);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(ACTION_OK)) {
if (regexpCheckBox.isSelected()) {
try {
Pattern pat = Pattern.compile(searchField.getText());
} catch (PatternSyntaxException ex) {
View.showMessageDialog(null, translate("error.invalidregexp"), translate("error"), JOptionPane.ERROR_MESSAGE);
return;
}
private void okButtonActionPerformed(ActionEvent evt) {
result = OK_OPTION;
if (regexpCheckBox.isSelected()) {
try {
Pattern pat = Pattern.compile(searchField.getText());
} catch (PatternSyntaxException ex) {
View.showMessageDialog(null, translate("error.invalidregexp"), translate("error"), JOptionPane.ERROR_MESSAGE);
return;
}
result = true;
} else {
result = false;
}
setVisible(false);
}
private void cancelButtonActionPerformed(ActionEvent evt) {
result = CANCEL_OPTION;
setVisible(false);
}
public int showDialog() {
setVisible(true);
return result;
}
}

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.gui;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
@@ -33,13 +32,7 @@ import jsyntaxpane.actions.DocumentSearchData;
* @author JPEXS
* @param <E> Element to search
*/
public class SearchPanel<E> extends JPanel implements ActionListener {
private static final String ACTION_SEARCH_PREV = "SEARCHPREV";
private static final String ACTION_SEARCH_NEXT = "SEARCHNEXT";
private static final String ACTION_SEARCH_CANCEL = "SEARCHCANCEL";
public class SearchPanel<E> extends JPanel {
private final SearchListener<E> listener;
@@ -64,16 +57,13 @@ public class SearchPanel<E> extends JPanel implements ActionListener {
JButton prevSearchButton = new JButton(View.getIcon("prev16"));
prevSearchButton.setMargin(new Insets(3, 3, 3, 3));
prevSearchButton.addActionListener(this);
prevSearchButton.setActionCommand(ACTION_SEARCH_PREV);
prevSearchButton.addActionListener(this::prevButtonActionPerformed);
JButton nextSearchButton = new JButton(View.getIcon("next16"));
nextSearchButton.setMargin(new Insets(3, 3, 3, 3));
nextSearchButton.addActionListener(this);
nextSearchButton.setActionCommand(ACTION_SEARCH_NEXT);
nextSearchButton.addActionListener(this::nextButtonActionPerformed);
JButton cancelSearchButton = new JButton(View.getIcon("cancel16"));
cancelSearchButton.setMargin(new Insets(3, 3, 3, 3));
cancelSearchButton.addActionListener(this);
cancelSearchButton.setActionCommand(ACTION_SEARCH_CANCEL);
cancelSearchButton.addActionListener(this::cancelButtonActionPerformed);
searchPos = new JLabel("0/0");
searchForLabel = new JLabel(AppStrings.translate("search.info").replace("%text%", ""));
add(searchForLabel);
@@ -130,26 +120,23 @@ public class SearchPanel<E> extends JPanel implements ActionListener {
});
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_SEARCH_CANCEL:
foundPos = 0;
setVisible(false);
found = new ArrayList<>();
searchFor = null;
break;
case ACTION_SEARCH_PREV:
foundPos--;
if (foundPos < 0) {
foundPos += found.size();
}
doUpdate();
break;
case ACTION_SEARCH_NEXT:
foundPos = (foundPos + 1) % found.size();
doUpdate();
break;
private void cancelButtonActionPerformed(ActionEvent evt) {
foundPos = 0;
setVisible(false);
found = new ArrayList<>();
searchFor = null;
}
private void prevButtonActionPerformed(ActionEvent evt) {
foundPos--;
if (foundPos < 0) {
foundPos += found.size();
}
doUpdate();
}
private void nextButtonActionPerformed(ActionEvent evt) {
foundPos = (foundPos + 1) % found.size();
doUpdate();
}
}

View File

@@ -22,7 +22,6 @@ 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;
@@ -37,7 +36,7 @@ import javax.swing.JScrollPane;
* @author JPEXS
* @param <E> Element to search
*/
public class SearchResultsDialog<E> extends AppDialog implements ActionListener {
public class SearchResultsDialog<E> extends AppDialog {
private final JList<E> resultsList;
@@ -45,10 +44,6 @@ public class SearchResultsDialog<E> extends AppDialog implements ActionListener
private final SearchListener<E> listener;
private static final String ACTION_GOTO = "GOTO";
private static final String ACTION_CANCEL = "CLOSE";
private final JButton gotoButton = new JButton(translate("button.goto"));
private final JButton closeButton = new JButton(translate("button.close"));
@@ -61,10 +56,9 @@ public class SearchResultsDialog<E> extends AppDialog implements ActionListener
resultsList = new JList<>(model);
this.listener = listener;
gotoButton.setActionCommand(ACTION_GOTO);
gotoButton.addActionListener(this);
closeButton.setActionCommand(ACTION_CANCEL);
closeButton.addActionListener(this);
gotoButton.addActionListener(this::gotoButtonActionPerformed);
closeButton.addActionListener(this::closeButtonActionPerformed);
JPanel buttonsPanel = new JPanel();
buttonsPanel.setLayout(new FlowLayout());
buttonsPanel.add(gotoButton);
@@ -97,17 +91,13 @@ public class SearchResultsDialog<E> extends AppDialog implements ActionListener
}
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_GOTO:
gotoElement();
setVisible(false);
break;
case ACTION_CANCEL:
setVisible(false);
break;
}
private void gotoButtonActionPerformed(ActionEvent evt) {
gotoElement();
setVisible(false);
}
private void closeButtonActionPerformed(ActionEvent evt) {
setVisible(false);
}
private void gotoElement() {

View File

@@ -21,7 +21,6 @@ import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.BoxLayout;
@@ -36,13 +35,9 @@ import jsyntaxpane.DefaultSyntaxKit;
*
* @author JPEXS
*/
public class SelectLanguageDialog extends AppDialog implements ActionListener {
public class SelectLanguageDialog extends AppDialog {
private static final String ACTION_OK = "OK";
private static final String ACTION_CANCEL = "CANCEL";
JComboBox<Language> languageCombobox = new JComboBox<>();
private JComboBox<Language> languageCombobox = new JComboBox<>();
public String languageCode = null;
@@ -86,11 +81,9 @@ public class SelectLanguageDialog extends AppDialog implements ActionListener {
JPanel buttonsPanel = new JPanel(new FlowLayout());
buttonsPanel.setAlignmentX(0.5f);
JButton okButton = new JButton(translate("button.ok"));
okButton.setActionCommand(ACTION_OK);
okButton.addActionListener(this);
okButton.addActionListener(this::okButtonActionPerformed);
JButton cancelButton = new JButton(translate("button.cancel"));
cancelButton.setActionCommand(ACTION_CANCEL);
cancelButton.addActionListener(this);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
buttonsPanel.add(okButton);
buttonsPanel.add(cancelButton);
cnt.add(buttonsPanel);
@@ -105,26 +98,22 @@ public class SelectLanguageDialog extends AppDialog implements ActionListener {
}
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_OK:
if (languageCombobox.getSelectedIndex() == -1) {
} else {
languageCode = ((Language) languageCombobox.getSelectedItem()).code;
String newLanguage = languageCode;
if (newLanguage.equals("en")) {
newLanguage = "";
}
Configuration.locale.set(newLanguage);
setVisible(false);
reloadUi();
}
break;
case ACTION_CANCEL:
setVisible(false);
break;
private void okButtonActionPerformed(ActionEvent evt) {
if (languageCombobox.getSelectedIndex() != -1) {
languageCode = ((Language) languageCombobox.getSelectedItem()).code;
String newLanguage = languageCode;
if (newLanguage.equals("en")) {
newLanguage = "";
}
Configuration.locale.set(newLanguage);
reloadUi();
}
setVisible(false);
}
private void cancelButtonActionPerformed(ActionEvent evt) {
setVisible(false);
}
public static void reloadUi() {

View File

@@ -40,6 +40,7 @@ import com.jpexs.decompiler.flash.abc.types.traits.Traits;
import com.jpexs.decompiler.flash.abc.usages.MultinameUsage;
import com.jpexs.decompiler.flash.abc.usages.TraitMultinameUsage;
import com.jpexs.decompiler.flash.configuration.Configuration;
import com.jpexs.decompiler.flash.gui.AppDialog;
import com.jpexs.decompiler.flash.gui.AppStrings;
import com.jpexs.decompiler.flash.gui.HeaderLabel;
import com.jpexs.decompiler.flash.gui.Main;
@@ -850,7 +851,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
View.showMessageDialog(null, AppStrings.translate("error.trait.exists").replace("%name%", name), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
}
again = false;
if (!newTraitDialog.display()) {
if (newTraitDialog.showDialog() != AppDialog.OK_OPTION) {
return;
}
kind = newTraitDialog.getTraitType();

View File

@@ -23,7 +23,6 @@ import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Hashtable;
import javax.swing.BoxLayout;
import javax.swing.JButton;
@@ -36,17 +35,13 @@ import javax.swing.JSlider;
*
* @author JPEXS
*/
public class DeobfuscationDialog extends AppDialog implements ActionListener {
private static final String ACTION_OK = "OK";
private static final String ACTION_CANCEL = "CANCEL";
public class DeobfuscationDialog extends AppDialog {
public JCheckBox processAllCheckbox = new JCheckBox(translate("processallclasses"));
public JSlider codeProcessingLevel;
public boolean ok = false;
private int result = ERROR_OPTION;
public static final int LEVEL_REMOVE_DEAD_CODE = 1;
@@ -92,11 +87,9 @@ public class DeobfuscationDialog extends AppDialog implements ActionListener {
processAllCheckbox.setSelected(true);
JButton cancelButton = new JButton(translate("button.cancel"));
cancelButton.addActionListener(this);
cancelButton.setActionCommand(ACTION_CANCEL);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
JButton okButton = new JButton(translate("button.ok"));
okButton.addActionListener(this);
okButton.setActionCommand(ACTION_OK);
okButton.addActionListener(this::okButtonActionPerformed);
JPanel buttonsPanel = new JPanel(new FlowLayout());
buttonsPanel.add(okButton);
@@ -110,25 +103,27 @@ public class DeobfuscationDialog extends AppDialog implements ActionListener {
setIconImage(View.loadImage("deobfuscate16"));
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_OK:
ok = true;
setVisible(false);
break;
case ACTION_CANCEL:
ok = false;
setVisible(false);
break;
}
}
@Override
public void setVisible(boolean b) {
if (b) {
ok = false;
result = ERROR_OPTION;
}
super.setVisible(b);
}
private void okButtonActionPerformed(ActionEvent evt) {
result = OK_OPTION;
setVisible(false);
}
private void cancelButtonActionPerformed(ActionEvent evt) {
result = CANCEL_OPTION;
setVisible(false);
}
public int showDialog() {
setVisible(true);
return result;
}
}

View File

@@ -27,7 +27,6 @@ import java.awt.CardLayout;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.BoxLayout;
@@ -43,13 +42,7 @@ import javax.swing.border.BevelBorder;
*
* @author JPEXS
*/
public class DetailPanel extends JPanel implements ActionListener {
private static final String ACTION_SAVE_DETAIL = "SAVEDETAIL";
private static final String ACTION_EDIT_DETAIL = "EDITDETAIL";
private static final String ACTION_CANCEL_DETAIL = "CANCELDETAIL";
public class DetailPanel extends JPanel {
public MethodTraitDetailPanel methodTraitPanel;
@@ -115,12 +108,9 @@ public class DetailPanel extends JPanel implements ActionListener {
buttonsPanel = new JPanel();
buttonsPanel.setLayout(new FlowLayout());
saveButton.setActionCommand(ACTION_SAVE_DETAIL);
saveButton.addActionListener(this);
editButton.setActionCommand(ACTION_EDIT_DETAIL);
editButton.addActionListener(this);
cancelButton.setActionCommand(ACTION_CANCEL_DETAIL);
cancelButton.addActionListener(this);
saveButton.addActionListener(this::saveButtonActionPerformed);
editButton.addActionListener(this::editButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
buttonsPanel.setBorder(new BevelBorder(BevelBorder.RAISED));
buttonsPanel.add(editButton);
buttonsPanel.add(saveButton);
@@ -194,40 +184,37 @@ public class DetailPanel extends JPanel implements ActionListener {
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_EDIT_DETAIL:
setEditMode(true);
methodTraitPanel.methodCodePanel.focusEditor();
break;
case ACTION_CANCEL_DETAIL:
setEditMode(false);
abcPanel.decompiledTextArea.resetEditing();
break;
case ACTION_SAVE_DETAIL:
if (cardMap.get(selectedCard) instanceof TraitDetail) {
if (((TraitDetail) cardMap.get(selectedCard)).save()) {
CancellableWorker worker = new CancellableWorker() {
private void editButtonActionPerformed(ActionEvent evt) {
setEditMode(true);
methodTraitPanel.methodCodePanel.focusEditor();
}
@Override
public Void doInBackground() throws Exception {
int lasttrait = abcPanel.decompiledTextArea.lastTraitIndex;
abcPanel.decompiledTextArea.reloadClass();
abcPanel.decompiledTextArea.gotoTrait(lasttrait);
return null;
}
private void cancelButtonActionPerformed(ActionEvent evt) {
setEditMode(false);
abcPanel.decompiledTextArea.resetEditing();
}
@Override
protected void done() {
setEditMode(false);
View.showMessageDialog(null, AppStrings.translate("message.trait.saved"), AppStrings.translate("dialog.message.title"), JOptionPane.INFORMATION_MESSAGE, Configuration.showTraitSavedMessage);
}
};
worker.execute();
private void saveButtonActionPerformed(ActionEvent evt) {
if (cardMap.get(selectedCard) instanceof TraitDetail) {
if (((TraitDetail) cardMap.get(selectedCard)).save()) {
CancellableWorker worker = new CancellableWorker() {
@Override
public Void doInBackground() throws Exception {
int lasttrait = abcPanel.decompiledTextArea.lastTraitIndex;
abcPanel.decompiledTextArea.reloadClass();
abcPanel.decompiledTextArea.gotoTrait(lasttrait);
return null;
}
}
break;
@Override
protected void done() {
setEditMode(false);
View.showMessageDialog(null, AppStrings.translate("message.trait.saved"), AppStrings.translate("dialog.message.title"), JOptionPane.INFORMATION_MESSAGE, Configuration.showTraitSavedMessage);
}
};
worker.execute();
}
}
}
}

View File

@@ -27,7 +27,6 @@ import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
@@ -38,13 +37,7 @@ import javax.swing.JToggleButton;
*
* @author JPEXS
*/
public class MethodCodePanel extends JPanel implements ActionListener {
private static final String ACTION_GRAPH = "GRAPH";
private static final String ACTION_HEX = "HEX";
private static final String ACTION_HEX_ONLY = "HEXONLY";
public class MethodCodePanel extends JPanel {
private final ASMSourceEditorPane sourceTextArea;
@@ -110,20 +103,17 @@ public class MethodCodePanel extends JPanel implements ActionListener {
buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
JButton graphButton = new JButton(View.getIcon("graph16"));
graphButton.setActionCommand(ACTION_GRAPH);
graphButton.addActionListener(this);
graphButton.addActionListener(this::graphButtonActionPerformed);
graphButton.setToolTipText(AppStrings.translate("button.viewgraph"));
graphButton.setMargin(new Insets(3, 3, 3, 3));
hexButton = new JToggleButton(View.getIcon("hexas16"));
hexButton.setActionCommand(ACTION_HEX);
hexButton.addActionListener(this);
hexButton.addActionListener(this::hexButtonActionPerformed);
hexButton.setToolTipText(AppStrings.translate("button.viewhex"));
hexButton.setMargin(new Insets(3, 3, 3, 3));
hexOnlyButton = new JToggleButton(View.getIcon("hex16"));
hexOnlyButton.setActionCommand(ACTION_HEX_ONLY);
hexOnlyButton.addActionListener(this);
hexOnlyButton.addActionListener(this::hexOnlyButtonActionPerformed);
hexOnlyButton.setToolTipText(AppStrings.translate("button.viewhex"));
hexOnlyButton.setMargin(new Insets(3, 3, 3, 3));
@@ -137,26 +127,30 @@ public class MethodCodePanel extends JPanel implements ActionListener {
add(buttonsPanel, BorderLayout.NORTH);
}
@Override
public void actionPerformed(ActionEvent e) {
private void graphButtonActionPerformed(ActionEvent evt) {
if (Main.isWorking()) {
return;
}
switch (e.getActionCommand()) {
case ACTION_GRAPH:
sourceTextArea.graph();
break;
case ACTION_HEX:
case ACTION_HEX_ONLY:
if (e.getActionCommand().equals(ACTION_HEX)) {
hexOnlyButton.setSelected(false);
} else {
hexButton.setSelected(false);
}
sourceTextArea.setHex(getExportMode(), false);
break;
sourceTextArea.graph();
}
private void hexButtonActionPerformed(ActionEvent evt) {
if (Main.isWorking()) {
return;
}
hexOnlyButton.setSelected(false);
sourceTextArea.setHex(getExportMode(), false);
}
private void hexOnlyButtonActionPerformed(ActionEvent evt) {
if (Main.isWorking()) {
return;
}
hexButton.setSelected(false);
sourceTextArea.setHex(getExportMode(), false);
}
private ScriptExportMode getExportMode() {

View File

@@ -26,7 +26,6 @@ import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
@@ -41,11 +40,7 @@ import javax.swing.event.AncestorListener;
*
* @author JPEXS
*/
public class NewTraitDialog extends AppDialog implements ActionListener {
private static final String ACTION_OK = "OK";
private static final String ACTION_CANCEL = "CANCEL";
public class NewTraitDialog extends AppDialog {
private static final int modifiers[] = new int[]{
Namespace.KIND_PACKAGE,
@@ -73,6 +68,8 @@ public class NewTraitDialog extends AppDialog implements ActionListener {
private final JTextField nameField;
private int result = ERROR_OPTION;
public boolean getStatic() {
return staticCheckbox.isSelected();
}
@@ -127,11 +124,9 @@ public class NewTraitDialog extends AppDialog implements ActionListener {
cnt.add(optionsPanel, BorderLayout.CENTER);
JPanel buttonsPanel = new JPanel(new FlowLayout());
JButton buttonOk = new JButton(AppStrings.translate("button.ok"));
buttonOk.setActionCommand(ACTION_OK);
buttonOk.addActionListener(this);
buttonOk.addActionListener(this::okButtonActionPerformed);
JButton buttonCancel = new JButton(AppStrings.translate("button.cancel"));
buttonCancel.setActionCommand(ACTION_CANCEL);
buttonCancel.addActionListener(this);
buttonCancel.addActionListener(this::cancelButtonActionPerformed);
buttonsPanel.add(buttonOk);
buttonsPanel.add(buttonCancel);
cnt.add(buttonsPanel, BorderLayout.SOUTH);
@@ -157,30 +152,33 @@ public class NewTraitDialog extends AppDialog implements ActionListener {
getRootPane().setDefaultButton(buttonOk);
}
public boolean display() {
nameField.setText("");
@Override
public void setVisible(boolean b) {
if (b) {
result = ERROR_OPTION;
nameField.setText("");
}
super.setVisible(b);
}
private void okButtonActionPerformed(ActionEvent evt) {
result = OK_OPTION;
if (nameField.getText().trim().isEmpty()) {
View.showMessageDialog(null, translate("error.name"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
return;
}
setVisible(false);
}
private void cancelButtonActionPerformed(ActionEvent evt) {
result = CANCEL_OPTION;
setVisible(false);
}
public int showDialog() {
setVisible(true);
return result;
}
private boolean result = false;
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_OK:
if (nameField.getText().trim().isEmpty()) {
View.showMessageDialog(null, translate("error.name"), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
return;
}
result = true;
setVisible(false);
break;
case ACTION_CANCEL:
result = false;
setVisible(false);
break;
}
}
}

View File

@@ -31,7 +31,6 @@ 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;
@@ -44,11 +43,7 @@ import javax.swing.JScrollPane;
*
* @author JPEXS
*/
public class UsageFrame extends AppDialog implements ActionListener, MouseListener {
private static final String ACTION_GOTO = "GOTO";
private static final String ACTION_CANCEL = "CANCEL";
public class UsageFrame extends AppDialog implements MouseListener {
private final JButton gotoButton = new JButton(translate("button.goto"));
@@ -83,10 +78,9 @@ public class UsageFrame extends AppDialog implements ActionListener, MouseListen
}
usageList = new JList<>(usageListModel);
usageList.setBackground(Color.white);
gotoButton.setActionCommand(ACTION_GOTO);
gotoButton.addActionListener(this);
cancelButton.setActionCommand(ACTION_CANCEL);
cancelButton.addActionListener(this);
gotoButton.addActionListener(this::gotoButtonActionPerformed);
cancelButton.addActionListener(this::cancelButtonActionPerformed);
JPanel buttonsPanel = new JPanel();
buttonsPanel.setLayout(new FlowLayout());
buttonsPanel.add(gotoButton);
@@ -151,17 +145,13 @@ public class UsageFrame extends AppDialog implements ActionListener, MouseListen
}
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_GOTO:
gotoUsage();
setVisible(false);
break;
case ACTION_CANCEL:
setVisible(false);
break;
}
private void gotoButtonActionPerformed(ActionEvent evt) {
gotoUsage();
setVisible(false);
}
private void cancelButtonActionPerformed(ActionEvent evt) {
setVisible(false);
}
@Override

View File

@@ -55,7 +55,6 @@ import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
@@ -87,25 +86,7 @@ import jsyntaxpane.Token;
import jsyntaxpane.TokenType;
import jsyntaxpane.actions.ActionUtils;
public class ActionPanel extends JPanel implements ActionListener, SearchListener<ActionSearchResult> {
private static final String ACTION_GRAPH = "GRAPH";
private static final String ACTION_HEX = "HEX";
private static final String ACTION_HEX_ONLY = "HEXONLY";
private static final String ACTION_SAVE_ACTION = "SAVEACTION";
private static final String ACTION_EDIT_ACTION = "EDITACTION";
private static final String ACTION_CANCEL_ACTION = "CANCELACTION";
private static final String ACTION_SAVE_DECOMPILED = "SAVEDECOMPILED";
private static final String ACTION_EDIT_DECOMPILED = "EDITDECOMPILED";
private static final String ACTION_CANCEL_DECOMPILED = "CANCELDECOMPILED";
public class ActionPanel extends JPanel implements SearchListener<ActionSearchResult> {
private MainPanel mainPanel;
@@ -482,20 +463,17 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
searchPanel = new SearchPanel<>(new FlowLayout(), this);
JButton graphButton = new JButton(View.getIcon("graph16"));
graphButton.setActionCommand(ACTION_GRAPH);
graphButton.addActionListener(this);
graphButton.addActionListener(this::graphButtonActionPerformed);
graphButton.setToolTipText(AppStrings.translate("button.viewgraph"));
graphButton.setMargin(new Insets(3, 3, 3, 3));
hexButton = new JToggleButton(View.getIcon("hexas16"));
hexButton.setActionCommand(ACTION_HEX);
hexButton.addActionListener(this);
hexButton.addActionListener(this::hexButtonActionPerformed);
hexButton.setToolTipText(AppStrings.translate("button.viewhex"));
hexButton.setMargin(new Insets(3, 3, 3, 3));
hexOnlyButton = new JToggleButton(View.getIcon("hex16"));
hexOnlyButton.setActionCommand(ACTION_HEX_ONLY);
hexOnlyButton.addActionListener(this);
hexOnlyButton.addActionListener(this::hexOnlyButtonActionPerformed);
hexOnlyButton.setToolTipText(AppStrings.translate("button.viewhex"));
hexOnlyButton.setMargin(new Insets(3, 3, 3, 3));
@@ -539,22 +517,15 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
//buttonsPan.add(loadHexButton);
panB.add(buttonsPan, BorderLayout.SOUTH);
saveButton.addActionListener(this);
saveButton.setActionCommand(ACTION_SAVE_ACTION);
editButton.addActionListener(this);
editButton.setActionCommand(ACTION_EDIT_ACTION);
cancelButton.addActionListener(this);
cancelButton.setActionCommand(ACTION_CANCEL_ACTION);
saveButton.addActionListener(this::saveActionButtonActionPerformed);
editButton.addActionListener(this::editActionButtonActionPerformed);
cancelButton.addActionListener(this::cancelActionButtonActionPerformed);
saveButton.setVisible(false);
cancelButton.setVisible(false);
saveDecompiledButton.addActionListener(this);
saveDecompiledButton.setActionCommand(ACTION_SAVE_DECOMPILED);
editDecompiledButton.addActionListener(this);
editDecompiledButton.setActionCommand(ACTION_EDIT_DECOMPILED);
cancelDecompiledButton.addActionListener(this);
cancelDecompiledButton.setActionCommand(ACTION_CANCEL_DECOMPILED);
saveDecompiledButton.addActionListener(this::saveDecompiledButtonActionPerformed);
editDecompiledButton.addActionListener(this::editDecompiledButtonActionPerformed);
cancelDecompiledButton.addActionListener(this::cancelDecompiledButtonActionPerformed);
saveDecompiledButton.setVisible(false);
cancelDecompiledButton.setVisible(false);
@@ -725,83 +696,85 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
decompiledEditor.requestFocusInWindow();
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_GRAPH:
if (lastCode != null) {
try {
GraphDialog gf = new GraphDialog(mainPanel.getMainFrame().getWindow(), new ActionGraph(lastCode, new HashMap<>(), new HashMap<>(), new HashMap<>(), SWF.DEFAULT_VERSION), "");
gf.setVisible(true);
} catch (InterruptedException ex) {
Logger.getLogger(ActionPanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
break;
case ACTION_EDIT_ACTION:
setEditMode(true);
break;
case ACTION_HEX:
case ACTION_HEX_ONLY:
if (e.getActionCommand().equals(ACTION_HEX)) {
hexOnlyButton.setSelected(false);
} else {
hexButton.setSelected(false);
}
setHex(getExportMode());
break;
case ACTION_CANCEL_ACTION:
setEditMode(false);
setHex(getExportMode());
break;
case ACTION_SAVE_ACTION:
try {
String text = editor.getText();
if (text.trim().startsWith("#hexdata")) {
src.setActionBytes(Helper.getBytesFromHexaText(text));
} else {
src.setActions(ASMParser.parse(0, true, text, src.getSwf().version, false));
}
src.setModified();
setSource(this.src, false);
View.showMessageDialog(this, AppStrings.translate("message.action.saved"), AppStrings.translate("dialog.message.title"), JOptionPane.INFORMATION_MESSAGE, Configuration.showCodeSavedMessage);
saveButton.setVisible(false);
cancelButton.setVisible(false);
editButton.setVisible(true);
editor.setEditable(false);
editMode = false;
} catch (IOException ex) {
} catch (ActionParseException ex) {
editor.gotoLine((int) ex.line);
editor.markError();
View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
}
break;
case ACTION_EDIT_DECOMPILED:
if (View.showConfirmDialog(null, AppStrings.translate("message.confirm.experimental.function"), AppStrings.translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, Configuration.warningExperimentalAS12Edit, JOptionPane.OK_OPTION) == JOptionPane.OK_OPTION) {
setDecompiledEditMode(true);
}
break;
case ACTION_CANCEL_DECOMPILED:
setDecompiledEditMode(false);
break;
case ACTION_SAVE_DECOMPILED:
try {
ActionScriptParser par = new ActionScriptParser(mainPanel.getCurrentSwf().version);
src.setActions(par.actionsFromString(decompiledEditor.getText()));
src.setModified();
setSource(src, false);
private void graphButtonActionPerformed(ActionEvent evt) {
if (lastCode != null) {
try {
GraphDialog gf = new GraphDialog(mainPanel.getMainFrame().getWindow(), new ActionGraph(lastCode, new HashMap<>(), new HashMap<>(), new HashMap<>(), SWF.DEFAULT_VERSION), "");
gf.setVisible(true);
} catch (InterruptedException ex) {
Logger.getLogger(ActionPanel.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
View.showMessageDialog(this, AppStrings.translate("message.action.saved"), AppStrings.translate("dialog.message.title"), JOptionPane.INFORMATION_MESSAGE, Configuration.showCodeSavedMessage);
setDecompiledEditMode(false);
} catch (IOException ex) {
Logger.getLogger(ActionPanel.class.getName()).log(Level.SEVERE, "IOException during action compiling", ex);
} catch (ActionParseException ex) {
View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
} catch (CompilationException ex) {
View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
}
break;
private void editActionButtonActionPerformed(ActionEvent evt) {
setEditMode(true);
}
private void hexButtonActionPerformed(ActionEvent evt) {
hexOnlyButton.setSelected(false);
setHex(getExportMode());
}
private void hexOnlyButtonActionPerformed(ActionEvent evt) {
hexButton.setSelected(false);
setHex(getExportMode());
}
private void cancelActionButtonActionPerformed(ActionEvent evt) {
setEditMode(false);
setHex(getExportMode());
}
private void saveActionButtonActionPerformed(ActionEvent evt) {
try {
String text = editor.getText();
if (text.trim().startsWith("#hexdata")) {
src.setActionBytes(Helper.getBytesFromHexaText(text));
} else {
src.setActions(ASMParser.parse(0, true, text, src.getSwf().version, false));
}
src.setModified();
setSource(this.src, false);
View.showMessageDialog(this, AppStrings.translate("message.action.saved"), AppStrings.translate("dialog.message.title"), JOptionPane.INFORMATION_MESSAGE, Configuration.showCodeSavedMessage);
saveButton.setVisible(false);
cancelButton.setVisible(false);
editButton.setVisible(true);
editor.setEditable(false);
editMode = false;
} catch (IOException ex) {
} catch (ActionParseException ex) {
editor.gotoLine((int) ex.line);
editor.markError();
View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
}
}
private void editDecompiledButtonActionPerformed(ActionEvent evt) {
if (View.showConfirmDialog(null, AppStrings.translate("message.confirm.experimental.function"), AppStrings.translate("message.warning"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, Configuration.warningExperimentalAS12Edit, JOptionPane.OK_OPTION) == JOptionPane.OK_OPTION) {
setDecompiledEditMode(true);
}
}
private void cancelDecompiledButtonActionPerformed(ActionEvent evt) {
setDecompiledEditMode(false);
}
private void saveDecompiledButtonActionPerformed(ActionEvent evt) {
try {
ActionScriptParser par = new ActionScriptParser(mainPanel.getCurrentSwf().version);
src.setActions(par.actionsFromString(decompiledEditor.getText()));
src.setModified();
setSource(src, false);
View.showMessageDialog(this, AppStrings.translate("message.action.saved"), AppStrings.translate("dialog.message.title"), JOptionPane.INFORMATION_MESSAGE, Configuration.showCodeSavedMessage);
setDecompiledEditMode(false);
} catch (IOException ex) {
Logger.getLogger(ActionPanel.class.getName()).log(Level.SEVERE, "IOException during action compiling", ex);
} catch (ActionParseException ex) {
View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
} catch (CompilationException ex) {
View.showMessageDialog(this, AppStrings.translate("error.action.save").replace("%error%", ex.text).replace("%line%", Long.toString(ex.line)), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
}
}

View File

@@ -34,7 +34,6 @@ import com.jpexs.helpers.Helper;
import com.jpexs.helpers.MemoryInputStream;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedOutputStream;
@@ -61,19 +60,7 @@ import javax.swing.tree.TreePath;
*
* @author JPEXS
*/
public class DumpTree extends JTree implements ActionListener {
private static final String ACTION_CLOSE_SWF = "CLOSESWF";
private static final String ACTION_EXPAND_RECURSIVE = "EXPANDRECURSIVE";
private static final String ACTION_SAVE_TO_FILE = "SAVETOFILE";
private static final String ACTION_PARSE_ACTIONS = "PARSEACTIONS";
private static final String ACTION_PARSE_ABC = "PARSEABC";
private static final String ACTION_PARSE_INSTRUCTIONS = "PARSEINSTRUCTIONS";
public class DumpTree extends JTree {
private final MainPanel mainPanel;
@@ -103,33 +90,27 @@ public class DumpTree extends JTree implements ActionListener {
final JPopupMenu contextPopupMenu = new JPopupMenu();
final JMenuItem expandRecursiveMenuItem = new JMenuItem(mainPanel.translate("contextmenu.expandAll"));
expandRecursiveMenuItem.addActionListener(this);
expandRecursiveMenuItem.setActionCommand(ACTION_EXPAND_RECURSIVE);
expandRecursiveMenuItem.addActionListener(this::expandRecursiveButtonActionPerformed);
contextPopupMenu.add(expandRecursiveMenuItem);
final JMenuItem saveToFileMenuItem = new JMenuItem(mainPanel.translate("contextmenu.saveToFile"));
saveToFileMenuItem.addActionListener(this);
saveToFileMenuItem.setActionCommand(ACTION_SAVE_TO_FILE);
saveToFileMenuItem.addActionListener(this::saveToFileButtonActionPerformed);
contextPopupMenu.add(saveToFileMenuItem);
final JMenuItem closeSelectionMenuItem = new JMenuItem(mainPanel.translate("contextmenu.closeSwf"));
closeSelectionMenuItem.setActionCommand(ACTION_CLOSE_SWF);
closeSelectionMenuItem.addActionListener(this);
closeSelectionMenuItem.addActionListener(this::closeSwfButtonActionPerformed);
contextPopupMenu.add(closeSelectionMenuItem);
final JMenuItem parseActionsMenuItem = new JMenuItem(mainPanel.translate("contextmenu.parseActions"));
parseActionsMenuItem.setActionCommand(ACTION_PARSE_ACTIONS);
parseActionsMenuItem.addActionListener(this);
parseActionsMenuItem.addActionListener(this::parseActionsButtonActionPerformed);
contextPopupMenu.add(parseActionsMenuItem);
final JMenuItem parseAbcMenuItem = new JMenuItem(mainPanel.translate("contextmenu.parseABC"));
parseAbcMenuItem.setActionCommand(ACTION_PARSE_ABC);
parseAbcMenuItem.addActionListener(this);
parseAbcMenuItem.addActionListener(this::parseAbcButtonActionPerformed);
contextPopupMenu.add(parseAbcMenuItem);
final JMenuItem parseInstructionsMenuItem = new JMenuItem(mainPanel.translate("contextmenu.parseInstructions"));
parseInstructionsMenuItem.setActionCommand(ACTION_PARSE_INSTRUCTIONS);
parseInstructionsMenuItem.addActionListener(this);
parseInstructionsMenuItem.addActionListener(this::parseInstructionsButtonActionPerformed);
contextPopupMenu.add(parseInstructionsMenuItem);
addMouseListener(new MouseAdapter() {
@@ -188,104 +169,98 @@ public class DumpTree extends JTree implements ActionListener {
});
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_EXPAND_RECURSIVE: {
TreePath path = getSelectionPath();
if (path == null) {
return;
}
View.expandTreeNodes(this, path, true);
}
break;
case ACTION_SAVE_TO_FILE: {
TreePath[] paths = getSelectionPaths();
DumpInfo dumpInfo = (DumpInfo) paths[0].getLastPathComponent();
JFileChooser fc = new JFileChooser();
String selDir = Configuration.lastOpenDir.get();
fc.setCurrentDirectory(new File(selDir));
if (!selDir.endsWith(File.separator)) {
selDir += File.separator;
}
JFrame f = new JFrame();
View.setWindowIcon(f);
if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
File sf = Helper.fixDialogFile(fc.getSelectedFile());
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(sf))) {
byte[] data = DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf().originalUncompressedData;
fos.write(data, (int) dumpInfo.startByte, (int) (dumpInfo.getEndByte() - dumpInfo.startByte + 1));
} catch (IOException ex) {
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
break;
case ACTION_PARSE_ACTIONS: {
TreePath[] paths = getSelectionPaths();
DumpInfo dumpInfo = (DumpInfo) paths[0].getLastPathComponent();
SWF swf = DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf();
byte[] data = swf.originalUncompressedData;
int prevLength = (int) dumpInfo.startByte;
try {
SWFInputStream rri = new SWFInputStream(swf, data);
if (prevLength != 0) {
rri.seek(prevLength);
}
List<Action> actions = ActionListReader.getOriginalActions(rri, prevLength, (int) dumpInfo.getEndByte());
for (Action action : actions) {
DumpInfo di = new DumpInfo(action.toString(), "Action", null, action.getAddress(), action.getTotalActionLength());
di.parent = dumpInfo;
rri.dumpInfo = di;
rri.seek(action.getAddress());
rri.readAction(new ConstantPool());
dumpInfo.getChildInfos().add(di);
}
repaint();
} catch (IOException | InterruptedException ex) {
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
}
}
break;
case ACTION_PARSE_ABC: {
TreePath[] paths = getSelectionPaths();
DumpInfo dumpInfo = (DumpInfo) paths[0].getLastPathComponent();
SWF swf = DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf();
byte[] data = swf.originalUncompressedData;
int prevLength = (int) dumpInfo.startByte;
try {
ABCInputStream ais = new ABCInputStream(new MemoryInputStream(data, 0, prevLength + (int) dumpInfo.lengthBytes));
ais.seek(prevLength);
ais.dumpInfo = dumpInfo;
new ABC(ais, swf, null);
} catch (IOException ex) {
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
}
repaint();
}
break;
case ACTION_PARSE_INSTRUCTIONS: {
TreePath[] paths = getSelectionPaths();
DumpInfo dumpInfo = (DumpInfo) paths[0].getLastPathComponent();
SWF swf = DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf();
byte[] data = swf.originalUncompressedData;
int prevLength = (int) dumpInfo.startByte;
try {
ABCInputStream ais = new ABCInputStream(new MemoryInputStream(data, 0, prevLength + (int) dumpInfo.lengthBytes));
ais.seek(prevLength);
ais.dumpInfo = dumpInfo;
new AVM2Code(ais);
} catch (IOException ex) {
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
}
repaint();
}
break;
case ACTION_CLOSE_SWF: {
Main.closeFile(mainPanel.getCurrentSwfList());
}
break;
private void expandRecursiveButtonActionPerformed(ActionEvent evt) {
TreePath path = getSelectionPath();
if (path == null) {
return;
}
View.expandTreeNodes(this, path, true);
}
private void saveToFileButtonActionPerformed(ActionEvent evt) {
TreePath[] paths = getSelectionPaths();
DumpInfo dumpInfo = (DumpInfo) paths[0].getLastPathComponent();
JFileChooser fc = new JFileChooser();
String selDir = Configuration.lastOpenDir.get();
fc.setCurrentDirectory(new File(selDir));
if (!selDir.endsWith(File.separator)) {
selDir += File.separator;
}
JFrame f = new JFrame();
View.setWindowIcon(f);
if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
File sf = Helper.fixDialogFile(fc.getSelectedFile());
try (OutputStream fos = new BufferedOutputStream(new FileOutputStream(sf))) {
byte[] data = DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf().originalUncompressedData;
fos.write(data, (int) dumpInfo.startByte, (int) (dumpInfo.getEndByte() - dumpInfo.startByte + 1));
} catch (IOException ex) {
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
private void parseActionsButtonActionPerformed(ActionEvent evt) {
TreePath[] paths = getSelectionPaths();
DumpInfo dumpInfo = (DumpInfo) paths[0].getLastPathComponent();
SWF swf = DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf();
byte[] data = swf.originalUncompressedData;
int prevLength = (int) dumpInfo.startByte;
try {
SWFInputStream rri = new SWFInputStream(swf, data);
if (prevLength != 0) {
rri.seek(prevLength);
}
List<Action> actions = ActionListReader.getOriginalActions(rri, prevLength, (int) dumpInfo.getEndByte());
for (Action action : actions) {
DumpInfo di = new DumpInfo(action.toString(), "Action", null, action.getAddress(), action.getTotalActionLength());
di.parent = dumpInfo;
rri.dumpInfo = di;
rri.seek(action.getAddress());
rri.readAction(new ConstantPool());
dumpInfo.getChildInfos().add(di);
}
repaint();
} catch (IOException | InterruptedException ex) {
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void parseAbcButtonActionPerformed(ActionEvent evt) {
TreePath[] paths = getSelectionPaths();
DumpInfo dumpInfo = (DumpInfo) paths[0].getLastPathComponent();
SWF swf = DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf();
byte[] data = swf.originalUncompressedData;
int prevLength = (int) dumpInfo.startByte;
try {
ABCInputStream ais = new ABCInputStream(new MemoryInputStream(data, 0, prevLength + (int) dumpInfo.lengthBytes));
ais.seek(prevLength);
ais.dumpInfo = dumpInfo;
new ABC(ais, swf, null);
} catch (IOException ex) {
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
}
repaint();
}
private void parseInstructionsButtonActionPerformed(ActionEvent evt) {
TreePath[] paths = getSelectionPaths();
DumpInfo dumpInfo = (DumpInfo) paths[0].getLastPathComponent();
SWF swf = DumpInfoSwfNode.getSwfNode(dumpInfo).getSwf();
byte[] data = swf.originalUncompressedData;
int prevLength = (int) dumpInfo.startByte;
try {
ABCInputStream ais = new ABCInputStream(new MemoryInputStream(data, 0, prevLength + (int) dumpInfo.lengthBytes));
ais.seek(prevLength);
ais.dumpInfo = dumpInfo;
new AVM2Code(ais);
} catch (IOException ex) {
Logger.getLogger(DumpTree.class.getName()).log(Level.SEVERE, null, ex);
}
repaint();
}
private void closeSwfButtonActionPerformed(ActionEvent evt) {
Main.closeFile(mainPanel.getCurrentSwfList());
}
@Override

View File

@@ -212,7 +212,7 @@ message.confirm.remove = \u0412\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b
#after version 1.6.5u1:
button.ok = OK
button.cancel = Cancel
button.cancel = \u041e\u0442\u043c\u0435\u043d\u0430
font.name = \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0448\u0440\u0438\u0444\u0442\u0430:
font.isbold = \u0416\u0438\u0440\u043d\u044b\u0439:

View File

@@ -19,7 +19,7 @@ newversionavailable = Nova vers\u00e3o disponivel:
changeslog = Log de altera\u00e7\u00f5es:
downloadnow = Actualizar agora?
button.ok = OK
button.cancel = Cancelae
button.cancel = Cancelar
dialog.title = Nova vers\u00e3o disponivel
newversion = Nova vers\u00e3o
newvermessage = Nova vers\u00e3o de %oldAppName% est\u00e1 disponivel: %newAppName%.\r\nPor favor v\u00e1 a %projectPage% para actualizar.

View File

@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
button.ok = OK
button.cancel = Cancel
button.cancel = Cancelar
#after version 1.7.0:
# This language name translated (e. g. \u010ce\u0161tina for Czech,...)
language = Portugu\u00eas

View File

@@ -21,4 +21,4 @@ deobfuscation.removetraps = Remover armadilhas
deobfuscation.restorecontrolflow = Restaurar o fluxo de control
button.ok = OK
button.cancel = Cancelae
button.cancel = Cancelar

View File

@@ -14,5 +14,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
button.goto = Gehen nach
button.cancel = Abbrehen
button.cancel = Abbrechen
dialog.title = Anwendungen:

View File

@@ -35,7 +35,6 @@ import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
@@ -62,31 +61,7 @@ import javax.swing.event.AncestorListener;
*
* @author JPEXS
*/
public class PlayerControls extends JPanel implements ActionListener, MediaDisplayListener {
private static final String ACTION_PAUSE = "PAUSE";
private static final String ACTION_STOP = "STOP";
private static final String ACTION_LOOP = "LOOP";
private static final String ACTION_SELECT_BKCOLOR = "SELECTCOLOR";
private static final String ACTION_ZOOMIN = "ZOOMIN";
private static final String ACTION_ZOOMOUT = "ZOOMOUT";
private static final String ACTION_ZOOMFIT = "ZOOMFIT";
private static final String ACTION_ZOOMNONE = "ZOOMNONE";
private static final String ACTION_SNAPSHOT = "SNAPSHOT";
private static final String ACTION_NEXTFRAME = "NEXTFRAME";
private static final String ACTION_PREVFRAME = "PREVFRAME";
private static final String ACTION_GOTOFRAME = "SELECTFRAME";
public class PlayerControls extends JPanel implements MediaDisplayListener {
private final JButton pauseButton;
@@ -159,33 +134,27 @@ public class PlayerControls extends JPanel implements ActionListener, MediaDispl
graphicControls = new JPanel(new BorderLayout());
JPanel graphicButtonsPanel = new JPanel(new FlowLayout());
JButton selectColorButton = new JButton(View.getIcon("color16"));
selectColorButton.addActionListener(this);
selectColorButton.setActionCommand(ACTION_SELECT_BKCOLOR);
selectColorButton.addActionListener(this::selectBkColorButtonActionPerformed);
selectColorButton.setToolTipText(AppStrings.translate("button.selectbkcolor.hint"));
JButton zoomInButton = new JButton(View.getIcon("zoomin16"));
zoomInButton.addActionListener(this);
zoomInButton.setActionCommand(ACTION_ZOOMIN);
zoomInButton.addActionListener(this::zoomInButtonActionPerformed);
zoomInButton.setToolTipText(AppStrings.translate("button.zoomin.hint"));
JButton zoomOutButton = new JButton(View.getIcon("zoomout16"));
zoomOutButton.addActionListener(this);
zoomOutButton.setActionCommand(ACTION_ZOOMOUT);
zoomOutButton.addActionListener(this::zoomOutButtonActionPerformed);
zoomOutButton.setToolTipText(AppStrings.translate("button.zoomout.hint"));
zoomFitButton = new JButton(View.getIcon("zoomfit16"));
zoomFitButton.addActionListener(this);
zoomFitButton.setActionCommand(ACTION_ZOOMFIT);
zoomFitButton.addActionListener(this::zoomFitButtonActionPerformed);
zoomFitButton.setToolTipText(AppStrings.translate("button.zoomfit.hint"));
JButton zoomNoneButton = new JButton(View.getIcon("zoomnone16"));
zoomNoneButton.addActionListener(this);
zoomNoneButton.setActionCommand(ACTION_ZOOMNONE);
zoomNoneButton.addActionListener(this::zoomNoneButtonActionPerformed);
zoomNoneButton.setToolTipText(AppStrings.translate("button.zoomnone.hint"));
snapshotButton = new JButton(View.getIcon("snapshot16"));
snapshotButton.addActionListener(this);
snapshotButton.setActionCommand(ACTION_SNAPSHOT);
snapshotButton.addActionListener(this::snapShotButtonActionPerformed);
snapshotButton.setToolTipText(AppStrings.translate("button.snapshot.hint"));
zoomPanel = new JPanel(new FlowLayout());
@@ -255,8 +224,7 @@ public class PlayerControls extends JPanel implements ActionListener, MediaDispl
JButton prevFrameButton = new JButton(View.getIcon("prevframe16"));
prevFrameButton.setToolTipText(AppStrings.translate("preview.prevframe"));
prevFrameButton.setMargin(new Insets(4, 2, 2, 2));
prevFrameButton.setActionCommand(ACTION_PREVFRAME);
prevFrameButton.addActionListener(this);
prevFrameButton.addActionListener(this::prevFrameButtonActionPerformed);
frameControls.add(prevFrameButton);
frameControls.setVisible(display.screenAvailable());
@@ -265,15 +233,13 @@ public class PlayerControls extends JPanel implements ActionListener, MediaDispl
JButton nextFrameButton = new JButton(View.getIcon("nextframe16"));
nextFrameButton.setToolTipText(AppStrings.translate("preview.nextframe"));
nextFrameButton.setMargin(new Insets(4, 2, 2, 2));
nextFrameButton.setActionCommand(ACTION_NEXTFRAME);
nextFrameButton.addActionListener(this);
nextFrameButton.addActionListener(this::nextFrameButtonActionPerformed);
frameControls.add(nextFrameButton);
JButton gotoFrameButton = new JButton(View.getIcon("gotoframe16"));
gotoFrameButton.setToolTipText(AppStrings.translate("preview.gotoframe"));
gotoFrameButton.setMargin(new Insets(4, 2, 2, 2));
gotoFrameButton.setActionCommand(ACTION_GOTOFRAME);
gotoFrameButton.addActionListener(this);
gotoFrameButton.addActionListener(this::gotoFrameButtonActionPerformed);
frameControls.add(gotoFrameButton);
JPanel currentPanel = new JPanel(new FlowLayout());
@@ -291,18 +257,15 @@ public class PlayerControls extends JPanel implements ActionListener, MediaDispl
pauseButton = new JButton(pauseIcon);
pauseButton.setToolTipText(AppStrings.translate("preview.pause"));
pauseButton.setMargin(new Insets(4, 2, 2, 2));
pauseButton.setActionCommand(ACTION_PAUSE);
pauseButton.addActionListener(this);
pauseButton.addActionListener(this::pauseButtonActionPerformed);
JButton stopButton = new JButton(View.getIcon("stop16"));
stopButton.setToolTipText(AppStrings.translate("preview.stop"));
stopButton.setMargin(new Insets(4, 2, 2, 2));
stopButton.setActionCommand(ACTION_STOP);
stopButton.addActionListener(this);
stopButton.addActionListener(this::stopButtonActionPerformed);
loopButton = new JButton(pauseIcon);
loopButton.setToolTipText(AppStrings.translate("preview.loop"));
loopButton.setMargin(new Insets(4, 2, 2, 2));
loopButton.setActionCommand(ACTION_LOOP);
loopButton.addActionListener(this);
loopButton.addActionListener(this::loopButtonActionPerformed);
boolean loop = Configuration.loopMedia.get();
loopButton.setIcon(loop ? loopIcon : noLoopIcon);
buttonsPanel.add(pauseButton);
@@ -449,110 +412,112 @@ public class PlayerControls extends JPanel implements ActionListener, MediaDispl
display.zoom(zoomObj);
}
@Override
public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case ACTION_PAUSE:
if (display.isPlaying()) {
display.pause();
} else {
display.play();
}
break;
case ACTION_LOOP:
boolean loop = !Configuration.loopMedia.get();
Configuration.loopMedia.set(loop);
loopButton.setIcon(loop ? loopIcon : noLoopIcon);
display.setLoop(loop);
break;
case ACTION_GOTOFRAME:
final JPanel gotoPanel = new JPanel(new BorderLayout());
final JTextField frameField = new JTextField("" + display.getCurrentFrame());
gotoPanel.add(new JLabel(AppStrings.translate("preview.gotoframe.dialog.message").replace("%min%", "1").replace("%max%", "" + display.getTotalFrames())), BorderLayout.NORTH);
gotoPanel.add(frameField, BorderLayout.CENTER);
gotoPanel.addAncestorListener(new AncestorListener() {
@Override
public void ancestorAdded(AncestorEvent event) {
final AncestorListener al = this;
View.execInEventDispatchLater(() -> {
frameField.selectAll();
frameField.requestFocusInWindow();
gotoPanel.removeAncestorListener(al);
});
}
@Override
public void ancestorRemoved(AncestorEvent event) {
}
@Override
public void ancestorMoved(AncestorEvent event) {
}
});
if (View.showConfirmDialog(this, gotoPanel, AppStrings.translate("preview.gotoframe.dialog.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) == JOptionPane.OK_OPTION) {
int frame = -1;
try {
frame = Integer.parseInt(frameField.getText());
} catch (NumberFormatException nfe) {
//handled as -1
}
if (frame <= 0 || frame > display.getTotalFrames()) {
View.showMessageDialog(this, AppStrings.translate("preview.gotoframe.dialog.frame.error").replace("%min%", "1").replace("%max%", "" + display.getTotalFrames()), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
return;
}
display.gotoFrame(frame - 1);
}
break;
case ACTION_NEXTFRAME:
display.gotoFrame(display.getCurrentFrame() + 1);
break;
case ACTION_PREVFRAME:
display.gotoFrame(display.getCurrentFrame() - 1);
break;
case ACTION_STOP:
display.stop();
break;
case ACTION_SELECT_BKCOLOR:
View.execInEventDispatch(() -> {
Color newColor = JColorChooser.showDialog(null, AppStrings.translate("dialog.selectbkcolor.title"), View.getSwfBackgroundColor());
if (newColor != null) {
View.setSwfBackgroundColor(newColor);
display.setBackground(newColor);
}
});
break;
case ACTION_ZOOMIN:
realZoom = getRealZoom() * ZOOM_MULTIPLIER;
zoomToFit = false;
updateZoom();
break;
case ACTION_ZOOMOUT:
realZoom = getRealZoom() / ZOOM_MULTIPLIER;
zoomToFit = false;
updateZoom();
break;
case ACTION_ZOOMNONE:
realZoom = 1.0;
zoomToFit = false;
updateZoom();
break;
case ACTION_ZOOMFIT:
realZoom = 1.0;
zoomToFit = true;
updateZoom();
break;
case ACTION_SNAPSHOT:
putImageToClipBoard(display.printScreen());
break;
private void pauseButtonActionPerformed(ActionEvent evt) {
if (display.isPlaying()) {
display.pause();
} else {
display.play();
}
}
private void loopButtonActionPerformed(ActionEvent evt) {
boolean loop = !Configuration.loopMedia.get();
Configuration.loopMedia.set(loop);
loopButton.setIcon(loop ? loopIcon : noLoopIcon);
display.setLoop(loop);
}
private void gotoFrameButtonActionPerformed(ActionEvent evt) {
final JPanel gotoPanel = new JPanel(new BorderLayout());
final JTextField frameField = new JTextField("" + display.getCurrentFrame());
gotoPanel.add(new JLabel(AppStrings.translate("preview.gotoframe.dialog.message").replace("%min%", "1").replace("%max%", "" + display.getTotalFrames())), BorderLayout.NORTH);
gotoPanel.add(frameField, BorderLayout.CENTER);
gotoPanel.addAncestorListener(new AncestorListener() {
@Override
public void ancestorAdded(AncestorEvent event) {
final AncestorListener al = this;
View.execInEventDispatchLater(() -> {
frameField.selectAll();
frameField.requestFocusInWindow();
gotoPanel.removeAncestorListener(al);
});
}
@Override
public void ancestorRemoved(AncestorEvent event) {
}
@Override
public void ancestorMoved(AncestorEvent event) {
}
});
if (View.showConfirmDialog(this, gotoPanel, AppStrings.translate("preview.gotoframe.dialog.title"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) == JOptionPane.OK_OPTION) {
int frame = -1;
try {
frame = Integer.parseInt(frameField.getText());
} catch (NumberFormatException nfe) {
//handled as -1
}
if (frame <= 0 || frame > display.getTotalFrames()) {
View.showMessageDialog(this, AppStrings.translate("preview.gotoframe.dialog.frame.error").replace("%min%", "1").replace("%max%", "" + display.getTotalFrames()), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
return;
}
display.gotoFrame(frame - 1);
}
}
private void nextFrameButtonActionPerformed(ActionEvent evt) {
display.gotoFrame(display.getCurrentFrame() + 1);
}
private void prevFrameButtonActionPerformed(ActionEvent evt) {
display.gotoFrame(display.getCurrentFrame() - 1);
}
private void stopButtonActionPerformed(ActionEvent evt) {
display.stop();
}
private void selectBkColorButtonActionPerformed(ActionEvent evt) {
Color newColor = JColorChooser.showDialog(null, AppStrings.translate("dialog.selectbkcolor.title"), View.getSwfBackgroundColor());
if (newColor != null) {
View.setSwfBackgroundColor(newColor);
display.setBackground(newColor);
}
}
private void zoomInButtonActionPerformed(ActionEvent evt) {
realZoom = getRealZoom() * ZOOM_MULTIPLIER;
zoomToFit = false;
updateZoom();
}
private void zoomOutButtonActionPerformed(ActionEvent evt) {
realZoom = getRealZoom() / ZOOM_MULTIPLIER;
zoomToFit = false;
updateZoom();
}
private void zoomNoneButtonActionPerformed(ActionEvent evt) {
realZoom = 1.0;
zoomToFit = false;
updateZoom();
}
private void zoomFitButtonActionPerformed(ActionEvent evt) {
realZoom = 1.0;
zoomToFit = true;
updateZoom();
}
private void snapShotButtonActionPerformed(ActionEvent evt) {
putImageToClipBoard(display.printScreen());
}
private double getRealZoom() {
if (zoomToFit) {
return display.getZoomToFit();

View File

@@ -43,7 +43,6 @@ import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
@@ -88,26 +87,10 @@ import javax.swing.table.DefaultTableModel;
*
* @author JPEXS
*/
public class ProxyFrame extends AppFrame implements ActionListener, CatchedListener, MouseListener, ReplacedListener {
public class ProxyFrame extends AppFrame implements CatchedListener, MouseListener, ReplacedListener {
private static final String REPLACEMENTS_NAME = "replacements.cfg";
private static final String ACTION_SWITCH_STATE = "SWITCHSTATE";
private static final String ACTION_OPEN = "OPEN";
private static final String ACTION_CLEAR = "CLEAR";
private static final String ACTION_RENAME = "RENAME";
private static final String ACTION_REMOVE = "REMOVE";
private static final String ACTION_COPYURL = "COPYURL";
private static final String ACTION_SAVEAS = "SAVEAS";
private static final String ACTION_REPLACE = "REPLACE";
private JTable replacementsTable;
private JButton switchButton = new JButton(translate("proxy.start"));
@@ -278,8 +261,7 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe
replacementsTable.addMouseListener(this);
replacementsTable.setFont(new Font("Monospaced", Font.PLAIN, 12));
switchButton.addActionListener(this);
switchButton.setActionCommand(ACTION_SWITCH_STATE);
switchButton.addActionListener(this::switchStateButtonActionPerformed);
Container cnt = getContentPane();
cnt.setLayout(new BorderLayout());
cnt.add(new JScrollPane(replacementsTable), BorderLayout.CENTER);
@@ -297,36 +279,29 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe
JPanel buttonsPanel21 = new JPanel(new FlowLayout());
JButton openButton = new JButton(translate("open"));
openButton.setActionCommand(ACTION_OPEN);
openButton.addActionListener(this);
openButton.addActionListener(this::openButtonActionPerformed);
buttonsPanel21.add(openButton);
JButton clearButton = new JButton(translate("clear"));
clearButton.setActionCommand(ACTION_CLEAR);
clearButton.addActionListener(this);
clearButton.addActionListener(this::clearButtonActionPerformed);
buttonsPanel21.add(clearButton);
JButton renameButton = new JButton(translate("rename"));
renameButton.setActionCommand(ACTION_RENAME);
renameButton.addActionListener(this);
renameButton.addActionListener(this::renameButtonActionPerformed);
buttonsPanel21.add(renameButton);
JButton removeButton = new JButton(translate("remove"));
removeButton.setActionCommand(ACTION_REMOVE);
removeButton.addActionListener(this);
removeButton.addActionListener(this::removeButtonActionPerformed);
buttonsPanel21.add(removeButton);
//JPanel buttonsPanel22 = new JPanel(new FlowLayout());
JButton copyUrlButton = new JButton(translate("copy.url"));
copyUrlButton.setActionCommand(ACTION_COPYURL);
copyUrlButton.addActionListener(this);
copyUrlButton.addActionListener(this::copyUrlButtonActionPerformed);
buttonsPanel21.add(copyUrlButton);
JButton saveAsButton = new JButton(translate("save.as"));
saveAsButton.setActionCommand(ACTION_SAVEAS);
saveAsButton.addActionListener(this);
saveAsButton.addActionListener(this::saveAsButtonActionPerformed);
buttonsPanel21.add(saveAsButton);
JButton replaceButton = new JButton(translate("replace"));
replaceButton.setActionCommand(ACTION_REPLACE);
replaceButton.addActionListener(this);
replaceButton.addActionListener(this::replaceButtonActionPerformed);
buttonsPanel21.add(replaceButton);
JPanel buttonsPanel3 = new JPanel();
@@ -394,193 +369,199 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe
return null;
}
/**
* Method handling actions from buttons
*
* @param e event
*/
@Override
public void actionPerformed(ActionEvent e) {
private int[] getSelectedRows() {
int sel[] = replacementsTable.getSelectedRows();
for (int i = 0; i < sel.length; i++) {
sel[i] = replacementsTable.getRowSorter().convertRowIndexToModel(sel[i]);
}
switch (e.getActionCommand()) {
case ACTION_OPEN:
open();
break;
case ACTION_SAVEAS:
if (sel.length == 1) {
Replacement r = replacements.get(sel[0]);
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File(Configuration.lastSaveDir.get()));
String n = r.urlPattern;
if (n.contains("?")) {
n = n.substring(0, n.indexOf('?'));
return sel;
}
private void openButtonActionPerformed(ActionEvent evt) {
open();
}
private void saveAsButtonActionPerformed(ActionEvent evt) {
int[] sel = getSelectedRows();
if (sel.length == 1) {
Replacement r = replacements.get(sel[0]);
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File(Configuration.lastSaveDir.get()));
String n = r.urlPattern;
if (n.contains("?")) {
n = n.substring(0, n.indexOf('?'));
}
if (n.contains("/")) {
n = n.substring(n.lastIndexOf('/'));
}
n = Helper.makeFileName(n);
fc.setSelectedFile(new File(Configuration.lastSaveDir.get(), n));
String ext = ".swf";
final String extension = ext;
FileFilter swfFilter = new FileFilter() {
@Override
public boolean accept(File f) {
return (f.getName().toLowerCase().endsWith(extension)) || (f.isDirectory());
}
@Override
public String getDescription() {
return AppStrings.translate("filter" + extension);
}
};
fc.setFileFilter(swfFilter);
fc.setAcceptAllFileFilterUsed(true);
JFrame f = new JFrame();
View.setWindowIcon(f);
if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
File file = Helper.fixDialogFile(fc.getSelectedFile());
try {
Files.copy(new File(r.targetFile).toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException ex) {
View.showMessageDialog(this, translate("error.save.as") + "\r\n" + ex.getLocalizedMessage(), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
}
}
} else {
GuiAbortRetryIgnoreHandler handler = new GuiAbortRetryIgnoreHandler();
File exportDir = new File(selectExportDir());
for (int s : sel) {
final Replacement r = replacements.get(s);
String n = r.urlPattern;
if (n.contains("?")) {
n = n.substring(0, n.indexOf('?'));
}
if (n.contains("/")) {
n = n.substring(n.lastIndexOf('/'));
}
n = Helper.makeFileName(n);
int c = 2;
String n2 = n;
while (new File(exportDir, n2).exists()) {
if (n.contains(".")) {
n2 = n.substring(0, n.lastIndexOf('.')) + c + n.substring(n.lastIndexOf('.'));
c++;
} else {
n2 = n + c + ".swf";
c++;
}
if (n.contains("/")) {
n = n.substring(n.lastIndexOf('/'));
}
n = Helper.makeFileName(n);
fc.setSelectedFile(new File(Configuration.lastSaveDir.get(), n));
String ext = ".swf";
final String extension = ext;
FileFilter swfFilter = new FileFilter() {
}
final File outfile = new File(exportDir, n2);
try {
new RetryTask(new RunnableIOEx() {
@Override
public boolean accept(File f) {
return (f.getName().toLowerCase().endsWith(extension)) || (f.isDirectory());
public void run() throws IOException {
Files.copy(new File(r.targetFile).toPath(), outfile.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
@Override
public String getDescription() {
return AppStrings.translate("filter" + extension);
}
};
fc.setFileFilter(swfFilter);
fc.setAcceptAllFileFilterUsed(true);
JFrame f = new JFrame();
View.setWindowIcon(f);
if (fc.showSaveDialog(f) == JFileChooser.APPROVE_OPTION) {
File file = Helper.fixDialogFile(fc.getSelectedFile());
try {
Files.copy(new File(r.targetFile).toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException ex) {
View.showMessageDialog(this, translate("error.save.as") + "\r\n" + ex.getLocalizedMessage(), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
}
}
} else {
GuiAbortRetryIgnoreHandler handler = new GuiAbortRetryIgnoreHandler();
File exportDir = new File(selectExportDir());
for (int s : sel) {
final Replacement r = replacements.get(s);
String n = r.urlPattern;
if (n.contains("?")) {
n = n.substring(0, n.indexOf('?'));
}
if (n.contains("/")) {
n = n.substring(n.lastIndexOf('/'));
}
n = Helper.makeFileName(n);
int c = 2;
String n2 = n;
while (new File(exportDir, n2).exists()) {
if (n.contains(".")) {
n2 = n.substring(0, n.lastIndexOf('.')) + c + n.substring(n.lastIndexOf('.'));
c++;
} else {
n2 = n + c + ".swf";
c++;
}
}
final File outfile = new File(exportDir, n2);
try {
new RetryTask(new RunnableIOEx() {
@Override
public void run() throws IOException {
Files.copy(new File(r.targetFile).toPath(), outfile.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
}, handler).run();
} catch (IOException ex) {
break;
}
}
}, handler).run();
} catch (IOException ex) {
break;
}
break;
case ACTION_REPLACE:
if (sel.length > 0) {
Replacement r = replacements.get(sel[0]);
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get()));
String ext = ".swf";
final String extension = ext;
FileFilter swfFilter = new FileFilter() {
@Override
public boolean accept(File f) {
return (f.getName().toLowerCase().endsWith(extension)) || (f.isDirectory());
}
@Override
public String getDescription() {
return AppStrings.translate("filter" + extension);
}
};
fc.setFileFilter(swfFilter);
fc.setAcceptAllFileFilterUsed(true);
JFrame f = new JFrame();
View.setWindowIcon(f);
if (fc.showOpenDialog(f) == JFileChooser.APPROVE_OPTION) {
File file = Helper.fixDialogFile(fc.getSelectedFile());
try {
Files.copy(file.toPath(), new File(r.targetFile).toPath(), StandardCopyOption.REPLACE_EXISTING);
tableModel.fireTableCellUpdated(sel[0], 1/*size*/);
} catch (IOException ex) {
View.showMessageDialog(f, translate("error.replace") + "\r\n" + ex.getLocalizedMessage(), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
}
}
}
break;
case ACTION_COPYURL:
String copyText = "";
for (int sc : sel) {
Replacement r = replacements.get(sc);
if (!copyText.isEmpty()) {
copyText += System.lineSeparator();
}
copyText += r.urlPattern;
}
if (!copyText.isEmpty()) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection stringSelection = new StringSelection(copyText);
clipboard.setContents(stringSelection, null);
}
break;
case ACTION_RENAME:
if (sel.length > 0) {
Replacement r = replacements.get(sel[0]);
String s = View.showInputDialog("URL", r.urlPattern);
if (s != null) {
r.urlPattern = s;
tableModel.setValueAt(s, sel[0], 2/*url*/);
}
}
break;
case ACTION_CLEAR:
for (Replacement r : replacements) {
File f;
try {
f = (new File(Main.tempFile(r.targetFile)));
if (f.exists()) {
f.delete();
}
} catch (IOException ex) {
Logger.getLogger(ProxyFrame.class.getName()).log(Level.SEVERE, null, ex);
}
}
tableModel.setRowCount(0);
replacements.clear();
saveReplacements();
break;
case ACTION_REMOVE:
Arrays.sort(sel);
for (int i = sel.length - 1; i >= 0; i--) {
tableModel.removeRow(sel[i]);
Replacement r = replacements.remove(sel[i]);
saveReplacements();
File f = (new File(r.targetFile));
if (f.exists()) {
f.delete();
}
}
break;
case ACTION_SWITCH_STATE:
Main.switchProxy();
break;
}
}
}
private void replaceButtonActionPerformed(ActionEvent evt) {
int[] sel = getSelectedRows();
if (sel.length > 0) {
Replacement r = replacements.get(sel[0]);
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get()));
String ext = ".swf";
final String extension = ext;
FileFilter swfFilter = new FileFilter() {
@Override
public boolean accept(File f) {
return (f.getName().toLowerCase().endsWith(extension)) || (f.isDirectory());
}
@Override
public String getDescription() {
return AppStrings.translate("filter" + extension);
}
};
fc.setFileFilter(swfFilter);
fc.setAcceptAllFileFilterUsed(true);
JFrame f = new JFrame();
View.setWindowIcon(f);
if (fc.showOpenDialog(f) == JFileChooser.APPROVE_OPTION) {
File file = Helper.fixDialogFile(fc.getSelectedFile());
try {
Files.copy(file.toPath(), new File(r.targetFile).toPath(), StandardCopyOption.REPLACE_EXISTING);
tableModel.fireTableCellUpdated(sel[0], 1/*size*/);
} catch (IOException ex) {
View.showMessageDialog(f, translate("error.replace") + "\r\n" + ex.getLocalizedMessage(), AppStrings.translate("error"), JOptionPane.ERROR_MESSAGE);
}
}
}
}
private void copyUrlButtonActionPerformed(ActionEvent evt) {
int[] sel = getSelectedRows();
String copyText = "";
for (int sc : sel) {
Replacement r = replacements.get(sc);
if (!copyText.isEmpty()) {
copyText += System.lineSeparator();
}
copyText += r.urlPattern;
}
if (!copyText.isEmpty()) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection stringSelection = new StringSelection(copyText);
clipboard.setContents(stringSelection, null);
}
}
private void renameButtonActionPerformed(ActionEvent evt) {
int[] sel = getSelectedRows();
if (sel.length > 0) {
Replacement r = replacements.get(sel[0]);
String s = View.showInputDialog("URL", r.urlPattern);
if (s != null) {
r.urlPattern = s;
tableModel.setValueAt(s, sel[0], 2/*url*/);
}
}
}
private void clearButtonActionPerformed(ActionEvent evt) {
for (Replacement r : replacements) {
File f;
try {
f = (new File(Main.tempFile(r.targetFile)));
if (f.exists()) {
f.delete();
}
} catch (IOException ex) {
Logger.getLogger(ProxyFrame.class.getName()).log(Level.SEVERE, null, ex);
}
}
tableModel.setRowCount(0);
replacements.clear();
saveReplacements();
}
private void removeButtonActionPerformed(ActionEvent evt) {
int[] sel = getSelectedRows();
Arrays.sort(sel);
for (int i = sel.length - 1; i >= 0; i--) {
tableModel.removeRow(sel[i]);
Replacement r = replacements.remove(sel[i]);
saveReplacements();
File f = (new File(r.targetFile));
if (f.exists()) {
f.delete();
}
}
}
private void switchStateButtonActionPerformed(ActionEvent evt) {
Main.switchProxy();
}
/**
* Switch proxy state
*/

View File

@@ -19,7 +19,6 @@ package com.jpexs.decompiler.flash.gui.tagtree;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.gui.AppDialog;
import com.jpexs.decompiler.flash.gui.Main;
import com.jpexs.decompiler.flash.gui.MainFrameRibbonMenu;
import com.jpexs.decompiler.flash.gui.MainPanel;
import com.jpexs.decompiler.flash.gui.ReplaceCharacterDialog;
import com.jpexs.decompiler.flash.gui.View;
@@ -133,13 +132,11 @@ public class TagTreeContextMenu extends JPopupMenu {
add(undoTagMenuItem);
exportSelectionMenuItem = new JMenuItem(mainPanel.translate("menu.file.export.selection"));
exportSelectionMenuItem.setActionCommand(MainFrameRibbonMenu.ACTION_EXPORT_SEL);
exportSelectionMenuItem.addActionListener(mainPanel);
exportSelectionMenuItem.addActionListener(mainPanel::exportSelectionActionPerformed);
add(exportSelectionMenuItem);
replaceMenuItem = new JMenuItem(mainPanel.translate("button.replace"));
replaceMenuItem.setActionCommand(MainPanel.ACTION_REPLACE);
replaceMenuItem.addActionListener(mainPanel);
replaceMenuItem.addActionListener(mainPanel::replaceButtonActionPerformed);
add(replaceMenuItem);
replaceWithTagMenuItem = new JMenuItem(mainPanel.translate("button.replaceWithTag"));
@@ -155,18 +152,15 @@ public class TagTreeContextMenu extends JPopupMenu {
add(jumpToCharacterMenuItem);
exportJavaSourceMenuItem = new JMenuItem(mainPanel.translate("contextmenu.exportJavaSource"));
exportJavaSourceMenuItem.setActionCommand(MainFrameRibbonMenu.ACTION_EXPORT_JAVA_SOURCE);
exportJavaSourceMenuItem.addActionListener(mainPanel);
exportJavaSourceMenuItem.addActionListener(mainPanel::exportJavaSourceActionPerformed);
add(exportJavaSourceMenuItem);
exportSwfXmlMenuItem = new JMenuItem(mainPanel.translate("contextmenu.exportSwfXml"));
exportSwfXmlMenuItem.setActionCommand(MainFrameRibbonMenu.ACTION_EXPORT_SWF_XML);
exportSwfXmlMenuItem.addActionListener(mainPanel);
exportSwfXmlMenuItem.addActionListener(mainPanel::exportSwfXmlActionPerformed);
add(exportSwfXmlMenuItem);
importSwfXmlMenuItem = new JMenuItem(mainPanel.translate("contextmenu.importSwfXml"));
importSwfXmlMenuItem.setActionCommand(MainFrameRibbonMenu.ACTION_IMPORT_SWF_XML);
importSwfXmlMenuItem.addActionListener(mainPanel);
importSwfXmlMenuItem.addActionListener(mainPanel::importSwfXmlActionPerformed);
add(importSwfXmlMenuItem);
closeMenuItem = new JMenuItem(mainPanel.translate("contextmenu.closeSwf"));