[Title] Add console title change function.
authorgyeongseok.seo <gyeongseok.seo@samsung.com>
Mon, 28 Nov 2011 12:17:58 +0000 (21:17 +0900)
committergyeongseok.seo <gyeongseok.seo@samsung.com>
Mon, 28 Nov 2011 12:23:07 +0000 (21:23 +0900)
[Type] Enhancement
[Module] common-ide-eplugin
[Priority] Major
[CQ#]
[Redmine#] 3497
[Problem] one time set name, then we can't changed...
[Cause] function not exist.
[Solution] java refrection
[TestCase] IDE

Change-Id: I34fdd9ca4b45158c08914ce944a1b3f116513ae1

com.samsung.tizen.common/src/com/samsung/tizen/common/console/ConsoleManager.java

index 451fb23..a03d0d9 100644 (file)
@@ -18,6 +18,7 @@
 
 package com.samsung.tizen.common.console;
 import java.io.IOException;
+import java.lang.reflect.Method;
 
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.swt.SWT;
@@ -34,7 +35,11 @@ import org.eclipse.ui.console.IConsoleView;
 import org.eclipse.ui.console.MessageConsole;
 import org.eclipse.ui.console.MessageConsoleStream;
 
-
+/**
+ * ConsoleManager.
+ * @author YoonKi Park {@literal <yoonki.park@samsung.com>} (S-Core)
+ * @author GyeongSeok Seo {@literal <gyeongseok.seo@samsung.com>} (S-Core)
+ */
 public class ConsoleManager
 {
        private IConsoleManager consoleManager;
@@ -57,6 +62,31 @@ public class ConsoleManager
                this.console = getMessageConsole();
        }
 
+       /**
+        * Change Console Name.
+        *
+        * @param newName - console Title. It shown console's tab bar. 
+        * @author Gyeongseok.seo@samsung.com
+        */
+       public void changeConsolName(String newName) throws NoSuchFieldException, IllegalAccessException {
+               this.consoleName = newName;
+               Runnable runnable = new Runnable() {
+                       public void run() {
+                               Class<?> cls;
+                               Method method;
+                               try {
+                                       cls = Class.forName("org.eclipse.ui.console.AbstractConsole");
+                                       method = cls.getDeclaredMethod("setName", String.class);
+                                       method.setAccessible(true);
+                                       method.invoke(getConsole(), consoleName);
+                               } catch (Exception e) {
+                                       ConsolePlugin.log(e);
+                               }
+                       }
+               };
+               Display.getDefault().syncExec(runnable);
+       }
+
        private MessageConsole getMessageConsole(){
                boolean found = false;