01: package tide.exttools;
02:
03: import tide.exttools.checkstyle.CheckStyleSettingsDialog;
04: import tide.exttools.checkstyle.CheckStyleLauncher;
05: import tide.project.ProjectSettings;
06: import tide.exttools.PMD.PMDLauncher;
07: import java.util.*;
08: import tide.sources.SourceFile;
09: import tide.exttools.PMD.PMDSettingsDialog;
10: import tide.editor.*;
11:
12: /** First purpose: manage interdependencies of tools that are set to autoupdate.
13: * (first apply tools that changes source, as astyle and then source and class tools)
14: */
15: public final class ToolsAutoApplyManager implements
16: ChangedFilesSaveListener {
17: static ToolsAutoApplyManager instance;
18:
19: private ToolsAutoApplyManager() {
20: MainEditorFrame.instance.editorPanel
21: .addChangedFilesSaveListener(this );
22: //MainEditorFrame.instance Add compilation listener !!! (TODO)
23: }
24:
25: public static synchronized ToolsAutoApplyManager getInstance() {
26: if (instance == null) {
27: instance = new ToolsAutoApplyManager();
28: }
29: return instance;
30: }
31:
32: /** ChangedFilesSaveListener interface. Called on source change commit (save, caused by save, compile, ...)
33: */
34: public void filesSaved(final Set<SourceFile> sources) {
35: ProjectSettings settings = MainEditorFrame.instance
36: .getActualProject();
37:
38: if (PMDSettingsDialog.isConfigured()) {
39: if (settings.getBooleanProperty("pmd_autoApplyOnChanges",
40: false)) {
41: PMDLauncher.getInstance().filesSaved(sources);
42: }
43: }
44:
45: if (CheckStyleSettingsDialog.isConfigured()) {
46: if (settings.getBooleanProperty(
47: "CheckStyle_autoApplyOnChanges", false)) {
48: CheckStyleLauncher.getInstance().filesSaved(sources);
49: }
50: }
51: }
52:
53: }
|