mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-26 20:26:05 +00:00
tag tree context menu deselected the selected nodes earlier. Now it preserves the selection, and applies the command for all selected nodes => removing multiple items.
This commit is contained in:
@@ -86,7 +86,7 @@ public class ActionListReader {
|
||||
|
||||
SWFInputStream sis = new SWFInputStream(rri, version);
|
||||
|
||||
// List of the actions. Item 0 contains the first (entry) action
|
||||
// List of the actions. N. item contains the action which starts in offset N.
|
||||
List<Action> actionMap = new ArrayList<>();
|
||||
List<Long> nextOffsets = new ArrayList<>();
|
||||
Action entryAction = readActionListAtPos(listeners, containerSWFOffset, cpool,
|
||||
@@ -248,7 +248,7 @@ public class ActionListReader {
|
||||
Map<Long, Action> map = new HashMap<>(actions.size());
|
||||
for (Action a : actions) {
|
||||
long address = a.getAddress();
|
||||
// There are multiple action in the same address (2nd action is a jump for deobfuscated code)
|
||||
// There are multiple actions in the same address (2nd action is a jump for obfuscated code)
|
||||
// So this check is required
|
||||
if (!map.containsKey(address)) {
|
||||
map.put(a.getAddress(), a);
|
||||
@@ -319,7 +319,6 @@ public class ActionListReader {
|
||||
Action a = actions.get(i);
|
||||
a.setAddress(address, version);
|
||||
int length = a.getBytes(version).length;
|
||||
//a.actionLength = length - 1 - ((a.actionCode >= 0x80) ? 2 : 0);
|
||||
if ((i != actions.size() - 1) && (a instanceof ActionEnd)) {
|
||||
// placeholder for jump action
|
||||
length = getTotalActionLength(new ActionJump(0));
|
||||
|
||||
@@ -960,16 +960,29 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
|
||||
if (SwingUtilities.isRightMouseButton(e)) {
|
||||
|
||||
int row = tagTree.getClosestRowForLocation(e.getX(), e.getY());
|
||||
tagTree.setSelectionRow(row);
|
||||
Object tagObj = tagTree.getLastSelectedPathComponent();
|
||||
if (tagObj == null) {
|
||||
int[] selectionRows = tagTree.getSelectionRows();
|
||||
if (!Helper.contains(selectionRows, row)) {
|
||||
tagTree.setSelectionRow(row);
|
||||
}
|
||||
|
||||
TreePath[] paths = tagTree.getSelectionPaths();
|
||||
if (paths == null || paths.length == 0) {
|
||||
return;
|
||||
}
|
||||
boolean allSelectedIsTag = true;
|
||||
for (TreePath treePath : paths) {
|
||||
Object tagObj = treePath.getLastPathComponent();
|
||||
|
||||
if (tagObj instanceof TagNode) {
|
||||
tagObj = ((TagNode) tagObj).tag;
|
||||
if (tagObj instanceof TagNode) {
|
||||
Object tag = ((TagNode) tagObj).tag;
|
||||
if (!(tag instanceof Tag)) {
|
||||
allSelectedIsTag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
removeMenuItem.setVisible(tagObj instanceof Tag);
|
||||
|
||||
removeMenuItem.setVisible(allSelectedIsTag);
|
||||
contextPopupMenu.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
}
|
||||
@@ -1923,6 +1936,21 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
|
||||
}
|
||||
}
|
||||
|
||||
public List<Object> getSelected(JTree tree) {
|
||||
TreeSelectionModel tsm = tree.getSelectionModel();
|
||||
TreePath tps[] = tsm.getSelectionPaths();
|
||||
List<Object> ret = new ArrayList<>();
|
||||
if (tps == null) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (TreePath tp : tps) {
|
||||
Object o = tp.getLastPathComponent();
|
||||
ret.add(o);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<Object> getAllSubs(JTree tree, Object o) {
|
||||
TreeModel tm = tree.getModel();
|
||||
List<Object> ret = new ArrayList<>();
|
||||
@@ -2424,17 +2452,31 @@ public class MainFrame extends AppRibbonFrame implements ActionListener, TreeSel
|
||||
}
|
||||
break;
|
||||
case "REMOVEITEM":
|
||||
tagObj = tagTree.getLastSelectedPathComponent();
|
||||
if (tagObj == null) {
|
||||
return;
|
||||
}
|
||||
List<Object> sel = getSelected(tagTree);
|
||||
|
||||
if (tagObj instanceof TagNode) {
|
||||
tagObj = ((TagNode) tagObj).tag;
|
||||
List<Tag> tagsToRemove = new ArrayList<>();
|
||||
for (Object o : sel) {
|
||||
Object tag = o;
|
||||
if (o instanceof TagNode) {
|
||||
tag = ((TagNode) o).tag;
|
||||
}
|
||||
if (tag instanceof Tag) {
|
||||
tagsToRemove.add((Tag) tag);
|
||||
}
|
||||
}
|
||||
if (tagObj instanceof Tag) {
|
||||
if (View.showConfirmDialog(this, translate("message.confirm.remove").replace("%item%", tagObj.toString()), translate("message.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
|
||||
swf.removeTag((Tag) tagObj);
|
||||
|
||||
if (tagsToRemove.size() == 1) {
|
||||
Tag tag = tagsToRemove.get(0);
|
||||
if (View.showConfirmDialog(this, translate("message.confirm.remove").replace("%item%", tag.toString()), translate("message.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
|
||||
swf.removeTag(tag);
|
||||
showCard(CARDEMPTYPANEL);
|
||||
refreshTree();
|
||||
}
|
||||
} else if (tagsToRemove.size() > 1) {
|
||||
if (View.showConfirmDialog(this, translate("message.confirm.removemultiple").replace("%count%", Integer.toString(tagsToRemove.size())), translate("message.confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
|
||||
for (Tag tag : tagsToRemove) {
|
||||
swf.removeTag(tag);
|
||||
}
|
||||
showCard(CARDEMPTYPANEL);
|
||||
refreshTree();
|
||||
}
|
||||
|
||||
@@ -350,4 +350,6 @@ ColorChooser.sampleText=Sample Text Sample Text
|
||||
#after version 1.7.1:
|
||||
preview.play = Play
|
||||
preview.pause = Pause
|
||||
preview.stop = Stop
|
||||
preview.stop = Stop
|
||||
|
||||
message.confirm.removemultiple = Are you sure you want to remove %count% items\n and all objects which depend on it?
|
||||
|
||||
@@ -350,4 +350,11 @@ ColorChooser.resetText = Alaphelyzet
|
||||
ColorChooser.previewText = El\u0151n\u00e9zet
|
||||
ColorChooser.swatchesNameText = Mint\u00e1k
|
||||
ColorChooser.swatchesRecentText = El\u0151zm\u00e9nyek:
|
||||
ColorChooser.sampleText=Minta Sz\u00f6veg Minta Sz\u00f6veg
|
||||
ColorChooser.sampleText=Minta Sz\u00f6veg Minta Sz\u00f6veg
|
||||
|
||||
#after version 1.7.1:
|
||||
preview.play = Lej\u00e1tsz\u00e1s
|
||||
preview.pause = Sz\u00fcnet
|
||||
preview.stop = Meg\u00e1ll\u00edt\u00e1s
|
||||
|
||||
message.confirm.removemultiple = Biztos benne, hogy t\u00f6r\u00f6lni k\u00edv\u00e1nja a %count% elemet\n \u00e9s az \u00f6sszes t\u0151le f\u00fcgg\u0151 objektumot ?
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.jpexs.helpers;
|
||||
|
||||
import com.jpexs.decompiler.flash.gui.Freed;
|
||||
import com.jpexs.decompiler.flash.helpers.Highlighting;
|
||||
import com.jpexs.decompiler.graph.GraphTargetItem;
|
||||
import java.awt.Component;
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -552,4 +551,13 @@ public class Helper {
|
||||
THREAD_POOL.execute(task);
|
||||
return task.get(timeout, timeUnit);
|
||||
}
|
||||
|
||||
public static boolean contains(int[] array, int value) {
|
||||
for (int i : array) {
|
||||
if (i == value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,11 +78,21 @@ public class ExportTest {
|
||||
}
|
||||
|
||||
@Test(dataProvider = "swfFiles")
|
||||
public void testDecompile(File f) {
|
||||
public void testDecompileAS(File f) {
|
||||
testDecompile(f, false);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "swfFiles")
|
||||
public void testDecompilePcode(File f) {
|
||||
testDecompile(f, true);
|
||||
}
|
||||
|
||||
public void testDecompile(File f, boolean isPcode) {
|
||||
try {
|
||||
SWF swf = new SWF(new FileInputStream(f), false);
|
||||
Configuration.DEBUG_COPY = true;
|
||||
File fdir = new File(TESTDATADIR + File.separator + "output" + File.separator + f.getName());
|
||||
String folderName = isPcode ? "outputp" : "output";
|
||||
File fdir = new File(TESTDATADIR + File.separator + folderName + File.separator + f.getName());
|
||||
fdir.mkdirs();
|
||||
|
||||
swf.exportActionScript(new AbortRetryIgnoreHandler() {
|
||||
@@ -96,7 +106,7 @@ public class ExportTest {
|
||||
return this;
|
||||
}
|
||||
|
||||
}, fdir.getAbsolutePath(), false, false);
|
||||
}, fdir.getAbsolutePath(), isPcode, false);
|
||||
} catch (Exception ex) {
|
||||
fail();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user