001: package tide.exttools.jad_decompiler;
002:
003: import javax.swing.text.JTextComponent;
004: import tide.project.*;
005: import tide.editor.*;
006: import javax.swing.*;
007: import java.awt.*;
008: import java.awt.event.*;
009: import javax.swing.border.*;
010: import java.util.*;
011: import java.io.*;
012: import snow.utils.*;
013: import snow.utils.storage.*;
014: import snow.utils.gui.*;
015:
016: /** JAD is not perfect.
017: * example: EventQueue.class => unknown opcodes, ...
018: */
019: public class JADDecompilerSettingsDialog extends JDialog {
020: private final FileField jadPath = new FileField("", false,
021: "Please specify the jad executable",
022: JFileChooser.FILES_ONLY);
023:
024: private final JCheckBox applyJadToClassFilesCB = new JCheckBox(
025: "Apply jad on lib classes per default (instead of viewing bytecode)",
026: false);
027: public boolean dialogWasAccepted = false;
028:
029: public final static String defaultJadLocation = "c:/java/jad/jad.exe";
030: public final static String homepage = "http://www.kpdus.com/jad.html";
031:
032: public JADDecompilerSettingsDialog(final JFrame parent,
033: final ProjectSettings settings) {
034: super (parent, "JAD Decompiler", true);
035:
036: JTextComponent ta = GUIUtils
037: .createReadOnlyDescriptionArea("JAD is an external tool used to decompile class files."
038: + "\r\nIt is available for free on "
039: + homepage
040: + "\n\nTo use the decompiler, just right-click on class files in the ClassPath tab.");
041: add(ta, BorderLayout.NORTH);
042:
043: JPanel inputPanel = new JPanel();
044: add(inputPanel, BorderLayout.CENTER);
045: GridLayout3 gl3 = new GridLayout3(2, inputPanel);
046: gl3.addSeparator();
047:
048: gl3.add("JAD application");
049: gl3.add(jadPath);
050: jadPath.setPath(settings.getProperty("JAD_path",
051: defaultJadLocation));
052: jadPath.offerRememberedGlobalCompletion(
053: MainEditorFrame.instance.globalProperties, "knownJADs");
054: jadPath.setComponentWidth(300);
055: jadPath.setAutoColorized();
056: if (SysUtils.is_Windows_OS()) {
057: jadPath.allowedExtensions.add("exe");
058: jadPath.fileTypeDescription = "Windows executables";
059: }
060:
061: gl3.addTitleSeparator("Options");
062: gl3.add("");
063: gl3.add(applyJadToClassFilesCB);
064: applyJadToClassFilesCB.setSelected(settings.getBooleanProperty(
065: "JAD_applyJadToClassFilesCB", false));
066:
067: CloseControlPanel ccp = new CloseControlPanel(this , true, true,
068: "Ok");
069: add(ccp, BorderLayout.SOUTH);
070:
071: pack();
072: this .setLocationRelativeTo(parent);
073: this .setVisible(true); // MODAL => waits
074:
075: if (ccp.getWasCancelled())
076: return;
077: dialogWasAccepted = true;
078:
079: // save settings
080: settings.setProperty("JAD_path", jadPath.getPath()
081: .getAbsolutePath());
082: settings.setBooleanProperty("JAD_applyJadToClassFilesCB",
083: applyJadToClassFilesCB.isSelected());
084:
085: jadPath.rememberPathForGlobalCompletion(
086: MainEditorFrame.instance.globalProperties, "knownJADs");
087:
088: }
089:
090: /** @return true if Lint4j path is present.
091: Used to detect if a setup dialog should be shown when starting the tool (if not found).
092: */
093: public static boolean isConfigured() {
094: ProjectSettings actualProject = MainEditorFrame.instance
095: .getActualProject();
096: return new File(actualProject.getProperty("JAD_path",
097: defaultJadLocation)).exists();
098: }
099:
100: /*test public static void main(String[] aa)
101: {
102: JFrame f = new JFrame("Test");
103: f.setDefaultCloseOperation(f.EXIT_ON_CLOSE);
104: ProjectSettings props = new ProjectSettings();
105: new JADDecompilerSettingsDialog(f, props);
106: System.exit(0);
107: }*/
108: }
|