From 1fb58e6dd8a082f50818c102aa263395050922af Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Tue, 3 Feb 2015 18:59:05 +0100 Subject: [PATCH] raw edit fix --- .../decompiler/flash/tags/DefineFont2Tag.java | 1 + .../decompiler/flash/tags/DefineFont3Tag.java | 4 ++ .../com/jpexs/helpers/ReflectionTools.java | 9 +++++ .../flash/gui/GenericTagTreePanel.java | 17 +++++++- .../decompiler/flash/gui/LoadingDialog.java | 16 ++++---- src/com/jpexs/decompiler/flash/gui/Main.java | 39 ++++++------------- .../jpexs/decompiler/flash/gui/MainPanel.java | 6 +-- 7 files changed, 52 insertions(+), 40 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java index 045dfa577..4a253659c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont2Tag.java @@ -91,6 +91,7 @@ public class DefineFont2Tag extends FontTag { @Conditional("fontFlagsHasLayout") public List fontBoundsTable; + @Conditional("fontFlagsHasLayout") public List fontKerningTable; public static final int ID = 48; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java index 470d94271..e837dad0c 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineFont3Tag.java @@ -83,10 +83,14 @@ public class DefineFont3Tag extends FontTag { @Conditional("fontFlagsHasLayout") public int fontLeading; + @SWFType(BasicType.SI16) + @Conditional("fontFlagsHasLayout") public List fontAdvanceTable; + @Conditional("fontFlagsHasLayout") public List fontBoundsTable; + @Conditional("fontFlagsHasLayout") public List fontKerningTable; public static final int ID = 75; diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/ReflectionTools.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/ReflectionTools.java index 9a59526d3..044038c9d 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/ReflectionTools.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/ReflectionTools.java @@ -33,6 +33,11 @@ import java.util.logging.Logger; */ public class ReflectionTools { + public static Object getValue(Object obj, Field field) throws IllegalArgumentException, IllegalAccessException { + Object value = field.get(obj); + return value; + } + public static Object getValue(Object obj, Field field, int index) throws IllegalArgumentException, IllegalAccessException { if (getFieldSubSize(obj, field) <= index) { return null; @@ -74,6 +79,10 @@ public class ReflectionTools { return 0; } + public static void setValue(Object obj, Field field, Object newValue) throws IllegalArgumentException, IllegalAccessException { + field.set(obj, newValue); + } + @SuppressWarnings("unchecked") public static void setValue(Object obj, Field field, int index, Object newValue) throws IllegalArgumentException, IllegalAccessException { Object value = field.get(obj); diff --git a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index e698178c1..c498bcc8f 100644 --- a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -47,6 +47,7 @@ import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.IOException; +import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; @@ -346,7 +347,7 @@ public class GenericTagTreePanel extends GenericTagPanel { } - private static class FieldNode extends DefaultMutableTreeNode { + private static final class FieldNode extends DefaultMutableTreeNode { private Object obj; @@ -358,6 +359,18 @@ public class GenericTagTreePanel extends GenericTagPanel { this.obj = obj; this.field = field; this.index = index; + + if (getValue() == null) { + try { + if (List.class.isAssignableFrom(field.getType())) { + ReflectionTools.setValue(obj, field, new ArrayList<>()); + } else if (field.getType().isArray()) { + ReflectionTools.setValue(obj, field, Array.newInstance(field.getType().getComponentType(), 0)); + } + } catch (IllegalArgumentException | IllegalAccessException ex) { + Logger.getLogger(GenericTagTreePanel.class.getName()).log(Level.SEVERE, null, ex); + } + } } @Override @@ -424,7 +437,7 @@ public class GenericTagTreePanel extends GenericTagPanel { public Object getValue() { try { if (ReflectionTools.needsIndex(field) && (index == -1)) { - return obj; + return ReflectionTools.getValue(obj, field); } Object val = ReflectionTools.getValue(obj, field, index); if (val == null) { diff --git a/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java b/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java index c1ca40af2..73b086586 100644 --- a/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java +++ b/src/com/jpexs/decompiler/flash/gui/LoadingDialog.java @@ -49,18 +49,18 @@ public class LoadingDialog extends AppDialog implements ImageObserver { View.execInEventDispatch(new Runnable() { @Override public void run() { - progressBar.setIndeterminate(false); - progressBar.setValue(percent); - progressBar.setStringPainted(true); + if (percent == -1) { + progressBar.setIndeterminate(true); + progressBar.setStringPainted(false); + } else { + progressBar.setIndeterminate(false); + progressBar.setValue(percent); + progressBar.setStringPainted(true); + } } }); } - public void hidePercent() { - progressBar.setIndeterminate(true); - progressBar.setStringPainted(false); - } - /** * Constructor * diff --git a/src/com/jpexs/decompiler/flash/gui/Main.java b/src/com/jpexs/decompiler/flash/gui/Main.java index e5706b837..b3aa0e9ec 100644 --- a/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/src/com/jpexs/decompiler/flash/gui/Main.java @@ -111,7 +111,7 @@ public class Main { private static List sourceInfos = new ArrayList<>(); - private static LoadingDialog loadingDialog; + public static LoadingDialog loadingDialog; public static ModeFrame modeFrame; @@ -188,23 +188,6 @@ public class Main { } } - protected static LoadingDialog getLoadingDialog() { - if (loadingDialog == null) { - synchronized (Main.class) { - if (loadingDialog == null) { - View.execInEventDispatch(new Runnable() { - @Override - public void run() { - loadingDialog = new LoadingDialog(); - } - }); - } - } - } - - return loadingDialog; - } - public static MainFrame getMainFrame() { return mainFrame; } @@ -283,12 +266,8 @@ public class Main { } } if (loadingDialog != null) { - getLoadingDialog().setDetail(name); - if (percent == -1) { - getLoadingDialog().hidePercent(); - } else { - getLoadingDialog().setPercent(percent); - } + loadingDialog.setDetail(name); + loadingDialog.setPercent(percent); } if (CommandLineArgumentParser.isCommandLineMode()) { System.out.println(name); @@ -307,7 +286,7 @@ public class Main { mainFrame.getPanel().setWorkStatus("", null); } if (loadingDialog != null) { - getLoadingDialog().setDetail(""); + loadingDialog.setDetail(""); } } }); @@ -495,7 +474,7 @@ public class Main { } } - getLoadingDialog().setVisible(false); + loadingDialog.setVisible(false); shouldCloseWhenClosingLoadingDialog = false; final SWF fswf = firstSWF; @@ -597,7 +576,7 @@ public class Main { Helper.freeMem(); } - getLoadingDialog().setVisible(true); + loadingDialog.setVisible(true); OpenFileWorker wrk = new OpenFileWorker(newSourceInfos); wrk.execute(); sourceInfos.addAll(Arrays.asList(newSourceInfos)); @@ -823,6 +802,12 @@ public class Main { } autoCheckForUpdates(); offerAssociation(); + View.execInEventDispatch(new Runnable() { + @Override + public void run() { + loadingDialog = new LoadingDialog(); + } + }); } public static void showModeFrame() { diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 19dc89d64..f9ea387ad 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2310,7 +2310,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec public void loadFromBinaryTag(final List binaryDataTags) { - Main.getLoadingDialog().setVisible(true); + Main.loadingDialog.setVisible(true); Main.startWork(AppStrings.translate("work.reading.swf") + "..."); new Thread() { @@ -2324,7 +2324,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec @Override public void progress(int p) { - Main.getLoadingDialog().setPercent(p); + Main.loadingDialog.setPercent(p); } }, Configuration.parallelSpeedUp.get()); binaryDataTag.innerSwf = bswf; @@ -2337,7 +2337,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec //ignore } - Main.getLoadingDialog().setVisible(false); + Main.loadingDialog.setVisible(false); Main.stopWork(); }