raw edit fix

This commit is contained in:
2015-02-03 18:59:05 +01:00
parent 74a101e1ea
commit 1fb58e6dd8
7 changed files with 52 additions and 40 deletions
@@ -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) {
@@ -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
*
+12 -27
View File
@@ -111,7 +111,7 @@ public class Main {
private static List<SWFSourceInfo> 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() {
@@ -2310,7 +2310,7 @@ public final class MainPanel extends JPanel implements ActionListener, TreeSelec
public void loadFromBinaryTag(final List<DefineBinaryDataTag> 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();
}