]> source.dussan.org Git - aspectj.git/commitdiff
fix for pr102479, allow clients to provide a custom message handler / holder to be...
authoracolyer <acolyer>
Thu, 1 Sep 2005 17:09:49 +0000 (17:09 +0000)
committeracolyer <acolyer>
Thu, 1 Sep 2005 17:09:49 +0000 (17:09 +0000)
ajde/src/org/aspectj/ajde/Ajde.java
ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java

index fd08eeccc417b23ef1b3fc14ded0e7ce1ad07f12..06a382e1dabbb32037f65214fe38aed19ae19325 100644 (file)
@@ -21,6 +21,7 @@ import org.aspectj.ajde.ui.StructureSearchManager;
 import org.aspectj.ajde.ui.StructureViewManager;
 import org.aspectj.ajde.ui.StructureViewNodeFactory;
 import org.aspectj.asm.AsmManager;
+import org.aspectj.bridge.IMessageHandler;
 import org.aspectj.bridge.Version;
 import org.aspectj.util.LangUtil;
 import org.aspectj.util.Reflection;
@@ -53,6 +54,7 @@ public class Ajde {
        private IdeUIAdapter ideUIAdapter;
        private ErrorHandler errorHandler;
        private PrintStream logPrintStream = null;
+       private IMessageHandler messageHandler = null; // allow provision of custom handler
        
        /**
         * This class can only be constructured by itself (as a singleton) or by sub-classes. 
@@ -114,6 +116,19 @@ public class Ajde {
        public void setConfigurationManager(BuildConfigManager configurationManager) {
                this.configurationManager = configurationManager;       
        }
+       
+       /**
+        * Call this method with a custom IMessageHandler to override the default message
+        * handling.
+        * @param aHandler
+        */
+       public void setMessageHandler(IMessageHandler aHandler) {
+               this.messageHandler = aHandler;
+       }
+       
+       public IMessageHandler getMessageHandler() {
+               return messageHandler;
+       }
 
        public BuildManager getBuildManager() {
                return buildManager;
index 13dc99cf0c66fa3af99a440eac1cde4011242bb8..504f2b927ae176324fb13004f5f9793a82ebc226 100644 (file)
@@ -45,7 +45,7 @@ public class CompilerAdapter {
        
 //     private Map optionsMap;
        private AjBuildManager buildManager = null;
-    private MessageHandlerAdapter messageHandler = null;
+    private IMessageHandler messageHandler = null;
     private BuildNotifierAdapter currNotifier = null;
        private boolean initialized = false;
        private boolean structureDirty = true;
@@ -99,7 +99,6 @@ public class CompilerAdapter {
                        buildConfig.setGenerateModelMode(buildModel);
                        currNotifier = new BuildNotifierAdapter(progressMonitor, buildManager);         
                        buildManager.setProgressListener(currNotifier);
-                       messageHandler.setBuildNotifierAdapter(currNotifier);
                        
                        String rtInfo = buildManager.checkRtJar(buildConfig); // !!! will get called twice
                        if (rtInfo != null) {
@@ -600,7 +599,11 @@ public class CompilerAdapter {
        private void init() {
                if (!initialized) {  // XXX plug into AJDE initialization
 //                     Ajde.getDefault().setErrorHandler(new DebugErrorHandler());
-                       this.messageHandler = new MessageHandlerAdapter();
+                       if (Ajde.getDefault().getMessageHandler() != null) {
+                               this.messageHandler = Ajde.getDefault().getMessageHandler();
+                       } else {
+                               this.messageHandler = new MessageHandlerAdapter();
+                       }
                        buildManager = new AjBuildManager(messageHandler);
             // XXX need to remove the properties file each time!
                        initialized = true;
@@ -609,8 +612,7 @@ public class CompilerAdapter {
        
        class MessageHandlerAdapter extends MessageHandler {
                private TaskListManager taskListManager;
-               private BuildNotifierAdapter buildNotifierAdapter;
-               
+
                public MessageHandlerAdapter() {
                        this.taskListManager = Ajde.getDefault().getTaskListManager();
                }       
@@ -625,10 +627,6 @@ public class CompilerAdapter {
                        taskListManager.addSourcelineTask(message);
                        return super.handleMessage(message); // also store...   
                }
-        // --------------- adje methods
-               public void setBuildNotifierAdapter(BuildNotifierAdapter buildNotifierAdapter) {
-                       this.buildNotifierAdapter = buildNotifierAdapter;
-               }
        }
 
        public void setState(AjState buildState) {