code hint fixes

This commit is contained in:
honfika@gmail.com
2015-01-18 22:49:59 +01:00
parent ade56d45a2
commit e4e9676081
25 changed files with 136 additions and 147 deletions

View File

@@ -16,10 +16,17 @@
*/
package com.jpexs.decompiler.flash.types.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* The String field can have large multiline text
*
* @author JPEXS
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Multiline {
}

View File

@@ -54,7 +54,11 @@ public class ChromeCache implements CacheImplementation {
public static ChromeCache getInstance() {
if (instance == null) {
instance = new ChromeCache();
synchronized (ChromeCache.class) {
if (instance == null) {
instance = new ChromeCache();
}
}
}
return instance;
}

View File

@@ -40,7 +40,11 @@ public class FirefoxCache implements CacheImplementation {
public static FirefoxCache getInstance() {
if (instance == null) {
instance = new FirefoxCache();
synchronized (FirefoxCache.class) {
if (instance == null) {
instance = new FirefoxCache();
}
}
}
return instance;
}

View File

@@ -60,10 +60,7 @@ public class FontFace implements Comparable<FontFace> {
return false;
}
final FontFace other = (FontFace) obj;
if (!Objects.equals(this.font, other.font)) {
return false;
}
return true;
return Objects.equals(this.font, other.font);
}
@Override

View File

@@ -60,10 +60,7 @@ public class FontFamily implements Comparable<FontFamily> {
return false;
}
final FontFamily other = (FontFamily) obj;
if (!Objects.equals(this.familyEn, other.familyEn)) {
return false;
}
return true;
return Objects.equals(this.familyEn, other.familyEn);
}
@Override

View File

