|
|
@ -1,12 +1,18 @@ |
|
|
|
package jode; |
|
|
|
package jode; |
|
|
|
import java.applet.*; |
|
|
|
import java.applet.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
|
|
|
|
|
///#ifndef AWT10
|
|
|
|
import java.awt.event.*; |
|
|
|
import java.awt.event.*; |
|
|
|
|
|
|
|
///#endif
|
|
|
|
import java.io.*; |
|
|
|
import java.io.*; |
|
|
|
import jode.decompiler.TabbedPrintWriter; |
|
|
|
import jode.decompiler.TabbedPrintWriter; |
|
|
|
|
|
|
|
|
|
|
|
public class JodeWindow |
|
|
|
public class JodeWindow |
|
|
|
implements ActionListener, Runnable |
|
|
|
implements Runnable |
|
|
|
|
|
|
|
///#ifndef AWT10
|
|
|
|
|
|
|
|
, ActionListener |
|
|
|
|
|
|
|
///#endif
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
TextField classpathField, classField; |
|
|
|
TextField classpathField, classField; |
|
|
|
TextArea sourcecodeArea, errorArea; |
|
|
|
TextArea sourcecodeArea, errorArea; |
|
|
@ -32,12 +38,17 @@ public class JodeWindow |
|
|
|
prettyCheck = new Checkbox("pretty", false); |
|
|
|
prettyCheck = new Checkbox("pretty", false); |
|
|
|
startButton = new Button("start"); |
|
|
|
startButton = new Button("start"); |
|
|
|
saveButton = new Button("save"); |
|
|
|
saveButton = new Button("save"); |
|
|
|
|
|
|
|
///#ifdef AWT10
|
|
|
|
|
|
|
|
/// saveButton.disable();
|
|
|
|
|
|
|
|
///#else
|
|
|
|
saveButton.setEnabled(false); |
|
|
|
saveButton.setEnabled(false); |
|
|
|
|
|
|
|
///#endif
|
|
|
|
|
|
|
|
|
|
|
|
sourcecodeArea.setEditable(false); |
|
|
|
sourcecodeArea.setEditable(false); |
|
|
|
errorArea.setEditable(false); |
|
|
|
errorArea.setEditable(false); |
|
|
|
|
|
|
|
|
|
|
|
window.setLayout(new GridBagLayout()); |
|
|
|
GridBagLayout gbl = new GridBagLayout(); |
|
|
|
|
|
|
|
window.setLayout(gbl); |
|
|
|
GridBagConstraints labelConstr = new GridBagConstraints(); |
|
|
|
GridBagConstraints labelConstr = new GridBagConstraints(); |
|
|
|
GridBagConstraints textConstr = new GridBagConstraints(); |
|
|
|
GridBagConstraints textConstr = new GridBagConstraints(); |
|
|
|
GridBagConstraints areaConstr = new GridBagConstraints(); |
|
|
|
GridBagConstraints areaConstr = new GridBagConstraints(); |
|
|
@ -59,8 +70,37 @@ public class JodeWindow |
|
|
|
areaConstr.weightx = 1.0; |
|
|
|
areaConstr.weightx = 1.0; |
|
|
|
areaConstr.weighty = 1.0; |
|
|
|
areaConstr.weighty = 1.0; |
|
|
|
|
|
|
|
|
|
|
|
window.add(new Label("class path: "), labelConstr); |
|
|
|
///#ifdef AWT10
|
|
|
|
window.add(classpathField, textConstr); |
|
|
|
/// Label label = new Label("class path: ");
|
|
|
|
|
|
|
|
/// gbl.setConstraints(label, labelConstr);
|
|
|
|
|
|
|
|
/// window.add(label);
|
|
|
|
|
|
|
|
/// gbl.setConstraints(classpathField, textConstr);
|
|
|
|
|
|
|
|
/// window.add(classpathField);
|
|
|
|
|
|
|
|
/// label = new Label("class name: ");
|
|
|
|
|
|
|
|
/// gbl.setConstraints(label, labelConstr);
|
|
|
|
|
|
|
|
/// window.add(label);
|
|
|
|
|
|
|
|
/// gbl.setConstraints(classField, textConstr);
|
|
|
|
|
|
|
|
/// window.add(classField);
|
|
|
|
|
|
|
|
/// gbl.setConstraints(verboseCheck, checkConstr);
|
|
|
|
|
|
|
|
/// window.add(verboseCheck);
|
|
|
|
|
|
|
|
/// gbl.setConstraints(prettyCheck, checkConstr);
|
|
|
|
|
|
|
|
/// window.add(prettyCheck);
|
|
|
|
|
|
|
|
/// labelConstr.weightx = 1.0;
|
|
|
|
|
|
|
|
/// label = new Label();
|
|
|
|
|
|
|
|
/// gbl.setConstraints(label, labelConstr);
|
|
|
|
|
|
|
|
/// window.add(label);
|
|
|
|
|
|
|
|
/// gbl.setConstraints(startButton, buttonConstr);
|
|
|
|
|
|
|
|
/// window.add(startButton);
|
|
|
|
|
|
|
|
/// buttonConstr.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
|
|
|
|
|
/// gbl.setConstraints(saveButton, buttonConstr);
|
|
|
|
|
|
|
|
/// window.add(saveButton);
|
|
|
|
|
|
|
|
/// gbl.setConstraints(sourcecodeArea, areaConstr);
|
|
|
|
|
|
|
|
/// window.add(sourcecodeArea);
|
|
|
|
|
|
|
|
/// areaConstr.gridheight = GridBagConstraints.REMAINDER;
|
|
|
|
|
|
|
|
/// areaConstr.weighty = 0.0;
|
|
|
|
|
|
|
|
/// gbl.setConstraints(errorArea, areaConstr);
|
|
|
|
|
|
|
|
/// window.add(errorArea);
|
|
|
|
|
|
|
|
///#else
|
|
|
|
window.add(new Label("class name: "), labelConstr); |
|
|
|
window.add(new Label("class name: "), labelConstr); |
|
|
|
window.add(classField, textConstr); |
|
|
|
window.add(classField, textConstr); |
|
|
|
window.add(verboseCheck, checkConstr); |
|
|
|
window.add(verboseCheck, checkConstr); |
|
|
@ -77,6 +117,7 @@ public class JodeWindow |
|
|
|
|
|
|
|
|
|
|
|
startButton.addActionListener(this); |
|
|
|
startButton.addActionListener(this); |
|
|
|
saveButton.addActionListener(this); |
|
|
|
saveButton.addActionListener(this); |
|
|
|
|
|
|
|
///#endif
|
|
|
|
Decompiler.err = new PrintStream(new AreaOutputStream(errorArea)); |
|
|
|
Decompiler.err = new PrintStream(new AreaOutputStream(errorArea)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -87,13 +128,23 @@ public class JodeWindow |
|
|
|
classField.setText(cls); |
|
|
|
classField.setText(cls); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///#ifdef AWT10
|
|
|
|
|
|
|
|
/// public synchronized void action(Object target) {
|
|
|
|
|
|
|
|
///#else
|
|
|
|
public synchronized void actionPerformed(ActionEvent e) { |
|
|
|
public synchronized void actionPerformed(ActionEvent e) { |
|
|
|
if (e.getSource() == startButton) { |
|
|
|
Object target = e.getSource(); |
|
|
|
|
|
|
|
///#endif
|
|
|
|
|
|
|
|
if (target == startButton) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///#ifdef AWT10
|
|
|
|
|
|
|
|
/// startButton.disable();
|
|
|
|
|
|
|
|
///#else
|
|
|
|
startButton.setEnabled(false); |
|
|
|
startButton.setEnabled(false); |
|
|
|
|
|
|
|
///#endif
|
|
|
|
decompileThread = new Thread(this); |
|
|
|
decompileThread = new Thread(this); |
|
|
|
sourcecodeArea.setText("Please wait, while decompiling...\n"); |
|
|
|
sourcecodeArea.setText("Please wait, while decompiling...\n"); |
|
|
|
decompileThread.start(); |
|
|
|
decompileThread.start(); |
|
|
|
} else if (e.getSource() == saveButton) { |
|
|
|
} else if (target == saveButton) { |
|
|
|
if (frame == null) |
|
|
|
if (frame == null) |
|
|
|
frame = new Frame(); //XXX
|
|
|
|
frame = new Frame(); //XXX
|
|
|
|
FileDialog fd = new FileDialog(frame, |
|
|
|
FileDialog fd = new FileDialog(frame, |
|
|
@ -127,11 +178,19 @@ public class JodeWindow |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void write(int b) throws IOException { |
|
|
|
public void write(int b) throws IOException { |
|
|
|
area.append(String.valueOf((byte)b)); |
|
|
|
///#ifdef AWT10
|
|
|
|
|
|
|
|
/// area.appendText(String.valueOf((char)b));
|
|
|
|
|
|
|
|
///#else
|
|
|
|
|
|
|
|
area.append(String.valueOf((char)b)); |
|
|
|
|
|
|
|
///#endif
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void write(byte[] b, int off, int len) throws IOException { |
|
|
|
public void write(byte[] b, int off, int len) throws IOException { |
|
|
|
|
|
|
|
///#ifdef AWT10
|
|
|
|
|
|
|
|
/// area.appendText(new String(b, off, len));
|
|
|
|
|
|
|
|
///#else
|
|
|
|
area.append(new String(b, off, len)); |
|
|
|
area.append(new String(b, off, len)); |
|
|
|
|
|
|
|
///#endif
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -139,7 +198,11 @@ public class JodeWindow |
|
|
|
Decompiler.isVerbose = verboseCheck.getState(); |
|
|
|
Decompiler.isVerbose = verboseCheck.getState(); |
|
|
|
Decompiler.prettyLocals = prettyCheck.getState(); |
|
|
|
Decompiler.prettyLocals = prettyCheck.getState(); |
|
|
|
errorArea.setText(""); |
|
|
|
errorArea.setText(""); |
|
|
|
|
|
|
|
///#ifdef AWT10
|
|
|
|
|
|
|
|
/// saveButton.disable();
|
|
|
|
|
|
|
|
///#else
|
|
|
|
saveButton.setEnabled(false); |
|
|
|
saveButton.setEnabled(false); |
|
|
|
|
|
|
|
///#endif
|
|
|
|
|
|
|
|
|
|
|
|
lastClassName = classField.getText(); |
|
|
|
lastClassName = classField.getText(); |
|
|
|
String cp = classpathField.getText(); |
|
|
|
String cp = classpathField.getText(); |
|
|
@ -151,7 +214,11 @@ public class JodeWindow |
|
|
|
TabbedPrintWriter writer = new TabbedPrintWriter(out); |
|
|
|
TabbedPrintWriter writer = new TabbedPrintWriter(out); |
|
|
|
env.doClass(lastClassName, writer); |
|
|
|
env.doClass(lastClassName, writer); |
|
|
|
sourcecodeArea.setText(out.toString()); |
|
|
|
sourcecodeArea.setText(out.toString()); |
|
|
|
|
|
|
|
///#ifdef AWT10
|
|
|
|
|
|
|
|
/// saveButton.enable();
|
|
|
|
|
|
|
|
///#else
|
|
|
|
saveButton.setEnabled(true); |
|
|
|
saveButton.setEnabled(true); |
|
|
|
|
|
|
|
///#endif
|
|
|
|
} catch (Throwable t) { |
|
|
|
} catch (Throwable t) { |
|
|
|
sourcecodeArea.setText("Didn't succeed.\n" |
|
|
|
sourcecodeArea.setText("Didn't succeed.\n" |
|
|
|
+"Check the below area for more info."); |
|
|
|
+"Check the below area for more info."); |
|
|
@ -159,7 +226,11 @@ public class JodeWindow |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
synchronized(this) { |
|
|
|
synchronized(this) { |
|
|
|
decompileThread = null; |
|
|
|
decompileThread = null; |
|
|
|
|
|
|
|
///#ifdef AWT10
|
|
|
|
|
|
|
|
/// startButton.enable();
|
|
|
|
|
|
|
|
///#else
|
|
|
|
startButton.setEnabled(true); |
|
|
|
startButton.setEnabled(true); |
|
|
|
|
|
|
|
///#endif
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -174,11 +245,13 @@ public class JodeWindow |
|
|
|
String cls = win.getClass().getName(); |
|
|
|
String cls = win.getClass().getName(); |
|
|
|
win.setClass(cls); |
|
|
|
win.setClass(cls); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///#ifndef AWT10
|
|
|
|
frame.addWindowListener(new WindowAdapter() { |
|
|
|
frame.addWindowListener(new WindowAdapter() { |
|
|
|
public void windowClosing(WindowEvent e) { |
|
|
|
public void windowClosing(WindowEvent e) { |
|
|
|
System.exit(0); |
|
|
|
System.exit(0); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
///#endif
|
|
|
|
frame.pack(); |
|
|
|
frame.pack(); |
|
|
|
frame.show(); |
|
|
|
frame.show(); |
|
|
|
} |
|
|
|
} |
|
|
|