awt1.0 code eingebettet

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@359 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 3f9e77383d
commit 77f2fbe9d7
  1. 87
      jode/jode/JodeWindow.java

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

Loading…
Cancel
Save