mail[Wesnoth-commits] r44545 - in /trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin: handlers/TestHandler.java utils/GUIUtils.java


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by timotei_cluj on July 22, 2010 - 19:34:
Author: timotei
Date: Thu Jul 22 19:34:50 2010
New Revision: 44545

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44545&view=rev
Log:
eclipse plugin: prevent opening multiple console for the same thing. instead 
return the already created one

Modified:
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/TestHandler.java
    
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/GUIUtils.java

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/TestHandler.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/TestHandler.java?rev=44545&r1=44544&r2=44545&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/TestHandler.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/handlers/TestHandler.java
 Thu Jul 22 19:34:50 2010
@@ -8,9 +8,15 @@
  
*******************************************************************************/
 package wesnoth_eclipse_plugin.handlers;
 
+import java.io.IOException;
+import java.io.OutputStream;
+
 import org.eclipse.core.commands.AbstractHandler;
 import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.console.MessageConsole;
+
+import wesnoth_eclipse_plugin.utils.GUIUtils;
 
 /**
  * Here it goes testing stuff in the plugin ( For DEBUG ONLY!)
@@ -21,6 +27,16 @@
        @Override
        public Object execute(ExecutionEvent event) throws ExecutionException
        {
+               try
+               {
+                       MessageConsole con = GUIUtils.createConsole("BB", 
null, true);
+                       OutputStream s =  con.newMessageStream();
+                       s.write("AAAAAAAAAAAAAA".getBytes());
+               }
+               catch (IOException e)
+               {
+                       e.printStackTrace();
+               }
 //             try
 //             {
 //                     IProject proj = WorkspaceUtils.getSelectedProject();

Modified: 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/GUIUtils.java
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/GUIUtils.java?rev=44545&r1=44544&r2=44545&view=diff
==============================================================================
--- 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/GUIUtils.java
 (original)
+++ 
trunk/utils/java/eclipse_plugin/src/wesnoth_eclipse_plugin/utils/GUIUtils.java
 Thu Jul 22 19:34:50 2010
@@ -14,6 +14,7 @@
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.console.ConsolePlugin;
 import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleManager;
 import org.eclipse.ui.console.MessageConsole;
 
 import wesnoth_eclipse_plugin.Logger;
@@ -116,12 +117,24 @@
        public static MessageConsole createConsole(String consoleTitle,
                                ImageDescriptor imageDescriptor, boolean 
activate)
        {
-               MessageConsole console = new MessageConsole(consoleTitle, 
imageDescriptor);
+               MessageConsole console = null;
+               IConsoleManager conMan = 
ConsolePlugin.getDefault().getConsoleManager();
+               IConsole[] existing = conMan.getConsoles();
+               for (int i = 0; i < existing.length; i++)
+                       if (consoleTitle.equals(existing[i].getName()))
+                       {
+                               console = (MessageConsole) existing[i];
+                               console.clearConsole();
+                               break;
+                       }
+
+               if (console == null) // console not found
+               {
+                       console = new MessageConsole(consoleTitle, 
imageDescriptor);
+                       conMan.addConsoles(new IConsole[] { console });
+               }
                if (activate)
                        console.activate();
-               
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { 
console });
-               //TODO: create a single console and add pages instead?
-               //MessageConsoleStream stream = console.newMessageStream();
                return console;
        }
 }




Related Messages


Powered by MHonArc, Updated Thu Jul 22 19:40:12 2010