diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/FontPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/FontPanel.java index 92c630a7e..d7e02bd65 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/FontPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/FontPanel.java @@ -41,6 +41,7 @@ public class FontPanel extends javax.swing.JPanel { /** * Creates new form FontPanel + * * @param mainPanel */ public FontPanel(MainPanel mainPanel) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/FontPreviewDialog.java b/trunk/src/com/jpexs/decompiler/flash/gui/FontPreviewDialog.java index bade74248..854793b41 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/FontPreviewDialog.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/FontPreviewDialog.java @@ -37,6 +37,7 @@ public class FontPreviewDialog extends AppDialog { /** * Creates new form FontPreviewDialog + * * @param parent * @param font * @param modal diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagPanel.java index 3b5d5ed12..77835f626 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagPanel.java @@ -63,6 +63,7 @@ import javax.swing.SpringLayout; /** * Old Generic Tag editor + * * @author JPEXS */ public class GenericTagPanel extends JPanel implements ChangeListener { @@ -102,8 +103,8 @@ public class GenericTagPanel extends JPanel implements ChangeListener { genericTagPropertiesEditPanel = new JPanel(); genericTagPropertiesEditPanel.setLayout(new SpringLayout()); - JPanel edPanel=new JPanel(new BorderLayout()); - edPanel.add(genericTagPropertiesEditPanel,BorderLayout.NORTH); + JPanel edPanel = new JPanel(new BorderLayout()); + edPanel.add(genericTagPropertiesEditPanel, BorderLayout.NORTH); genericTagPropertiesEditPanelScrollPanel = new JScrollPane(edPanel); } @@ -122,15 +123,15 @@ public class GenericTagPanel extends JPanel implements ChangeListener { } public void setEditMode(boolean edit, Tag tag) { - if(tag==null){ + if (tag == null) { tag = this.tag; } - + this.tag = tag; - this.editedTag = (Tag)Helper.deepCopy(tag); + this.editedTag = (Tag) Helper.deepCopy(tag); generateEditControls(editedTag, !edit); - - if (edit){ + + if (edit) { remove(genericTagPropertiesEditorPaneScrollPanel); add(genericTagPropertiesEditPanelScrollPanel, BorderLayout.CENTER); } else { @@ -276,7 +277,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener { try { //If countField exists, decrement, otherwise do nothing Field countField = obj.getClass().getDeclaredField(swfType.countField()); - if(countField!=null){ + if (countField != null) { int cnt = countField.getInt(obj); cnt--; countField.setInt(obj, cnt); @@ -287,8 +288,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener { } else { ReflectionTools.removeFromField(obj, field, index); } - - + generateEditControls(editedTag, false); //Restore scroll top after some time. TODO: Handle this better. I don't know how :-(. @@ -309,7 +309,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener { }); } - }.start(); + }.start(); revalidate(); repaint(); } @@ -323,13 +323,13 @@ public class GenericTagPanel extends JPanel implements ChangeListener { for (int f = 0; f < fields.length; f++) { SWFType fieldSwfType = fields[f].getAnnotation(SWFType.class); if (fieldSwfType != null && fieldSwfType.countField().equals(swfType.countField())) { - ReflectionTools.addToField(obj, fields[f], ReflectionTools.getFieldSubSize(obj, fields[f]),true); + ReflectionTools.addToField(obj, fields[f], ReflectionTools.getFieldSubSize(obj, fields[f]), true); } } try { //If countField exists, increment, otherwise do nothing Field countField = obj.getClass().getDeclaredField(swfType.countField()); - if(countField!=null){ + if (countField != null) { int cnt = countField.getInt(obj); cnt++; countField.setInt(obj, cnt); @@ -338,7 +338,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener { //ignored } } else { - ReflectionTools.addToField(obj, field,ReflectionTools.getFieldSubSize(obj, field), true); + ReflectionTools.addToField(obj, field, ReflectionTools.getFieldSubSize(obj, field), true); } generateEditControls(editedTag, false); @@ -362,7 +362,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener { }.start(); revalidate(); - repaint(); + repaint(); } private int addEditor(String name, Object obj, Field field, int index, Class type, Object value, List parentList, List parentIndices, boolean readonly) throws IllegalArgumentException, IllegalAccessException { @@ -391,7 +391,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener { } else if (type.equals(boolean.class) || type.equals(Boolean.class)) { editor = new BooleanEditor(name, obj, field, index, type); } else if (type.equals(String.class)) { - editor = new StringEditor(name, obj, field, index, type,multiline!=null); + editor = new StringEditor(name, obj, field, index, type, multiline != null); } else if (type.equals(RGB.class) || type.equals(RGBA.class) || type.equals(ARGB.class)) { editor = new ColorEditor(name, obj, field, index, type); } else { @@ -459,16 +459,16 @@ public class GenericTagPanel extends JPanel implements ChangeListener { } return result; } - - private void assignTag(Tag t,Tag assigned){ - if(t.getClass()!=assigned.getClass()){ + + private void assignTag(Tag t, Tag assigned) { + if (t.getClass() != assigned.getClass()) { return; } - for(Field f:t.getClass().getDeclaredFields()){ - if((f.getModifiers()&Modifier.FINAL) == Modifier.FINAL){ + for (Field f : t.getClass().getDeclaredFields()) { + if ((f.getModifiers() & Modifier.FINAL) == Modifier.FINAL) { continue; } - if((f.getModifiers()&Modifier.STATIC) == Modifier.STATIC){ + if ((f.getModifiers() & Modifier.STATIC) == Modifier.STATIC) { continue; } try { @@ -485,7 +485,7 @@ public class GenericTagPanel extends JPanel implements ChangeListener { ((GenericTagEditor) component).save(); } } - SWF swf=tag.getSwf(); + SWF swf = tag.getSwf(); assignTag(tag, editedTag); tag.setModified(true); tag.setSwf(swf); @@ -565,8 +565,8 @@ public class GenericTagPanel extends JPanel implements ChangeListener { dependentEditor = addButtons.get(key); } else if (removeButtons.containsKey(key)) { //It's array/list, add remove button JPanel editRemPanel = new JPanel(new BorderLayout()); - editRemPanel.add((Component) editors.get(key),BorderLayout.CENTER); - editRemPanel.add(removeButtons.get(key),BorderLayout.EAST); + editRemPanel.add((Component) editors.get(key), BorderLayout.CENTER); + editRemPanel.add(removeButtons.get(key), BorderLayout.EAST); dependentEditor = editRemPanel; } else { dependentEditor = (Component) editors.get(key); @@ -581,8 +581,8 @@ public class GenericTagPanel extends JPanel implements ChangeListener { } } /*genericTagPropertiesEditPanel.add(new JPanel()); - genericTagPropertiesEditPanel.add(new JPanel()); - genericTagPropertiesEditPanel.add(new JPanel());*/ + genericTagPropertiesEditPanel.add(new JPanel()); + genericTagPropertiesEditPanel.add(new JPanel());*/ relayout(propCount /*+ 1*/); } } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java index 041ab3fe5..7161f4ab7 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/GenericTagTreePanel.java @@ -194,7 +194,7 @@ public class GenericTagTreePanel extends GenericTagPanel { public boolean stopCellEditing() { super.stopCellEditing(); editor.save(); - ((MyTreeModel)tree.getModel()).vchanged(tree.getSelectionPath()); + ((MyTreeModel) tree.getModel()).vchanged(tree.getSelectionPath()); return true; } @@ -221,10 +221,10 @@ public class GenericTagTreePanel extends GenericTagPanel { final FieldNode fnode = (FieldNode) selObject; SWFArray swfArray = fnode.field.getAnnotation(SWFArray.class); String itemStr = ""; - if(swfArray!=null){ + if (swfArray != null) { itemStr = swfArray.value(); } - if(itemStr.equals("")){ + if (itemStr.equals("")) { itemStr = AppStrings.translate("generictag.array.item"); } if (ReflectionTools.needsIndex(fnode.field)) { @@ -296,7 +296,7 @@ public class GenericTagTreePanel extends GenericTagPanel { private Tag tag; - public class MyTreeCellRenderer extends DefaultTreeCellRenderer { + public class MyTreeCellRenderer extends DefaultTreeCellRenderer { @Override public Component getTreeCellRendererComponent( @@ -315,7 +315,7 @@ public class GenericTagTreePanel extends GenericTagPanel { setUI(new BasicLabelUI()); setOpaque(false); - setBackgroundNonSelectionColor(Color.white); + setBackgroundNonSelectionColor(Color.white); return this; } @@ -343,9 +343,8 @@ public class GenericTagTreePanel extends GenericTagPanel { } - /* -*/ + */ @Override public String toString() { @@ -356,27 +355,27 @@ public class GenericTagTreePanel extends GenericTagPanel { Object val = getValue(); Color color = null; String colorAdd = ""; - if(val instanceof RGB){ //Note: Can be RGBA too - color = ((RGB)val).toColor(); + if (val instanceof RGB) { //Note: Can be RGBA too + color = ((RGB) val).toColor(); } - if(val instanceof ARGB){ - color = ((ARGB)val).toColor(); + if (val instanceof ARGB) { + color = ((ARGB) val).toColor(); } - - if(color!=null){ - colorAdd = " "; + + if (color != null) { + colorAdd = " "; } - + valStr += " = " + colorAdd + val.toString(); } - return ""+getNameType() + valStr+""; + return "" + getNameType() + valStr + ""; } public String getType() { SWFType swfType = field.getAnnotation(SWFType.class); SWFArray swfArray = field.getAnnotation(SWFArray.class); String typeStr = null; - if ((swfType != null || swfArray!=null) && !(ReflectionTools.needsIndex(field) && (index > -1))) { + if ((swfType != null || swfArray != null) && !(ReflectionTools.needsIndex(field) && (index > -1))) { Class type = field.getType(); if (ReflectionTools.needsIndex(field)) { type = ReflectionTools.getFieldSubType(obj, field); @@ -393,8 +392,8 @@ public class GenericTagTreePanel extends GenericTagPanel { public String getName() { SWFArray swfArray = field.getAnnotation(SWFArray.class); - String name=""; - if(swfArray!=null){ + String name = ""; + if (swfArray != null) { name = swfArray.value(); } return (index > -1 ? name + "[" + index + "]" : field.getName()); @@ -456,7 +455,7 @@ public class GenericTagTreePanel extends GenericTagPanel { } @Override - public Object getRoot() { + public Object getRoot() { return root; } @@ -507,7 +506,7 @@ public class GenericTagTreePanel extends GenericTagPanel { return r; } - public void vchanged(TreePath path){ + public void vchanged(TreePath path) { fireTreeNodesChanged(this, path.getPath(), null, null); } @@ -534,8 +533,11 @@ public class GenericTagTreePanel extends GenericTagPanel { } this.tag = tag; this.editedTag = (Tag) Helper.deepCopy(tag); - refreshTree(); tree.setEditable(edit); + if (!edit) { + tree.stopEditing(); + } + refreshTree(); } @Override @@ -565,23 +567,23 @@ public class GenericTagTreePanel extends GenericTagPanel { return tag; } - public static String swfArrayToString(SWFArray swfArray){ - String result=""; - if(swfArray==null){ + public static String swfArrayToString(SWFArray swfArray) { + String result = ""; + if (swfArray == null) { return result; } if (swfArray.count() > 0) { result += "[" + swfArray.count() + "]"; } else if (!swfArray.countField().equals("")) { - result += "[" + swfArray.countField()+ "]"; + result += "[" + swfArray.countField() + "]"; } - return result; + return result; } - + public static String swfTypeToString(Class type, SWFType swfType, SWFArray swfArray) { String stype = type.getSimpleName(); - if (swfType == null) { - return stype+swfArrayToString(swfArray); + if (swfType == null) { + return stype + swfArrayToString(swfArray); } String result = swfType.value().toString(); if (swfType.value() == BasicType.OTHER) { @@ -600,7 +602,7 @@ public class GenericTagTreePanel extends GenericTagPanel { } result += "]"; } - return result+swfArrayToString(swfArray); + return result + swfArrayToString(swfArray); } private static boolean hasEditor(Object obj, Field field, int index) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index f01348b2b..e4988b1c4 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -132,7 +132,7 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis if (drawable instanceof BoundedTag) { BoundedTag bounded = (BoundedTag) drawable; RECT rect = bounded.getRect(characters, new Stack()); - SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, + SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, (int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); Matrix m = new Matrix(); m.translate(-rect.Xmin, -rect.Ymin); @@ -205,13 +205,13 @@ public final class ImagePanel extends JPanel implements ActionListener, FlashDis if (drawable instanceof BoundedTag) { BoundedTag bounded = (BoundedTag) drawable; RECT rect = bounded.getRect(characters, new Stack()); - SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, + SerializableImage image = new SerializableImage((int) (rect.getWidth() / SWF.unitDivisor) + 1, (int) (rect.getHeight() / SWF.unitDivisor) + 1, SerializableImage.TYPE_INT_ARGB); Matrix m = new Matrix(); m.translate(-rect.Xmin, -rect.Ymin); drawable.toImage(nframe, swf.tags, characters, new Stack(), image, m); img = image; - + } else { img = drawable.toImage(nframe, swf.tags, characters, new Stack(), Matrix.getScaleInstance(1 / SWF.unitDivisor)); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/LinkLabel.java b/trunk/src/com/jpexs/decompiler/flash/gui/LinkLabel.java index a9fcef938..04bac5e7a 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/LinkLabel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/LinkLabel.java @@ -37,6 +37,7 @@ public class LinkLabel extends JLabel { /** * Creates a new LinkLabel with the given text. + * * @param text */ public LinkLabel(String text) { @@ -49,6 +50,7 @@ public class LinkLabel extends JLabel { /** * Sets the text of the label. + * * @param text */ @Override @@ -59,7 +61,8 @@ public class LinkLabel extends JLabel { /** * Returns the text set by the user. - * @return + * + * @return */ public String getNormalText() { return text; @@ -67,6 +70,7 @@ public class LinkLabel extends JLabel { /** * Processes mouse events and responds to clicks. + * * @param evt */ @Override diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java index 080d569e7..3e42a9c23 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/Main.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/Main.java @@ -709,7 +709,7 @@ public class Main { } private static void initGui() { - if(GraphicsEnvironment.isHeadless()){ + if (GraphicsEnvironment.isHeadless()) { System.err.println("Error: Your system does not support Graphic User Interface"); exit(); } @@ -750,7 +750,7 @@ public class Main { } public static void initLang() { - if(GraphicsEnvironment.isHeadless()){ //No GUI in OS + if (GraphicsEnvironment.isHeadless()) { //No GUI in OS return; } Locale.setDefault(Locale.forLanguageTag(Configuration.locale.get())); @@ -1001,7 +1001,7 @@ public class Main { public static void exit() { Configuration.saveConfig(); - if(!GraphicsEnvironment.isHeadless()){ + if (!GraphicsEnvironment.isHeadless()) { FlashPlayerPanel.unload(); } System.exit(0); @@ -1154,7 +1154,7 @@ public class Main { fileTxt.setFormatter(formatterTxt); logger.addHandler(fileTxt); - if(!GraphicsEnvironment.isHeadless()){ + if (!GraphicsEnvironment.isHeadless()) { ErrorLogFrame.getInstance().clearErrorState(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java index 3603fb680..600015356 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -2011,8 +2011,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec showCard(CARDEMPTYPANEL); refreshTree(); } - - public void refreshTree(){ + + public void refreshTree() { View.refreshTree(tagTree, new TagTreeModel(mainFrame, swfs)); expandSwfNodes(); } @@ -2164,8 +2164,8 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec genericSaveButton.setVisible(true); genericCancelButton.setVisible(true); //genericTagPanel.generateEditControls((Tag) item, false); - genericTagPanel.setEditMode(true,(Tag) item); - + genericTagPanel.setEditMode(true, (Tag) item); + } } break; @@ -2178,14 +2178,14 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec genericEditButton.setVisible(true); genericSaveButton.setVisible(false); genericCancelButton.setVisible(false); - genericTagPanel.setEditMode(false,null); + genericTagPanel.setEditMode(false, null); } break; case ACTION_CANCEL_GENERIC_TAG: { genericEditButton.setVisible(true); genericSaveButton.setVisible(false); genericCancelButton.setVisible(false); - genericTagPanel.setEditMode(false,null); + genericTagPanel.setEditMode(false, null); } break; case ACTION_REMOVE_ITEM: @@ -2488,7 +2488,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec genericEditButton.setVisible(true); genericSaveButton.setVisible(false); genericCancelButton.setVisible(false); - genericTagPanel.setEditMode(false,(Tag)tagObj); + genericTagPanel.setEditMode(false, (Tag) tagObj); } else { showCard(CARDEMPTYPANEL); } @@ -2884,7 +2884,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec showDetailWithPreview(CARDFONTPANEL); } - public void expandSwfNodes() { + public void expandSwfNodes() { TreeModel model = tagTree.getModel(); Object node = model.getRoot(); int childCount = model.getChildCount(node); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/View.java b/trunk/src/com/jpexs/decompiler/flash/gui/View.java index 8dc665b1f..830cf4a9f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/View.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/View.java @@ -356,15 +356,13 @@ public class View { public static SubstanceColorScheme getColorScheme() { return SubstanceColorSchemeUtilities.getActiveColorScheme(new JButton(), ComponentState.ENABLED); } - - public static void refreshTree(JTree tree,TreeModel model) { + + public static void refreshTree(JTree tree, TreeModel model) { List> expandedNodes = getExpandedNodes(tree); tree.setModel(model); expandTreeNodes(tree, expandedNodes); } - - private static List> getExpandedNodes(JTree tree) { List> expandedNodes = new ArrayList<>(); int rowCount = tree.getRowCount(); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/BooleanEditor.java b/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/BooleanEditor.java index bc6776322..2172a42ad 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/BooleanEditor.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/BooleanEditor.java @@ -33,7 +33,7 @@ public class BooleanEditor extends JCheckBox implements GenericTagEditor { private final Class type; private final String fieldName; - public BooleanEditor(String fieldName,Object obj, Field field, int index, Class type) { + public BooleanEditor(String fieldName, Object obj, Field field, int index, Class type) { super(); this.obj = obj; this.field = field; @@ -58,7 +58,7 @@ public class BooleanEditor extends JCheckBox implements GenericTagEditor { @Override public void addChangeListener(final ChangeListener l) { - final GenericTagEditor t=this; + final GenericTagEditor t = this; addActionListener(new ActionListener() { @Override @@ -72,7 +72,7 @@ public class BooleanEditor extends JCheckBox implements GenericTagEditor { public Object getChangedValue() { return isSelected(); } - + @Override public String getFieldName() { return fieldName; @@ -87,7 +87,5 @@ public class BooleanEditor extends JCheckBox implements GenericTagEditor { public String getReadOnlyValue() { return getChangedValue().toString(); } - - - + } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/ChangeListener.java b/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/ChangeListener.java index 4794adf4e..a596fa465 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/ChangeListener.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/ChangeListener.java @@ -14,7 +14,6 @@ * 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; /** @@ -22,5 +21,6 @@ package com.jpexs.decompiler.flash.gui.generictageditors; * @author JPEXS */ public interface ChangeListener { + public void change(GenericTagEditor editor); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/ColorEditor.java b/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/ColorEditor.java index d2d060d17..66658c161 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/ColorEditor.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/ColorEditor.java @@ -58,63 +58,58 @@ public class ColorEditor extends JPanel implements GenericTagEditor, ActionListe return colorType; } - - - - public ColorEditor(String fieldName,Object obj, Field field, int index, Class type) { + public ColorEditor(String fieldName, Object obj, Field field, int index, Class type) { this.obj = obj; this.field = field; this.index = index; - this.type = type; + this.type = type; this.fieldName = fieldName; try { Object val = ReflectionTools.getValue(obj, field, index); - if(val instanceof RGBA){ + if (val instanceof RGBA) { colorType = COLOR_TYPE_RGBA; - }else if(val instanceof RGB){ + } else if (val instanceof RGB) { colorType = COLOR_TYPE_RGB; - }else if(val instanceof ARGB){ + } else if (val instanceof ARGB) { colorType = COLOR_TYPE_ARGB; - }else{ + } else { throw new IllegalArgumentException("Invalid value type"); } - if(val instanceof RGB){ //Note: Can be RGBA too - color = ((RGB)val).toColor(); + if (val instanceof RGB) { //Note: Can be RGBA too + color = ((RGB) val).toColor(); } - if(val instanceof ARGB){ - color = ((ARGB)val).toColor(); + if (val instanceof ARGB) { + color = ((ARGB) val).toColor(); } setLayout(new FlowLayout()); - - //add(colorPanel); - buttonChange=new JButton(""){ - + //add(colorPanel); + buttonChange = new JButton("") { + @Override protected void paintComponent(Graphics g) { g.setColor(getBackground()); g.fillRect(0, 0, getWidth(), getHeight()); super.paintBorder(g); } - - }; + + }; buttonChange.setToolTipText(AppStrings.translate("button.selectcolor.hint")); buttonChange.setCursor(new Cursor(Cursor.HAND_CURSOR)); buttonChange.addActionListener(this); - buttonChange.setBackground(color); + buttonChange.setBackground(color); buttonChange.setBorderPainted(true); buttonChange.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); - Dimension colorDim=new Dimension(16,16); + Dimension colorDim = new Dimension(16, 16); buttonChange.setSize(colorDim); buttonChange.setPreferredSize(colorDim); add(buttonChange); } catch (IllegalArgumentException | IllegalAccessException ex) { // ignore } - + } - - + @Override public void save() { Object val = getChangedValue(); @@ -124,7 +119,7 @@ public class ColorEditor extends JPanel implements GenericTagEditor, ActionListe // ignore } } - + @Override public void addChangeListener(final ChangeListener l) { final GenericTagEditor t = this; @@ -141,7 +136,7 @@ public class ColorEditor extends JPanel implements GenericTagEditor, ActionListe @Override public Object getChangedValue() { Object val = null; - switch(colorType){ + switch (colorType) { case COLOR_TYPE_RGB: val = new RGB(color); break; @@ -149,7 +144,7 @@ public class ColorEditor extends JPanel implements GenericTagEditor, ActionListe val = new RGBA(color); break; case COLOR_TYPE_ARGB: - val = new ARGB(); + val = new ARGB(); break; } return val; @@ -159,7 +154,7 @@ public class ColorEditor extends JPanel implements GenericTagEditor, ActionListe public String getFieldName() { return fieldName; } - + @Override public Field getField() { return field; @@ -168,18 +163,17 @@ public class ColorEditor extends JPanel implements GenericTagEditor, ActionListe @Override public void actionPerformed(ActionEvent e) { Color newColor = JColorChooser.showDialog(null, AppStrings.translate("dialog.selectcolor.title"), color); - if(newColor!=null){ + if (newColor != null) { color = newColor; buttonChange.setBackground(color); repaint(); } } - - + @Override public String getReadOnlyValue() { - int h=System.identityHashCode(this); - return "     "+getChangedValue().toString(); + int h = System.identityHashCode(this); + return "     " + getChangedValue().toString(); } - + } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/GenericTagEditor.java b/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/GenericTagEditor.java index d6b1b66e2..f3b25b6d3 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/GenericTagEditor.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/GenericTagEditor.java @@ -25,11 +25,14 @@ import java.lang.reflect.Field; public interface GenericTagEditor { public void save(); - + public void addChangeListener(ChangeListener l); + public Object getChangedValue(); + public String getFieldName(); + public Field getField(); - + public String getReadOnlyValue(); } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/NumberEditor.java b/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/NumberEditor.java index 391bd9f8b..53391d271 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/NumberEditor.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/NumberEditor.java @@ -50,10 +50,8 @@ public class NumberEditor extends JSpinner implements GenericTagEditor { public int getBaseline(int width, int height) { return 0; } - - - public NumberEditor(String fieldName,Object obj, Field field, int index, Class type, SWFType swfType) { + public NumberEditor(String fieldName, Object obj, Field field, int index, Class type, SWFType swfType) { setSize(100, getSize().height); setMaximumSize(getSize()); this.obj = obj; @@ -64,8 +62,8 @@ public class NumberEditor extends JSpinner implements GenericTagEditor { this.fieldName = fieldName; try { Object value = ReflectionTools.getValue(obj, field, index); - setModel(getModel(swfType, value)); - JFormattedTextField jtf = ((JSpinner.NumberEditor)getEditor()).getTextField(); + setModel(getModel(swfType, value)); + JFormattedTextField jtf = ((JSpinner.NumberEditor) getEditor()).getTextField(); DefaultFormatter formatter = (DefaultFormatter) jtf.getFormatter(); formatter.setCommitsOnValidEdit(true); } catch (IllegalArgumentException | IllegalAccessException ex) { @@ -187,7 +185,7 @@ public class NumberEditor extends JSpinner implements GenericTagEditor { } @Override - public Object getChangedValue() { + public Object getChangedValue() { Object value = null; if (type.equals(int.class) || type.equals(Integer.class)) { value = Integer.parseInt(getValue().toString()); @@ -207,12 +205,12 @@ public class NumberEditor extends JSpinner implements GenericTagEditor { public String getFieldName() { return fieldName; } - + @Override public Field getField() { return field; } - + @Override public String getReadOnlyValue() { return getChangedValue().toString(); diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/ReflectionTools.java b/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/ReflectionTools.java index dce6d4dff..204c0840f 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/ReflectionTools.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/generictageditors/ReflectionTools.java @@ -30,7 +30,7 @@ import java.util.logging.Logger; public class ReflectionTools { public static Object getValue(Object obj, Field field, int index) throws IllegalArgumentException, IllegalAccessException { - if(getFieldSubSize(obj, field)<=index){ + if (getFieldSubSize(obj, field) <= index) { return null; } Object value = field.get(obj); @@ -53,9 +53,9 @@ public class ReflectionTools { } return false; } - + @SuppressWarnings("unchecked") - public static int getFieldSubSize(Object obj,Field field){ + public static int getFieldSubSize(Object obj, Field field) { Object val; try { val = field.get(obj); @@ -63,7 +63,7 @@ public class ReflectionTools { return 0; } if (List.class.isAssignableFrom(field.getType())) { - return ((List)val).size(); + return ((List) val).size(); } else if (field.getType().isArray()) { return Array.getLength(val); } @@ -73,7 +73,7 @@ public class ReflectionTools { @SuppressWarnings("unchecked") public static void setValue(Object obj, Field field, int index, Object newValue) throws IllegalArgumentException, IllegalAccessException { Object value = field.get(obj); - if(needsIndex(field)&& index>=getFieldSubSize(obj, field)){ //outofbounds, ignore + if (needsIndex(field) && index >= getFieldSubSize(obj, field)) { //outofbounds, ignore return; } if (List.class.isAssignableFrom(field.getType())) { @@ -85,14 +85,14 @@ public class ReflectionTools { } } - public static Object newInstanceOf(Class cls) throws InstantiationException, IllegalAccessException { + public static Object newInstanceOf(Class cls) throws InstantiationException, IllegalAccessException { if (cls == Integer.class || cls == int.class) { return new Integer(0); } else if (cls == Float.class || cls == float.class) { return new Float(0.0f); - } else if (cls == Double.class || cls == double.class ) { + } else if (cls == Double.class || cls == double.class) { return new Double(0); - } else if(cls == Long.class || cls == long.class){ + } else if (cls == Long.class || cls == long.class) { return new Long(0L); } return cls.newInstance(); @@ -114,7 +114,7 @@ public class ReflectionTools { Class parameterClass = (Class) listType.getActualTypeArguments()[0]; try { Object val = newInstanceOf(parameterClass); - list.add(index,val); + list.add(index, val); } catch (InstantiationException | IllegalAccessException ex) { Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); return false; @@ -122,23 +122,23 @@ public class ReflectionTools { return true; } - public static Class getFieldSubType(Object object,Field field){ - if(field.getType().isArray()){ + public static Class getFieldSubType(Object object, Field field) { + if (field.getType().isArray()) { Object arrValue; try { arrValue = field.get(object); return arrValue.getClass().getComponentType(); } catch (IllegalArgumentException | IllegalAccessException ex) { return null; - } + } } - if(List.class.isAssignableFrom(field.getType())) { + if (List.class.isAssignableFrom(field.getType())) { ParameterizedType listType = (ParameterizedType) field.getGenericType(); - return (Class) listType.getActualTypeArguments()[0]; + return (Class) listType.getActualTypeArguments()[0]; } return null; } - + public static boolean addToArray(Object object, Field field, int index, boolean notnull) { if (!field.getType().isArray()) { return false; @@ -166,8 +166,8 @@ public class ReflectionTools { } } //Copy items after - for (int i = index; i < originalSize ; i++) { - Array.set(copy, i+1, Array.get(arrValue, i)); + for (int i = index; i < originalSize; i++) { + Array.set(copy, i + 1, Array.get(arrValue, i)); } try { field.set(object, copy); @@ -178,44 +178,44 @@ public class ReflectionTools { return true; } - public static boolean addToField(Object object, Field field, int index,boolean notnull) { + public static boolean addToField(Object object, Field field, int index, boolean notnull) { if (List.class.isAssignableFrom(field.getType())) { - return addToList(object, field,index); + return addToList(object, field, index); } if (field.getType().isArray()) { - return addToArray(object, field, index,notnull); + return addToArray(object, field, index, notnull); } return false; } - - public static boolean removeFromField(Object object, Field field,int index){ + + public static boolean removeFromField(Object object, Field field, int index) { if (List.class.isAssignableFrom(field.getType())) { - return removeFromList(object, field,index); + return removeFromList(object, field, index); } - + if (field.getType().isArray()) { return removeFromArray(object, field, index); } return false; } - - public static boolean removeFromList(Object object, Field field,int index){ + + public static boolean removeFromList(Object object, Field field, int index) { List list; - try { - list=(List)field.get(object); + try { + list = (List) field.get(object); } catch (IllegalArgumentException | IllegalAccessException ex) { Logger.getLogger(ReflectionTools.class.getName()).log(Level.SEVERE, null, ex); return false; } - if(index<0 || index>=list.size()){ + if (index < 0 || index >= list.size()) { return false; } - list.remove(index); + list.remove(index); return true; } - - public static boolean removeFromArray(Object object, Field field, int index){ + + public static boolean removeFromArray(Object object, Field field, int index) { Object arrValue; try { arrValue = field.get(object); @@ -226,14 +226,14 @@ public class ReflectionTools { Class componentClass = arrValue.getClass().getComponentType(); int originalSize = Array.getLength(arrValue); Object copy = Array.newInstance(componentClass, originalSize - 1); - int pos=0; + int pos = 0; //copy all before index for (int i = 0; i < index; i++) { Array.set(copy, pos, Array.get(arrValue, i)); pos++; } //copy all after index - for (int i = index+1; i type, boolean multiline) { - setLineWrap(true); + + public StringEditor(String fieldName, Object obj, Field field, int index, Class type, boolean multiline) { + setLineWrap(true); this.obj = obj; this.field = field; this.index = index; - this.type = type; + this.type = type; this.fieldName = fieldName; this.multiline = multiline; - if(multiline){ - Dimension d = new Dimension(500,200); + if (multiline) { + Dimension d = new Dimension(500, 200); setPreferredSize(d); setSize(d); } @@ -89,7 +87,7 @@ public class StringEditor extends JTextArea implements GenericTagEditor { // ignore } } - + @Override public void addChangeListener(final ChangeListener l) { final GenericTagEditor t = this; @@ -112,15 +110,15 @@ public class StringEditor extends JTextArea implements GenericTagEditor { public String getFieldName() { return fieldName; } - + @Override public Field getField() { return field; } - + @Override public String getReadOnlyValue() { return Helper.escapeHTML(getChangedValue().toString()); - } - + } + } diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/helpers/SpringUtilities.java b/trunk/src/com/jpexs/decompiler/flash/gui/helpers/SpringUtilities.java index 2cc3fdcb8..0841dde0c 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/helpers/SpringUtilities.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/helpers/SpringUtilities.java @@ -45,6 +45,7 @@ public class SpringUtilities { /** * A debugging utility that prints to stdout the component's minimum, * preferred, and maximum sizes. + * * @param c */ public static void printSizes(Component c) { diff --git a/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java b/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java index 8483fba69..182be5672 100644 --- a/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java +++ b/trunk/src/com/jpexs/decompiler/flash/gui/proxy/ProxyFrame.java @@ -99,6 +99,7 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe /** * Constructor + * * @param mainFrame */ public ProxyFrame(final MainFrame mainFrame) {