ConsoleManager2
implements ITizenConsoleManager, IHyperlinkManager
{
-
- /**
- * MessageConsole to be delegated
- */
- protected final MessageConsoleSpy console;
-
- /**
- * Link manager
- */
- protected final HyperlinkManager hyperlinkManager;
-
- /**
- * console's name
- *
- * @see {@link IConsole#setName(String)}
- */
- private String consoleName;
-
- /**
- * document model's virtual length
- */
- protected int documentLength = 0;
-
- /**
- * Constructs a new console manager.
- *
- * @param consoleName - the key title
- * @param focus - true if focus on console, false if not
- */
- public
- ConsoleManager2(
- final String consoleName,
- final boolean focus
- )
- {
- this.consoleName = consoleName;
- this.console = createMessageConsole();
- this.hyperlinkManager = new HyperlinkManager( console );
- this.console.getDocument().addDocumentListener( hyperlinkManager );
-
- if ( focus )
- {
- getConsoleManager().showConsoleView(console);
- }
-
- setName( consoleName );
- }
-
- /**
- * return {@link IConsoleManager} from {@link ConsolePlugin}
- *
- * @return {@link IConsoleManager}
- *
- * @see ConsolePlugin#getConsoleManager()
- */
- protected IConsoleManager getConsoleManager()
- {
- return ConsolePlugin.getDefault().getConsoleManager();
- }
-
- /**
- * return <code>IConsole</code>s to be attached to {@link IConsoleManager}
- *
- * @return <code>IConsole</code>s
- *
- * @see #getConsoleManager()
- * @see IConsoleManager#getConsoles()
- */
- protected IConsole[] getConsoles()
- {
- return getConsoleManager().getConsoles();
- }
-
-
- /**
- * Change Console Name.
- *
- * @param newName - console Title. It shown console's tab bar.
- * @author Gyeongseok.seo@samsung.com
- */
- public void
- setName(
- final String newName
- )
- {
- Assert.notNull( newName );
- this.consoleName = newName;
- asyncExec( new Runnable()
- {
- public void run()
- {
- if ( null == console )
- {
- return ;
- }
- console.setName(newName);
- }
- } );
- }
-
- /**
- * Create message console
- *
- * @return Message console for emulator
- */
- synchronized protected MessageConsoleSpy createMessageConsole()
- {
- // Delete Old Console from console view
- final IConsole[] consoles = getConsoles();
- for ( int i = 0, n = consoles.length ; i < n ; ++i )
- {
- if ( !this.consoleName.equals(consoles[i].getName() ) )
- {
- continue;
- }
- getConsoleManager().removeConsoles( new IConsole[] { console } );
- }
+
+ /**
+ * MessageConsole to be delegated
+ */
+ protected final MessageConsoleSpy console;
+
+ /**
+ * Link manager
+ */
+ protected final HyperlinkManager hyperlinkManager;
+
+ /**
+ * console's name
+ *
+ * @see {@link IConsole#setName(String)}
+ */
+ private String consoleName;
+
+ /**
+ * document model's virtual length
+ */
+ protected int documentLength = 0;
+
+ /**
+ * Constructs a new console manager.
+ *
+ * @param consoleName - the key title
+ * @param focus - true if focus on console, false if not
+ */
+ public
+ ConsoleManager2(
+ final String consoleName,
+ final boolean focus
+ )
+ {
+ this.consoleName = consoleName;
+ this.console = createMessageConsole();
+ this.hyperlinkManager = new HyperlinkManager( console );
+ this.console.getDocument().addDocumentListener( hyperlinkManager );
+
+ if ( focus )
+ {
+ getConsoleManager().showConsoleView(console);
+ }
+
+ setName( consoleName );
+ }
+
+ /**
+ * return {@link IConsoleManager} from {@link ConsolePlugin}
+ *
+ * @return {@link IConsoleManager}
+ *
+ * @see ConsolePlugin#getConsoleManager()
+ */
+ protected IConsoleManager getConsoleManager()
+ {
+ return ConsolePlugin.getDefault().getConsoleManager();
+ }
+
+ /**
+ * return <code>IConsole</code>s to be attached to {@link IConsoleManager}
+ *
+ * @return <code>IConsole</code>s
+ *
+ * @see #getConsoleManager()
+ * @see IConsoleManager#getConsoles()
+ */
+ protected IConsole[] getConsoles()
+ {
+ return getConsoleManager().getConsoles();
+ }
+
+
+ /**
+ * Changes Console Name.
+ *
+ * @param newName - console Title. It shown console's tab bar.
+ * @author Gyeongseok.seo@samsung.com
+ */
+ public void
+ setName(
+ final String newName
+ )
+ {
+ Assert.notNull( newName );
+ synchronized ( this ) {
+ this.consoleName = newName;
+ }
+ asyncExec( new Runnable()
+ {
+ public void run()
+ {
+ if ( null == console )
+ {
+ return ;
+ }
+ console.setName(newName);
+ }
+ } );
+ }
+
+ /**
+ * Create message console
+ *
+ * @return Message console for emulator
+ */
+ synchronized protected MessageConsoleSpy createMessageConsole()
+ {
+ // Delete Old Console from console view
+ final IConsole[] consoles = getConsoles();
+ for ( int i = 0, n = consoles.length ; i < n ; ++i )
+ {
+ if ( !this.consoleName.equals(consoles[i].getName() ) )
+ {
+ continue;
+ }
+ getConsoleManager().removeConsoles( new IConsole[] { console } );
+ }
- final MessageConsoleSpy console = new MessageConsoleSpy( this.consoleName );
- getConsoleManager().addConsoles( new IConsole[] { console } );
-
- return console;
- }
-
- /**
- * return {@link IConsole}
- *
- * @return {@link IConsole} to be managed
- */
- public IConsole getConsole() {
- return this.console;
- }
-
- /**
- * print <code>line</code> out to {@link IConsole} with line separator
- *
- * @param line text to print
- */
- synchronized public void println(String line) {
- final MessageConsoleStream output = createConsoleStream();
-
- try
- {
- output.println( line );
- documentLength += ( line.length() + 1 );
-
- } finally
- {
- tryClose( output );
- }
- }
-
- /**
- * Print out using {@link Process}
- * @param process
- */
- public void printProcessStreams( final Process process) {
-
- clear();
- // waitAndRead while process is running
- ConsoleProcessClosure closure = new ConsoleProcessClosure(process, this);
-
- closure.runBlocking(); // a blocking cal
- }
-
-
- /**
- * Return configured <code>MessageConsoleStream</code>
- *
- * with <code>fontStyle</code> and <code>color</code>
- *
- * @param fontStyle SWT font style like {@link SWT#BOLD}, {@link SWT#ITALIC}, and etc.
- * @param color color of message to be printed
- *
- * @return configured <code>MessageConsoleStream</code>
- *
- * @see #configureConsole(MessageConsoleStream, int, Color)
- */
- protected
- MessageConsoleStream
- getConsoleStream(
- final int fontStyle,
- final Color color
- )
- {
- final MessageConsoleStream stream = createConsoleStream();
-
- configureConsole( stream, fontStyle, color );
-
- return stream;
- }
-
-
- /**
- * Factory method for <code>MessageConsoleStream</code>
- *
- * @return <code>MessageConsoleStream</code> to be created
- *
- * @see MessageConsole#newMessageStream()
- */
- protected
- MessageConsoleStream
- createConsoleStream()
- {
- final MessageConsoleStream stream = console.newMessageStream();
-
- return stream;
- }
-
- /**
- * Configure <code>stream</code> with <code>fontStyle</code> and <code>color</code>
- *
- * @param stream <code>MessageConsoleStream</code> to configure
- * @param fontStyle SWT font style
- * @param color
- *
- * @see SWT#NORMAL
- * @see SWT#BOLD
- * @see SWT#ITALIC
- */
- protected void
- configureConsole(
- final MessageConsoleStream stream,
- final int fontStyle,
- final Color color
- )
- {
- syncExec( new Runnable()
- {
- public void run()
- {
- // font setting
- stream.setFontStyle( fontStyle );
-
- // color setting
- stream.setColor( color );
- }
- } );
- }
-
- /**
- * print out <code>message</code> with <code>fontStyle</code> and <code>color</code>
- *
- * @param message message to print out
- * @param fontStyle SWT font style
- * @param color color of message
- */
- synchronized public
- void
- print(
- final String message,
- final int fontStyle,
- final Color color
- )
- {
- final MessageConsoleStream stream = getConsoleStream( fontStyle, color );
- try
- {
- stream.print(message);
- documentLength += (message.length() );
- }
- finally
- {
- tryClose( stream );
- }
- }
-
- /**
- * print out with line separator
- *
- * @param message message to print out
- * @param fontStyle font style
- * @param color color
- *
- * @see #print(String, int, Color)
- */
- public
- void
- println(
- final String message,
- final int fontStyle,
- final Color color
- )
- {
- print( message + "\n", fontStyle, color );
- }
-
- /**
- * clear message console
- */
- synchronized public
- void
- clear()
- {
- syncExec(
- new Runnable() {
- public void run() {
- IDocument document = console.getDocument();
- if ( null == document )
- {
- return ;
- }
- document.set("");
- }
- }
- );
- documentLength = 0;
- }
-
- /**
- * Activate console
- */
- public
- void
- show()
- {
- syncExec(
- new Runnable() {
- public void run() {
- final IWorkbenchPage page = getActivePage();
- if ( null == page )
- {
- // How to handle no active page( no view page )
- throw new IllegalStateException();
- }
- try {
- IConsoleView view = (IConsoleView) page.showView( IConsoleConstants.ID_CONSOLE_VIEW );
- view.display(getConsole());
- } catch (
- final PartInitException e
- )
- {
- ConsolePlugin.log(e);
- }
- }
- }
- );
- }
-
- /* (non-Javadoc)
- * @see org.tizen.common.console.IHyperlinkerManager#addLinker(org.tizen.common.console.LinkInfo)
- */
- @Override
- public
- void
- addLinker(
- final LinkInfo link
- )
- {
- hyperlinkManager.addLinker( link );
- }
+ final MessageConsoleSpy console = new MessageConsoleSpy( this.consoleName );
+ getConsoleManager().addConsoles( new IConsole[] { console } );
+
+ return console;
+ }
+
+ /**
+ * return {@link IConsole}
+ *
+ * @return {@link IConsole} to be managed
+ */
+ public IConsole getConsole() {
+ return this.console;
+ }
+
+ /**
+ * print <code>line</code> out to {@link IConsole} with line separator
+ *
+ * @param line text to print
+ */
+ synchronized public void println(String line) {
+ final MessageConsoleStream output = createConsoleStream();
+
+ try
+ {
+ output.println( line );
+ documentLength += ( line.length() + 1 );
+
+ } finally
+ {
+ tryClose( output );
+ }
+ }
+
+ /**
+ * Prints out using {@link Process}.
+ * @param process
+ */
+ public void printProcessStreams( final Process process) {
+
+ clear();
+ // waitAndRead while process is running
+ ConsoleProcessClosure closure = new ConsoleProcessClosure(process, this);
+
+ closure.runBlocking(); // a blocking cal
+ }
+
+
+ /**
+ * Returns configured <code>MessageConsoleStream</code> with <code>fontStyle</code> and <code>color</code>.
+ *
+ * @param fontStyle SWT font style like {@link SWT#BOLD}, {@link SWT#ITALIC}, and etc.
+ * @param color color of message to be printed
+ *
+ * @return configured <code>MessageConsoleStream</code>
+ *
+ * @see #configureConsole(MessageConsoleStream, int, Color)
+ */
+ protected
+ MessageConsoleStream
+ getConsoleStream(
+ final int fontStyle,
+ final Color color
+ )
+ {
+ final MessageConsoleStream stream = createConsoleStream();
+
+ configureConsole( stream, fontStyle, color );
+
+ return stream;
+ }
+
+
+ /**
+ * Factory method for <code>MessageConsoleStream</code>
+ *
+ * @return <code>MessageConsoleStream</code> to be created
+ *
+ * @see MessageConsole#newMessageStream()
+ */
+ protected
+ MessageConsoleStream
+ createConsoleStream()
+ {
+ final MessageConsoleStream stream = console.newMessageStream();
+
+ return stream;
+ }
+
+ /**
+ * Configure <code>stream</code> with <code>fontStyle</code> and <code>color</code>
+ *
+ * @param stream <code>MessageConsoleStream</code> to configure
+ * @param fontStyle SWT font style
+ * @param color
+ *
+ * @see SWT#NORMAL
+ * @see SWT#BOLD
+ * @see SWT#ITALIC
+ */
+ protected void
+ configureConsole(
+ final MessageConsoleStream stream,
+ final int fontStyle,
+ final Color color
+ )
+ {
+ syncExec( new Runnable()
+ {
+ public void run()
+ {
+ // font setting
+ stream.setFontStyle( fontStyle );
+ // color setting
+ stream.setColor( color );
+ }
+ } );
+ }
+
+ /**
+ * print out <code>message</code> with <code>fontStyle</code> and <code>color</code>
+ *
+ * @param message message to print out
+ * @param fontStyle SWT font style
+ * @param color color of message
+ */
+ synchronized public
+ void
+ print(
+ final String message,
+ final int fontStyle,
+ final Color color
+ )
+ {
+ final MessageConsoleStream stream = getConsoleStream( fontStyle, color );
+ try
+ {
+ stream.print(message);
+ documentLength += (message.length() );
+ }
+ finally
+ {
+ tryClose( stream );
+ }
+ }
+
+ /**
+ * print out with line separator
+ *
+ * @param message message to print out
+ * @param fontStyle font style
+ * @param color color
+ *
+ * @see #print(String, int, Color)
+ */
+ public
+ void
+ println(
+ final String message,
+ final int fontStyle,
+ final Color color
+ )
+ {
+ print( message + "\n", fontStyle, color );
+ }
+
+ /**
+ * clear message console
+ */
+ synchronized public
+ void
+ clear()
+ {
+ syncExec(
+ new Runnable() {
+ public void run() {
+ IDocument document = console.getDocument();
+ if ( null == document )
+ {
+ return ;
+ }
+ document.set("");
+ }
+ }
+ );
+ documentLength = 0;
+ }
+
+ /**
+ * Activates console.
+ */
+ public
+ void
+ show()
+ {
+ syncExec(
+ new Runnable() {
+ public void run() {
+ final IWorkbenchPage page = getActivePage();
+ if ( null == page )
+ {
+ // How to handle no active page( no view page )
+ throw new IllegalStateException();
+ }
+ try {
+ IConsoleView view = (IConsoleView) page.showView( IConsoleConstants.ID_CONSOLE_VIEW );
+ view.display(getConsole());
+ } catch (
+ final PartInitException e
+ )
+ {
+ ConsolePlugin.log(e);
+ }
+ }
+ }
+ );
+ }
+
+ /* (non-Javadoc)
+ * @see org.tizen.common.console.IHyperlinkerManager#addLinker(org.tizen.common.console.LinkInfo)
+ */
+ @Override
+ public
+ void
+ addLinker(
+ final LinkInfo link
+ )
+ {
+ hyperlinkManager.addLinker( link );
+ }
+
@Override
public void print(String line) {
MessageConsoleStream output = this.console.newMessageStream();
}
}
}
-