diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java index eccdbad62..7649ff95b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFInputStream.java @@ -119,6 +119,7 @@ import com.jpexs.decompiler.flash.action.swf7.ActionImplementsOp; import com.jpexs.decompiler.flash.action.swf7.ActionThrow; import com.jpexs.decompiler.flash.action.swf7.ActionTry; import com.jpexs.decompiler.flash.amf.amf3.Amf3InputStream; +import com.jpexs.decompiler.flash.amf.amf3.Amf3Value; import com.jpexs.decompiler.flash.amf.amf3.NoSerializerExistsException; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.dumpview.DumpInfo; @@ -767,13 +768,13 @@ public class SWFInputStream implements AutoCloseable { * @return * @throws IOException */ - public Object readAmf3Object(String name) throws IOException { + public Amf3Value readAmf3Object(String name) throws IOException { Amf3InputStream ai = new Amf3InputStream(is); ai.dumpInfo = this.dumpInfo; try { - return ai.readValue("amfData"); + return new Amf3Value(ai.readValue("amfData")); } catch (NoSerializerExistsException nse) { - return nse.getIncompleteData(); + return new Amf3Value(nse.getIncompleteData()); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java index 41296c298..9ad13c603 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/SWFOutputStream.java @@ -17,6 +17,7 @@ package com.jpexs.decompiler.flash; import com.jpexs.decompiler.flash.amf.amf3.Amf3OutputStream; +import com.jpexs.decompiler.flash.amf.amf3.Amf3Value; import com.jpexs.decompiler.flash.amf.amf3.NoSerializerExistsException; import com.jpexs.decompiler.flash.amf.amf3.ObjectTypeSerializeHandler; import com.jpexs.decompiler.flash.configuration.Configuration; @@ -1962,9 +1963,9 @@ public class SWFOutputStream extends OutputStream { * @throws IOException * @throws NoSerializerExistsException */ - public void writeAmf3Object(Object value, Map serializers) throws IOException, NoSerializerExistsException { + public void writeAmf3Object(Amf3Value value, Map serializers) throws IOException, NoSerializerExistsException { Amf3OutputStream ao = new Amf3OutputStream(os); - ao.writeValue(value, serializers); + ao.writeValue(value.getValue(), serializers); } /** @@ -1975,7 +1976,7 @@ public class SWFOutputStream extends OutputStream { * @throws IOException * @throws NoSerializerExistsException */ - public void writeAmf3Object(Object value) throws IOException, NoSerializerExistsException { + public void writeAmf3Object(Amf3Value value) throws IOException, NoSerializerExistsException { writeAmf3Object(value, new HashMap<>()); } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/Amf3Value.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/Amf3Value.java new file mode 100644 index 000000000..45d4a7b04 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/Amf3Value.java @@ -0,0 +1,48 @@ +package com.jpexs.decompiler.flash.amf.amf3; + +import com.jpexs.decompiler.flash.amf.amf3.types.Amf3ValueType; +import com.jpexs.decompiler.flash.exporters.amf.amf3.Amf3Exporter; + +public class Amf3Value { + + private Object value; + + public Amf3Value(Object value) { + setValue(value); + } + + public void setValue(Object value) { + if (!isValueValid(value)) { + throw new IllegalArgumentException("Invalid Amf value: " + value.getClass().getSimpleName()); + } + this.value = value; + } + + public static boolean isValueValid(Object value) { + if (value instanceof Long) { + return true; + } + if (value instanceof Double) { + return true; + } + if (value instanceof String) { + return true; + } + if (value instanceof Boolean) { + return true; + } + if (value instanceof Amf3ValueType) { + return true; + } + return false; + } + + public Object getValue() { + return value; + } + + @Override + public String toString() { + return Amf3Exporter.amfToString(value); + } +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/AbstractVectorType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/AbstractVectorType.java index 8e87f4009..9449e7049 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/AbstractVectorType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/AbstractVectorType.java @@ -5,7 +5,7 @@ import java.util.ArrayList; import java.util.List; import com.jpexs.decompiler.flash.amf.amf3.WithSubValues; -public abstract class AbstractVectorType implements WithSubValues { +public abstract class AbstractVectorType implements WithSubValues, Amf3ValueType { private boolean fixed; private List values; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/Amf3ValueType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/Amf3ValueType.java new file mode 100644 index 000000000..9cbd90d01 --- /dev/null +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/Amf3ValueType.java @@ -0,0 +1,5 @@ +package com.jpexs.decompiler.flash.amf.amf3.types; + +public interface Amf3ValueType { + +} diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/ArrayType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/ArrayType.java index 411d90003..637219def 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/ArrayType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/ArrayType.java @@ -7,7 +7,7 @@ import java.util.ArrayList; import java.util.List; import com.jpexs.decompiler.flash.amf.amf3.WithSubValues; -public class ArrayType implements WithSubValues { +public class ArrayType implements WithSubValues, Amf3ValueType { private List denseValues; private List> associativeValues; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/BasicType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/BasicType.java index 1d5752451..6fc6866c9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/BasicType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/BasicType.java @@ -1,6 +1,6 @@ package com.jpexs.decompiler.flash.amf.amf3.types; -public enum BasicType { +public enum BasicType implements Amf3ValueType { NULL { @Override public String toString() { diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/DateType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/DateType.java index 50e73f215..e481a3cc9 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/DateType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/DateType.java @@ -3,7 +3,7 @@ package com.jpexs.decompiler.flash.amf.amf3.types; import com.jpexs.decompiler.flash.exporters.amf.amf3.Amf3Exporter; import java.util.Date; -public class DateType { +public class DateType implements Amf3ValueType { private double val; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/DictionaryType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/DictionaryType.java index bcae93132..5acd6a9dd 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/DictionaryType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/DictionaryType.java @@ -6,7 +6,7 @@ import java.util.ArrayList; import java.util.List; import com.jpexs.decompiler.flash.amf.amf3.WithSubValues; -public class DictionaryType implements WithSubValues { +public class DictionaryType implements WithSubValues, Amf3ValueType { private boolean weakKeys; private List> pairs; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/ObjectType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/ObjectType.java index 4333a0f9c..98cf21353 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/ObjectType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/ObjectType.java @@ -8,7 +8,7 @@ import java.util.ArrayList; import java.util.List; import com.jpexs.decompiler.flash.amf.amf3.WithSubValues; -public class ObjectType implements WithSubValues { +public class ObjectType implements WithSubValues, Amf3ValueType { private List> sealedMembers; private List> dynamicMembers; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/XmlDocType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/XmlDocType.java index 37207bccf..20fddf116 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/XmlDocType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/XmlDocType.java @@ -1,6 +1,6 @@ package com.jpexs.decompiler.flash.amf.amf3.types; -public class XmlDocType { +public class XmlDocType implements Amf3ValueType { private String data; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/XmlType.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/XmlType.java index bd0e77027..43beffc45 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/XmlType.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/amf/amf3/types/XmlType.java @@ -1,6 +1,6 @@ package com.jpexs.decompiler.flash.amf.amf3.types; -public class XmlType { +public class XmlType implements Amf3ValueType { private String data; diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java index f078ef36b..5aed2b36b 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/PlaceObject4Tag.java @@ -20,6 +20,7 @@ import com.jpexs.decompiler.flash.EndOfStreamException; import com.jpexs.decompiler.flash.SWF; import com.jpexs.decompiler.flash.SWFInputStream; import com.jpexs.decompiler.flash.SWFOutputStream; +import com.jpexs.decompiler.flash.amf.amf3.Amf3Value; import com.jpexs.decompiler.flash.amf.amf3.NoSerializerExistsException; import com.jpexs.decompiler.flash.tags.base.ASMSourceContainer; import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag; @@ -234,8 +235,7 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont @Reserved public boolean reserved; - //public byte[] amfData; //TODO: Parse AMF data? - public Object amfData; + public Amf3Value amfData; /** * Constructor @@ -246,7 +246,7 @@ public class PlaceObject4Tag extends PlaceObjectTypeTag implements ASMSourceCont super(swf, ID, NAME, null); } - public PlaceObject4Tag(SWF swf, boolean placeFlagMove, int depth, String className, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, List surfaceFilterList, int blendMode, int bitmapCache, int visible, RGBA backgroundColor, CLIPACTIONS clipActions, Object amfData) { + public PlaceObject4Tag(SWF swf, boolean placeFlagMove, int depth, String className, int characterId, MATRIX matrix, CXFORMWITHALPHA colorTransform, int ratio, String name, int clipDepth, List surfaceFilterList, int blendMode, int bitmapCache, int visible, RGBA backgroundColor, CLIPACTIONS clipActions, Amf3Value amfData) { super(swf, ID, NAME, null); this.placeFlagHasClassName = className != null; this.placeFlagHasFilterList = surfaceFilterList != null; diff --git a/src/com/jpexs/decompiler/flash/gui/GenericTagPanel.java b/src/com/jpexs/decompiler/flash/gui/GenericTagPanel.java index 67e2522f0..efa2c213a 100644 --- a/src/com/jpexs/decompiler/flash/gui/GenericTagPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/GenericTagPanel.java @@ -17,12 +17,15 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.amf.amf3.Amf3Value; +import com.jpexs.decompiler.flash.gui.generictageditors.Amf3ValueEditor; import com.jpexs.decompiler.flash.gui.generictageditors.BinaryDataEditor; import com.jpexs.decompiler.flash.gui.generictageditors.BooleanEditor; import com.jpexs.decompiler.flash.gui.generictageditors.ChangeListener; import com.jpexs.decompiler.flash.gui.generictageditors.ColorEditor; import com.jpexs.decompiler.flash.gui.generictageditors.GenericTagEditor; import com.jpexs.decompiler.flash.gui.generictageditors.NumberEditor; +import com.jpexs.decompiler.flash.gui.generictageditors.ScrollPanedEditor; import com.jpexs.decompiler.flash.gui.generictageditors.StringEditor; import com.jpexs.decompiler.flash.gui.helpers.SpringUtilities; import com.jpexs.decompiler.flash.tags.Tag; @@ -409,6 +412,8 @@ public class GenericTagPanel extends JPanel implements ChangeListener { editor = new ColorEditor(name, obj, field, index, type); } else if (type.equals(ByteArrayRange.class)) { editor = new BinaryDataEditor(mainPanel, name, obj, field, index, type); + } else if (type.equals(Amf3Value.class)) { + editor = new ScrollPanedEditor(new Amf3ValueEditor(name, obj, field, index, type)); } else { if (value == null) { if (readonly) { @@ -436,6 +441,8 @@ public class GenericTagPanel extends JPanel implements ChangeListener { fieldPaths.put(name, parList); fieldIndices.put(name, parIndices); addRow(name, editor, field); + + ce.added(); } return 1; } diff --git a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index 6f27fc481..96eb27d64 100644 --- a/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -17,11 +17,14 @@ package com.jpexs.decompiler.flash.gui; import com.jpexs.decompiler.flash.SWF; +import com.jpexs.decompiler.flash.amf.amf3.Amf3Value; +import com.jpexs.decompiler.flash.gui.generictageditors.Amf3ValueEditor; import com.jpexs.decompiler.flash.gui.generictageditors.BinaryDataEditor; import com.jpexs.decompiler.flash.gui.generictageditors.BooleanEditor; import com.jpexs.decompiler.flash.gui.generictageditors.ColorEditor; import com.jpexs.decompiler.flash.gui.generictageditors.GenericTagEditor; import com.jpexs.decompiler.flash.gui.generictageditors.NumberEditor; +import com.jpexs.decompiler.flash.gui.generictageditors.ScrollPanedEditor; import com.jpexs.decompiler.flash.gui.generictageditors.StringEditor; import com.jpexs.decompiler.flash.tags.Tag; import com.jpexs.decompiler.flash.tags.base.ASMSource; @@ -166,6 +169,8 @@ public class GenericTagTreePanel extends GenericTagPanel { editor = new ColorEditor(field.getName(), obj, field, index, type); } else if (type.equals(byte[].class) || type.equals(ByteArrayRange.class)) { editor = new BinaryDataEditor(mainPanel, field.getName(), obj, field, index, type); + } else if (type.equals(Amf3Value.class)) { + editor = new ScrollPanedEditor(new Amf3ValueEditor(field.getName(), obj, field, index, type)); } if (editor != null) { if (editors == null) { @@ -199,6 +204,9 @@ public class GenericTagTreePanel extends GenericTagPanel { nameLabel.setSize(nameLabel.getWidth(), editorComponent.getHeight()); editorComponent.setAlignmentY(TOP_ALIGNMENT); pan.add(editorComponent); + if (editorComponent instanceof GenericTagEditor) { + ((GenericTagEditor) editorComponent).added(); + } pan.setPreferredSize(new Dimension((int) nameLabel.getPreferredSize().getWidth() + 5 + (int) editorComponent.getPreferredSize().getWidth(), (int) editorComponent.getPreferredSize().getHeight())); } else { pan.setPreferredSize(new Dimension((int) nameLabel.getPreferredSize().getWidth(), (int) nameLabel.getPreferredSize().getHeight())); @@ -946,6 +954,8 @@ public class GenericTagTreePanel extends GenericTagPanel { return true; } else if (isByteArray || type.equals(ByteArrayRange.class)) { return true; + } else if (type.equals(Amf3Value.class)) { + return true; } else { return false; } diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java new file mode 100644 index 000000000..373dca6c2 --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/Amf3ValueEditor.java @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2016 Jindra + * + * 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 . + */ +package com.jpexs.decompiler.flash.gui.generictageditors; + +import com.jpexs.decompiler.flash.amf.amf3.Amf3Value; +import com.jpexs.decompiler.flash.exporters.amf.amf3.Amf3Exporter; +import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3Importer; +import com.jpexs.decompiler.flash.importers.amf.amf3.Amf3ParseException; +import com.jpexs.helpers.Helper; +import com.jpexs.helpers.ReflectionTools; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.io.IOException; +import java.lang.reflect.Field; +import javax.swing.JEditorPane; + +/** + * + * @author JPEXS + */ +public class Amf3ValueEditor extends JEditorPane implements GenericTagEditor { + + private final Object obj; + + private final Field field; + + private final int index; + + private final Class type; + + private String fieldName; + + @Override + public void added() { + String s = getText(); + setContentType("text/javascript"); + setText(s); + } + + @Override + public boolean getScrollableTracksViewportWidth() { + return true; + } + + /* @Override + public Dimension getPreferredSize() { + Dimension ret = super.getPreferredSize(); + ret.width = 300; + return ret; + }*/ + @Override + public Component.BaselineResizeBehavior getBaselineResizeBehavior() { + return Component.BaselineResizeBehavior.CONSTANT_ASCENT; + } + + @Override + public int getBaseline(int width, int height) { + return 0; + } + + public Amf3ValueEditor(String fieldName, Object obj, Field field, int index, Class type) { + this.obj = obj; + this.field = field; + this.index = index; + this.type = type; + this.fieldName = fieldName; + try { + Amf3Value val = (Amf3Value) ReflectionTools.getValue(obj, field, index); + String stringVal = Amf3Exporter.amfToString(val.getValue()); + setText(stringVal); + } catch (IllegalArgumentException | IllegalAccessException ex) { + // ignore + } + } + + @Override + public void save() { + Amf3Importer importer = new Amf3Importer(); + try { + Object newValue = importer.stringToAmf(getText()); + ReflectionTools.setValue(obj, field, index, new Amf3Value(newValue)); + } catch (IOException | Amf3ParseException | IllegalArgumentException | IllegalAccessException ex) { + //ignore + } + } + + @Override + public void addChangeListener(final ChangeListener l) { + final GenericTagEditor t = this; + addFocusListener(new FocusAdapter() { + + @Override + public void focusLost(FocusEvent e) { + l.change(t); + } + + }); + } + + @Override + public Object getChangedValue() { + Amf3Importer importer = new Amf3Importer(); + try { + return new Amf3Value(importer.stringToAmf(getText())); + } catch (IOException | Amf3ParseException ex) { + //ignore + } + return null; + } + + @Override + public String getFieldName() { + return fieldName; + } + + @Override + public Field getField() { + return field; + } + + @Override + public String getReadOnlyValue() { + return Helper.escapeHTML(getChangedValue().toString()); + } + +} diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/BinaryDataEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/BinaryDataEditor.java index 030072b80..57f999c53 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/BinaryDataEditor.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/BinaryDataEditor.java @@ -139,4 +139,9 @@ public class BinaryDataEditor extends JButton implements GenericTagEditor { public int getBaseline(int width, int height) { return 0; } + + @Override + public void added() { + + } } diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/BooleanEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/BooleanEditor.java index 5f907548b..5474f3a2a 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/BooleanEditor.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/BooleanEditor.java @@ -38,6 +38,11 @@ public class BooleanEditor extends JCheckBox implements GenericTagEditor { private final String fieldName; + @Override + public void added() { + + } + public BooleanEditor(String fieldName, Object obj, Field field, int index, Class type) { super(); this.obj = obj; diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/ColorEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/ColorEditor.java index e01bc321e..8ac7fa53e 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/ColorEditor.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/ColorEditor.java @@ -75,6 +75,11 @@ public class ColorEditor extends JPanel implements GenericTagEditor, ActionListe return colorType; } + @Override + public void added() { + + } + public ColorEditor(String fieldName, Object obj, Field field, int index, Class type) { this.obj = obj; this.field = field; diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/GenericTagEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/GenericTagEditor.java index d105e315a..ff55a7f5e 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/GenericTagEditor.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/GenericTagEditor.java @@ -24,6 +24,8 @@ import java.lang.reflect.Field; */ public interface GenericTagEditor { + public void added(); + public void save(); public void addChangeListener(ChangeListener l); diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/NumberEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/NumberEditor.java index e79f46299..16b44fe92 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/NumberEditor.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/NumberEditor.java @@ -57,6 +57,11 @@ public class NumberEditor extends JSpinner implements GenericTagEditor { return 0; } + @Override + public void added() { + + } + public NumberEditor(String fieldName, Object obj, Field field, int index, Class type, SWFType swfType) { setSize(100, getSize().height); setMaximumSize(getSize()); diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/ScrollPanedEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/ScrollPanedEditor.java new file mode 100644 index 000000000..af151a97c --- /dev/null +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/ScrollPanedEditor.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2016 Jindra + * + * 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 . + */ +package com.jpexs.decompiler.flash.gui.generictageditors; + +import java.awt.Component; +import java.awt.Dimension; +import java.lang.reflect.Field; +import javax.swing.JScrollPane; + +/** + * + * @author JPEXS + */ +public class ScrollPanedEditor extends JScrollPane implements GenericTagEditor { + + private final GenericTagEditor editor; + + public ScrollPanedEditor(GenericTagEditor editor) { + super((Component) editor); + this.editor = editor; + Dimension d = new Dimension(500, 300); + setSize(d); + setPreferredSize(d); + } + + @Override + public void save() { + editor.save(); + } + + @Override + public void addChangeListener(ChangeListener l) { + editor.addChangeListener(l); + } + + @Override + public Object getChangedValue() { + return editor.getChangedValue(); + } + + @Override + public String getFieldName() { + return editor.getFieldName(); + } + + @Override + public Field getField() { + return editor.getField(); + } + + @Override + public String getReadOnlyValue() { + return editor.getReadOnlyValue(); + } + + @Override + public void added() { + editor.added(); + } +} diff --git a/src/com/jpexs/decompiler/flash/gui/generictageditors/StringEditor.java b/src/com/jpexs/decompiler/flash/gui/generictageditors/StringEditor.java index 4d7e8b218..c08cfb0cd 100644 --- a/src/com/jpexs/decompiler/flash/gui/generictageditors/StringEditor.java +++ b/src/com/jpexs/decompiler/flash/gui/generictageditors/StringEditor.java @@ -126,4 +126,9 @@ public class StringEditor extends JTextArea implements GenericTagEditor { public String getReadOnlyValue() { return Helper.escapeHTML(getChangedValue().toString()); } + + @Override + public void added() { + + } }