@@ -291,11 +291,9 @@ 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) {
int cnt = countField.getInt(obj);
cnt--;
countField.setInt(obj, cnt);
}
int cnt = countField.getInt(obj);
cnt--;
countField.setInt(obj, cnt);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
//ignored
}
@@ -343,11 +341,9 @@ public class GenericTagPanel extends JPanel implements ChangeListener {
try {
//If countField exists, increment, otherwise do nothing
Field countField = obj.getClass().getDeclaredField(swfType.countField());
if (countField != null) {
int cnt = countField.getInt(obj);
cnt++;
countField.setInt(obj, cnt);
}
int cnt = countField.getInt(obj);
cnt++;
countField.setInt(obj, cnt);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
//ignored
}

View File

@@ -129,7 +129,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
try {
type = ReflectionTools.getValue(obj, field, index).getClass();
} catch (IllegalArgumentException | IllegalAccessException ex) {
ex.printStackTrace();
Logger.getLogger(GenericTagTreePanel.class.getName()).log(Level.SEVERE, "Fixing characters order failed, recursion detected.");
return null;
}
SWFType swfType = field.getAnnotation(SWFType.class);
@@ -197,7 +197,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
Object obj = path.getLastPathComponent();
boolean ret = super.isCellEditable(e)
&& path != null && (tree.getModel().isLeaf(obj));
&& tree.getModel().isLeaf(obj);
return ret;
}
@@ -320,8 +320,8 @@ public class GenericTagTreePanel extends GenericTagPanel {
}
}
}
} else if (e.getClickCount() == 2) {
//myDoubleClick(selRow, selPath);
//} else if (e.getClickCount() == 2) {
// myDoubleClick(selRow, selPath);
}
}
}
@@ -479,10 +479,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
if (!Objects.equals(this.field, other.field)) {
return false;
}
if (this.index != other.index) {
return false;
}
return true;
return this.index == other.index;
}
}
@@ -797,7 +794,7 @@ public class GenericTagTreePanel extends GenericTagPanel {
if (value instanceof Boolean) {
fieldMap.put(sf, (Boolean) value);
} else if (value instanceof Integer) {
int intValue = (int) value;
int intValue = (Integer) value;
boolean found = false;
for (int i : cond.options()) {
if (i == intValue) {
@@ -866,11 +863,9 @@ public class GenericTagTreePanel extends GenericTagPanel {
try {
//If countField exists, increment, otherwise do nothing
Field countField = obj.getClass().getDeclaredField(swfArray.countField());
if (countField != null) {
int cnt = countField.getInt(obj);
cnt++;
countField.setInt(obj, cnt);
}
int cnt = countField.getInt(obj);
cnt++;
countField.setInt(obj, cnt);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
//ignored
}
@@ -903,11 +898,9 @@ public class GenericTagTreePanel extends GenericTagPanel {
try {
//If countField exists, decrement, otherwise do nothing
Field countField = obj.getClass().getDeclaredField(swfArray.countField());
if (countField != null) {
int cnt = countField.getInt(obj);
cnt--;
countField.setInt(obj, cnt);
}
int cnt = countField.getInt(obj);
cnt--;
countField.setInt(obj, cnt);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException ex) {
//ignored
}

View File

@@ -1,16 +1,16 @@
/*
* Copyright (C) 2010-2015 JPEXS
*
*
* 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 <http://www.gnu.org/licenses/>.
*/
@@ -65,8 +65,8 @@ public class LicenseUpdater {
You should have received a copy of the GNU Lesser General Public
License along with this library.
*/
int defaultStartYear = 2010;
int defaultFinalYear = 2015;
@@ -137,11 +137,8 @@ public class LicenseUpdater {
} catch (IOException ex) {
}
FileOutputStream fos;
try {
fos = new FileOutputStream(f);
try (FileOutputStream fos = new FileOutputStream(f)) {
fos.write(baos.toByteArray());
fos.close();
} catch (IOException ex) {
}
}

View File

@@ -135,7 +135,7 @@ public class LoadingPanel extends JPanel {
g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
AffineTransform t = AffineTransform.getRotateInstance(getRotation(), size / 2, size / 2);
AffineTransform t = AffineTransform.getRotateInstance(getRotation(), size / 2.0, size / 2.0);
g2.setTransform(t);
g2.drawImage(lastImage, 0, 0, this);
}

View File

@@ -107,11 +107,11 @@ import javax.swing.filechooser.FileFilter;
*/
public class Main {
public static ProxyFrame proxyFrame;
protected static ProxyFrame proxyFrame;
private static List<SWFSourceInfo> sourceInfos = new ArrayList<>();
public static LoadingDialog loadingDialog;
protected static LoadingDialog loadingDialog;
public static ModeFrame modeFrame;
@@ -127,9 +127,9 @@ public class Main {
public static final int UPDATE_SYSTEM_MINOR = 2;
public static LoadFromMemoryFrame loadFromMemoryFrame;
private static LoadFromMemoryFrame loadFromMemoryFrame;
public static LoadFromCacheFrame loadFromCacheFrame;
private static LoadFromCacheFrame loadFromCacheFrame;
private static final Logger logger = Logger.getLogger(Main.class.getName());
@@ -171,12 +171,18 @@ public class Main {
public static void ensureMainFrame() {
if (mainFrame == null) {
if (Configuration.useRibbonInterface.get()) {
mainFrame = new MainFrameRibbon();
} else {
mainFrame = new MainFrameClassic();
synchronized (Main.class) {
if (mainFrame == null) {
MainFrame frame;
if (Configuration.useRibbonInterface.get()) {
frame = new MainFrameRibbon();
} else {
frame = new MainFrameClassic();
}
frame.getPanel().setErrorState(ErrorLogFrame.getInstance().getErrorState());
mainFrame = frame;
}
}
mainFrame.getPanel().setErrorState(ErrorLogFrame.getInstance().getErrorState());
}
}
@@ -1277,8 +1283,13 @@ public class Main {
private static void initDebugger() {
if (debugger == null) {
debugger = new Debugger(Configuration.debuggerPort.get());
debugger.start();
synchronized (Main.class) {
if (debugger == null) {
Debugger dbg = new Debugger(Configuration.debuggerPort.get());
dbg.start();
debugger = dbg;
}
}
}
}
@@ -1467,10 +1478,13 @@ public class Main {
public static void clearLogFile() {
Logger logger = Logger.getLogger("");
if (fileTxt != null) {
fileTxt.flush();
fileTxt.close();
FileHandler oldFileTxt = fileTxt;
fileTxt = null;
if (oldFileTxt != null) {
logger.removeHandler(fileTxt);
oldFileTxt.flush();
oldFileTxt.close();
}
String fileName;

View File

@@ -572,7 +572,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
@Override
public void propertyChange(PropertyChangeEvent pce) {
if (splitsInited) {
Configuration.guiSplitPane1DividerLocation.set((int) pce.getNewValue());
Configuration.guiSplitPane1DividerLocation.set((Integer) pce.getNewValue());
}
}
});
@@ -581,7 +581,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
@Override
public void propertyChange(PropertyChangeEvent pce) {
if (detailPanel.isVisible()) {
Configuration.guiSplitPane2DividerLocation.set((int) pce.getNewValue());
Configuration.guiSplitPane2DividerLocation.set((Integer) pce.getNewValue());
}
}
});
@@ -2368,9 +2368,9 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
preferScript = true;
}
if (flashPanel != null) {
//flashPanel.specialPlayback = false;
}
//if (flashPanel != null) {
// flashPanel.specialPlayback = false;
//}
folderPreviewPanel.setItems(new ArrayList<TreeItem>());
previewPanel.clear();
stopFlashPlayer();

View File

@@ -1,16 +1,16 @@
/*
* Copyright (C) 2010-2015 JPEXS
*
*
* 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 <http://www.gnu.org/licenses/>.
*/
@@ -38,9 +38,9 @@ public class MyProgressBarUI extends SubstanceProgressBarUI {
public void stateChanged(ChangeEvent e) {
SubstanceCoreUtilities.testComponentStateChangeThreadingViolation(progressBar);
if (displayTimeline != null) { //Main Change - this should be first
//displayTimeline.abort();
}
//if (displayTimeline != null) { //Main Change - this should be first
// displayTimeline.abort();
//}
int currValue = progressBar.getValue();
int span = progressBar.getMaximum() - progressBar.getMinimum();
@@ -69,12 +69,12 @@ public class MyProgressBarUI extends SubstanceProgressBarUI {
displayTimeline);*/
boolean isInCellRenderer = (SwingUtilities.getAncestorOfClass(
CellRendererPane.class, progressBar) != null);
if (false) {//currValue > 0 && !isInCellRenderer && Math.abs(pixelDelta) > 5) {
displayTimeline.play();
} else {
displayedValue = currValue;
progressBar.repaint();
}
//if (false) {//currValue > 0 && !isInCellRenderer && Math.abs(pixelDelta) > 5) {
// displayTimeline.play();
//} else {
displayedValue = currValue;
progressBar.repaint();
//}
}
}

View File

@@ -177,11 +177,10 @@ public class MyRibbonApplicationMenuButtonUI extends BasicRibbonApplicationMenuB
if (regular == null) {
return;
}
if (regular != null) {
Graphics2D g2d = (Graphics2D) g.create();
regular.paintIcon(this.applicationMenuButton, g2d, 0, 0);
g2d.dispose();
}
Graphics2D g2d = (Graphics2D) g.create();
regular.paintIcon(this.applicationMenuButton, g2d, 0, 0);
g2d.dispose();
}
/*

View File

@@ -101,9 +101,11 @@ public class NewVersionDialog extends AppDialog implements ActionListener {
}
changesText.setContentType("text/html");
changesText.setText("<html>" + changesStr + "</html>");
JLabel newAvailableLabel = new JLabel("<html><b><center>" + translate("newversionavailable") + " " + latestVersion.appName + " " + translate("version") + " " + latestVersion.versionName + "</center></b></html>", SwingConstants.CENTER);
newAvailableLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
cnt.add(newAvailableLabel);
if (latestVersion != null) {
JLabel newAvailableLabel = new JLabel("<html><b><center>" + translate("newversionavailable") + " " + latestVersion.appName + " " + translate("version") + " " + latestVersion.versionName + "</center></b></html>", SwingConstants.CENTER);
newAvailableLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
cnt.add(newAvailableLabel);
}
JLabel changeslogLabel = new JLabel("<html>" + translate("changeslog") + "</html>");
changeslogLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);

View File

@@ -194,7 +194,7 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
@Override
public void propertyChange(PropertyChangeEvent pce) {
if (splitsInited && getRightComponent().isVisible()) {
Configuration.guiPreviewSplitPaneDividerLocation.set((int) pce.getNewValue());
Configuration.guiPreviewSplitPaneDividerLocation.set((Integer) pce.getNewValue());
}
}
});
@@ -894,9 +894,9 @@ public class PreviewPanel extends JSplitPane implements ActionListener {
new ShowFrameTag(swf).writeTag(sos2);
new ShowFrameTag(swf).writeTag(sos2);
if (flashPanel != null) {
//flashPanel.specialPlayback = true;
}
//if (flashPanel != null) {
// flashPanel.specialPlayback = true;
//}
} else if (tagObj instanceof DefineVideoStreamTag) {
new PlaceObject2Tag(swf, false, false, false, false, false, true, true, false, 1, chtId, mat, null, 0, null, 0, null).writeTag(sos2);

View File

@@ -46,7 +46,7 @@ public class SelectLanguageDialog extends AppDialog implements ActionListener {
public String languageCode = null;
public static final String[] languages = new String[]{"en", "ca", "cs", "zh", "de", "es", "fr", "hu", "nl", "pl", "pt", "pt-BR", "ru", "sv", "uk"};
protected static final String[] languages = new String[]{"en", "ca", "cs", "zh", "de", "es", "fr", "hu", "nl", "pl", "pt", "pt-BR", "ru", "sv", "uk"};
public SelectLanguageDialog() {
setSize(350, 130);

View File

@@ -223,7 +223,7 @@ public class SoundTagPlayer implements MediaDisplay {
if (active) {
clip.stop();
}
clip.setMicrosecondPosition(frame * FRAME_DIVISOR);
clip.setMicrosecondPosition((long) frame * FRAME_DIVISOR);
if (active) {
clip.start();

View File

@@ -182,7 +182,7 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
}
}
public synchronized void setClassIndex(int classIndex) {
public void setClassIndex(int classIndex) {
this.classIndex = classIndex;
}
@@ -529,16 +529,15 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
Highlighting tm = Highlighting.searchPos(methodHighlights, pos);
if (tm != null) {
String name = "";
if (abc != null) {
if (classIndex > -1) {
name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, false);
}
if (classIndex > -1) {
name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, false);
}
Trait currentTrait = null;
currentTraitHighlight = Highlighting.searchPos(traitHighlights, pos);
if (currentTraitHighlight != null) {
lastTraitIndex = (int) currentTraitHighlight.getProperties().index;
if ((abc != null) && (classIndex != -1)) {
if (classIndex != -1) {
currentTrait = getCurrentTrait();
isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex);
if (currentTrait != null) {
@@ -579,13 +578,11 @@ public class DecompiledEditorPane extends LineMarkedEditorPane implements CaretL
currentMethodHighlight = null;
String name = "";
currentTrait = null;
if (abc != null) {
name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, false);
currentTrait = getCurrentTrait();
isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex);
if (currentTrait != null) {
name += ":" + currentTrait.getName(abc).getName(abc.constants, new ArrayList<String>(), false);
}
name = abc.instance_info.get(classIndex).getName(abc.constants).getNameWithNamespace(abc.constants, false);
currentTrait = getCurrentTrait();
isStatic = abc.isStaticTraitId(classIndex, lastTraitIndex);
if (currentTrait != null) {
name += ":" + currentTrait.getName(abc).getName(abc.constants, new ArrayList<String>(), false);
}
displayMethod(pos, abc.findMethodIdByTraitId(classIndex, lastTraitIndex), name, currentTrait, isStatic);

View File

@@ -38,11 +38,7 @@ public class MethodTraitDetailPanel extends JPanel implements TraitDetail {
@Override
public boolean save() {
if (!methodCodePanel.save()) {
return false;
}
return true;
return methodCodePanel.save();
}
@Override

View File

@@ -17,12 +17,10 @@
package com.jpexs.decompiler.flash.gui.abc;
import com.jpexs.decompiler.flash.abc.ABC;
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.List;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.event.ListSelectionEvent;
@@ -68,10 +66,6 @@ public class TraitsList extends JList<Object> implements ListSelectionListener {
setClassIndex(-1, -1);
}
private List<ABCContainerTag> getAbcTags() {
return abc == null ? null : abc.getSwf().getAbcList();
}
public void setClassIndex(int classIndex, int scriptIndex) {
if (classIndex >= abc.instance_info.size()) {
return;
@@ -80,9 +74,7 @@ public class TraitsList extends JList<Object> implements ListSelectionListener {
if (classIndex == -1) {
setModel(new DefaultListModel<>());
} else {
if (abc != null) {
setModel(new TraitsListModel(abc, classIndex, scriptIndex, sorted));
}
setModel(new TraitsListModel(abc, classIndex, scriptIndex, sorted));
}
}

View File

@@ -597,7 +597,7 @@ public class ActionPanel extends JPanel implements ActionListener, SearchListene
splitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent pce) {
Configuration.guiActionSplitPaneDividerLocation.set((int) pce.getNewValue());
Configuration.guiActionSplitPaneDividerLocation.set((Integer) pce.getNewValue());
}
});

View File

@@ -138,10 +138,11 @@ public class PlayerControls extends JPanel implements ActionListener {
private static Font notUnderlinedFont = null;
static {
notUnderlinedFont = new JLabel().getFont();
Font font = new JLabel().getFont();
notUnderlinedFont = font;
Map<TextAttribute, Integer> fontAttributes = new HashMap<>();
fontAttributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
underlinedFont = notUnderlinedFont.deriveFont(fontAttributes);
underlinedFont = font.deriveFont(fontAttributes);
}
public PlayerControls(final MainPanel mainPanel, MediaDisplay display) {

View File

@@ -491,13 +491,6 @@ public class ProxyFrame extends AppFrame implements ActionListener, CatchedListe
Replacement r = replacements.get(sel[0]);
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File(Configuration.lastOpenDir.get()));
String n = r.urlPattern;
if (n.contains("?")) {
n = n.substring(0, n.indexOf('?'));
}
if (n.contains("/")) {
n = n.substring(n.lastIndexOf('/'));
}
String ext = ".swf";
final String extension = ext;
FileFilter swfFilter = new FileFilter() {

View File

@@ -43,31 +43,31 @@ public class TimelineBodyPanel extends JPanel implements MouseListener, KeyListe
private final Timeline timeLine;
public static Color motionTweenColor = new Color(0x59, 0xfe, 0x7c);
public static final Color motionTweenColor = new Color(0x59, 0xfe, 0x7c);
public static Color shapeTweenColor = new Color(0xd1, 0xac, 0xf1);
public static final Color shapeTweenColor = new Color(0xd1, 0xac, 0xf1);
public static Color frameColor = new Color(0xbd, 0xd8, 0xfc);
public static final Color frameColor = new Color(0xbd, 0xd8, 0xfc);
public static Color emptyFrameColor = Color.white;
public static final Color emptyFrameColor = Color.white;
public static Color emptyFrameSecondColor = new Color(0xea, 0xf2, 0xfc);
public static final Color emptyFrameSecondColor = new Color(0xea, 0xf2, 0xfc);
public static Color borderColor = Color.black;
public static final Color borderColor = Color.black;
public static Color emptyBorderColor = new Color(0xbd, 0xd8, 0xfc);
public static final Color emptyBorderColor = new Color(0xbd, 0xd8, 0xfc);
public static Color keyColor = Color.black;
public static final Color keyColor = Color.black;
public static Color aColor = Color.black;
public static final Color aColor = Color.black;
public static Color stopColor = Color.white;
public static final Color stopColor = Color.white;
public static Color stopBorderColor = Color.black;
public static final Color stopBorderColor = Color.black;
public static Color borderLinesColor = new Color(0xde, 0xde, 0xde);
public static final Color borderLinesColor = new Color(0xde, 0xde, 0xde);
public static Color selectedColor = new Color(113, 174, 235);
public static final Color selectedColor = new Color(113, 174, 235);
public static final int borderLinesLength = 2;

View File

@@ -44,11 +44,11 @@ public class TimelinePanel extends JPanel {
public static final int FRAME_HEIGHT = 18;
public static Color selectedColor = new Color(0xff, 0x99, 0x99);
public static final Color selectedColor = new Color(0xff, 0x99, 0x99);
public static Color selectedBorderColor = new Color(0xcc, 0, 0);
public static final Color selectedBorderColor = new Color(0xcc, 0, 0);
public static Color backgroundColor = new Color(0xd9, 0xe7, 0xfa);
public static final Color backgroundColor = new Color(0xd9, 0xe7, 0xfa);
public Timeline getTimeline() {
return timeline;