001: package tide.staticanalysis;
002:
003: import javax.swing.border.EmptyBorder;
004: import tide.editor.MainEditorFrame;
005: import java.awt.BorderLayout;
006: import snow.utils.gui.*;
007: import javax.swing.*;
008:
009: public final class StaticAnalysisSettingsDialog extends JDialog {
010: public StaticAnalysisSettingsDialog() {
011: super (MainEditorFrame.instance, "Static analysis settings",
012: true);
013:
014: CloseControlPanel ccp = new CloseControlPanel(this , true, true,
015: "Ok");
016: add(ccp, BorderLayout.SOUTH);
017:
018: JPanel cpPanel = new JPanel();
019: add(cpPanel, BorderLayout.CENTER);
020: GridLayout3 gl3 = new GridLayout3(2, cpPanel);
021: cpPanel.setBorder(new EmptyBorder(5, 2, 2, 2));
022:
023: gl3
024: .addExplanationArea("tIDE's integrated analysis uses the java source parser, reflection and the asm bytecode visitor."
025: + "\nIt adds support for tIDE's own annotations @Recurse, @SubclassMustInvoke and @Implements."
026: + "\nIt has several other check functions but does not aim to be a global static checker."
027: + "\nYou should also continue to use PMD, findbugs and other checkers."
028: + "\n\nNote: @Override checking is made by the compiler. Here we just detect missing @Override."
029: + "\nNote: The tIDE own annotation can be used in all projects: for example you just have to create an annotation,"
030: + "\n somewhere, named @Recurse and use it."
031:
032: );
033:
034: gl3.addTitleSeparator("Checkers");
035:
036: // check @Override is made by the compiler
037: final JCheckBox cbMissingOverride = new JCheckBox(
038: "detect missing @Override",
039: StaticAnalysis.detectMissingOverrides);
040: gl3.add(cbMissingOverride);
041: gl3.addTF("High");
042:
043: final JCheckBox cbDetectStaticOverloads = new JCheckBox(
044: "detect static overloads",
045: StaticAnalysis.detectStaticOverloads);
046: gl3.add(cbDetectStaticOverloads);
047: gl3.addTF("Medium");
048:
049: final JCheckBox cbDetectNearOverrides = new JCheckBox(
050: "detect near overrides",
051: StaticAnalysis.detectNearOverrides);
052: gl3.add(cbDetectNearOverrides);
053: gl3.addTF("Low");
054:
055: final JCheckBox detectPrivateOverloads = new JCheckBox(
056: "detect private overloads",
057: StaticAnalysis.detectPrivateOverloads);
058: gl3.add(detectPrivateOverloads);
059: gl3.addTF("Medium");
060:
061: gl3.addSeparator();
062:
063: final JCheckBox detectOverrideMustInvoke = new JCheckBox(
064: "detect failing @OverrideMustInvoke",
065: StaticAnalysis.detectOverrideMustInvoke);
066: gl3.add(detectOverrideMustInvoke);
067: gl3.addTF("High");
068:
069: gl3.addSeparator();
070:
071: final JCheckBox detectRecurseAnn = new JCheckBox(
072: "check @Recurse and @NonRecurse",
073: StaticAnalysis.detectRecurseAnn);
074: gl3.add(detectRecurseAnn);
075: gl3.addTF("High");
076:
077: final JCheckBox detectMissingRecurseAnn = new JCheckBox(
078: "detect missing @Recurse",
079: StaticAnalysis.detectMissingRecurseAnn);
080: gl3.add(detectMissingRecurseAnn);
081: gl3.addTF("Low");
082:
083: gl3.addSeparator();
084:
085: final JCheckBox detectImplementsAnn = new JCheckBox(
086: "check @Implements", StaticAnalysis.detectImplementsAnn);
087: gl3.add(detectImplementsAnn);
088: gl3.addTF("Low: Experimental, use to mark intentions");
089:
090: gl3.addTitleSeparator("Integration");
091:
092: final JCheckBox autoApplyAfterComp = new JCheckBox(
093: "Autoapply after each compilation", false);
094: autoApplyAfterComp.setEnabled(false);
095: gl3.add(autoApplyAfterComp);
096: gl3
097: .addTF("comming soon... stay informed on tIDE's homepage !");
098:
099: pack();
100: setLocationRelativeTo(null);
101: setVisible(true); // MODAL
102:
103: if (ccp.getWasCancelled())
104: return;
105:
106: // write back
107: StaticAnalysis.detectMissingOverrides = cbMissingOverride
108: .isSelected();
109: StaticAnalysis.detectStaticOverloads = cbDetectStaticOverloads
110: .isSelected();
111: StaticAnalysis.detectNearOverrides = cbDetectNearOverrides
112: .isSelected();
113: StaticAnalysis.detectPrivateOverloads = detectPrivateOverloads
114: .isSelected();
115:
116: StaticAnalysis.detectOverrideMustInvoke = detectOverrideMustInvoke
117: .isSelected();
118:
119: StaticAnalysis.detectRecurseAnn = detectRecurseAnn.isSelected();
120: StaticAnalysis.detectMissingRecurseAnn = detectMissingRecurseAnn
121: .isSelected();
122:
123: StaticAnalysis.detectImplementsAnn = detectImplementsAnn
124: .isSelected();
125:
126: // and save.
127: if (MainEditorFrame.instance != null) {
128: StaticAnalysis.saveSettings(MainEditorFrame.instance
129: .getActualProject());
130: }
131:
132: }
133:
134: public static void main(String[] args) {
135: // Strange: when run standalone, one can resize it below its actual size.
136: // when ran in the ide, on can't !!!!!! :-(... ???
137: new StaticAnalysisSettingsDialog();
138: }
139:
140: }
|