mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 08:41:17 +00:00
java source code formatting
This commit is contained in:
@@ -1,57 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.AppStrings;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import java.awt.Window;
|
||||
import java.util.ResourceBundle;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JRootPane;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public abstract class AppDialog extends JDialog {
|
||||
|
||||
private ResourceBundle resourceBundle = ResourceBundle.getBundle(AppStrings.getResourcePath(getClass()));
|
||||
|
||||
public AppDialog() {
|
||||
View.installEscapeCloseOperation(this);
|
||||
if (Configuration.useRibbonInterface.get()) {
|
||||
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
|
||||
}
|
||||
}
|
||||
|
||||
public AppDialog(Window owner) {
|
||||
super(owner);
|
||||
View.installEscapeCloseOperation(this);
|
||||
if (Configuration.useRibbonInterface.get()) {
|
||||
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String translate(String key) {
|
||||
return resourceBundle.getString(key);
|
||||
}
|
||||
|
||||
public void updateLanguage() {
|
||||
resourceBundle = ResourceBundle.getBundle(AppStrings.getResourcePath(getClass()));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.AppStrings;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import java.awt.Window;
|
||||
import java.util.ResourceBundle;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JRootPane;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public abstract class AppDialog extends JDialog {
|
||||
|
||||
private ResourceBundle resourceBundle = ResourceBundle.getBundle(AppStrings.getResourcePath(getClass()));
|
||||
|
||||
public AppDialog() {
|
||||
View.installEscapeCloseOperation(this);
|
||||
if (Configuration.useRibbonInterface.get()) {
|
||||
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
|
||||
}
|
||||
}
|
||||
|
||||
public AppDialog(Window owner) {
|
||||
super(owner);
|
||||
View.installEscapeCloseOperation(this);
|
||||
if (Configuration.useRibbonInterface.get()) {
|
||||
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
|
||||
}
|
||||
}
|
||||
|
||||
public String translate(String key) {
|
||||
return resourceBundle.getString(key);
|
||||
}
|
||||
|
||||
public void updateLanguage() {
|
||||
resourceBundle = ResourceBundle.getBundle(AppStrings.getResourcePath(getClass()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import javax.swing.tree.TreeModel;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class DumpTree extends JTree {
|
||||
|
||||
|
||||
public class DumpTreeCellRenderer extends DefaultTreeCellRenderer {
|
||||
|
||||
@Override
|
||||
@@ -50,7 +50,6 @@ public class DumpTree extends JTree {
|
||||
hasFocus);
|
||||
|
||||
//DumpInfo dumpInfo = (DumpInfo) value;
|
||||
|
||||
setUI(new BasicLabelUI());
|
||||
setOpaque(false);
|
||||
setBackgroundNonSelectionColor(Color.white);
|
||||
@@ -83,7 +82,5 @@ public class DumpTree extends JTree {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import javax.swing.tree.TreePath;
|
||||
public class DumpTreeModel implements TreeModel {
|
||||
|
||||
private final DumpInfo root;
|
||||
|
||||
|
||||
public DumpTreeModel(List<SWFList> swfs) {
|
||||
DumpInfo root = new DumpInfo("root", "", null, 0, 0);
|
||||
for (SWFList swfList : swfs) {
|
||||
@@ -42,7 +42,7 @@ public class DumpTreeModel implements TreeModel {
|
||||
}
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getRoot() {
|
||||
return root;
|
||||
@@ -80,5 +80,5 @@ public class DumpTreeModel implements TreeModel {
|
||||
@Override
|
||||
public void removeTreeModelListener(TreeModelListener tl) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,19 +34,19 @@ import javax.swing.table.TableColumnModel;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class DumpViewPanel extends JPanel {
|
||||
|
||||
|
||||
private final int bytesInRow = 16;
|
||||
private final JLabel dumpViewLabel;
|
||||
private final JTable dumpViewHexTable;
|
||||
private byte[] data;
|
||||
|
||||
|
||||
public DumpViewPanel() {
|
||||
super(new BorderLayout());
|
||||
|
||||
dumpViewLabel = new JLabel();
|
||||
dumpViewLabel.setMinimumSize(new Dimension(100, 20));
|
||||
add(dumpViewLabel, BorderLayout.SOUTH);
|
||||
|
||||
|
||||
dumpViewHexTable = new JTable();
|
||||
dumpViewHexTable.setBackground(Color.white);
|
||||
dumpViewHexTable.setFont(new Font("Monospaced", Font.PLAIN, 12));
|
||||
@@ -81,7 +81,7 @@ public class DumpViewPanel extends JPanel {
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 2*bytesInRow + 1;
|
||||
return 2 * bytesInRow + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,7 +93,7 @@ public class DumpViewPanel extends JPanel {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int row, int column) {
|
||||
if (column == 0) {
|
||||
@@ -107,7 +107,7 @@ public class DumpViewPanel extends JPanel {
|
||||
} else {
|
||||
int pos = row * bytesInRow + column - bytesInRow - 1;
|
||||
if (pos < data.length) {
|
||||
return (char)data[pos];
|
||||
return (char) data[pos];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -115,11 +115,11 @@ public class DumpViewPanel extends JPanel {
|
||||
});
|
||||
add(new JScrollPane(dumpViewHexTable), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
|
||||
public void setData(byte[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
public void setLabelText(String text) {
|
||||
dumpViewLabel.setText(text);
|
||||
}
|
||||
|
||||
@@ -1,336 +1,336 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphPart;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Window;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class GraphDialog extends AppDialog {
|
||||
|
||||
private class GraphPanel extends JPanel {
|
||||
|
||||
private static final int SPACE_VERTICAL = 16;
|
||||
private static final int SPACE_HORIZONTAL = 10;
|
||||
private static final int SPACE_BACKLINKS = 5;
|
||||
private static final int BLOCK_WIDTH = 200;
|
||||
private static final int BLOCK_HEIGHT = 20;
|
||||
private final HashMap<GraphPart, Point> partPos = new HashMap<>();
|
||||
private final Point size;
|
||||
private int backLinksLeft = 0;
|
||||
private int backLinksRight = 0;
|
||||
private final GraphPart head;
|
||||
|
||||
public GraphPanel(Graph graph) throws InterruptedException {
|
||||
graph.init(null);
|
||||
size = getPartPositions(head = graph.heads.get(0), SPACE_VERTICAL + SPACE_VERTICAL + BLOCK_HEIGHT / 2, getPartWidth(graph.heads.get(0), new HashSet<GraphPart>()) * (BLOCK_WIDTH + SPACE_HORIZONTAL) / 2 - SPACE_HORIZONTAL, partPos, true);
|
||||
backLinksLeft = 1;
|
||||
backLinksRight = 1;
|
||||
for (GraphPart part : partPos.keySet()) {
|
||||
Point p = partPos.get(part);
|
||||
for (GraphPart n : part.nextParts) {
|
||||
Point npos = partPos.get(n);
|
||||
if (npos.y < p.y) {
|
||||
if (p.x > size.x / 2) {
|
||||
backLinksRight++;
|
||||
} else {
|
||||
backLinksLeft++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
size.x += 2 * SPACE_BACKLINKS + backLinksLeft * SPACE_BACKLINKS + backLinksRight * SPACE_BACKLINKS;
|
||||
setPreferredSize(new Dimension(size.x, size.y));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
/*g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);*/
|
||||
g2.setColor(Color.black);
|
||||
int startX = SPACE_BACKLINKS + backLinksLeft * SPACE_BACKLINKS;
|
||||
int blLeft = 0;
|
||||
int blRight = 0;
|
||||
for (GraphPart part : partPos.keySet()) {
|
||||
Point p = partPos.get(part);
|
||||
g2.setColor(Color.white);
|
||||
g2.fillRect(startX + p.x - BLOCK_WIDTH / 2, p.y - BLOCK_HEIGHT / 2, BLOCK_WIDTH, BLOCK_HEIGHT);
|
||||
g2.setColor(Color.black);
|
||||
g2.drawRect(startX + p.x - BLOCK_WIDTH / 2, p.y - BLOCK_HEIGHT / 2, BLOCK_WIDTH, BLOCK_HEIGHT);
|
||||
g2.drawString(part.toString(), startX + p.x - g2.getFontMetrics().stringWidth(part.toString()) / 2, p.y + g2.getFontMetrics().getHeight() / 2);
|
||||
}
|
||||
|
||||
Point hp = partPos.get(head);
|
||||
drawArrow(g2, startX + hp.x, hp.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL, startX + hp.x, hp.y - BLOCK_HEIGHT / 2);
|
||||
|
||||
for (GraphPart part : partPos.keySet()) {
|
||||
Point p = partPos.get(part);
|
||||
|
||||
for (int n = 0; n < part.nextParts.size(); n++) {
|
||||
boolean isIf = part.nextParts.size() == 2;
|
||||
if (isIf) {
|
||||
if (n == 0) {
|
||||
g2.setColor(new Color(0, 0x80, 0));
|
||||
} else {
|
||||
g2.setColor(Color.red);
|
||||
}
|
||||
} else {
|
||||
g2.setColor(Color.black);
|
||||
}
|
||||
Point npos = partPos.get(part.nextParts.get(n));
|
||||
if (npos.y < p.y) {
|
||||
int sidex = startX;
|
||||
if (p.x > size.x / 2) {
|
||||
blRight++;
|
||||
sidex = size.x - backLinksRight * SPACE_BACKLINKS;
|
||||
sidex += SPACE_BACKLINKS + SPACE_BACKLINKS * blRight;
|
||||
} else {
|
||||
blLeft++;
|
||||
sidex -= SPACE_BACKLINKS + SPACE_BACKLINKS * blLeft;
|
||||
}
|
||||
g2.drawLine(startX + p.x, p.y + BLOCK_HEIGHT / 2, startX + p.x, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2);
|
||||
g2.drawLine(startX + p.x, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2, sidex, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2);
|
||||
g2.drawLine(sidex, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, sidex, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2);
|
||||
drawArrow(g2, sidex, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2);
|
||||
g2.drawLine(startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2);
|
||||
} else {
|
||||
drawArrow(g2, startX + p.x, p.y + BLOCK_HEIGHT / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2);
|
||||
g2.drawLine(startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Point getPartSubPositions(Point ret, int totalWidth, GraphPart part, int y, int x, HashMap<GraphPart, Point> used) {
|
||||
if (used.containsKey(part)) {
|
||||
Point p = used.get(part);
|
||||
return new Point(x, y);
|
||||
}
|
||||
used.put(part, new Point(x, y));
|
||||
if (part.nextParts.size() > 0) {
|
||||
int cx = x - totalWidth / 2;
|
||||
for (int p = 0; p < part.nextParts.size(); p++) {
|
||||
HashSet<GraphPart> k = new HashSet<>();
|
||||
k.addAll(used.keySet());
|
||||
int partWidth = getPartWidth(part.nextParts.get(p), k);
|
||||
int cellWidth = partWidth * (BLOCK_WIDTH + SPACE_HORIZONTAL);
|
||||
Point pt = getPartPositions(part.nextParts.get(p), y + BLOCK_HEIGHT + SPACE_VERTICAL, cx + cellWidth / 2, used, false);
|
||||
if (pt.x > ret.x) {
|
||||
ret.x = pt.x;
|
||||
}
|
||||
if (pt.y > ret.y) {
|
||||
ret.y = pt.y;
|
||||
}
|
||||
cx += cellWidth;
|
||||
|
||||
}
|
||||
cx = x - totalWidth / 2;
|
||||
for (int p = 0; p < part.nextParts.size(); p++) {
|
||||
HashSet<GraphPart> k = new HashSet<>();
|
||||
k.addAll(used.keySet());
|
||||
int cellWidth = getPartWidth(part.nextParts.get(p), k) * (BLOCK_WIDTH + SPACE_HORIZONTAL);
|
||||
|
||||
HashSet<GraphPart> hs = new HashSet<>();
|
||||
hs.addAll(used.keySet());
|
||||
int totalWidthParts2 = getPartWidth(part.nextParts.get(p), hs);
|
||||
int totalWidth2 = totalWidthParts2 * (BLOCK_WIDTH + SPACE_HORIZONTAL);
|
||||
|
||||
Point pt = getPartSubPositions(ret, totalWidth2, part.nextParts.get(p), y + BLOCK_HEIGHT + SPACE_VERTICAL, cx + cellWidth / 2, used);
|
||||
if (pt.x > ret.x) {
|
||||
ret.x = pt.x;
|
||||
}
|
||||
if (pt.y > ret.y) {
|
||||
ret.y = pt.y;
|
||||
}
|
||||
cx += cellWidth;
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Point getPartPositions(GraphPart part, int y, int x, HashMap<GraphPart, Point> used, boolean goSub) {
|
||||
HashMap<GraphPart, Point> l = new HashMap<>();
|
||||
l.putAll(used);
|
||||
HashSet<GraphPart> hs = new HashSet<>();
|
||||
hs.addAll(l.keySet());
|
||||
int totalWidthParts = getPartWidth(part, hs);
|
||||
int totalWidth = totalWidthParts * (BLOCK_WIDTH + SPACE_HORIZONTAL);
|
||||
|
||||
if (used.containsKey(part)) {
|
||||
Point p = used.get(part);
|
||||
return new Point(x, y);
|
||||
}
|
||||
Point ret = new Point(x - BLOCK_WIDTH / 2 - SPACE_HORIZONTAL / 2 + BLOCK_WIDTH, y + BLOCK_HEIGHT);
|
||||
if (goSub) {
|
||||
Point p2 = getPartSubPositions(ret, totalWidth, part, y, x, used);
|
||||
if (p2.x > ret.x) {
|
||||
ret.x = p2.x;
|
||||
}
|
||||
if (p2.y > ret.y) {
|
||||
ret.y = p2.y;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int getPartHeight(GraphPart part, List<GraphPart> used) {
|
||||
if (used.contains(part)) {
|
||||
return 1;
|
||||
}
|
||||
used.add(part);
|
||||
int maxH = 0;
|
||||
for (int p = 0; p < part.nextParts.size(); p++) {
|
||||
int h = getPartHeight(part.nextParts.get(p), used);
|
||||
if (h > maxH) {
|
||||
maxH = h;
|
||||
}
|
||||
}
|
||||
return 1 + maxH;
|
||||
}
|
||||
|
||||
private int getPartWidth(GraphPart part, HashSet<GraphPart> used) {
|
||||
|
||||
if (used.contains(part)) {
|
||||
return 1;
|
||||
}
|
||||
used.add(part);
|
||||
if (part.nextParts.isEmpty()) {
|
||||
return 1;
|
||||
}
|
||||
int w = 0;
|
||||
for (GraphPart subpart : part.nextParts) {
|
||||
w += getPartWidth(subpart, used);
|
||||
}
|
||||
return w;
|
||||
}
|
||||
}
|
||||
GraphPanel gp;
|
||||
int scrollBarWidth;
|
||||
int scrollBarHeight;
|
||||
int frameWidthDiff;
|
||||
int frameHeightDiff;
|
||||
|
||||
public GraphDialog(Window owner,Graph graph, String name) throws InterruptedException {
|
||||
super(owner);
|
||||
setSize(500, 500);
|
||||
Container cnt = getContentPane();
|
||||
cnt.setLayout(new BorderLayout());
|
||||
gp = new GraphPanel(graph);
|
||||
setTitle(translate("graph") + " " + name);
|
||||
JScrollPane scrollPane = new JScrollPane(gp);
|
||||
scrollBarWidth = scrollPane.getVerticalScrollBar().getPreferredSize().width;
|
||||
scrollBarHeight = scrollPane.getHorizontalScrollBar().getPreferredSize().height;
|
||||
cnt.add(scrollPane, BorderLayout.CENTER);
|
||||
pack();
|
||||
|
||||
Dimension size = getSize();
|
||||
Dimension innerSize = getContentPane().getSize();
|
||||
|
||||
frameWidthDiff = size.width - innerSize.width;
|
||||
frameHeightDiff = size.height - innerSize.height;
|
||||
|
||||
View.setWindowIcon(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean b) {
|
||||
|
||||
super.setVisible(b);
|
||||
Dimension screen = getToolkit().getScreenSize();
|
||||
Dimension dim = new Dimension(0, 0);
|
||||
Dimension panDim = gp.getPreferredSize();
|
||||
// add some magic constants
|
||||
panDim = new Dimension(panDim.width + 3, panDim.height + 2);
|
||||
|
||||
boolean tooHigh = false;
|
||||
boolean tooWide = false;
|
||||
|
||||
if (panDim.width + frameWidthDiff < screen.width) {
|
||||
dim.width = panDim.width;
|
||||
} else {
|
||||
dim.width = screen.width;
|
||||
tooWide = true;
|
||||
}
|
||||
if (panDim.height + frameHeightDiff < screen.height) {
|
||||
dim.height = panDim.height;
|
||||
} else {
|
||||
dim.height = screen.height;
|
||||
tooHigh = true;
|
||||
}
|
||||
|
||||
if (tooWide) {
|
||||
dim.height += scrollBarHeight;
|
||||
dim.height = Math.min(dim.height, screen.height);
|
||||
}
|
||||
if (tooHigh) {
|
||||
dim.width += scrollBarWidth;
|
||||
dim.width = Math.min(dim.width, screen.width);
|
||||
}
|
||||
|
||||
setVisibleSize(dim);
|
||||
View.centerScreen(this);
|
||||
}
|
||||
|
||||
private void setVisibleSize(Dimension dim) {
|
||||
setSize(new Dimension(dim.width + frameWidthDiff, dim.height + frameHeightDiff));
|
||||
}
|
||||
|
||||
private void drawArrow(Graphics g, int x1, int y1, int x2, int y2) {
|
||||
Polygon arrowHead = new Polygon();
|
||||
arrowHead.addPoint(0, 0);
|
||||
arrowHead.addPoint(-3, -8);
|
||||
arrowHead.addPoint(3, -8);
|
||||
Line2D.Double line = new Line2D.Double(x1, y1, x2, y2);
|
||||
AffineTransform tx = new AffineTransform();
|
||||
tx.setToIdentity();
|
||||
double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
|
||||
tx.translate(line.x2, line.y2);
|
||||
tx.rotate((angle - Math.PI / 2d));
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
AffineTransform oldTransform = g2d.getTransform();
|
||||
g2d.draw(line);
|
||||
tx.preConcatenate(oldTransform);
|
||||
g2d.setTransform(tx);
|
||||
g2d.fill(arrowHead);
|
||||
g2d.setTransform(oldTransform);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.graph.Graph;
|
||||
import com.jpexs.decompiler.graph.GraphPart;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Window;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class GraphDialog extends AppDialog {
|
||||
|
||||
private class GraphPanel extends JPanel {
|
||||
|
||||
private static final int SPACE_VERTICAL = 16;
|
||||
private static final int SPACE_HORIZONTAL = 10;
|
||||
private static final int SPACE_BACKLINKS = 5;
|
||||
private static final int BLOCK_WIDTH = 200;
|
||||
private static final int BLOCK_HEIGHT = 20;
|
||||
private final HashMap<GraphPart, Point> partPos = new HashMap<>();
|
||||
private final Point size;
|
||||
private int backLinksLeft = 0;
|
||||
private int backLinksRight = 0;
|
||||
private final GraphPart head;
|
||||
|
||||
public GraphPanel(Graph graph) throws InterruptedException {
|
||||
graph.init(null);
|
||||
size = getPartPositions(head = graph.heads.get(0), SPACE_VERTICAL + SPACE_VERTICAL + BLOCK_HEIGHT / 2, getPartWidth(graph.heads.get(0), new HashSet<GraphPart>()) * (BLOCK_WIDTH + SPACE_HORIZONTAL) / 2 - SPACE_HORIZONTAL, partPos, true);
|
||||
backLinksLeft = 1;
|
||||
backLinksRight = 1;
|
||||
for (GraphPart part : partPos.keySet()) {
|
||||
Point p = partPos.get(part);
|
||||
for (GraphPart n : part.nextParts) {
|
||||
Point npos = partPos.get(n);
|
||||
if (npos.y < p.y) {
|
||||
if (p.x > size.x / 2) {
|
||||
backLinksRight++;
|
||||
} else {
|
||||
backLinksLeft++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
size.x += 2 * SPACE_BACKLINKS + backLinksLeft * SPACE_BACKLINKS + backLinksRight * SPACE_BACKLINKS;
|
||||
setPreferredSize(new Dimension(size.x, size.y));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
/*g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);*/
|
||||
g2.setColor(Color.black);
|
||||
int startX = SPACE_BACKLINKS + backLinksLeft * SPACE_BACKLINKS;
|
||||
int blLeft = 0;
|
||||
int blRight = 0;
|
||||
for (GraphPart part : partPos.keySet()) {
|
||||
Point p = partPos.get(part);
|
||||
g2.setColor(Color.white);
|
||||
g2.fillRect(startX + p.x - BLOCK_WIDTH / 2, p.y - BLOCK_HEIGHT / 2, BLOCK_WIDTH, BLOCK_HEIGHT);
|
||||
g2.setColor(Color.black);
|
||||
g2.drawRect(startX + p.x - BLOCK_WIDTH / 2, p.y - BLOCK_HEIGHT / 2, BLOCK_WIDTH, BLOCK_HEIGHT);
|
||||
g2.drawString(part.toString(), startX + p.x - g2.getFontMetrics().stringWidth(part.toString()) / 2, p.y + g2.getFontMetrics().getHeight() / 2);
|
||||
}
|
||||
|
||||
Point hp = partPos.get(head);
|
||||
drawArrow(g2, startX + hp.x, hp.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL, startX + hp.x, hp.y - BLOCK_HEIGHT / 2);
|
||||
|
||||
for (GraphPart part : partPos.keySet()) {
|
||||
Point p = partPos.get(part);
|
||||
|
||||
for (int n = 0; n < part.nextParts.size(); n++) {
|
||||
boolean isIf = part.nextParts.size() == 2;
|
||||
if (isIf) {
|
||||
if (n == 0) {
|
||||
g2.setColor(new Color(0, 0x80, 0));
|
||||
} else {
|
||||
g2.setColor(Color.red);
|
||||
}
|
||||
} else {
|
||||
g2.setColor(Color.black);
|
||||
}
|
||||
Point npos = partPos.get(part.nextParts.get(n));
|
||||
if (npos.y < p.y) {
|
||||
int sidex = startX;
|
||||
if (p.x > size.x / 2) {
|
||||
blRight++;
|
||||
sidex = size.x - backLinksRight * SPACE_BACKLINKS;
|
||||
sidex += SPACE_BACKLINKS + SPACE_BACKLINKS * blRight;
|
||||
} else {
|
||||
blLeft++;
|
||||
sidex -= SPACE_BACKLINKS + SPACE_BACKLINKS * blLeft;
|
||||
}
|
||||
g2.drawLine(startX + p.x, p.y + BLOCK_HEIGHT / 2, startX + p.x, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2);
|
||||
g2.drawLine(startX + p.x, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2, sidex, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2);
|
||||
g2.drawLine(sidex, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, sidex, p.y + BLOCK_HEIGHT / 2 + SPACE_VERTICAL / 2);
|
||||
drawArrow(g2, sidex, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2);
|
||||
g2.drawLine(startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2);
|
||||
} else {
|
||||
drawArrow(g2, startX + p.x, p.y + BLOCK_HEIGHT / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2);
|
||||
g2.drawLine(startX + npos.x, npos.y - BLOCK_HEIGHT / 2 - SPACE_VERTICAL / 2, startX + npos.x, npos.y - BLOCK_HEIGHT / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Point getPartSubPositions(Point ret, int totalWidth, GraphPart part, int y, int x, HashMap<GraphPart, Point> used) {
|
||||
if (used.containsKey(part)) {
|
||||
Point p = used.get(part);
|
||||
return new Point(x, y);
|
||||
}
|
||||
used.put(part, new Point(x, y));
|
||||
if (part.nextParts.size() > 0) {
|
||||
int cx = x - totalWidth / 2;
|
||||
for (int p = 0; p < part.nextParts.size(); p++) {
|
||||
HashSet<GraphPart> k = new HashSet<>();
|
||||
k.addAll(used.keySet());
|
||||
int partWidth = getPartWidth(part.nextParts.get(p), k);
|
||||
int cellWidth = partWidth * (BLOCK_WIDTH + SPACE_HORIZONTAL);
|
||||
Point pt = getPartPositions(part.nextParts.get(p), y + BLOCK_HEIGHT + SPACE_VERTICAL, cx + cellWidth / 2, used, false);
|
||||
if (pt.x > ret.x) {
|
||||
ret.x = pt.x;
|
||||
}
|
||||
if (pt.y > ret.y) {
|
||||
ret.y = pt.y;
|
||||
}
|
||||
cx += cellWidth;
|
||||
|
||||
}
|
||||
cx = x - totalWidth / 2;
|
||||
for (int p = 0; p < part.nextParts.size(); p++) {
|
||||
HashSet<GraphPart> k = new HashSet<>();
|
||||
k.addAll(used.keySet());
|
||||
int cellWidth = getPartWidth(part.nextParts.get(p), k) * (BLOCK_WIDTH + SPACE_HORIZONTAL);
|
||||
|
||||
HashSet<GraphPart> hs = new HashSet<>();
|
||||
hs.addAll(used.keySet());
|
||||
int totalWidthParts2 = getPartWidth(part.nextParts.get(p), hs);
|
||||
int totalWidth2 = totalWidthParts2 * (BLOCK_WIDTH + SPACE_HORIZONTAL);
|
||||
|
||||
Point pt = getPartSubPositions(ret, totalWidth2, part.nextParts.get(p), y + BLOCK_HEIGHT + SPACE_VERTICAL, cx + cellWidth / 2, used);
|
||||
if (pt.x > ret.x) {
|
||||
ret.x = pt.x;
|
||||
}
|
||||
if (pt.y > ret.y) {
|
||||
ret.y = pt.y;
|
||||
}
|
||||
cx += cellWidth;
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Point getPartPositions(GraphPart part, int y, int x, HashMap<GraphPart, Point> used, boolean goSub) {
|
||||
HashMap<GraphPart, Point> l = new HashMap<>();
|
||||
l.putAll(used);
|
||||
HashSet<GraphPart> hs = new HashSet<>();
|
||||
hs.addAll(l.keySet());
|
||||
int totalWidthParts = getPartWidth(part, hs);
|
||||
int totalWidth = totalWidthParts * (BLOCK_WIDTH + SPACE_HORIZONTAL);
|
||||
|
||||
if (used.containsKey(part)) {
|
||||
Point p = used.get(part);
|
||||
return new Point(x, y);
|
||||
}
|
||||
Point ret = new Point(x - BLOCK_WIDTH / 2 - SPACE_HORIZONTAL / 2 + BLOCK_WIDTH, y + BLOCK_HEIGHT);
|
||||
if (goSub) {
|
||||
Point p2 = getPartSubPositions(ret, totalWidth, part, y, x, used);
|
||||
if (p2.x > ret.x) {
|
||||
ret.x = p2.x;
|
||||
}
|
||||
if (p2.y > ret.y) {
|
||||
ret.y = p2.y;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int getPartHeight(GraphPart part, List<GraphPart> used) {
|
||||
if (used.contains(part)) {
|
||||
return 1;
|
||||
}
|
||||
used.add(part);
|
||||
int maxH = 0;
|
||||
for (int p = 0; p < part.nextParts.size(); p++) {
|
||||
int h = getPartHeight(part.nextParts.get(p), used);
|
||||
if (h > maxH) {
|
||||
maxH = h;
|
||||
}
|
||||
}
|
||||
return 1 + maxH;
|
||||
}
|
||||
|
||||
private int getPartWidth(GraphPart part, HashSet<GraphPart> used) {
|
||||
|
||||
if (used.contains(part)) {
|
||||
return 1;
|
||||
}
|
||||
used.add(part);
|
||||
if (part.nextParts.isEmpty()) {
|
||||
return 1;
|
||||
}
|
||||
int w = 0;
|
||||
for (GraphPart subpart : part.nextParts) {
|
||||
w += getPartWidth(subpart, used);
|
||||
}
|
||||
return w;
|
||||
}
|
||||
}
|
||||
GraphPanel gp;
|
||||
int scrollBarWidth;
|
||||
int scrollBarHeight;
|
||||
int frameWidthDiff;
|
||||
int frameHeightDiff;
|
||||
|
||||
public GraphDialog(Window owner, Graph graph, String name) throws InterruptedException {
|
||||
super(owner);
|
||||
setSize(500, 500);
|
||||
Container cnt = getContentPane();
|
||||
cnt.setLayout(new BorderLayout());
|
||||
gp = new GraphPanel(graph);
|
||||
setTitle(translate("graph") + " " + name);
|
||||
JScrollPane scrollPane = new JScrollPane(gp);
|
||||
scrollBarWidth = scrollPane.getVerticalScrollBar().getPreferredSize().width;
|
||||
scrollBarHeight = scrollPane.getHorizontalScrollBar().getPreferredSize().height;
|
||||
cnt.add(scrollPane, BorderLayout.CENTER);
|
||||
pack();
|
||||
|
||||
Dimension size = getSize();
|
||||
Dimension innerSize = getContentPane().getSize();
|
||||
|
||||
frameWidthDiff = size.width - innerSize.width;
|
||||
frameHeightDiff = size.height - innerSize.height;
|
||||
|
||||
View.setWindowIcon(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean b) {
|
||||
|
||||
super.setVisible(b);
|
||||
Dimension screen = getToolkit().getScreenSize();
|
||||
Dimension dim = new Dimension(0, 0);
|
||||
Dimension panDim = gp.getPreferredSize();
|
||||
// add some magic constants
|
||||
panDim = new Dimension(panDim.width + 3, panDim.height + 2);
|
||||
|
||||
boolean tooHigh = false;
|
||||
boolean tooWide = false;
|
||||
|
||||
if (panDim.width + frameWidthDiff < screen.width) {
|
||||
dim.width = panDim.width;
|
||||
} else {
|
||||
dim.width = screen.width;
|
||||
tooWide = true;
|
||||
}
|
||||
if (panDim.height + frameHeightDiff < screen.height) {
|
||||
dim.height = panDim.height;
|
||||
} else {
|
||||
dim.height = screen.height;
|
||||
tooHigh = true;
|
||||
}
|
||||
|
||||
if (tooWide) {
|
||||
dim.height += scrollBarHeight;
|
||||
dim.height = Math.min(dim.height, screen.height);
|
||||
}
|
||||
if (tooHigh) {
|
||||
dim.width += scrollBarWidth;
|
||||
dim.width = Math.min(dim.width, screen.width);
|
||||
}
|
||||
|
||||
setVisibleSize(dim);
|
||||
View.centerScreen(this);
|
||||
}
|
||||
|
||||
private void setVisibleSize(Dimension dim) {
|
||||
setSize(new Dimension(dim.width + frameWidthDiff, dim.height + frameHeightDiff));
|
||||
}
|
||||
|
||||
private void drawArrow(Graphics g, int x1, int y1, int x2, int y2) {
|
||||
Polygon arrowHead = new Polygon();
|
||||
arrowHead.addPoint(0, 0);
|
||||
arrowHead.addPoint(-3, -8);
|
||||
arrowHead.addPoint(3, -8);
|
||||
Line2D.Double line = new Line2D.Double(x1, y1, x2, y2);
|
||||
AffineTransform tx = new AffineTransform();
|
||||
tx.setToIdentity();
|
||||
double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
|
||||
tx.translate(line.x2, line.y2);
|
||||
tx.rotate((angle - Math.PI / 2d));
|
||||
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
AffineTransform oldTransform = g2d.getTransform();
|
||||
g2d.draw(line);
|
||||
tx.preConcatenate(oldTransform);
|
||||
g2d.setTransform(tx);
|
||||
g2d.fill(arrowHead);
|
||||
g2d.setTransform(oldTransform);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1051,7 +1051,7 @@ public class Main {
|
||||
// sometimes during development the version information is not available
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
List<String> accepted = new ArrayList<>();
|
||||
if (Configuration.checkForUpdatesStable.get()) {
|
||||
accepted.add("stable");
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import java.awt.Window;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface MainFrame {
|
||||
|
||||
public void setTitle(String string);
|
||||
|
||||
public String translate(String key);
|
||||
|
||||
public MainPanel getPanel();
|
||||
|
||||
public boolean isVisible();
|
||||
|
||||
public void setVisible(boolean b);
|
||||
|
||||
public Window getWindow();
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import java.awt.Window;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public interface MainFrame {
|
||||
|
||||
public void setTitle(String string);
|
||||
|
||||
public String translate(String key);
|
||||
|
||||
public MainPanel getPanel();
|
||||
|
||||
public boolean isVisible();
|
||||
|
||||
public void setVisible(boolean b);
|
||||
|
||||
public Window getWindow();
|
||||
}
|
||||
|
||||
@@ -124,6 +124,5 @@ public final class MainFrameClassic extends AppFrame implements MainFrame {
|
||||
public Window getWindow() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -116,8 +116,7 @@ public final class MainFrameRibbon extends AppRibbonFrame implements MainFrame {
|
||||
});
|
||||
|
||||
View.centerScreen(this);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void getApplicationMenuButtons(Component comp, List<JRibbonApplicationMenuButton> ret) {
|
||||
@@ -220,9 +219,8 @@ public final class MainFrameRibbon extends AppRibbonFrame implements MainFrame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Window getWindow() {
|
||||
public Window getWindow() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -283,8 +283,6 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
public MainFrame getMainFrame() {
|
||||
return mainFrame;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static {
|
||||
try {
|
||||
@@ -441,7 +439,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
expandRecursiveMenuItem.setVisible(model.getChildCount(treeNode) > 0);
|
||||
|
||||
jumpToCharacterMenuItem.setVisible(item instanceof CharacterIdTag && !(item instanceof CharacterTag));
|
||||
|
||||
|
||||
rawEditMenuItem.setVisible(item instanceof Tag);
|
||||
}
|
||||
|
||||
@@ -2281,7 +2279,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
showCard(CARDPREVIEWPANEL);
|
||||
previewPanel.showGenericTagPanel((Tag) item);
|
||||
}
|
||||
@@ -2291,7 +2289,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
if (item == null || !(item instanceof CharacterIdTag)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
CharacterIdTag characterIdTag = (CharacterIdTag) item;
|
||||
setTreeItem(item.getSwf().characters.get(characterIdTag.getCharacterId()));
|
||||
}
|
||||
@@ -2385,10 +2383,10 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
DumpInfo dumpInfo = (DumpInfo) e.getPath().getLastPathComponent();
|
||||
if (dumpInfo.lengthBytes != 0 || dumpInfo.lengthBits != 0) {
|
||||
// todo
|
||||
dumpViewPanel.setLabelText("startByte: " + dumpInfo.startByte +
|
||||
" startBit: " + dumpInfo.startBit +
|
||||
" lengthBytes: " + dumpInfo.lengthBytes +
|
||||
" lengthBits: " + dumpInfo.lengthBits);
|
||||
dumpViewPanel.setLabelText("startByte: " + dumpInfo.startByte
|
||||
+ " startBit: " + dumpInfo.startBit
|
||||
+ " lengthBytes: " + dumpInfo.lengthBytes
|
||||
+ " lengthBits: " + dumpInfo.lengthBits);
|
||||
}
|
||||
|
||||
// todo honfika: support multiple swf
|
||||
@@ -2396,7 +2394,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
|
||||
dumpViewPanel.revalidate();
|
||||
showCard(CARDDUMPVIEW);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
Object source = e.getSource();
|
||||
|
||||
@@ -93,7 +93,7 @@ public class PreviewImage extends JPanel {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Tag tag = (Tag) treeItem;
|
||||
Tag tag = (Tag) treeItem;
|
||||
tag.getSwf().removeTag(tag, false);
|
||||
mainPanel.refreshTree();
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class PreviewImage extends JPanel {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Tag tag = (Tag) treeItem;
|
||||
Tag tag = (Tag) treeItem;
|
||||
tag.getSwf().removeTag(tag, true);
|
||||
mainPanel.refreshTree();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
@@ -46,30 +45,29 @@ import jsyntaxpane.components.Markers;
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class QuickFindPanel extends JPanel implements ActionListener, jsyntaxpane.actions.QuickFindHandler {
|
||||
|
||||
public JTextField findTextField;
|
||||
public JButton prevButton,nextButton;
|
||||
public JCheckBox ignoreCaseCheckbox,regExpCheckbox,wrapCheckbox;
|
||||
public JButton prevButton, nextButton;
|
||||
public JCheckBox ignoreCaseCheckbox, regExpCheckbox, wrapCheckbox;
|
||||
public JLabel statusLabel;
|
||||
|
||||
|
||||
private final Markers.SimpleMarker marker = new Markers.SimpleMarker(Color.PINK);
|
||||
private WeakReference<JTextComponent> target;
|
||||
private WeakReference<DocumentSearchData> dsd;
|
||||
private int oldCaretPosition;
|
||||
|
||||
public QuickFindPanel(){
|
||||
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||
|
||||
|
||||
private WeakReference<JTextComponent> target;
|
||||
private WeakReference<DocumentSearchData> dsd;
|
||||
private int oldCaretPosition;
|
||||
|
||||
public QuickFindPanel() {
|
||||
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||
|
||||
setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
|
||||
|
||||
|
||||
JPanel pan1 = new JPanel(new WrapLayout());
|
||||
JPanel pan2 = new JPanel(new WrapLayout());
|
||||
pan1.setAlignmentX(0);
|
||||
pan2.setAlignmentX(0);
|
||||
pan1.setAlignmentY(0);
|
||||
pan2.setAlignmentY(0);
|
||||
|
||||
|
||||
|
||||
JLabel jLabel1 = new javax.swing.JLabel();
|
||||
findTextField = new javax.swing.JTextField();
|
||||
prevButton = new javax.swing.JButton();
|
||||
@@ -78,21 +76,20 @@ public class QuickFindPanel extends JPanel implements ActionListener, jsyntaxpan
|
||||
regExpCheckbox = new javax.swing.JCheckBox();
|
||||
wrapCheckbox = new javax.swing.JCheckBox();
|
||||
statusLabel = new javax.swing.JLabel();
|
||||
|
||||
|
||||
setName("QuickFindDialog"); // NOI18N
|
||||
|
||||
|
||||
jLabel1.setLabelFor(findTextField);
|
||||
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle"); // NOI18N
|
||||
jLabel1.setText(bundle.getString("QuickFindDialog.jLabel1.text")); // NOI18N
|
||||
pan1.add(jLabel1);
|
||||
|
||||
|
||||
findTextField.setColumns(30);
|
||||
findTextField.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
findTextField.setMaximumSize(new java.awt.Dimension(200, 24));
|
||||
findTextField.setMinimumSize(new java.awt.Dimension(60, 24));
|
||||
pan1.add(findTextField);
|
||||
|
||||
|
||||
prevButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/META-INF/images/small-icons/go-up.png"))); // NOI18N
|
||||
prevButton.setFocusable(false);
|
||||
prevButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
@@ -136,124 +133,117 @@ public class QuickFindPanel extends JPanel implements ActionListener, jsyntaxpan
|
||||
pan2.add(wrapCheckbox);
|
||||
wrapCheckbox.addActionListener(this);
|
||||
|
||||
|
||||
statusLabel.setFont(statusLabel.getFont().deriveFont(statusLabel.getFont().getStyle() | java.awt.Font.BOLD, statusLabel.getFont().getSize()-2));
|
||||
statusLabel.setFont(statusLabel.getFont().deriveFont(statusLabel.getFont().getStyle() | java.awt.Font.BOLD, statusLabel.getFont().getSize() - 2));
|
||||
statusLabel.setForeground(java.awt.Color.red);
|
||||
pan2.add(statusLabel);
|
||||
|
||||
|
||||
add(pan1);
|
||||
add(pan2);
|
||||
setPreferredSize(getMinimumSize());
|
||||
setVisible(false);
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch(e.getActionCommand()){
|
||||
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"));
|
||||
}
|
||||
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"));
|
||||
}
|
||||
statusLabel.setText(null);
|
||||
} else {
|
||||
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void showQuickFind(final JTextComponent t,DocumentSearchData ds) {
|
||||
public void showQuickFind(final JTextComponent t, DocumentSearchData ds) {
|
||||
dsd = new WeakReference<DocumentSearchData>(ds);
|
||||
oldCaretPosition = t.getCaretPosition();
|
||||
Container view = t.getParent();
|
||||
Dimension wd = getSize();
|
||||
wd.width = t.getVisibleRect().width;
|
||||
Point loc = new Point(0, view.getHeight());
|
||||
setSize(wd);
|
||||
SwingUtilities.convertPointToScreen(loc, view);
|
||||
setLocation(loc);
|
||||
findTextField.setFont(t.getFont());
|
||||
final DocumentListener dl;
|
||||
findTextField.getDocument().addDocumentListener(dl = new DocumentListener() {
|
||||
Container view = t.getParent();
|
||||
Dimension wd = getSize();
|
||||
wd.width = t.getVisibleRect().width;
|
||||
Point loc = new Point(0, view.getHeight());
|
||||
setSize(wd);
|
||||
SwingUtilities.convertPointToScreen(loc, view);
|
||||
setLocation(loc);
|
||||
findTextField.setFont(t.getFont());
|
||||
final DocumentListener dl;
|
||||
findTextField.getDocument().addDocumentListener(dl = new DocumentListener() {
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
updateFind();
|
||||
}
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
updateFind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
updateFind();
|
||||
}
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
updateFind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
updateFind();
|
||||
}
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
updateFind();
|
||||
}
|
||||
|
||||
private void updateFind() {
|
||||
JTextComponent t = target.get();
|
||||
DocumentSearchData d = dsd.get();
|
||||
String toFind = findTextField.getText();
|
||||
if (toFind == null || toFind.isEmpty()) {
|
||||
statusLabel.setText(null);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
d.setWrap(wrapCheckbox.isSelected());
|
||||
d.setPattern(toFind,
|
||||
regExpCheckbox.isSelected(),
|
||||
ignoreCaseCheckbox.isSelected());
|
||||
// The dsd doFindNext will always find from current pos,
|
||||
// so we need to relocate to our saved pos before we call doFindNext
|
||||
statusLabel.setText(null);
|
||||
t.setCaretPosition(oldCaretPosition);
|
||||
if (!d.doFindNext(t)) {
|
||||
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
|
||||
} else {
|
||||
statusLabel.setText(null);
|
||||
}
|
||||
} catch (PatternSyntaxException e) {
|
||||
statusLabel.setText(e.getDescription());
|
||||
}
|
||||
private void updateFind() {
|
||||
JTextComponent t = target.get();
|
||||
DocumentSearchData d = dsd.get();
|
||||
String toFind = findTextField.getText();
|
||||
if (toFind == null || toFind.isEmpty()) {
|
||||
statusLabel.setText(null);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
d.setWrap(wrapCheckbox.isSelected());
|
||||
d.setPattern(toFind,
|
||||
regExpCheckbox.isSelected(),
|
||||
ignoreCaseCheckbox.isSelected());
|
||||
// The dsd doFindNext will always find from current pos,
|
||||
// so we need to relocate to our saved pos before we call doFindNext
|
||||
statusLabel.setText(null);
|
||||
t.setCaretPosition(oldCaretPosition);
|
||||
if (!d.doFindNext(t)) {
|
||||
statusLabel.setText(java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("QuickFindDialog.NotFound"));
|
||||
} else {
|
||||
statusLabel.setText(null);
|
||||
}
|
||||
} catch (PatternSyntaxException e) {
|
||||
statusLabel.setText(e.getDescription());
|
||||
}
|
||||
}
|
||||
});
|
||||
this.target = new WeakReference<>(t);
|
||||
Pattern p = dsd.get().getPattern();
|
||||
if (p != null) {
|
||||
findTextField.setText(p.pattern());
|
||||
}
|
||||
});
|
||||
this.target = new WeakReference<>(t);
|
||||
Pattern p = dsd.get().getPattern();
|
||||
if (p != null) {
|
||||
findTextField.setText(p.pattern());
|
||||
}
|
||||
wrapCheckbox.setSelected(dsd.get().isWrap());
|
||||
|
||||
|
||||
setVisible(true);
|
||||
wrapCheckbox.setSelected(dsd.get().isWrap());
|
||||
|
||||
setVisible(true);
|
||||
getParent().revalidate();
|
||||
getParent().repaint();
|
||||
getParent().repaint();
|
||||
findTextField.requestFocusInWindow();
|
||||
}
|
||||
/*
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
/*
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
removeFocusListener(this);
|
||||
setVisible(false);
|
||||
getParent().revalidate();
|
||||
getParent().repaint();
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
removeFocusListener(this);
|
||||
setVisible(false);
|
||||
getParent().revalidate();
|
||||
getParent().repaint();
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
@@ -39,25 +38,26 @@ import javax.swing.SwingUtilities;
|
||||
* @author JPEXS
|
||||
* @param <E>
|
||||
*/
|
||||
public class SearchResultsDialog<E> extends AppDialog implements ActionListener{
|
||||
public class SearchResultsDialog<E> extends AppDialog implements ActionListener {
|
||||
|
||||
private final JList<E> resultsList;
|
||||
private final DefaultListModel<E> model;
|
||||
private final SearchListener<E> listener;
|
||||
|
||||
|
||||
static final String ACTION_GOTO = "GOTO";
|
||||
static final String ACTION_CANCEL = "CLOSE";
|
||||
|
||||
private final JButton gotoButton = new JButton(translate("button.goto"));
|
||||
private final JButton closeButton = new JButton(translate("button.close"));
|
||||
|
||||
public SearchResultsDialog(Window owner,String text,SearchListener<E> listener) {
|
||||
|
||||
public SearchResultsDialog(Window owner, String text, SearchListener<E> listener) {
|
||||
super(owner);
|
||||
setTitle(translate("dialog.title").replace("%text%", text));
|
||||
Container cnt=getContentPane();
|
||||
Container cnt = getContentPane();
|
||||
model = new DefaultListModel<>();
|
||||
resultsList = new JList<>(model);
|
||||
resultsList = new JList<>(model);
|
||||
this.listener = listener;
|
||||
|
||||
|
||||
gotoButton.setActionCommand(ACTION_GOTO);
|
||||
gotoButton.addActionListener(this);
|
||||
closeButton.setActionCommand(ACTION_CANCEL);
|
||||
@@ -74,24 +74,24 @@ public class SearchResultsDialog<E> extends AppDialog implements ActionListener{
|
||||
gotoElement();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
cnt.setLayout(new BorderLayout());
|
||||
JScrollPane sp = new JScrollPane(resultsList);
|
||||
sp.setPreferredSize(new Dimension(300,300));
|
||||
cnt.add(sp,BorderLayout.CENTER);
|
||||
cnt.add(buttonsPanel,BorderLayout.SOUTH);
|
||||
sp.setPreferredSize(new Dimension(300, 300));
|
||||
cnt.add(sp, BorderLayout.CENTER);
|
||||
cnt.add(buttonsPanel, BorderLayout.SOUTH);
|
||||
pack();
|
||||
View.centerScreen(this);
|
||||
View.setWindowIcon(this);
|
||||
}
|
||||
|
||||
public void setResults(List<E> results){
|
||||
|
||||
public void setResults(List<E> results) {
|
||||
model.clear();
|
||||
for(E e:results){
|
||||
for (E e : results) {
|
||||
model.addElement(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,18 +106,18 @@ public class SearchResultsDialog<E> extends AppDialog implements ActionListener{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void gotoElement(){
|
||||
|
||||
private void gotoElement() {
|
||||
if (resultsList.getSelectedIndex() != -1) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
public void run() {
|
||||
listener.updateSearchPos(resultsList.getSelectedValue());
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,139 +1,139 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
import com.jpexs.decompiler.flash.treeitems.TreeItem;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TextPanel extends JPanel implements ActionListener {
|
||||
|
||||
private static final String ACTION_EDIT_TEXT = "EDITTEXT";
|
||||
private static final String ACTION_CANCEL_TEXT = "CANCELTEXT";
|
||||
private static final String ACTION_SAVE_TEXT = "SAVETEXT";
|
||||
|
||||
private final MainPanel mainPanel;
|
||||
private final SearchPanel<TextTag> textSearchPanel;
|
||||
private final LineMarkedEditorPane textValue;
|
||||
private final JButton textSaveButton;
|
||||
private final JButton textEditButton;
|
||||
private final JButton textCancelButton;
|
||||
|
||||
public TextPanel(MainPanel mainPanel) {
|
||||
super(new BorderLayout());
|
||||
|
||||
this.mainPanel = mainPanel;
|
||||
textSearchPanel = new SearchPanel<>(new FlowLayout(), mainPanel);
|
||||
add(textSearchPanel, BorderLayout.NORTH);
|
||||
textValue = new LineMarkedEditorPane();
|
||||
add(new JScrollPane(textValue), BorderLayout.CENTER);
|
||||
textValue.setEditable(false);
|
||||
|
||||
JPanel textButtonsPanel = new JPanel();
|
||||
textButtonsPanel.setLayout(new FlowLayout());
|
||||
|
||||
textSaveButton = new JButton(mainPanel.translate("button.save"), View.getIcon("save16"));
|
||||
textSaveButton.setMargin(new Insets(3, 3, 3, 10));
|
||||
textSaveButton.setActionCommand(ACTION_SAVE_TEXT);
|
||||
textSaveButton.addActionListener(this);
|
||||
|
||||
textEditButton = new JButton(mainPanel.translate("button.edit"), View.getIcon("edit16"));
|
||||
textEditButton.setMargin(new Insets(3, 3, 3, 10));
|
||||
textEditButton.setActionCommand(ACTION_EDIT_TEXT);
|
||||
textEditButton.addActionListener(this);
|
||||
|
||||
textCancelButton = new JButton(mainPanel.translate("button.cancel"), View.getIcon("cancel16"));
|
||||
textCancelButton.setMargin(new Insets(3, 3, 3, 10));
|
||||
textCancelButton.setActionCommand(ACTION_CANCEL_TEXT);
|
||||
textCancelButton.addActionListener(this);
|
||||
|
||||
textButtonsPanel.add(textEditButton);
|
||||
textButtonsPanel.add(textSaveButton);
|
||||
textButtonsPanel.add(textCancelButton);
|
||||
|
||||
textSaveButton.setVisible(false);
|
||||
textCancelButton.setVisible(false);
|
||||
|
||||
add(textButtonsPanel, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
public SearchPanel<TextTag> getSearchPanel() {
|
||||
return textSearchPanel;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
textValue.setContentType("text/swf_text");
|
||||
// textValue.setFont(new Font("Monospaced", Font.PLAIN, 13));
|
||||
textValue.setText(text);
|
||||
textValue.setCaretPosition(0);
|
||||
}
|
||||
|
||||
public void setEditText(boolean edit) {
|
||||
textValue.setEditable(edit);
|
||||
textSaveButton.setVisible(edit);
|
||||
textEditButton.setVisible(!edit);
|
||||
textCancelButton.setVisible(edit);
|
||||
}
|
||||
|
||||
public void updateSearchPos() {
|
||||
textValue.setCaretPosition(0);
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
textSearchPanel.showQuickFindDialog(textValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case ACTION_EDIT_TEXT:
|
||||
setEditText(true);
|
||||
break;
|
||||
case ACTION_CANCEL_TEXT:
|
||||
setEditText(false);
|
||||
mainPanel.reload(true);
|
||||
break;
|
||||
case ACTION_SAVE_TEXT:
|
||||
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
|
||||
if (item instanceof TextTag) {
|
||||
TextTag textTag = (TextTag) item;
|
||||
if (mainPanel.saveText(textTag, textValue.getText(), null)) {
|
||||
setEditText(false);
|
||||
mainPanel.reload(true);
|
||||
}
|
||||
SWF.clearImageCache();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.gui.abc.LineMarkedEditorPane;
|
||||
import com.jpexs.decompiler.flash.tags.base.TextTag;
|
||||
import com.jpexs.decompiler.flash.treeitems.TreeItem;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Insets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class TextPanel extends JPanel implements ActionListener {
|
||||
|
||||
private static final String ACTION_EDIT_TEXT = "EDITTEXT";
|
||||
private static final String ACTION_CANCEL_TEXT = "CANCELTEXT";
|
||||
private static final String ACTION_SAVE_TEXT = "SAVETEXT";
|
||||
|
||||
private final MainPanel mainPanel;
|
||||
private final SearchPanel<TextTag> textSearchPanel;
|
||||
private final LineMarkedEditorPane textValue;
|
||||
private final JButton textSaveButton;
|
||||
private final JButton textEditButton;
|
||||
private final JButton textCancelButton;
|
||||
|
||||
public TextPanel(MainPanel mainPanel) {
|
||||
super(new BorderLayout());
|
||||
|
||||
this.mainPanel = mainPanel;
|
||||
textSearchPanel = new SearchPanel<>(new FlowLayout(), mainPanel);
|
||||
add(textSearchPanel, BorderLayout.NORTH);
|
||||
textValue = new LineMarkedEditorPane();
|
||||
add(new JScrollPane(textValue), BorderLayout.CENTER);
|
||||
textValue.setEditable(false);
|
||||
|
||||
JPanel textButtonsPanel = new JPanel();
|
||||
textButtonsPanel.setLayout(new FlowLayout());
|
||||
|
||||
textSaveButton = new JButton(mainPanel.translate("button.save"), View.getIcon("save16"));
|
||||
textSaveButton.setMargin(new Insets(3, 3, 3, 10));
|
||||
textSaveButton.setActionCommand(ACTION_SAVE_TEXT);
|
||||
textSaveButton.addActionListener(this);
|
||||
|
||||
textEditButton = new JButton(mainPanel.translate("button.edit"), View.getIcon("edit16"));
|
||||
textEditButton.setMargin(new Insets(3, 3, 3, 10));
|
||||
textEditButton.setActionCommand(ACTION_EDIT_TEXT);
|
||||
textEditButton.addActionListener(this);
|
||||
|
||||
textCancelButton = new JButton(mainPanel.translate("button.cancel"), View.getIcon("cancel16"));
|
||||
textCancelButton.setMargin(new Insets(3, 3, 3, 10));
|
||||
textCancelButton.setActionCommand(ACTION_CANCEL_TEXT);
|
||||
textCancelButton.addActionListener(this);
|
||||
|
||||
textButtonsPanel.add(textEditButton);
|
||||
textButtonsPanel.add(textSaveButton);
|
||||
textButtonsPanel.add(textCancelButton);
|
||||
|
||||
textSaveButton.setVisible(false);
|
||||
textCancelButton.setVisible(false);
|
||||
|
||||
add(textButtonsPanel, BorderLayout.SOUTH);
|
||||
}
|
||||
|
||||
public SearchPanel<TextTag> getSearchPanel() {
|
||||
return textSearchPanel;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
textValue.setContentType("text/swf_text");
|
||||
// textValue.setFont(new Font("Monospaced", Font.PLAIN, 13));
|
||||
textValue.setText(text);
|
||||
textValue.setCaretPosition(0);
|
||||
}
|
||||
|
||||
public void setEditText(boolean edit) {
|
||||
textValue.setEditable(edit);
|
||||
textSaveButton.setVisible(edit);
|
||||
textEditButton.setVisible(!edit);
|
||||
textCancelButton.setVisible(edit);
|
||||
}
|
||||
|
||||
public void updateSearchPos() {
|
||||
textValue.setCaretPosition(0);
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
textSearchPanel.showQuickFindDialog(textValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
switch (e.getActionCommand()) {
|
||||
case ACTION_EDIT_TEXT:
|
||||
setEditText(true);
|
||||
break;
|
||||
case ACTION_CANCEL_TEXT:
|
||||
setEditText(false);
|
||||
mainPanel.reload(true);
|
||||
break;
|
||||
case ACTION_SAVE_TEXT:
|
||||
TreeItem item = mainPanel.tagTree.getCurrentTreeItem();
|
||||
if (item instanceof TextTag) {
|
||||
TextTag textTag = (TextTag) item;
|
||||
if (mainPanel.saveText(textTag, textValue.getText(), null)) {
|
||||
setEditText(false);
|
||||
mainPanel.reload(true);
|
||||
}
|
||||
SWF.clearImageCache();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,18 +504,18 @@ public class View {
|
||||
tree.collapsePath(parent);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addEditorAction(JEditorPane editor,AbstractAction a,String key, String name, String keyStroke){
|
||||
|
||||
public static void addEditorAction(JEditorPane editor, AbstractAction a, String key, String name, String keyStroke) {
|
||||
KeyStroke ks = KeyStroke.getKeyStroke(keyStroke);
|
||||
a.putValue(Action.ACCELERATOR_KEY, ks);
|
||||
a.putValue(Action.NAME, name);
|
||||
|
||||
|
||||
String actionName = key;
|
||||
ActionMap amap = editor.getActionMap();
|
||||
InputMap imap = editor.getInputMap(JTextComponent.WHEN_FOCUSED);
|
||||
imap.put(ks, actionName);
|
||||
amap.put(actionName, a);
|
||||
|
||||
|
||||
JPopupMenu pmenu = editor.getComponentPopupMenu();
|
||||
JMenuItem findUsagesMenu = new JMenuItem(a);
|
||||
pmenu.add(findUsagesMenu);
|
||||
|
||||
@@ -136,7 +136,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
public DetailPanel detailPanel;
|
||||
public JPanel navPanel;
|
||||
public JTabbedPane tabbedPane;
|
||||
public SearchPanel<ABCPanelSearchResult> searchPanel;
|
||||
public SearchPanel<ABCPanelSearchResult> searchPanel;
|
||||
private NewTraitDialog newTraitDialog;
|
||||
public JLabel scriptNameLabel;
|
||||
|
||||
@@ -155,9 +155,6 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean search(final String txt, boolean ignoreCase, boolean regexp) {
|
||||
if ((txt != null) && (!txt.isEmpty())) {
|
||||
searchPanel.setOptions(ignoreCase, regexp);
|
||||
@@ -207,23 +204,21 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
|
||||
System.gc();
|
||||
Main.stopWork();
|
||||
|
||||
|
||||
searchPanel.setSearchText(txt);
|
||||
|
||||
|
||||
View.execInEventDispatch(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SearchResultsDialog<ABCPanelSearchResult> sr=new SearchResultsDialog<>(ABCPanel.this.mainPanel.getMainFrame().getWindow(),txt,ABCPanel.this);
|
||||
SearchResultsDialog<ABCPanelSearchResult> sr = new SearchResultsDialog<>(ABCPanel.this.mainPanel.getMainFrame().getWindow(), txt, ABCPanel.this);
|
||||
sr.setResults(found);
|
||||
sr.setVisible(true);
|
||||
sr.setVisible(true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
//return searchPanel.setResults(found);
|
||||
}
|
||||
return false;
|
||||
@@ -410,7 +405,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
iconDecPanel.add(scriptNameLabel);
|
||||
iconDecPanel.add(iconsPanel);
|
||||
iconDecPanel.add(decompiledScrollPane);
|
||||
|
||||
|
||||
JPanel decButtonsPan = new JPanel(new FlowLayout());
|
||||
decButtonsPan.setBorder(new BevelBorder(BevelBorder.RAISED));
|
||||
decButtonsPan.add(editDecompiledButton);
|
||||
@@ -459,32 +454,30 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
});
|
||||
decompiledTextArea.setContentType("text/actionscript");
|
||||
decompiledTextArea.setFont(new Font("Monospaced", Font.PLAIN, decompiledTextArea.getFont().getSize()));
|
||||
|
||||
|
||||
|
||||
|
||||
View.addEditorAction(decompiledTextArea, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
int multinameIndex = decompiledTextArea.getMultinameUnderCursor();
|
||||
if(multinameIndex>-1){
|
||||
UsageFrame usageFrame = new UsageFrame(swf.abcList, abc, multinameIndex, ABCPanel.this,false);
|
||||
int multinameIndex = decompiledTextArea.getMultinameUnderCursor();
|
||||
if (multinameIndex > -1) {
|
||||
UsageFrame usageFrame = new UsageFrame(swf.abcList, abc, multinameIndex, ABCPanel.this, false);
|
||||
usageFrame.setVisible(true);
|
||||
}
|
||||
}
|
||||
}, "find-usages", AppStrings.translate("abc.action.find-usages"), "control U");
|
||||
|
||||
|
||||
View.addEditorAction(decompiledTextArea, new AbstractAction() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
gotoDeclaration();
|
||||
gotoDeclaration();
|
||||
}
|
||||
}, "find-declaration", AppStrings.translate("abc.action.find-declaration"), "control B");
|
||||
|
||||
}, "find-declaration", AppStrings.translate("abc.action.find-declaration"), "control B");
|
||||
|
||||
CtrlClickHandler cch = new CtrlClickHandler();
|
||||
decompiledTextArea.addKeyListener(cch);
|
||||
decompiledTextArea.addMouseListener(cch);
|
||||
decompiledTextArea.addMouseMotionListener(cch);
|
||||
|
||||
|
||||
JPanel pan2 = new JPanel();
|
||||
pan2.setLayout(new BorderLayout());
|
||||
pan2.add((abcComboBox = new JComboBox<>(new ABCComboBoxModel(new ArrayList<ABCContainerTag>()))), BorderLayout.NORTH);
|
||||
@@ -508,7 +501,7 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
});
|
||||
|
||||
Main.startWork(AppStrings.translate("work.buildingscripttree") + "...");
|
||||
|
||||
|
||||
tabbedPane = new JTabbedPane();
|
||||
tabbedPane.addTab(AppStrings.translate("traits"), navPanel);
|
||||
abcComboBox.addItemListener(this);
|
||||
@@ -548,45 +541,44 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
panConstants.add(new JScrollPane(constantTable), BorderLayout.CENTER);
|
||||
tabbedPane.addTab(AppStrings.translate("constants"), panConstants);
|
||||
}
|
||||
|
||||
private void gotoDeclaration(){
|
||||
|
||||
private void gotoDeclaration() {
|
||||
int multinameIndex = decompiledTextArea.getMultinameUnderCursor();
|
||||
if(multinameIndex>-1){
|
||||
List<MultinameUsage> usages = abc.findMultinameDefinition(swf.abcList,multinameIndex);
|
||||
|
||||
if (multinameIndex > -1) {
|
||||
List<MultinameUsage> usages = abc.findMultinameDefinition(swf.abcList, multinameIndex);
|
||||
|
||||
Multiname m = abc.constants.constant_multiname.get(multinameIndex);
|
||||
//search other ABC tags if this is not private multiname
|
||||
if(m.namespace_index>0 && abc.constants.constant_namespace.get(m.namespace_index).kind != Namespace.KIND_PRIVATE)
|
||||
{
|
||||
for(ABCContainerTag at:swf.abcList){
|
||||
if (m.namespace_index > 0 && abc.constants.constant_namespace.get(m.namespace_index).kind != Namespace.KIND_PRIVATE) {
|
||||
for (ABCContainerTag at : swf.abcList) {
|
||||
ABC a = at.getABC();
|
||||
if(a == abc){
|
||||
if (a == abc) {
|
||||
continue;
|
||||
}
|
||||
int mid=a.constants.getMultinameId(m,false);
|
||||
if(mid>0){
|
||||
}
|
||||
int mid = a.constants.getMultinameId(m, false);
|
||||
if (mid > 0) {
|
||||
usages.addAll(a.findMultinameDefinition(swf.abcList, mid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//more than one? display list
|
||||
if(usages.size()>1){
|
||||
UsageFrame usageFrame = new UsageFrame(swf.abcList, abc, multinameIndex, ABCPanel.this,true);
|
||||
if (usages.size() > 1) {
|
||||
UsageFrame usageFrame = new UsageFrame(swf.abcList, abc, multinameIndex, ABCPanel.this, true);
|
||||
usageFrame.setVisible(true);
|
||||
}else if(!usages.isEmpty()){ //one
|
||||
} else if (!usages.isEmpty()) { //one
|
||||
UsageFrame.gotoUsage(ABCPanel.this, usages.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class CtrlClickHandler extends KeyAdapter implements MouseListener, MouseMotionListener {
|
||||
|
||||
private boolean ctrlDown = false;
|
||||
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if(e.getKeyCode() == 17 && !decompiledTextArea.isEditable()){
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getKeyCode() == 17 && !decompiledTextArea.isEditable()) {
|
||||
ctrlDown = true;
|
||||
decompiledTextArea.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
}
|
||||
@@ -594,24 +586,24 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
if(e.getKeyCode() == 17){
|
||||
if (e.getKeyCode() == 17) {
|
||||
ctrlDown = false;
|
||||
decompiledTextArea.setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if(ctrlDown && e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 1 && !decompiledTextArea.isEditable()){
|
||||
if (ctrlDown && e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 1 && !decompiledTextArea.isEditable()) {
|
||||
ctrlDown = false;
|
||||
decompiledTextArea.setCursor(Cursor.getDefaultCursor());
|
||||
gotoDeclaration();
|
||||
}
|
||||
gotoDeclaration();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -634,12 +626,12 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
if(ctrlDown && decompiledTextArea.isEditable()){
|
||||
if (ctrlDown && decompiledTextArea.isEditable()) {
|
||||
ctrlDown = false;
|
||||
decompiledTextArea.setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
@@ -713,11 +705,11 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
View.execInEventDispatchLater(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
public void run() {
|
||||
searchPanel.showQuickFindDialog(decompiledTextArea);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public String lastDecompiled = null;
|
||||
@@ -951,6 +943,5 @@ public class ABCPanel extends JPanel implements ItemListener, ActionListener, Se
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,37 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ClassPath;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ABCPanelSearchResult {
|
||||
|
||||
public ScriptPack scriptPack;
|
||||
public ClassPath classPath;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return classPath.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ClassPath;
|
||||
import com.jpexs.decompiler.flash.abc.ScriptPack;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ABCPanelSearchResult {
|
||||
|
||||
public ScriptPack scriptPack;
|
||||
public ClassPath classPath;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return classPath.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,348 +1,348 @@
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.UnknownInstructionCode;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2Graph;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.pcode.ASM3Parser;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.pcode.MissingSymbolHandler;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.gui.GraphDialog;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.event.CaretEvent;
|
||||
import javax.swing.event.CaretListener;
|
||||
|
||||
public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretListener {
|
||||
|
||||
public ABC abc;
|
||||
public int bodyIndex = -1;
|
||||
private List<Highlighting> disassembledHilights = new ArrayList<>();
|
||||
private List<Highlighting> specialHilights = new ArrayList<>();
|
||||
private final DecompiledEditorPane decompiledEditor;
|
||||
private boolean ignoreCarret = false;
|
||||
private String name;
|
||||
private HilightedText textWithHex;
|
||||
private HilightedText textNoHex;
|
||||
private HilightedText textHexOnly;
|
||||
private ScriptExportMode exportMode = ScriptExportMode.PCODE;
|
||||
private Trait trait;
|
||||
|
||||
public ABCPanel getAbcPanel(){
|
||||
return decompiledEditor.getAbcPanel();
|
||||
}
|
||||
|
||||
public ScriptExportMode getExportMode() {
|
||||
return exportMode;
|
||||
}
|
||||
|
||||
private HilightedText getHilightedText(ScriptExportMode exportMode) {
|
||||
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
|
||||
abc.bodies.get(bodyIndex).code.toASMSource(abc.constants, trait, abc.method_info.get(abc.bodies.get(bodyIndex).method_info), abc.bodies.get(bodyIndex), exportMode, writer);
|
||||
return new HilightedText(writer);
|
||||
}
|
||||
|
||||
public void setHex(ScriptExportMode exportMode, boolean force) {
|
||||
if (this.exportMode == exportMode & !force) {
|
||||
return;
|
||||
}
|
||||
this.exportMode = exportMode;
|
||||
long oldOffset = getSelectedOffset();
|
||||
if (exportMode == ScriptExportMode.PCODE) {
|
||||
setContentType("text/flasm");
|
||||
if (textNoHex == null) {
|
||||
textNoHex = getHilightedText(exportMode);
|
||||
}
|
||||
setText(textNoHex);
|
||||
} else if (exportMode == ScriptExportMode.PCODE_HEX) {
|
||||
setContentType("text/flasm");
|
||||
if (textWithHex == null) {
|
||||
textWithHex = getHilightedText(exportMode);
|
||||
}
|
||||
setText(textWithHex);
|
||||
} else {
|
||||
setContentType("text/plain");
|
||||
if (textHexOnly == null) {
|
||||
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
|
||||
Helper.byteArrayToHexWithHeader(writer, abc.bodies.get(bodyIndex).code.getBytes());
|
||||
textHexOnly = new HilightedText(writer);
|
||||
}
|
||||
setText(textHexOnly);
|
||||
}
|
||||
hilighOffset(oldOffset);
|
||||
}
|
||||
|
||||
public void setIgnoreCarret(boolean ignoreCarret) {
|
||||
this.ignoreCarret = ignoreCarret;
|
||||
}
|
||||
|
||||
public ASMSourceEditorPane(DecompiledEditorPane decompiledEditor) {
|
||||
this.decompiledEditor = decompiledEditor;
|
||||
addCaretListener(this);
|
||||
}
|
||||
|
||||
public void hilighSpecial(String type, int index) {
|
||||
Highlighting h2 = null;
|
||||
for (Highlighting sh : specialHilights) {
|
||||
if (type.equals(sh.getPropertyString("subtype"))) {
|
||||
if (sh.getPropertyString("index").equals("" + index)) {
|
||||
h2 = sh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (h2 != null) {
|
||||
ignoreCarret = true;
|
||||
if (h2.startPos <= getDocument().getLength()) {
|
||||
setCaretPosition(h2.startPos);
|
||||
}
|
||||
getCaret().setVisible(true);
|
||||
ignoreCarret = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void hilighOffset(long offset) {
|
||||
if (isEditable()) {
|
||||
return;
|
||||
}
|
||||
Highlighting h2 = Highlighting.search(disassembledHilights, "offset", "" + offset);
|
||||
if (h2 != null) {
|
||||
ignoreCarret = true;
|
||||
if (h2.startPos <= getDocument().getLength()) {
|
||||
setCaretPosition(h2.startPos);
|
||||
}
|
||||
getCaret().setVisible(true);
|
||||
ignoreCarret = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return super.getName();
|
||||
}
|
||||
|
||||
public void setBodyIndex(int bodyIndex, ABC abc, String name, Trait trait) {
|
||||
this.bodyIndex = bodyIndex;
|
||||
this.abc = abc;
|
||||
this.name = name;
|
||||
this.trait = trait;
|
||||
if (bodyIndex == -1) {
|
||||
return;
|
||||
}
|
||||
textWithHex = null;
|
||||
textNoHex = null;
|
||||
setHex(exportMode, true);
|
||||
}
|
||||
|
||||
public void graph() {
|
||||
try {
|
||||
AVM2Graph gr = new AVM2Graph(abc.bodies.get(bodyIndex).code, abc, abc.bodies.get(bodyIndex), false, -1, -1, new HashMap<Integer, GraphTargetItem>(), new Stack<GraphTargetItem>(), new HashMap<Integer, String>(), new ArrayList<String>(), new HashMap<Integer, Integer>(), abc.bodies.get(bodyIndex).code.visitCode(abc.bodies.get(bodyIndex)));
|
||||
(new GraphDialog(getAbcPanel().getMainPanel().getMainFrame().getWindow(),gr, name)).setVisible(true);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(ASMSourceEditorPane.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void exec() {
|
||||
HashMap<Integer, Object> args = new HashMap<>();
|
||||
args.put(0, new Object()); //object "this"
|
||||
args.put(1, new Long(466561)); //param1
|
||||
Object o = abc.bodies.get(bodyIndex).code.execute(args, abc.constants);
|
||||
View.showMessageDialog(this, "Returned object:" + o.toString());
|
||||
}
|
||||
|
||||
public boolean save(ConstantPool constants) {
|
||||
try {
|
||||
String text = getText();
|
||||
if (text.trim().startsWith("#hexdata")) {
|
||||
byte[] data = Helper.getBytesFromHexaText(text);
|
||||
MethodBody mb = abc.bodies.get(bodyIndex);
|
||||
mb.codeBytes = data;
|
||||
try {
|
||||
mb.code = new AVM2Code(new ByteArrayInputStream(mb.codeBytes));
|
||||
} catch (UnknownInstructionCode re) {
|
||||
mb.code = new AVM2Code();
|
||||
Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, null, re);
|
||||
}
|
||||
mb.code.compact();
|
||||
} else {
|
||||
AVM2Code acode = ASM3Parser.parse(new StringReader(text), constants, trait, new MissingSymbolHandler() {
|
||||
//no longer ask for adding new constants
|
||||
@Override
|
||||
public boolean missingString(String value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean missingInt(long value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean missingUInt(long value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean missingDouble(double value) {
|
||||
return true;
|
||||
}
|
||||
}, abc.bodies.get(bodyIndex), abc.method_info.get(abc.bodies.get(bodyIndex).method_info));
|
||||
acode.getBytes(abc.bodies.get(bodyIndex).codeBytes);
|
||||
abc.bodies.get(bodyIndex).code = acode;
|
||||
}
|
||||
((Tag) abc.parentTag).setModified(true);
|
||||
} catch (IOException ex) {
|
||||
} catch (InterruptedException ex) {
|
||||
} catch (ParseException ex) {
|
||||
View.showMessageDialog(this, (ex.text + " on line " + ex.line));
|
||||
selectLine((int) ex.line);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String t) {
|
||||
disassembledHilights = new ArrayList<>();
|
||||
specialHilights = new ArrayList<>();
|
||||
super.setText(t);
|
||||
setCaretPosition(0);
|
||||
}
|
||||
|
||||
public void setText(HilightedText hilightedText) {
|
||||
disassembledHilights = hilightedText.instructionHilights;
|
||||
specialHilights = hilightedText.specialHilights;
|
||||
super.setText(hilightedText.text);
|
||||
setCaretPosition(0);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
setText("");
|
||||
bodyIndex = -1;
|
||||
setCaretPosition(0);
|
||||
}
|
||||
|
||||
public void selectInstruction(int pos) {
|
||||
String text = getText();
|
||||
int lineCnt = 1;
|
||||
int lineStart = 0;
|
||||
int lineEnd;
|
||||
int instrCount = 0;
|
||||
int dot = -2;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (text.charAt(i) == '\n') {
|
||||
|
||||
lineCnt++;
|
||||
lineEnd = i;
|
||||
String ins = text.substring(lineStart, lineEnd).trim();
|
||||
if (!((i > 0) && (text.charAt(i - 1) == ':'))) {
|
||||
if (!ins.startsWith("exception ")) {
|
||||
instrCount++;
|
||||
}
|
||||
}
|
||||
if (instrCount == pos + 1) {
|
||||
break;
|
||||
}
|
||||
lineStart = i + 1;
|
||||
}
|
||||
}
|
||||
if (lineCnt == -1) {
|
||||
//lineEnd = text.length() - 1;
|
||||
}
|
||||
//select(lineStart, lineEnd);
|
||||
setCaretPosition(lineStart);
|
||||
//requestFocus();
|
||||
}
|
||||
|
||||
public void selectLine(int line) {
|
||||
String text = getText();
|
||||
int lineCnt = 1;
|
||||
int lineStart = 0;
|
||||
int lineEnd = -1;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (text.charAt(i) == '\n') {
|
||||
lineCnt++;
|
||||
if (lineCnt == line) {
|
||||
lineStart = i;
|
||||
}
|
||||
if (lineCnt == line + 1) {
|
||||
lineEnd = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lineCnt == -1) {
|
||||
lineEnd = text.length() - 1;
|
||||
}
|
||||
select(lineStart, lineEnd);
|
||||
requestFocus();
|
||||
}
|
||||
|
||||
public Highlighting getSelectedSpecial() {
|
||||
return Highlighting.search(specialHilights, getCaretPosition());
|
||||
}
|
||||
|
||||
public long getSelectedOffset() {
|
||||
int pos = getCaretPosition();
|
||||
Highlighting lastH = null;
|
||||
for (Highlighting h : disassembledHilights) {
|
||||
if (pos < h.startPos) {
|
||||
break;
|
||||
}
|
||||
lastH = h;
|
||||
}
|
||||
return lastH == null ? 0 : lastH.getPropertyLong("offset");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void caretUpdate(CaretEvent e) {
|
||||
if (isEditable()) {
|
||||
return;
|
||||
}
|
||||
if (ignoreCarret) {
|
||||
return;
|
||||
}
|
||||
getCaret().setVisible(true);
|
||||
|
||||
decompiledEditor.hilightOffset(getSelectedOffset());
|
||||
Highlighting spec = getSelectedSpecial();
|
||||
if (spec != null) {
|
||||
decompiledEditor.hilightSpecial(spec.getPropertyString("subtype"), (int) (long) spec.getPropertyLong("index"));
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2010-2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui.abc;
|
||||
|
||||
import com.jpexs.decompiler.flash.abc.ABC;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.AVM2Code;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.ConstantPool;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.UnknownInstructionCode;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.graph.AVM2Graph;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.ParseException;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.pcode.ASM3Parser;
|
||||
import com.jpexs.decompiler.flash.abc.avm2.parser.pcode.MissingSymbolHandler;
|
||||
import com.jpexs.decompiler.flash.abc.types.MethodBody;
|
||||
import com.jpexs.decompiler.flash.abc.types.traits.Trait;
|
||||
import com.jpexs.decompiler.flash.configuration.Configuration;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ScriptExportMode;
|
||||
import com.jpexs.decompiler.flash.gui.GraphDialog;
|
||||
import com.jpexs.decompiler.flash.gui.View;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedText;
|
||||
import com.jpexs.decompiler.flash.helpers.HilightedTextWriter;
|
||||
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.event.CaretEvent;
|
||||
import javax.swing.event.CaretListener;
|
||||
|
||||
public class ASMSourceEditorPane extends LineMarkedEditorPane implements CaretListener {
|
||||
|
||||
public ABC abc;
|
||||
public int bodyIndex = -1;
|
||||
private List<Highlighting> disassembledHilights = new ArrayList<>();
|
||||
private List<Highlighting> specialHilights = new ArrayList<>();
|
||||
private final DecompiledEditorPane decompiledEditor;
|
||||
private boolean ignoreCarret = false;
|
||||
private String name;
|
||||
private HilightedText textWithHex;
|
||||
private HilightedText textNoHex;
|
||||
private HilightedText textHexOnly;
|
||||
private ScriptExportMode exportMode = ScriptExportMode.PCODE;
|
||||
private Trait trait;
|
||||
|
||||
public ABCPanel getAbcPanel() {
|
||||
return decompiledEditor.getAbcPanel();
|
||||
}
|
||||
|
||||
public ScriptExportMode getExportMode() {
|
||||
return exportMode;
|
||||
}
|
||||
|
||||
private HilightedText getHilightedText(ScriptExportMode exportMode) {
|
||||
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
|
||||
abc.bodies.get(bodyIndex).code.toASMSource(abc.constants, trait, abc.method_info.get(abc.bodies.get(bodyIndex).method_info), abc.bodies.get(bodyIndex), exportMode, writer);
|
||||
return new HilightedText(writer);
|
||||
}
|
||||
|
||||
public void setHex(ScriptExportMode exportMode, boolean force) {
|
||||
if (this.exportMode == exportMode & !force) {
|
||||
return;
|
||||
}
|
||||
this.exportMode = exportMode;
|
||||
long oldOffset = getSelectedOffset();
|
||||
if (exportMode == ScriptExportMode.PCODE) {
|
||||
setContentType("text/flasm");
|
||||
if (textNoHex == null) {
|
||||
textNoHex = getHilightedText(exportMode);
|
||||
}
|
||||
setText(textNoHex);
|
||||
} else if (exportMode == ScriptExportMode.PCODE_HEX) {
|
||||
setContentType("text/flasm");
|
||||
if (textWithHex == null) {
|
||||
textWithHex = getHilightedText(exportMode);
|
||||
}
|
||||
setText(textWithHex);
|
||||
} else {
|
||||
setContentType("text/plain");
|
||||
if (textHexOnly == null) {
|
||||
HilightedTextWriter writer = new HilightedTextWriter(Configuration.getCodeFormatting(), true);
|
||||
Helper.byteArrayToHexWithHeader(writer, abc.bodies.get(bodyIndex).code.getBytes());
|
||||
textHexOnly = new HilightedText(writer);
|
||||
}
|
||||
setText(textHexOnly);
|
||||
}
|
||||
hilighOffset(oldOffset);
|
||||
}
|
||||
|
||||
public void setIgnoreCarret(boolean ignoreCarret) {
|
||||
this.ignoreCarret = ignoreCarret;
|
||||
}
|
||||
|
||||
public ASMSourceEditorPane(DecompiledEditorPane decompiledEditor) {
|
||||
this.decompiledEditor = decompiledEditor;
|
||||
addCaretListener(this);
|
||||
}
|
||||
|
||||
public void hilighSpecial(String type, int index) {
|
||||
Highlighting h2 = null;
|
||||
for (Highlighting sh : specialHilights) {
|
||||
if (type.equals(sh.getPropertyString("subtype"))) {
|
||||
if (sh.getPropertyString("index").equals("" + index)) {
|
||||
h2 = sh;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (h2 != null) {
|
||||
ignoreCarret = true;
|
||||
if (h2.startPos <= getDocument().getLength()) {
|
||||
setCaretPosition(h2.startPos);
|
||||
}
|
||||
getCaret().setVisible(true);
|
||||
ignoreCarret = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void hilighOffset(long offset) {
|
||||
if (isEditable()) {
|
||||
return;
|
||||
}
|
||||
Highlighting h2 = Highlighting.search(disassembledHilights, "offset", "" + offset);
|
||||
if (h2 != null) {
|
||||
ignoreCarret = true;
|
||||
if (h2.startPos <= getDocument().getLength()) {
|
||||
setCaretPosition(h2.startPos);
|
||||
}
|
||||
getCaret().setVisible(true);
|
||||
ignoreCarret = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return super.getName();
|
||||
}
|
||||
|
||||
public void setBodyIndex(int bodyIndex, ABC abc, String name, Trait trait) {
|
||||
this.bodyIndex = bodyIndex;
|
||||
this.abc = abc;
|
||||
this.name = name;
|
||||
this.trait = trait;
|
||||
if (bodyIndex == -1) {
|
||||
return;
|
||||
}
|
||||
textWithHex = null;
|
||||
textNoHex = null;
|
||||
setHex(exportMode, true);
|
||||
}
|
||||
|
||||
public void graph() {
|
||||
try {
|
||||
AVM2Graph gr = new AVM2Graph(abc.bodies.get(bodyIndex).code, abc, abc.bodies.get(bodyIndex), false, -1, -1, new HashMap<Integer, GraphTargetItem>(), new Stack<GraphTargetItem>(), new HashMap<Integer, String>(), new ArrayList<String>(), new HashMap<Integer, Integer>(), abc.bodies.get(bodyIndex).code.visitCode(abc.bodies.get(bodyIndex)));
|
||||
(new GraphDialog(getAbcPanel().getMainPanel().getMainFrame().getWindow(), gr, name)).setVisible(true);
|
||||
} catch (InterruptedException ex) {
|
||||
Logger.getLogger(ASMSourceEditorPane.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void exec() {
|
||||
HashMap<Integer, Object> args = new HashMap<>();
|
||||
args.put(0, new Object()); //object "this"
|
||||
args.put(1, new Long(466561)); //param1
|
||||
Object o = abc.bodies.get(bodyIndex).code.execute(args, abc.constants);
|
||||
View.showMessageDialog(this, "Returned object:" + o.toString());
|
||||
}
|
||||
|
||||
public boolean save(ConstantPool constants) {
|
||||
try {
|
||||
String text = getText();
|
||||
if (text.trim().startsWith("#hexdata")) {
|
||||
byte[] data = Helper.getBytesFromHexaText(text);
|
||||
MethodBody mb = abc.bodies.get(bodyIndex);
|
||||
mb.codeBytes = data;
|
||||
try {
|
||||
mb.code = new AVM2Code(new ByteArrayInputStream(mb.codeBytes));
|
||||
} catch (UnknownInstructionCode re) {
|
||||
mb.code = new AVM2Code();
|
||||
Logger.getLogger(ABC.class.getName()).log(Level.SEVERE, null, re);
|
||||
}
|
||||
mb.code.compact();
|
||||
} else {
|
||||
AVM2Code acode = ASM3Parser.parse(new StringReader(text), constants, trait, new MissingSymbolHandler() {
|
||||
//no longer ask for adding new constants
|
||||
@Override
|
||||
public boolean missingString(String value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean missingInt(long value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean missingUInt(long value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean missingDouble(double value) {
|
||||
return true;
|
||||
}
|
||||
}, abc.bodies.get(bodyIndex), abc.method_info.get(abc.bodies.get(bodyIndex).method_info));
|
||||
acode.getBytes(abc.bodies.get(bodyIndex).codeBytes);
|
||||
abc.bodies.get(bodyIndex).code = acode;
|
||||
}
|
||||
((Tag) abc.parentTag).setModified(true);
|
||||
} catch (IOException ex) {
|
||||
} catch (InterruptedException ex) {
|
||||
} catch (ParseException ex) {
|
||||
View.showMessageDialog(this, (ex.text + " on line " + ex.line));
|
||||
selectLine((int) ex.line);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String t) {
|
||||
disassembledHilights = new ArrayList<>();
|
||||
specialHilights = new ArrayList<>();
|
||||
super.setText(t);
|
||||
setCaretPosition(0);
|
||||
}
|
||||
|
||||
public void setText(HilightedText hilightedText) {
|
||||
disassembledHilights = hilightedText.instructionHilights;
|
||||
specialHilights = hilightedText.specialHilights;
|
||||
super.setText(hilightedText.text);
|
||||
setCaretPosition(0);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
setText("");
|
||||
bodyIndex = -1;
|
||||
setCaretPosition(0);
|
||||
}
|
||||
|
||||
public void selectInstruction(int pos) {
|
||||
String text = getText();
|
||||
int lineCnt = 1;
|
||||
int lineStart = 0;
|
||||
int lineEnd;
|
||||
int instrCount = 0;
|
||||
int dot = -2;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (text.charAt(i) == '\n') {
|
||||
|
||||
lineCnt++;
|
||||
lineEnd = i;
|
||||
String ins = text.substring(lineStart, lineEnd).trim();
|
||||
if (!((i > 0) && (text.charAt(i - 1) == ':'))) {
|
||||
if (!ins.startsWith("exception ")) {
|
||||
instrCount++;
|
||||
}
|
||||
}
|
||||
if (instrCount == pos + 1) {
|
||||
break;
|
||||
}
|
||||
lineStart = i + 1;
|
||||
}
|
||||
}
|
||||
if (lineCnt == -1) {
|
||||
//lineEnd = text.length() - 1;
|
||||
}
|
||||
//select(lineStart, lineEnd);
|
||||
setCaretPosition(lineStart);
|
||||
//requestFocus();
|
||||
}
|
||||
|
||||
public void selectLine(int line) {
|
||||
String text = getText();
|
||||
int lineCnt = 1;
|
||||
int lineStart = 0;
|
||||
int lineEnd = -1;
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
if (text.charAt(i) == '\n') {
|
||||
lineCnt++;
|
||||
if (lineCnt == line) {
|
||||
lineStart = i;
|
||||
}
|
||||
if (lineCnt == line + 1) {
|
||||
lineEnd = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lineCnt == -1) {
|
||||
lineEnd = text.length() - 1;
|
||||
}
|
||||
select(lineStart, lineEnd);
|
||||
requestFocus();
|
||||
}
|
||||
|
||||
public Highlighting getSelectedSpecial() {
|
||||
return Highlighting.search(specialHilights, getCaretPosition());
|
||||
}
|
||||
|
||||
public long getSelectedOffset() {
|
||||
int pos = getCaretPosition();
|
||||
Highlighting lastH = null;
|
||||
for (Highlighting h : disassembledHilights) {
|
||||
if (pos < h.startPos) {
|
||||
break;
|
||||
}
|
||||
lastH = h;
|
||||
}
|
||||
return lastH == null ? 0 : lastH.getPropertyLong("offset");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void caretUpdate(CaretEvent e) {
|
||||
if (isEditable()) {
|
||||
return;
|
||||
}
|
||||
if (ignoreCarret) {
|
||||
return;
|
||||
}
|
||||
getCaret().setVisible(true);
|
||||
|
||||
decompiledEditor.hilightOffset(getSelectedOffset());
|
||||
Highlighting spec = getSelectedSpecial();
|
||||
if (spec != null) {
|
||||
decompiledEditor.hilightSpecial(spec.getPropertyString("subtype"), (int) (long) spec.getPropertyLong("index"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,29 +61,27 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
private boolean isStatic = false;
|
||||
private final Cache<CachedDecompilation> cache = Cache.getInstance(true);
|
||||
private Trait currentTrait = null;
|
||||
|
||||
|
||||
private final List<Runnable> scriptListeners = new ArrayList<Runnable>();
|
||||
|
||||
public void addScriptListener(Runnable l){
|
||||
|
||||
public void addScriptListener(Runnable l) {
|
||||
scriptListeners.add(l);
|
||||
}
|
||||
|
||||
public ABCPanel getAbcPanel() {
|
||||
return abcPanel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void removeScriptListener(Runnable l){
|
||||
|
||||
public void removeScriptListener(Runnable l) {
|
||||
scriptListeners.remove(l);
|
||||
}
|
||||
|
||||
public void fireScript(){
|
||||
for(int i=0;i<scriptListeners.size();i++){
|
||||
public void fireScript() {
|
||||
for (int i = 0; i < scriptListeners.size(); i++) {
|
||||
scriptListeners.get(i).run();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Trait getCurrentTrait() {
|
||||
return currentTrait;
|
||||
}
|
||||
@@ -96,7 +94,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
return isStatic;
|
||||
}
|
||||
|
||||
public void setNoTrait() {
|
||||
public void setNoTrait() {
|
||||
abcPanel.detailPanel.showCard(DetailPanel.UNSUPPORTED_TRAIT_CARD, null);
|
||||
}
|
||||
|
||||
@@ -450,7 +448,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
setEditable(false);
|
||||
getCaret().setVisible(true);
|
||||
addCaretListener(this);
|
||||
this.abcPanel = abcPanel;
|
||||
this.abcPanel = abcPanel;
|
||||
}
|
||||
private List<ABCContainerTag> abcList;
|
||||
|
||||
@@ -537,7 +535,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String t) {
|
||||
public void setText(String t) {
|
||||
super.setText(t);
|
||||
setCaretPosition(0);
|
||||
}
|
||||
|
||||
@@ -58,18 +58,17 @@ public class UsageFrame extends AppDialog implements ActionListener, MouseListen
|
||||
public UsageFrame(List<ABCContainerTag> abcTags, ABC abc, int multinameIndex, ABCPanel abcPanel, boolean definitions) {
|
||||
super(abcPanel.getMainPanel().getMainFrame().getWindow());
|
||||
this.abcPanel = abcPanel;
|
||||
List<MultinameUsage> usages = definitions?abc.findMultinameDefinition(abcTags,multinameIndex):abc.findMultinameUsage(abcTags,multinameIndex);
|
||||
List<MultinameUsage> usages = definitions ? abc.findMultinameDefinition(abcTags, multinameIndex) : abc.findMultinameUsage(abcTags, multinameIndex);
|
||||
Multiname m = abc.constants.constant_multiname.get(multinameIndex);
|
||||
if(m.namespace_index>0 && abc.constants.constant_namespace.get(m.namespace_index).kind != Namespace.KIND_PRIVATE)
|
||||
{
|
||||
for(ABCContainerTag at:abcTags){
|
||||
if (m.namespace_index > 0 && abc.constants.constant_namespace.get(m.namespace_index).kind != Namespace.KIND_PRIVATE) {
|
||||
for (ABCContainerTag at : abcTags) {
|
||||
ABC a = at.getABC();
|
||||
if(a == abc){
|
||||
if (a == abc) {
|
||||
continue;
|
||||
}
|
||||
int mid=a.constants.getMultinameId(m,false);
|
||||
if(mid>0){
|
||||
usages.addAll(definitions?a.findMultinameDefinition(abcTags, mid):a.findMultinameUsage(abcTags, mid));
|
||||
}
|
||||
int mid = a.constants.getMultinameId(m, false);
|
||||
if (mid > 0) {
|
||||
usages.addAll(definitions ? a.findMultinameDefinition(abcTags, mid) : a.findMultinameUsage(abcTags, mid));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,57 +93,56 @@ public class UsageFrame extends AppDialog implements ActionListener, MouseListen
|
||||
cont.add(new JScrollPane(usageList), BorderLayout.CENTER);
|
||||
cont.add(buttonsPanel, BorderLayout.SOUTH);
|
||||
setSize(400, 300);
|
||||
setTitle((definitions?translate("dialog.title.declaration"):translate("dialog.title")) + abc.constants.getMultiname(multinameIndex).getNameWithNamespace(abc.constants));
|
||||
setTitle((definitions ? translate("dialog.title.declaration") : translate("dialog.title")) + abc.constants.getMultiname(multinameIndex).getNameWithNamespace(abc.constants));
|
||||
View.centerScreen(this);
|
||||
View.setWindowIcon(this);
|
||||
}
|
||||
|
||||
public static void gotoUsage(final ABCPanel abcPanel,final MultinameUsage usage){
|
||||
public static void gotoUsage(final ABCPanel abcPanel, final MultinameUsage usage) {
|
||||
if (usage instanceof InsideClassMultinameUsage) {
|
||||
final InsideClassMultinameUsage icu = (InsideClassMultinameUsage) usage;
|
||||
|
||||
Runnable settrait = new Runnable() {
|
||||
final InsideClassMultinameUsage icu = (InsideClassMultinameUsage) usage;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
abcPanel.decompiledTextArea.removeScriptListener(this);
|
||||
abcPanel.decompiledTextArea.setClassIndex(icu.classIndex);
|
||||
if (usage instanceof TraitMultinameUsage) {
|
||||
TraitMultinameUsage tmu = (TraitMultinameUsage) usage;
|
||||
int traitIndex;
|
||||
if (tmu.parentTraitIndex > -1) {
|
||||
traitIndex = tmu.parentTraitIndex;
|
||||
} else {
|
||||
traitIndex = tmu.traitIndex;
|
||||
}
|
||||
if (!tmu.isStatic) {
|
||||
traitIndex += abcPanel.abc.class_info.get(tmu.classIndex).static_traits.traits.size();
|
||||
}
|
||||
if (tmu instanceof MethodMultinameUsage) {
|
||||
MethodMultinameUsage mmu = (MethodMultinameUsage) usage;
|
||||
if (mmu.isInitializer == true) {
|
||||
traitIndex = abcPanel.abc.class_info.get(mmu.classIndex).static_traits.traits.size() + abcPanel.abc.instance_info.get(mmu.classIndex).instance_traits.traits.size() + (mmu.isStatic ? 1 : 0);
|
||||
}
|
||||
}
|
||||
abcPanel.decompiledTextArea.gotoTrait(traitIndex);
|
||||
Runnable settrait = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
abcPanel.decompiledTextArea.removeScriptListener(this);
|
||||
abcPanel.decompiledTextArea.setClassIndex(icu.classIndex);
|
||||
if (usage instanceof TraitMultinameUsage) {
|
||||
TraitMultinameUsage tmu = (TraitMultinameUsage) usage;
|
||||
int traitIndex;
|
||||
if (tmu.parentTraitIndex > -1) {
|
||||
traitIndex = tmu.parentTraitIndex;
|
||||
} else {
|
||||
traitIndex = tmu.traitIndex;
|
||||
}
|
||||
if (!tmu.isStatic) {
|
||||
traitIndex += abcPanel.abc.class_info.get(tmu.classIndex).static_traits.traits.size();
|
||||
}
|
||||
if (tmu instanceof MethodMultinameUsage) {
|
||||
MethodMultinameUsage mmu = (MethodMultinameUsage) usage;
|
||||
if (mmu.isInitializer == true) {
|
||||
traitIndex = abcPanel.abc.class_info.get(mmu.classIndex).static_traits.traits.size() + abcPanel.abc.instance_info.get(mmu.classIndex).instance_traits.traits.size() + (mmu.isStatic ? 1 : 0);
|
||||
}
|
||||
}
|
||||
abcPanel.decompiledTextArea.gotoTrait(traitIndex);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if(abcPanel.decompiledTextArea.getClassIndex() == icu.classIndex && abcPanel.abc == icu.abc){
|
||||
settrait.run();
|
||||
}else{
|
||||
abcPanel.decompiledTextArea.addScriptListener(settrait);
|
||||
abcPanel.hilightScript(abcPanel.swf, abcPanel.abc.instance_info.get(icu.classIndex).getName(abcPanel.abc.constants).getNameWithNamespace(abcPanel.abc.constants));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (abcPanel.decompiledTextArea.getClassIndex() == icu.classIndex && abcPanel.abc == icu.abc) {
|
||||
settrait.run();
|
||||
} else {
|
||||
abcPanel.decompiledTextArea.addScriptListener(settrait);
|
||||
abcPanel.hilightScript(abcPanel.swf, abcPanel.abc.instance_info.get(icu.classIndex).getName(abcPanel.abc.constants).getNameWithNamespace(abcPanel.abc.constants));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void gotoUsage() {
|
||||
if (usageList.getSelectedIndex() != -1) {
|
||||
MultinameUsage usage = usageListModel.getUsage(usageList.getSelectedIndex());
|
||||
gotoUsage(abcPanel,usage);
|
||||
gotoUsage(abcPanel, usage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,41 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.jpexs.decompiler.flash.gui.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ActionSearchResult {
|
||||
public ASMSource src;
|
||||
public String path;
|
||||
|
||||
public ActionSearchResult(ASMSource src, String path) {
|
||||
this.src = src;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2014 JPEXS
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.gui.action;
|
||||
|
||||
import com.jpexs.decompiler.flash.tags.base.ASMSource;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JPEXS
|
||||
*/
|
||||
public class ActionSearchResult {
|
||||
|
||||
public ASMSource src;
|
||||
public String path;
|
||||
|
||||
public ActionSearchResult(ASMSource src, String path) {
|
||||
this.src = src;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user