Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixes #20: Add a way to dump individual Flash elements
- Loading branch information
Showing
5 changed files
with
174 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
java/src/tv/porst/swfretools/dissector/gui/main/flashtree/actions/DumpElementAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package tv.porst.swfretools.dissector.gui.main.flashtree.actions; | ||
|
||
import java.awt.Window; | ||
import java.awt.event.ActionEvent; | ||
|
||
import javax.swing.AbstractAction; | ||
|
||
import tv.porst.splib.binaryparser.IFileElement; | ||
import tv.porst.swfretools.dissector.gui.main.flashtree.implementations.FlashTreeImplementations; | ||
import tv.porst.swfretools.dissector.gui.main.models.LoadedFile; | ||
|
||
/** | ||
* Action that is used to dump SWF elements to a file. | ||
*/ | ||
public final class DumpElementAction extends AbstractAction { | ||
|
||
/** | ||
* Parent window used for dialogs. | ||
*/ | ||
private final Window parent; | ||
|
||
/** | ||
* The loaded file whose decompressed data is dumped to disk. | ||
*/ | ||
private final LoadedFile loadedFile; | ||
|
||
/** | ||
* The element to dump to a file. | ||
*/ | ||
private final IFileElement element; | ||
|
||
/** | ||
* Creates a new action object. | ||
* | ||
* @param parent Parent window used for dialogs. | ||
* @param loadedFile The loaded file whose decompressed data is dumped to disk. | ||
* @param element The element to dump to a file. | ||
*/ | ||
public DumpElementAction(final Window parent, final LoadedFile loadedFile, final IFileElement element) { | ||
super("Dump to file"); | ||
|
||
if (parent == null) { | ||
throw new IllegalArgumentException("Parent argument must not be null."); | ||
} | ||
|
||
if (loadedFile == null) { | ||
throw new IllegalArgumentException("Loaded file argument must not be null."); | ||
} | ||
|
||
if (element == null) { | ||
throw new IllegalArgumentException("Element argument must not be null."); | ||
} | ||
|
||
this.parent = parent; | ||
this.loadedFile = loadedFile; | ||
this.element = element; | ||
} | ||
|
||
@Override | ||
public void actionPerformed(final ActionEvent event) { | ||
FlashTreeImplementations.dumpElement(parent, loadedFile, element); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
java/src/tv/porst/swfretools/dissector/gui/main/flashtree/menus/FlashAnyNodeMenu.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package tv.porst.swfretools.dissector.gui.main.flashtree.menus; | ||
|
||
import java.awt.Window; | ||
|
||
import javax.swing.JMenuItem; | ||
import javax.swing.JPopupMenu; | ||
|
||
import tv.porst.swfretools.dissector.gui.main.flashtree.actions.DumpElementAction; | ||
import tv.porst.swfretools.dissector.gui.main.flashtree.nodes.FlashTreeNode; | ||
import tv.porst.swfretools.dissector.gui.main.models.LoadedFile; | ||
|
||
/** | ||
* Popup menu that is shown when the user right-clicks on a node that does not | ||
* have a more specific menu. | ||
*/ | ||
public final class FlashAnyNodeMenu extends JPopupMenu { | ||
|
||
/** | ||
* Creates a new menu object. | ||
* | ||
* @param parent Parent window used for dialogs. | ||
* @param loadedFile The loaded file. | ||
* @param node The clicked node. | ||
*/ | ||
public FlashAnyNodeMenu(final Window parent, final LoadedFile loadedFile, final FlashTreeNode<?> node) { | ||
|
||
if (parent == null) { | ||
throw new IllegalArgumentException("Parent argument must not be null."); | ||
} | ||
|
||
if (loadedFile == null) { | ||
throw new IllegalArgumentException("Loaded file argument must not be null."); | ||
} | ||
|
||
if (node == null) { | ||
throw new IllegalArgumentException("Node argument must not be null."); | ||
} | ||
|
||
add(new JMenuItem(new DumpElementAction(parent, loadedFile, node.getUserObject()))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters