diff options
author | Simeon Andreev | 2017-09-20 08:15:32 +0000 |
---|---|---|
committer | Simeon Andreev | 2017-09-20 08:59:34 +0000 |
commit | c2a10306c92c88d6bc460956e8bab8f5c0e0c473 (patch) | |
tree | 78ca9b6d4fb390141a1e15f7bd9ae98d3b3e2eea | |
parent | d49b76e20affb3c5788294cc2b2d99a283f53dae (diff) | |
download | eclipse.platform.debug-c2a10306c92c88d6bc460956e8bab8f5c0e0c473.tar.gz eclipse.platform.debug-c2a10306c92c88d6bc460956e8bab8f5c0e0c473.tar.xz eclipse.platform.debug-c2a10306c92c88d6bc460956e8bab8f5c0e0c473.zip |
Bug 522241 - org.eclipse.ui.console mixes tabs and spaces code indentI20170925-2000I20170924-2000I20170923-1500I20170922-2000I20170921-2000I20170920-2000
The source of org.eclipse.ui.console has a mix of tabs and spaces, in
some caes on the same line. This makes editing the source very awkward.
E.g. changing code and undo-ing changes results in indentation changes
nevertheless (on save action).
In this change space indentations are replaced with tab indentations,
for the source of plug-in org.eclipse.ui.console. This follows the
project formatting settings.
Change-Id: I9ee197b4eeea1c2764b2e55dce55bbeb3881a64a
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
48 files changed, 3683 insertions, 3683 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/AbstractConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/AbstractConsole.java index 301729a2a..a609ba5e1 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/AbstractConsole.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/AbstractConsole.java @@ -108,7 +108,7 @@ public abstract class AbstractConsole implements IConsole { fEvent = event; for (IPropertyChangeListener iPropertyChangeListener : fListeners) { fListener = iPropertyChangeListener; - SafeRunner.run(this); + SafeRunner.run(this); } fListener = null; } @@ -126,7 +126,7 @@ public abstract class AbstractConsole implements IConsole { * @since 3.1 */ public AbstractConsole(String name, ImageDescriptor imageDescriptor, boolean autoLifecycle) { - this(name, null, imageDescriptor, autoLifecycle); + this(name, null, imageDescriptor, autoLifecycle); } /** @@ -146,7 +146,7 @@ public abstract class AbstractConsole implements IConsole { setType(type); setImageDescriptor(imageDescriptor); if (autoLifecycle) { - ConsolePlugin.getDefault().getConsoleManager().addConsoleListener(new Lifecycle()); + ConsolePlugin.getDefault().getConsoleManager().addConsoleListener(new Lifecycle()); } } @@ -174,12 +174,12 @@ public abstract class AbstractConsole implements IConsole { * @param name the new name */ protected void setName(String name) { - if (!name.equals(fName)) { - String old = fName; - fName = name; - firePropertyChange(this, IBasicPropertyConstants.P_TEXT, old, name); - } - } + if (!name.equals(fName)) { + String old = fName; + fName = name; + firePropertyChange(this, IBasicPropertyConstants.P_TEXT, old, name); + } + } @Override public ImageDescriptor getImageDescriptor() { @@ -238,7 +238,7 @@ public abstract class AbstractConsole implements IConsole { * @since 3.1 */ public final void initialize() { - init(); + init(); } /** @@ -261,7 +261,7 @@ public abstract class AbstractConsole implements IConsole { * @since 3.1 */ public final void destroy() { - dispose(); + dispose(); } /** @@ -281,38 +281,38 @@ public abstract class AbstractConsole implements IConsole { * * @since 3.1 */ - public void activate() { - ConsolePlugin.getDefault().getConsoleManager().showConsoleView(this); - } - - /** - * Sets this console's type identifier. - * - * @param typeIdentifier the type identifier for this console - * @since 3.1 - */ - protected void setType(String typeIdentifier) { - fType = typeIdentifier; - } - - /** - * @since 3.1 - */ - @Override + public void activate() { + ConsolePlugin.getDefault().getConsoleManager().showConsoleView(this); + } + + /** + * Sets this console's type identifier. + * + * @param typeIdentifier the type identifier for this console + * @since 3.1 + */ + protected void setType(String typeIdentifier) { + fType = typeIdentifier; + } + + /** + * @since 3.1 + */ + @Override public String getType() { - return fType; - } - - /** - * Returns the help context identifier for this console, or <code>null</code> - * if none. When a non-<code>null</code> value is returned the associated help - * will be installed for this console. - * - * @return help context id or <code>null</code> - * @since 3.2 - */ - public String getHelpContextId() { - return null; - } + return fType; + } + + /** + * Returns the help context identifier for this console, or <code>null</code> + * if none. When a non-<code>null</code> value is returned the associated help + * will be installed for this console. + * + * @return help context id or <code>null</code> + * @since 3.2 + */ + public String getHelpContextId() { + return null; + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/ConsolePlugin.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/ConsolePlugin.java index 67be06052..19d005da4 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/ConsolePlugin.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/ConsolePlugin.java @@ -142,43 +142,43 @@ public class ConsolePlugin extends AbstractUIPlugin { ErrorDialog.openError(shell, title, message, status); } - /** - * Returns the <code>Image</code> identified by the given key, - * or <code>null</code> if it does not exist. - * - * @return the <code>Image</code> identified by the given key, - * or <code>null</code> if it does not exist - * @since 3.1 - */ - public static Image getImage(String key) { - return ConsolePluginImages.getImage(key); - } - - /** - * Returns the <code>ImageDescriptor</code> identified by the given key, - * or <code>null</code> if it does not exist. - * - * @return the <code>ImageDescriptor</code> identified by the given key, - * or <code>null</code> if it does not exist - * @since 3.1 - */ - public static ImageDescriptor getImageDescriptor(String key) { - return ConsolePluginImages.getImageDescriptor(key); - } - - /* (non-Javadoc) - * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) - */ + /** + * Returns the <code>Image</code> identified by the given key, + * or <code>null</code> if it does not exist. + * + * @return the <code>Image</code> identified by the given key, + * or <code>null</code> if it does not exist + * @since 3.1 + */ + public static Image getImage(String key) { + return ConsolePluginImages.getImage(key); + } + + /** + * Returns the <code>ImageDescriptor</code> identified by the given key, + * or <code>null</code> if it does not exist. + * + * @return the <code>ImageDescriptor</code> identified by the given key, + * or <code>null</code> if it does not exist + * @since 3.1 + */ + public static ImageDescriptor getImageDescriptor(String key) { + return ConsolePluginImages.getImageDescriptor(key); + } + + /* (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ @Override public void stop(BundleContext context) throws Exception { - if (fConsoleManager != null) { - IConsole[] consoles = fConsoleManager.getConsoles(); - if (consoles != null) { - fConsoleManager.removeConsoles(consoles); - } - } - super.stop(context); - } + if (fConsoleManager != null) { + IConsole[] consoles = fConsoleManager.getConsoles(); + if (consoles != null) { + fConsoleManager.removeConsoles(consoles); + } + } + super.stop(context); + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java index dbf506f10..27e8b0969 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java @@ -34,7 +34,7 @@ public interface IConsoleConstants { * Type identifier for MessageConsole * @since 3.1 */ - public static final String MESSAGE_CONSOLE_TYPE = "org.eclipse.ui.MessageConsole"; //$NON-NLS-1$ + public static final String MESSAGE_CONSOLE_TYPE = "org.eclipse.ui.MessageConsole"; //$NON-NLS-1$ /** * The name of the font to use for the Console (value <code>"org.eclipse.ui.console.ConsoleFont"</code>). @@ -79,23 +79,23 @@ public interface IConsoleConstants { * * @since 3.1 */ - public static final String EXTENSION_POINT_CONSOLE_PATTERN_MATCH_LISTENERS = "consolePatternMatchListeners"; //$NON-NLS-1$ + public static final String EXTENSION_POINT_CONSOLE_PATTERN_MATCH_LISTENERS = "consolePatternMatchListeners"; //$NON-NLS-1$ - /** - * Console page participants extension point identifier - * (value <code>"consolePageParticipants"</code>). - * - * @since 3.1 - */ - public static final String EXTENSION_POINT_CONSOLE_PAGE_PARTICIPANTS = "consolePageParticipants"; //$NON-NLS-1$ + /** + * Console page participants extension point identifier + * (value <code>"consolePageParticipants"</code>). + * + * @since 3.1 + */ + public static final String EXTENSION_POINT_CONSOLE_PAGE_PARTICIPANTS = "consolePageParticipants"; //$NON-NLS-1$ - /** - * Console factories extension point identifier - * (value <code>"consoleFactories"</code>). - * - * @since 3.1 - */ - public static final String EXTENSION_POINT_CONSOLE_FACTORIES = "consoleFactories"; //$NON-NLS-1$ + /** + * Console factories extension point identifier + * (value <code>"consoleFactories"</code>). + * + * @since 3.1 + */ + public static final String EXTENSION_POINT_CONSOLE_FACTORIES = "consoleFactories"; //$NON-NLS-1$ /** * Property constant indicating a console's font has changed. @@ -147,11 +147,11 @@ public interface IConsoleConstants { */ public static final String P_BACKGROUND_COLOR = ConsolePlugin.getUniqueIdentifier() + ".P_BACKGROUND_COLOR"; //$NON-NLS-1$ - /** - * The default tab size for text consoles. - * - * @since 3.1 - */ - public static final int DEFAULT_TAB_SIZE = 8; + /** + * The default tab size for text consoles. + * + * @since 3.1 + */ + public static final int DEFAULT_TAB_SIZE = 8; } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleDocumentPartitioner.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleDocumentPartitioner.java index 33672ffa2..25146aea8 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleDocumentPartitioner.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleDocumentPartitioner.java @@ -28,24 +28,24 @@ import org.eclipse.swt.custom.StyleRange; */ public interface IConsoleDocumentPartitioner extends IDocumentPartitioner { - /** - * Returns whether this partitioner's document is read-only at the specified - * offset. The user is not allowed to type in read-only locations. - * - * @param offset document offset - * @return whether this partitioner's document is read-only at the specified - * offset - */ - public boolean isReadOnly(int offset); + /** + * Returns whether this partitioner's document is read-only at the specified + * offset. The user is not allowed to type in read-only locations. + * + * @param offset document offset + * @return whether this partitioner's document is read-only at the specified + * offset + */ + public boolean isReadOnly(int offset); - /** - * Returns style ranges for the specified region of this partitioner's document - * to use when rendering, or <code>null</code> if none. - * - * @param offset beginning offset for which style ranges are requested - * @param length the length of text for which style ranges are requested - * @return style ranges for the specified region of this partitioner's document - * to use when rendering, or <code>null</code> if none - */ - public StyleRange[] getStyleRanges(int offset, int length); + /** + * Returns style ranges for the specified region of this partitioner's document + * to use when rendering, or <code>null</code> if none. + * + * @param offset beginning offset for which style ranges are requested + * @param length the length of text for which style ranges are requested + * @return style ranges for the specified region of this partitioner's document + * to use when rendering, or <code>null</code> if none + */ + public StyleRange[] getStyleRanges(int offset, int length); } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleFactory.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleFactory.java index 5eb621333..b32d5f19c 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleFactory.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleFactory.java @@ -39,10 +39,10 @@ package org.eclipse.ui.console; * @since 3.1 */ public interface IConsoleFactory { - /** - * Opens a console in the console view. Implementations may create a new - * console or activate an existing console. - */ - public void openConsole(); + /** + * Opens a console in the console view. Implementations may create a new + * console or activate an existing console. + */ + public void openConsole(); } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleManager.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleManager.java index 269c9eb4b..e203d2f94 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleManager.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleManager.java @@ -84,24 +84,24 @@ public interface IConsoleManager { * to be used in a new console. No methods on the participants have been * called. Clients are responsible for connecting to and disconnecting from * the pattern match listeners. - * <p> - * Console pattern match listeners are contributed via the - * <code>org.eclipse.ui.console.consolePatternMatchListeners</code> extension point. - * </p> + * <p> + * Console pattern match listeners are contributed via the + * <code>org.eclipse.ui.console.consolePatternMatchListeners</code> extension point. + * </p> * * @param console the console for which pattern match listeners are requested * @return a collection of new pattern match listeners - * @see IPatternMatchListener + * @see IPatternMatchListener * @since 3.1 */ public IPatternMatchListener[] createPatternMatchListeners(IConsole console); - /** - * Requests a redraw of any visible console page containing the specified console. - * - * @param console the console to be refreshed - * @since 3.1 - */ - public void refresh(IConsole console); + /** + * Requests a redraw of any visible console page containing the specified console. + * + * @param console the console to be refreshed + * @since 3.1 + */ + public void refresh(IConsole console); } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsolePageParticipant.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsolePageParticipant.java index 4e1f4983b..a48fc0380 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsolePageParticipant.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsolePageParticipant.java @@ -43,29 +43,29 @@ import org.eclipse.ui.part.IPageBookViewPage; * @since 3.1 */ public interface IConsolePageParticipant extends IAdaptable { - /** - * Called during page initialization. Marks the start of this - * page participant's lifecycle. - * - * @param page the page corresponding to the given console - * @param console the console for which a page has been created - */ - public void init(IPageBookViewPage page, IConsole console); + /** + * Called during page initialization. Marks the start of this + * page participant's lifecycle. + * + * @param page the page corresponding to the given console + * @param console the console for which a page has been created + */ + public void init(IPageBookViewPage page, IConsole console); - /** - * Disposes this page participant. Marks the end of this - * page participant's lifecycle. - */ - public void dispose(); + /** + * Disposes this page participant. Marks the end of this + * page participant's lifecycle. + */ + public void dispose(); - /** - * Notification this participant's page has been activated. - */ - public void activated(); + /** + * Notification this participant's page has been activated. + */ + public void activated(); - /** - * Notification this participant's page has been deactivated. - */ - public void deactivated(); + /** + * Notification this participant's page has been deactivated. + */ + public void deactivated(); } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleView.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleView.java index 17628858d..596db8c7d 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleView.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleView.java @@ -31,23 +31,23 @@ public interface IConsoleView extends IViewPart, IScrollLockStateProvider { /** * Pins this console view. No other console page will be displayed until - * this console view is un-pinned. + * this console view is un-pinned. * * @param pin <code>true</code> to pin the current console to the - * top of the stack, <code>false</code> otherwise - * @since 3.1 + * top of the stack, <code>false</code> otherwise + * @since 3.1 */ public void setPinned(boolean pin); - /** - * Displays and pins the given console in this console view. No - * other console can be displayed until this console view is - * un-pinned. Specifying <code>null</code> un-pins this console - * - * @param console console to pin, or <code>null</code> to un-pin - * @deprecated rather than pinning a specific console, a console view is - * pinned - use <code>setPinned(boolean)</code> - */ + /** + * Displays and pins the given console in this console view. No + * other console can be displayed until this console view is + * un-pinned. Specifying <code>null</code> un-pins this console + * + * @param console console to pin, or <code>null</code> to un-pin + * @deprecated rather than pinning a specific console, a console view is + * pinned - use <code>setPinned(boolean)</code> + */ @Deprecated public void pin(IConsole console); @@ -76,22 +76,22 @@ public interface IConsoleView extends IViewPart, IScrollLockStateProvider { */ public void warnOfContentChange(IConsole console); - /** - * Sets the scroll lock state of the currently active console. - * - * @param scrollLock <code>true</code> to turn scroll lock on, otherwise <code>false</code> - * @since 3.1 - */ - @Override + /** + * Sets the scroll lock state of the currently active console. + * + * @param scrollLock <code>true</code> to turn scroll lock on, otherwise <code>false</code> + * @since 3.1 + */ + @Override public void setScrollLock(boolean scrollLock); - /** - * Returns the scroll lock state of the currently active console. - * - * @return <code>true</code> if scroll lock is on, <code>false</code> otherwise - * @since 3.1 - */ - @Override + /** + * Returns the scroll lock state of the currently active console. + * + * @return <code>true</code> if scroll lock is on, <code>false</code> otherwise + * @since 3.1 + */ + @Override public boolean getScrollLock(); /** diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java index 44cbfc4d7..b07d283b6 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java @@ -39,58 +39,58 @@ public class IOConsole extends TextConsole { /** * The document partitioner */ - private IOConsolePartitioner partitioner; + private IOConsolePartitioner partitioner; - /** - * The stream from which user input may be read - */ + /** + * The stream from which user input may be read + */ private InputStream inputStream; - /** - * A collection of open streams connected to this console. - */ + /** + * A collection of open streams connected to this console. + */ private List<Closeable> openStreams = Collections.synchronizedList(new ArrayList<Closeable>()); - /** - * The encoding used to for displaying console output. - */ + /** + * The encoding used to for displaying console output. + */ private Charset charset; - /** - * Constructs a console with the given name, type, image, and lifecycle, with the - * workbench's default encoding. - * - * @param name name to display for this console - * @param consoleType console type identifier or <code>null</code> - * @param imageDescriptor image to display for this console or <code>null</code> - * @param autoLifecycle whether lifecycle methods should be called automatically - * when this console is added/removed from the console manager - */ - public IOConsole(String name, String consoleType, ImageDescriptor imageDescriptor, boolean autoLifecycle) { + /** + * Constructs a console with the given name, type, image, and lifecycle, with the + * workbench's default encoding. + * + * @param name name to display for this console + * @param consoleType console type identifier or <code>null</code> + * @param imageDescriptor image to display for this console or <code>null</code> + * @param autoLifecycle whether lifecycle methods should be called automatically + * when this console is added/removed from the console manager + */ + public IOConsole(String name, String consoleType, ImageDescriptor imageDescriptor, boolean autoLifecycle) { this(name, consoleType, imageDescriptor, (String)null, autoLifecycle); - } + } - /** - * Constructs a console with the given name, type, image, encoding and lifecycle. - * - * @param name name to display for this console - * @param consoleType console type identifier or <code>null</code> - * @param imageDescriptor image to display for this console or <code>null</code> - * @param encoding the encoding that should be used to render the text, or <code>null</code> - * if the system default encoding should be used - * @param autoLifecycle whether lifecycle methods should be called automatically - * when this console is added/removed from the console manager - */ - public IOConsole(String name, String consoleType, ImageDescriptor imageDescriptor, String encoding, boolean autoLifecycle) { + /** + * Constructs a console with the given name, type, image, encoding and lifecycle. + * + * @param name name to display for this console + * @param consoleType console type identifier or <code>null</code> + * @param imageDescriptor image to display for this console or <code>null</code> + * @param encoding the encoding that should be used to render the text, or <code>null</code> + * if the system default encoding should be used + * @param autoLifecycle whether lifecycle methods should be called automatically + * when this console is added/removed from the console manager + */ + public IOConsole(String name, String consoleType, ImageDescriptor imageDescriptor, String encoding, boolean autoLifecycle) { this(name, consoleType, imageDescriptor, encoding == null - ? Charset.forName(WorkbenchEncoding.getWorkbenchDefaultEncoding()) + ? Charset.forName(WorkbenchEncoding.getWorkbenchDefaultEncoding()) : Charset.forName(encoding), - autoLifecycle); - } + autoLifecycle); + } - /** + /** * Constructs a console with the given name, type, image, encoding and * lifecycle. * @@ -106,83 +106,83 @@ public class IOConsole extends TextConsole { * @since 3.7 */ public IOConsole(String name, String consoleType, ImageDescriptor imageDescriptor, Charset charset, boolean autoLifecycle) { - super(name, consoleType, imageDescriptor, autoLifecycle); + super(name, consoleType, imageDescriptor, autoLifecycle); this.charset = charset; - synchronized (openStreams) { + synchronized (openStreams) { inputStream = new IOConsoleInputStream(this); - openStreams.add(inputStream); + openStreams.add(inputStream); } if (inputStream instanceof IOConsoleInputStream) { partitioner = new IOConsolePartitioner((IOConsoleInputStream) inputStream, this); partitioner.connect(getDocument()); } - } + } - /** - * Constructs a console with the given name, type, and image with the workbench's - * default encoding. Lifecycle methods will be called when this console is - * added/removed from the console manager. - * - * @param name name to display for this console - * @param consoleType console type identifier or <code>null</code> - * @param imageDescriptor image to display for this console or <code>null</code> - */ - public IOConsole(String name, String consoleType, ImageDescriptor imageDescriptor) { - this(name, consoleType, imageDescriptor, true); - } + /** + * Constructs a console with the given name, type, and image with the workbench's + * default encoding. Lifecycle methods will be called when this console is + * added/removed from the console manager. + * + * @param name name to display for this console + * @param consoleType console type identifier or <code>null</code> + * @param imageDescriptor image to display for this console or <code>null</code> + */ + public IOConsole(String name, String consoleType, ImageDescriptor imageDescriptor) { + this(name, consoleType, imageDescriptor, true); + } - /** - * Constructs a console with the given name and image. Lifecycle methods - * will be called when this console is added/removed from the console manager. - * This console will have an unspecified (<code>null</code>) type. - * - * @param name name to display for this console - * @param imageDescriptor image to display for this console or <code>null</code> - */ - public IOConsole(String name, ImageDescriptor imageDescriptor) { - this(name, null, imageDescriptor); - } + /** + * Constructs a console with the given name and image. Lifecycle methods + * will be called when this console is added/removed from the console manager. + * This console will have an unspecified (<code>null</code>) type. + * + * @param name name to display for this console + * @param imageDescriptor image to display for this console or <code>null</code> + */ + public IOConsole(String name, ImageDescriptor imageDescriptor) { + this(name, null, imageDescriptor); + } - /* (non-Javadoc) - * @see org.eclipse.ui.console.IConsole#createPage(org.eclipse.ui.console.IConsoleView) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.console.IConsole#createPage(org.eclipse.ui.console.IConsoleView) + */ + @Override public IPageBookViewPage createPage(IConsoleView view) { - return new IOConsolePage(this, view); - } + return new IOConsolePage(this, view); + } - /** - * Creates and returns a new output stream which may be used to write to this console. - * A console may be connected to more than one output stream at once. Clients are - * responsible for closing any output streams created on this console. - * <p> - * Clients should avoid writing large amounts of output to this stream in the UI - * thread. The console needs to process the output in the UI thread and if the client - * hogs the UI thread writing output to the console, the console will not be able - * to process the output. - * </p> - * @return a new output stream connected to this console - */ - public IOConsoleOutputStream newOutputStream() { + /** + * Creates and returns a new output stream which may be used to write to this console. + * A console may be connected to more than one output stream at once. Clients are + * responsible for closing any output streams created on this console. + * <p> + * Clients should avoid writing large amounts of output to this stream in the UI + * thread. The console needs to process the output in the UI thread and if the client + * hogs the UI thread writing output to the console, the console will not be able + * to process the output. + * </p> + * @return a new output stream connected to this console + */ + public IOConsoleOutputStream newOutputStream() { IOConsoleOutputStream outputStream = new IOConsoleOutputStream(this, this.charset); - synchronized(openStreams) { - openStreams.add(outputStream); - } - return outputStream; - } + synchronized(openStreams) { + openStreams.add(outputStream); + } + return outputStream; + } - /** - * Returns the input stream connected to the keyboard. - * - * @return the input stream connected to the keyboard. - */ - public IOConsoleInputStream getInputStream() { + /** + * Returns the input stream connected to the keyboard. + * + * @return the input stream connected to the keyboard. + */ + public IOConsoleInputStream getInputStream() { if (inputStream instanceof IOConsoleInputStream) { return (IOConsoleInputStream) inputStream; } return null; - } + } /** * Sets the new input stream. @@ -194,15 +194,15 @@ public class IOConsole extends TextConsole { this.inputStream = inputStream; } - /** - * Returns this console's document partitioner. - * - * @return this console's document partitioner - */ - @Override + /** + * Returns this console's document partitioner. + * + * @return this console's document partitioner + */ + @Override protected IConsoleDocumentPartitioner getPartitioner() { - return partitioner; - } + return partitioner; + } /** * Returns the maximum number of characters that the console will display at @@ -212,7 +212,7 @@ public class IOConsole extends TextConsole { * @return the maximum number of characters that the console will display */ public int getHighWaterMark() { - return partitioner.getHighWaterMark(); + return partitioner.getHighWaterMark(); } /** @@ -239,68 +239,68 @@ public class IOConsole extends TextConsole { * @exception IllegalArgumentException if low >= high & low != -1 */ public void setWaterMarks(int low, int high) { - if (low >= 0) { - if (low >= high) { - throw new IllegalArgumentException("High water mark must be greater than low water mark"); //$NON-NLS-1$ - } - } + if (low >= 0) { + if (low >= high) { + throw new IllegalArgumentException("High water mark must be greater than low water mark"); //$NON-NLS-1$ + } + } partitioner.setWaterMarks(low, high); } - /** - * Check if all streams connected to this console are closed. If so, - * notify the partitioner that this console is finished. - */ - private void checkFinished() { + /** + * Check if all streams connected to this console are closed. If so, + * notify the partitioner that this console is finished. + */ + private void checkFinished() { if (openStreams.isEmpty()) { partitioner.streamsClosed(); } - } + } - /** - * Notification that an output stream connected to this console has been closed. - * - * @param stream stream that closed - */ - void streamClosed(IOConsoleOutputStream stream) { - synchronized (openStreams) { - openStreams.remove(stream); - checkFinished(); + /** + * Notification that an output stream connected to this console has been closed. + * + * @param stream stream that closed + */ + void streamClosed(IOConsoleOutputStream stream) { + synchronized (openStreams) { + openStreams.remove(stream); + checkFinished(); } - } + } - /** - * Notification that the input stream connected to this console has been closed. - * - * @param stream stream that closed - */ - void streamClosed(IOConsoleInputStream stream) { - synchronized (openStreams) { - openStreams.remove(stream); - checkFinished(); + /** + * Notification that the input stream connected to this console has been closed. + * + * @param stream stream that closed + */ + void streamClosed(IOConsoleInputStream stream) { + synchronized (openStreams) { + openStreams.remove(stream); + checkFinished(); } - } + } - /* (non-Javadoc) - * @see org.eclipse.ui.console.TextConsole#clearConsole() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.console.TextConsole#clearConsole() + */ + @Override public void clearConsole() { - if (partitioner != null) { - partitioner.clearBuffer(); - } - } + if (partitioner != null) { + partitioner.clearBuffer(); + } + } - /** - * Disposes this console. - */ + /** + * Disposes this console. + */ @Override protected void dispose() { - super.dispose(); - partitioner.disconnect(); - //make a copy of the open streams and close them all - //a copy is needed as close the streams results in a callback that - //removes the streams from the openStreams collection (bug 152794) + super.dispose(); + partitioner.disconnect(); + //make a copy of the open streams and close them all + //a copy is needed as close the streams results in a callback that + //removes the streams from the openStreams collection (bug 152794) List<Closeable> list = new ArrayList<Closeable>(openStreams); for (Closeable closable : list) { try { @@ -309,17 +309,17 @@ public class IOConsole extends TextConsole { // e.printStackTrace(); } } - inputStream = null; - } + inputStream = null; + } - /** - * Returns the encoding for this console, or <code>null</code> to indicate - * default encoding. - * - * @return the encoding set for this console, or <code>null</code> to indicate - * default encoding - * @since 3.3 - */ + /** + * Returns the encoding for this console, or <code>null</code> to indicate + * default encoding. + * + * @return the encoding set for this console, or <code>null</code> to indicate + * default encoding + * @since 3.3 + */ public String getEncoding() { return this.charset.name(); } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java index 74e32f2c1..15a219b4d 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java @@ -28,141 +28,141 @@ import org.eclipse.swt.graphics.Color; * */ public class IOConsoleInputStream extends InputStream { - /** - * Buffer to hold data from console until it is read. - */ - private byte[] input = new byte[100]; + /** + * Buffer to hold data from console until it is read. + */ + private byte[] input = new byte[100]; - /** - * Location in the buffer that the next byte of data from the - * console should be stored. - */ - private int inPointer = 0; + /** + * Location in the buffer that the next byte of data from the + * console should be stored. + */ + private int inPointer = 0; - /** - * Location in the buffer that the next byte of data read from - * this stream should come from. - */ - private int outPointer = 0; + /** + * Location in the buffer that the next byte of data read from + * this stream should come from. + */ + private int outPointer = 0; - /** - * The number of bytes of real data currently in the buffer. - */ - private int size = 0; + /** + * The number of bytes of real data currently in the buffer. + */ + private int size = 0; - /** - * Flag to indicate that EOF has been sent already. - */ - private boolean eofSent = false; + /** + * Flag to indicate that EOF has been sent already. + */ + private boolean eofSent = false; - /** - * Flag to indicate that the stream has been closed. - */ - private boolean closed = false; + /** + * Flag to indicate that the stream has been closed. + */ + private boolean closed = false; - /** - * The console that this stream is connected to. - */ - private IOConsole console; + /** + * The console that this stream is connected to. + */ + private IOConsole console; - /** - * The color used to display input in the console. - */ - private Color color; + /** + * The color used to display input in the console. + */ + private Color color; - /** - * The font style used to decorate input in the console. - */ - private int fontStyle = SWT.NORMAL; + /** + * The font style used to decorate input in the console. + */ + private int fontStyle = SWT.NORMAL; - /** - * Constructs a new input stream on the given console. - * - * @param console I/O console - */ - IOConsoleInputStream(IOConsole console) { - this.console = console; - } + /** + * Constructs a new input stream on the given console. + * + * @param console I/O console + */ + IOConsoleInputStream(IOConsole console) { + this.console = console; + } - /* - * (non-Javadoc) - * @see java.io.InputStream#read(byte[], int, int) - */ - @Override + /* + * (non-Javadoc) + * @see java.io.InputStream#read(byte[], int, int) + */ + @Override public synchronized int read(byte[] b, int off, int len) throws IOException { - waitForData(); - if (available() == -1) { - return -1; - } + waitForData(); + if (available() == -1) { + return -1; + } - int toCopy = Math.min(len, size); - if(input.length-outPointer > toCopy) { - System.arraycopy(input, outPointer, b, off, toCopy); - outPointer += toCopy; - size -= toCopy; - } else { - int bytesToEnd = input.length-outPointer; - System.arraycopy(input, outPointer, b, off, bytesToEnd); - System.arraycopy(input, 0, b, off+bytesToEnd, toCopy-bytesToEnd); - outPointer = toCopy-bytesToEnd; - size -=toCopy; - } - return toCopy; - } + int toCopy = Math.min(len, size); + if(input.length-outPointer > toCopy) { + System.arraycopy(input, outPointer, b, off, toCopy); + outPointer += toCopy; + size -= toCopy; + } else { + int bytesToEnd = input.length-outPointer; + System.arraycopy(input, outPointer, b, off, bytesToEnd); + System.arraycopy(input, 0, b, off+bytesToEnd, toCopy-bytesToEnd); + outPointer = toCopy-bytesToEnd; + size -=toCopy; + } + return toCopy; + } - /* - * (non-Javadoc) - * @see java.io.InputStream#read(byte[]) - */ - @Override + /* + * (non-Javadoc) + * @see java.io.InputStream#read(byte[]) + */ + @Override public int read(byte[] b) throws IOException { - return read(b, 0, b.length); - } + return read(b, 0, b.length); + } - /* - * (non-Javadoc) - * @see java.io.InputStream#read() - */ - @Override + /* + * (non-Javadoc) + * @see java.io.InputStream#read() + */ + @Override public synchronized int read() throws IOException { - waitForData(); - if (available() == -1) { - return -1; - } + waitForData(); + if (available() == -1) { + return -1; + } - byte b = input[outPointer]; - outPointer++; - if (outPointer == input.length) { - outPointer = 0; - } - size -= 1; - return b; - } + byte b = input[outPointer]; + outPointer++; + if (outPointer == input.length) { + outPointer = 0; + } + size -= 1; + return b; + } - /** - * Blocks until data is available to be read. - * Ensure that the monitor for this object is obtained before - * calling this method. - */ - private void waitForData() { - while (size == 0 && !closed) { - try { - wait(); - } catch (InterruptedException e) { - } - } - } + /** + * Blocks until data is available to be read. + * Ensure that the monitor for this object is obtained before + * calling this method. + */ + private void waitForData() { + while (size == 0 && !closed) { + try { + wait(); + } catch (InterruptedException e) { + } + } + } - /** - * Appends text to this input stream's buffer. - * - * @param text the text to append to the buffer. - */ - public synchronized void appendData(String text) { - String encoding = console.getEncoding(); - byte[] newData; - if (encoding!=null) { + /** + * Appends text to this input stream's buffer. + * + * @param text the text to append to the buffer. + */ + public synchronized void appendData(String text) { + String encoding = console.getEncoding(); + byte[] newData; + if (encoding!=null) { try { newData = text.getBytes(encoding); } catch (UnsupportedEncodingException e) { @@ -172,122 +172,122 @@ public class IOConsoleInputStream extends InputStream { newData = text.getBytes(); } - while(input.length-size < newData.length) { - growArray(); - } + while(input.length-size < newData.length) { + growArray(); + } - if (size == 0) { //inPointer == outPointer - System.arraycopy(newData, 0, input, 0, newData.length); - inPointer = newData.length; - size = newData.length; - outPointer = 0; - } else if (inPointer < outPointer || input.length - inPointer > newData.length) { - System.arraycopy(newData, 0, input, inPointer, newData.length); - inPointer += newData.length; - size += newData.length; - } else { - System.arraycopy(newData, 0, input, inPointer, input.length-inPointer); - System.arraycopy(newData, input.length-inPointer, input, 0, newData.length-(input.length-inPointer)); - inPointer = newData.length-(input.length-inPointer); - size += newData.length; - } + if (size == 0) { //inPointer == outPointer + System.arraycopy(newData, 0, input, 0, newData.length); + inPointer = newData.length; + size = newData.length; + outPointer = 0; + } else if (inPointer < outPointer || input.length - inPointer > newData.length) { + System.arraycopy(newData, 0, input, inPointer, newData.length); + inPointer += newData.length; + size += newData.length; + } else { + System.arraycopy(newData, 0, input, inPointer, input.length-inPointer); + System.arraycopy(newData, input.length-inPointer, input, 0, newData.length-(input.length-inPointer)); + inPointer = newData.length-(input.length-inPointer); + size += newData.length; + } - if (inPointer == input.length) { - inPointer = 0; - } - notifyAll(); - } + if (inPointer == input.length) { + inPointer = 0; + } + notifyAll(); + } - /** - * Enlarges the buffer. - */ - private void growArray() { - byte[] newInput = new byte[input.length+1024]; - if (outPointer < inPointer) { - System.arraycopy(input, outPointer, newInput, 0, size); - } else { - System.arraycopy(input, outPointer, newInput, 0, input.length-outPointer); - System.arraycopy(input, 0, newInput, input.length-outPointer, inPointer); - } - outPointer = 0; - inPointer = size; - input = newInput; - newInput = null; - } + /** + * Enlarges the buffer. + */ + private void growArray() { + byte[] newInput = new byte[input.length+1024]; + if (outPointer < inPointer) { + System.arraycopy(input, outPointer, newInput, 0, size); + } else { + System.arraycopy(input, outPointer, newInput, 0, input.length-outPointer); + System.arraycopy(input, 0, newInput, input.length-outPointer, inPointer); + } + outPointer = 0; + inPointer = size; + input = newInput; + newInput = null; + } - /** - * Returns this stream's font style. - * - * @return the font style used to decorate input in the associated console - */ - public int getFontStyle() { - return fontStyle; - } + /** + * Returns this stream's font style. + * + * @return the font style used to decorate input in the associated console + */ + public int getFontStyle() { + return fontStyle; + } - /** - * Sets this stream's font style. - * - * @param newFontStyle the font style to be used to decorate input in the associated console - */ - public void setFontStyle(int newFontStyle) { - if (newFontStyle != fontStyle) { - int old = fontStyle; - fontStyle = newFontStyle; - console.firePropertyChange(this, IConsoleConstants.P_FONT_STYLE, Integer.valueOf(old), Integer.valueOf(fontStyle)); - } - } + /** + * Sets this stream's font style. + * + * @param newFontStyle the font style to be used to decorate input in the associated console + */ + public void setFontStyle(int newFontStyle) { + if (newFontStyle != fontStyle) { + int old = fontStyle; + fontStyle = newFontStyle; + console.firePropertyChange(this, IConsoleConstants.P_FONT_STYLE, Integer.valueOf(old), Integer.valueOf(fontStyle)); + } + } - /** - * Sets the color to used to decorate input in the associated console. - * - * @param newColor the color to used to decorate input in the associated console. - */ - public void setColor(Color newColor) { - Color old = color; - if (old == null || !old.equals(newColor)) { - color = newColor; - console.firePropertyChange(this, IConsoleConstants.P_STREAM_COLOR, old, newColor); - } - } + /** + * Sets the color to used to decorate input in the associated console. + * + * @param newColor the color to used to decorate input in the associated console. + */ + public void setColor(Color newColor) { + Color old = color; + if (old == null || !old.equals(newColor)) { + color = newColor; + console.firePropertyChange(this, IConsoleConstants.P_STREAM_COLOR, old, newColor); + } + } - /** - * Returns the color used to decorate input in the associated console - * - * @return the color used to decorate input in the associated console - */ - public Color getColor() { - return color; - } + /** + * Returns the color used to decorate input in the associated console + * + * @return the color used to decorate input in the associated console + */ + public Color getColor() { + return color; + } - /* (non-Javadoc) - * @see java.io.InputStream#available() - */ + /* (non-Javadoc) + * @see java.io.InputStream#available() + */ @Override public int available() throws IOException { - if (closed && eofSent) { - throw new IOException("Input Stream Closed"); //$NON-NLS-1$ - } else if (size == 0) { - if (!eofSent) { - eofSent = true; - return -1; - } - throw new IOException("Input Stream Closed"); //$NON-NLS-1$ - } + if (closed && eofSent) { + throw new IOException("Input Stream Closed"); //$NON-NLS-1$ + } else if (size == 0) { + if (!eofSent) { + eofSent = true; + return -1; + } + throw new IOException("Input Stream Closed"); //$NON-NLS-1$ + } - return size; - } + return size; + } - /* (non-Javadoc) - * @see java.io.InputStream#close() - */ - @Override + /* (non-Javadoc) + * @see java.io.InputStream#close() + */ + @Override public synchronized void close() throws IOException { - if(closed) { + if(closed) { // Closeable#close() has no effect if already closed return; - } - closed = true; - notifyAll(); - console.streamClosed(this); - } + } + closed = true; + notifyAll(); + console.streamClosed(this); + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleOutputStream.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleOutputStream.java index e2b6b3cc8..7536fb4e9 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleOutputStream.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleOutputStream.java @@ -37,107 +37,107 @@ import org.eclipse.ui.internal.console.StreamDecoder; * @noextend This class is not intended to be subclassed by clients. */ public class IOConsoleOutputStream extends OutputStream { - /** - * Flag indicating whether this stream has been closed. - */ - private boolean closed = false; + /** + * Flag indicating whether this stream has been closed. + */ + private boolean closed = false; - /** - * The console's document partitioner. - */ - private IOConsolePartitioner partitioner; + /** + * The console's document partitioner. + */ + private IOConsolePartitioner partitioner; - /** - * The console this stream is attached to. - */ - private IOConsole console; + /** + * The console this stream is attached to. + */ + private IOConsole console; - /** - * Flag indicating that the console should be activated when data - * is written to this stream. - */ - private boolean activateOnWrite = false; + /** + * Flag indicating that the console should be activated when data + * is written to this stream. + */ + private boolean activateOnWrite = false; - /** - * The color used to decorate data written to this stream. - */ - private Color color; + /** + * The color used to decorate data written to this stream. + */ + private Color color; - /** - * The font style used to decorate data written to this stream. - */ - private int fontStyle; + /** + * The font style used to decorate data written to this stream. + */ + private int fontStyle; private StreamDecoder decoder; - private boolean prependCR; + private boolean prependCR; - /** - * Constructs a new output stream on the given console. - * - * @param console I/O console - */ + /** + * Constructs a new output stream on the given console. + * + * @param console I/O console + */ IOConsoleOutputStream(IOConsole console, Charset charset) { this.decoder = new StreamDecoder(charset); this.console = console; - this.partitioner = (IOConsolePartitioner) console.getPartitioner(); - } + this.partitioner = (IOConsolePartitioner) console.getPartitioner(); + } - /** - * Returns the font style used to decorate data written to this stream. - * - * @return the font style used to decorate data written to this stream - */ - public int getFontStyle() { - return fontStyle; - } + /** + * Returns the font style used to decorate data written to this stream. + * + * @return the font style used to decorate data written to this stream + */ + public int getFontStyle() { + return fontStyle; + } - /** - * Sets the font style to be used to decorate data written to this stream. - * - * @param newFontStyle the font style to be used to decorate data written to this stream - */ - public void setFontStyle(int newFontStyle) { - if (newFontStyle != fontStyle) { - int old = fontStyle; - fontStyle = newFontStyle; - console.firePropertyChange(this, IConsoleConstants.P_FONT_STYLE, Integer.valueOf(old), Integer.valueOf(fontStyle)); - } - } + /** + * Sets the font style to be used to decorate data written to this stream. + * + * @param newFontStyle the font style to be used to decorate data written to this stream + */ + public void setFontStyle(int newFontStyle) { + if (newFontStyle != fontStyle) { + int old = fontStyle; + fontStyle = newFontStyle; + console.firePropertyChange(this, IConsoleConstants.P_FONT_STYLE, Integer.valueOf(old), Integer.valueOf(fontStyle)); + } + } - /** - * Returns whether the console this stream is writing to will be activated when this stream - * is written to. - * - * @return whether the console this stream is writing to will be activated when this stream - * is written to. - */ - public boolean isActivateOnWrite() { - return activateOnWrite; - } + /** + * Returns whether the console this stream is writing to will be activated when this stream + * is written to. + * + * @return whether the console this stream is writing to will be activated when this stream + * is written to. + */ + public boolean isActivateOnWrite() { + return activateOnWrite; + } - /** - * Sets whether to activate the console this stream is writing to when this stream - * is written to. - * - * @param activateOnWrite whether the console this stream is writing to will be activated when this stream - * is written to. - */ - public void setActivateOnWrite(boolean activateOnWrite) { - this.activateOnWrite = activateOnWrite; - } + /** + * Sets whether to activate the console this stream is writing to when this stream + * is written to. + * + * @param activateOnWrite whether the console this stream is writing to will be activated when this stream + * is written to. + */ + public void setActivateOnWrite(boolean activateOnWrite) { + this.activateOnWrite = activateOnWrite; + } /** * Sets the color of this stream. Use <code>null</code> to indicate - * the default color. + * the default color. * * @param newColor color of this stream, or <code>null</code> */ public void setColor(Color newColor) { Color old = color; if (old == null || !old.equals(newColor)) { - color = newColor; - console.firePropertyChange(this, IConsoleConstants.P_STREAM_COLOR, old, newColor); + color = newColor; + console.firePropertyChange(this, IConsoleConstants.P_STREAM_COLOR, old, newColor); } } @@ -148,16 +148,16 @@ public class IOConsoleOutputStream extends OutputStream { * @return the color of this stream, or <code>null</code> */ public Color getColor() { - return color; + return color; } - /** - * Returns true if the stream has been closed - * @return true is the stream has been closed, false otherwise. - */ - public synchronized boolean isClosed() { - return closed; - } + /** + * Returns true if the stream has been closed + * @return true is the stream has been closed, false otherwise. + */ + public synchronized boolean isClosed() { + return closed; + } /* * (non-Javadoc) @@ -165,41 +165,41 @@ public class IOConsoleOutputStream extends OutputStream { */ @Override public synchronized void close() throws IOException { - if(closed) { + if(closed) { // Closeable#close() has no effect if already closed return; - } + } StringBuilder builder = new StringBuilder(); - if (prependCR) { // force writing of last /r - prependCR = false; + if (prependCR) { // force writing of last /r + prependCR = false; builder.append('\r'); - } + } this.decoder.finish(builder); if (builder.length() > 0) { notifyParitioner(builder.toString()); } - console.streamClosed(this); - closed = true; - partitioner = null; + console.streamClosed(this); + closed = true; + partitioner = null; decoder = null; - } + } - /* - * (non-Javadoc) - * @see java.io.OutputStream#flush() - */ - @Override + /* + * (non-Javadoc) + * @see java.io.OutputStream#flush() + */ + @Override public void flush() throws IOException { - if(closed) { - throw new IOException("Output Stream is closed"); //$NON-NLS-1$ - } - } + if(closed) { + throw new IOException("Output Stream is closed"); //$NON-NLS-1$ + } + } - /* - * (non-Javadoc) - * @see java.io.OutputStream#write(byte[], int, int) - */ - @Override + /* + * (non-Javadoc) + * @see java.io.OutputStream#write(byte[], int, int) + */ + @Override public synchronized void write(byte[] b, int off, int len) throws IOException { if (closed) { throw new IOException("Output Stream is closed"); //$NON-NLS-1$ @@ -207,23 +207,23 @@ public class IOConsoleOutputStream extends OutputStream { StringBuilder builder = new StringBuilder(); this.decoder.decode(builder, b, off, len); encodedWrite(builder.toString()); - } - /* - * (non-Javadoc) - * @see java.io.OutputStream#write(byte[]) - */ - @Override + } + /* + * (non-Javadoc) + * @see java.io.OutputStream#write(byte[]) + */ + @Override public void write(byte[] b) throws IOException { - write(b, 0, b.length); - } - /* - * (non-Javadoc) - * @see java.io.OutputStream#write(int) - */ - @Override + write(b, 0, b.length); + } + /* + * (non-Javadoc) + * @see java.io.OutputStream#write(int) + */ + @Override public void write(int b) throws IOException { - write(new byte[] {(byte)b}, 0, 1); - } + write(new byte[] {(byte)b}, 0, 1); + } /** * Writes a character array to the attached console. @@ -252,7 +252,7 @@ public class IOConsoleOutputStream extends OutputStream { this.encodedWrite(str); } - /** + /** * Writes a character sequence to the attached console. * * @param chars the string/characters to write to the attached console. @@ -262,57 +262,57 @@ public class IOConsoleOutputStream extends OutputStream { public void write(CharSequence chars) throws IOException { String str = chars.toString(); encodedWrite(str); - } + } - /** + /** * Writes a string to the attached console. * * @param str the string to write to the attached console * @throws IOException if the stream is closed */ - public void write(String str) throws IOException { - encodedWrite(str); - } + public void write(String str) throws IOException { + encodedWrite(str); + } - private synchronized void encodedWrite(String encodedString) throws IOException { - if(closed) { - throw new IOException("Output Stream is closed"); //$NON-NLS-1$ - } + private synchronized void encodedWrite(String encodedString) throws IOException { + if(closed) { + throw new IOException("Output Stream is closed"); //$NON-NLS-1$ + } String newencoding = encodedString; - if (prependCR){ + if (prependCR){ newencoding = "\r" + newencoding; //$NON-NLS-1$ - prependCR=false; - } + prependCR=false; + } if (newencoding.endsWith("\r")) { //$NON-NLS-1$ - prependCR = true; + prependCR = true; newencoding = new String(newencoding.substring(0, newencoding.length() - 1)); - } + } notifyParitioner(newencoding); - } + } - private void notifyParitioner(String encodedString) throws IOException { - try { - partitioner.streamAppended(this, encodedString); + private void notifyParitioner(String encodedString) throws IOException { + try { + partitioner.streamAppended(this, encodedString); - if (activateOnWrite) { - console.activate(); - } else { - ConsolePlugin.getDefault().getConsoleManager().warnOfContentChange(console); - } - } catch (IOException e) { - if (!closed) { - close(); - } - throw e; - } - } + if (activateOnWrite) { + console.activate(); + } else { + ConsolePlugin.getDefault().getConsoleManager().warnOfContentChange(console); + } + } catch (IOException e) { + if (!closed) { + close(); + } + throw e; + } + } - /** - * Sets the character encoding used to interpret characters written to this steam. - * - * @param encoding encoding identifier - */ - public void setEncoding(String encoding) { + /** + * Sets the character encoding used to interpret characters written to this steam. + * + * @param encoding encoding identifier + */ + public void setEncoding(String encoding) { String charsetName; if (encoding == null) { charsetName = WorkbenchEncoding.getWorkbenchDefaultEncoding(); @@ -343,6 +343,6 @@ public class IOConsoleOutputStream extends OutputStream { this.encodedWrite(builder.toString()); } this.decoder = new StreamDecoder(charset); - } + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListener.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListener.java index a8a41b57a..2eed22e00 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListener.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListener.java @@ -53,35 +53,35 @@ package org.eclipse.ui.console; * @since 3.1 */ public interface IPatternMatchListener extends IPatternMatchListenerDelegate { - /** - * Returns the pattern to be used for matching. The pattern is - * a string representing a regular expression. - * - * @return the regular expression to be used for matching - */ - public String getPattern(); + /** + * Returns the pattern to be used for matching. The pattern is + * a string representing a regular expression. + * + * @return the regular expression to be used for matching + */ + public String getPattern(); - /** - * Returns the flags to use when compiling this pattern match listener's - * regular expression, as defined by by <code>Pattern.compile(String regex, int flags)</code> - * - * @return the flags to use when compiling this pattern match listener's - * regular expression - * @see java.util.regex.Pattern#compile(java.lang.String, int) - */ - public int getCompilerFlags(); + /** + * Returns the flags to use when compiling this pattern match listener's + * regular expression, as defined by by <code>Pattern.compile(String regex, int flags)</code> + * + * @return the flags to use when compiling this pattern match listener's + * regular expression + * @see java.util.regex.Pattern#compile(java.lang.String, int) + */ + public int getCompilerFlags(); - /** - * Returns a simple regular expression used to identify lines that may - * match this pattern matcher's complete pattern, or <code>null</code>. - * Use of this attribute can improve performance by disqualifying lines - * from the search. When a line is found containing a match for this expression, - * the line is searched from the beginning for this pattern matcher's - * complete pattern. Lines not containing this pattern are discarded. - * - * @return a simple regular expression used to identify lines that may - * match this pattern matcher's complete pattern, or <code>null</code> - */ - public String getLineQualifier(); + /** + * Returns a simple regular expression used to identify lines that may + * match this pattern matcher's complete pattern, or <code>null</code>. + * Use of this attribute can improve performance by disqualifying lines + * from the search. When a line is found containing a match for this expression, + * the line is searched from the beginning for this pattern matcher's + * complete pattern. Lines not containing this pattern are discarded. + * + * @return a simple regular expression used to identify lines that may + * match this pattern matcher's complete pattern, or <code>null</code> + */ + public String getLineQualifier(); } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListenerDelegate.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListenerDelegate.java index 7b96c9335..57784de0d 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListenerDelegate.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListenerDelegate.java @@ -23,24 +23,24 @@ package org.eclipse.ui.console; * @since 3.1 */ public interface IPatternMatchListenerDelegate { - /** - * Notification that pattern matching will begin in the specified console. - * A pattern matcher is connected to only one console at a time. - * - * @param console the console in which pattern matching will be performed - */ - public void connect(TextConsole console); + /** + * Notification that pattern matching will begin in the specified console. + * A pattern matcher is connected to only one console at a time. + * + * @param console the console in which pattern matching will be performed + */ + public void connect(TextConsole console); - /** - * Notification that pattern matching has been completed in the console - * this delegate was last connected to. - */ - public void disconnect(); + /** + * Notification that pattern matching has been completed in the console + * this delegate was last connected to. + */ + public void disconnect(); - /** - * Notification that a match has been found. - * - * @param event event describing where the match was found - */ - public void matchFound(PatternMatchEvent event); + /** + * Notification that a match has been found. + * + * @param event event describing where the match was found + */ + public void matchFound(PatternMatchEvent event); } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsole.java index aa399164e..e32ac502f 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsole.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsole.java @@ -59,12 +59,12 @@ public class MessageConsole extends IOConsole { @Deprecated public static final int DEFAULT_TAB_SIZE = IConsoleConstants.DEFAULT_TAB_SIZE; - /** - * Constructs a message console with the given name and image. - * - * @param name console name - * @param imageDescriptor console image descriptor or <code>null</code> - */ + /** + * Constructs a message console with the given name and image. + * + * @param name console name + * @param imageDescriptor console image descriptor or <code>null</code> + */ public MessageConsole(String name, ImageDescriptor imageDescriptor) { this(name, imageDescriptor, true); } @@ -82,33 +82,33 @@ public class MessageConsole extends IOConsole { this(name, IConsoleConstants.MESSAGE_CONSOLE_TYPE, imageDescriptor, autoLifecycle); } - /** - * Constructs a message console with the given name, type, image, and lifecycle. - * - * @param name console name - * @param consoleType console type identifier or <code>null</code> - * @param imageDescriptor console image descriptor or <code>null</code> - * @param autoLifecycle whether lifecycle methods should be called automatically + /** + * Constructs a message console with the given name, type, image, and lifecycle. + * + * @param name console name + * @param consoleType console type identifier or <code>null</code> + * @param imageDescriptor console image descriptor or <code>null</code> + * @param autoLifecycle whether lifecycle methods should be called automatically * when added and removed from the console manager * - * @since 3.4 - */ + * @since 3.4 + */ public MessageConsole(String name, String consoleType, ImageDescriptor imageDescriptor, boolean autoLifecycle) { this(name, consoleType, imageDescriptor, null, autoLifecycle); } - /** - * Constructs a message console with the given name, type, image, encoding, and lifecycle specification. - * - * @param name the name to display for this console - * @param consoleType console type identifier or <code>null</code> - * @param imageDescriptor console image descriptor or <code>null</code> - * @param encoding the encoding that should be used to render the text, or <code>null</code> - * if the system default encoding should be used - * @param autoLifecycle whether lifecycle methods should be called automatically + /** + * Constructs a message console with the given name, type, image, encoding, and lifecycle specification. + * + * @param name the name to display for this console + * @param consoleType console type identifier or <code>null</code> + * @param imageDescriptor console image descriptor or <code>null</code> + * @param encoding the encoding that should be used to render the text, or <code>null</code> + * if the system default encoding should be used + * @param autoLifecycle whether lifecycle methods should be called automatically * when added and removed from the console manager * @since 3.5 - */ + */ public MessageConsole(String name, String consoleType, ImageDescriptor imageDescriptor, String encoding, boolean autoLifecycle) { super(name, consoleType, imageDescriptor, encoding, autoLifecycle); } @@ -116,34 +116,34 @@ public class MessageConsole extends IOConsole { /** * Returns a new message stream connected to this console. * <p> - * Clients should avoid writing large amounts of output to this stream in the UI - * thread. The console needs to process the output in the UI thread and if the client - * hogs the UI thread writing output to the console, the console will not be able - * to process the output. - * </p> + * Clients should avoid writing large amounts of output to this stream in the UI + * thread. The console needs to process the output in the UI thread and if the client + * hogs the UI thread writing output to the console, the console will not be able + * to process the output. + * </p> * @return a new message stream connected to this console */ public MessageConsoleStream newMessageStream() { return new MessageConsoleStream(this, this.getCharset()); } - /* (non-Javadoc) - * @see org.eclipse.ui.console.IConsole#createPage(org.eclipse.ui.console.IConsoleView) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.console.IConsole#createPage(org.eclipse.ui.console.IConsoleView) + */ + @Override public IPageBookViewPage createPage(IConsoleView view) { - IOConsolePage page = (IOConsolePage) super.createPage(view); - page.setReadOnly(); - return page; - } + IOConsolePage page = (IOConsolePage) super.createPage(view); + page.setReadOnly(); + return page; + } - /* (non-Javadoc) - * @see org.eclipse.ui.console.IOConsole#getInputStream() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.console.IOConsole#getInputStream() + */ + @Override public IOConsoleInputStream getInputStream() { - throw new UnsupportedOperationException("Message Console does not support user input"); //$NON-NLS-1$ - } + throw new UnsupportedOperationException("Message Console does not support user input"); //$NON-NLS-1$ + } /** diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsoleStream.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsoleStream.java index c8593d53a..580a1cce4 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsoleStream.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsoleStream.java @@ -37,7 +37,7 @@ import org.eclipse.ui.WorkbenchEncoding; */ public class MessageConsoleStream extends IOConsoleOutputStream { - private MessageConsole fMessageConsole; + private MessageConsole fMessageConsole; /** * Constructs a new stream connected to the given console. @@ -56,7 +56,7 @@ public class MessageConsoleStream extends IOConsoleOutputStream { */ public MessageConsoleStream(MessageConsole console, Charset charset) { super(console, charset); - fMessageConsole = console; + fMessageConsole = console; } /** @@ -66,10 +66,10 @@ public class MessageConsoleStream extends IOConsoleOutputStream { */ public void print(String message) { try { - write(message); - } catch (IOException e) { - ConsolePlugin.log(e); - } + write(message); + } catch (IOException e) { + ConsolePlugin.log(e); + } } @@ -78,10 +78,10 @@ public class MessageConsoleStream extends IOConsoleOutputStream { */ public void println() { try { - write("\n"); //$NON-NLS-1$ - } catch (IOException e) { - ConsolePlugin.log(e); - } + write("\n"); //$NON-NLS-1$ + } catch (IOException e) { + ConsolePlugin.log(e); + } } /** @@ -94,12 +94,12 @@ public class MessageConsoleStream extends IOConsoleOutputStream { print(message + "\n"); //$NON-NLS-1$ } - /** - * Returns the console this stream is connected to. - * - * @return the console this stream is connected to - */ - public MessageConsole getConsole() { - return fMessageConsole; - } + /** + * Returns the console this stream is connected to. + * + * @return the console this stream is connected to + */ + public MessageConsole getConsole() { + return fMessageConsole; + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/PatternMatchEvent.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/PatternMatchEvent.java index 309b64b34..4467836ae 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/PatternMatchEvent.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/PatternMatchEvent.java @@ -24,50 +24,50 @@ import java.util.EventObject; * @noextend This class is not intended to be subclassed by clients. */ public class PatternMatchEvent extends EventObject { - /* - * required by EventObject for ObjectSerialization. - */ - private static final long serialVersionUID = 876890383326854537L; + /* + * required by EventObject for ObjectSerialization. + */ + private static final long serialVersionUID = 876890383326854537L; - /** - * The offset of the match within the console's document. - */ - private int offset; + /** + * The offset of the match within the console's document. + */ + private int offset; - /** - * The length of the matched string - */ - private int length; + /** + * The length of the matched string + */ + private int length; - /** - * Constructs a new pattern match event. - * - * @param console the console in which the match was found - * @param matchOffset the offset at which the match was found - * @param matchLength the length of the text that matched - */ - public PatternMatchEvent(TextConsole console, int matchOffset, int matchLength) { - super(console); - offset = matchOffset; - length = matchLength; - } + /** + * Constructs a new pattern match event. + * + * @param console the console in which the match was found + * @param matchOffset the offset at which the match was found + * @param matchLength the length of the text that matched + */ + public PatternMatchEvent(TextConsole console, int matchOffset, int matchLength) { + super(console); + offset = matchOffset; + length = matchLength; + } - /** - * Returns the length of the matched string. - * - * @return the length of the matched string - */ - public int getLength() { - return length; - } + /** + * Returns the length of the matched string. + * + * @return the length of the matched string + */ + public int getLength() { + return length; + } - /** - * Returns the offset of the match within the document. - * - * @return the offset of the match within the document - */ - public int getOffset() { - return offset; - } + /** + * Returns the offset of the match within the document. + * + * @return the offset of the match within the document + */ + public int getOffset() { + return offset; + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java index 49cfc55a7..02c17158f 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java @@ -44,185 +44,185 @@ import org.eclipse.ui.part.IPageBookViewPage; */ public abstract class TextConsole extends AbstractConsole { - /** - * The current width of the console. Used for fixed width consoles. - * A value of <=0 means does not have a fixed width. - */ - private int fConsoleWidth; - /** - * The current tab width - */ - private int fTabWidth; - /** + /** + * The current width of the console. Used for fixed width consoles. + * A value of <=0 means does not have a fixed width. + */ + private int fConsoleWidth; + /** + * The current tab width + */ + private int fTabWidth; + /** * The font used by this console */ - private Font fFont; + private Font fFont; - /** - * The background color used by this console or <code>null</code> if default - */ - private Color fBackground; + /** + * The background color used by this console or <code>null</code> if default + */ + private Color fBackground; - /** - * The Console's regular expression pattern matcher - */ - private ConsolePatternMatcher fPatternMatcher; + /** + * The Console's regular expression pattern matcher + */ + private ConsolePatternMatcher fPatternMatcher; - /** - * The Console's document - */ - private ConsoleDocument fDocument; + /** + * The Console's document + */ + private ConsoleDocument fDocument; - /** - * indication that the console's partitioner is not expecting more input - */ - private boolean fPartitionerFinished = false; + /** + * indication that the console's partitioner is not expecting more input + */ + private boolean fPartitionerFinished = false; - /** - * Indication that the console's pattern matcher has finished. - * (all matches have been found and all listeners notified) - */ - private boolean fMatcherFinished = false; + /** + * Indication that the console's pattern matcher has finished. + * (all matches have been found and all listeners notified) + */ + private boolean fMatcherFinished = false; - /** - * indication that the console output complete property has been fired - */ - private boolean fCompleteFired = false; + /** + * indication that the console output complete property has been fired + */ + private boolean fCompleteFired = false; - /** - * Map of client defined attributes - */ + /** + * Map of client defined attributes + */ private HashMap<String, Object> fAttributes = new HashMap<String, Object>(); - private IConsoleManager fConsoleManager = ConsolePlugin.getDefault().getConsoleManager(); + private IConsoleManager fConsoleManager = ConsolePlugin.getDefault().getConsoleManager(); - /* (non-Javadoc) - * @see org.eclipse.ui.console.AbstractConsole#dispose() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.console.AbstractConsole#dispose() + */ + @Override protected void dispose() { - super.dispose(); - fFont = null; + super.dispose(); + fFont = null; synchronized(fAttributes) { - fAttributes.clear(); + fAttributes.clear(); } - } - /** - * Constructs a console with the given name, image descriptor, and lifecycle - * - * @param name name to display for this console - * @param consoleType console type identifier or <code>null</code> - * @param imageDescriptor image to display for this console or <code>null</code> - * @param autoLifecycle whether lifecycle methods should be called automatically - * when this console is added/removed from the console manager - */ - public TextConsole(String name, String consoleType, ImageDescriptor imageDescriptor, boolean autoLifecycle) { - super(name, consoleType, imageDescriptor, autoLifecycle); - fDocument = new ConsoleDocument(); - fDocument.addPositionCategory(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); - fPatternMatcher = new ConsolePatternMatcher(this); - fDocument.addDocumentListener(fPatternMatcher); - fTabWidth = IConsoleConstants.DEFAULT_TAB_SIZE; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.console.IConsole#createPage(org.eclipse.ui.console.IConsoleView) - */ - @Override + } + /** + * Constructs a console with the given name, image descriptor, and lifecycle + * + * @param name name to display for this console + * @param consoleType console type identifier or <code>null</code> + * @param imageDescriptor image to display for this console or <code>null</code> + * @param autoLifecycle whether lifecycle methods should be called automatically + * when this console is added/removed from the console manager + */ + public TextConsole(String name, String consoleType, ImageDescriptor imageDescriptor, boolean autoLifecycle) { + super(name, consoleType, imageDescriptor, autoLifecycle); + fDocument = new ConsoleDocument(); + fDocument.addPositionCategory(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); + fPatternMatcher = new ConsolePatternMatcher(this); + fDocument.addDocumentListener(fPatternMatcher); + fTabWidth = IConsoleConstants.DEFAULT_TAB_SIZE; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.console.IConsole#createPage(org.eclipse.ui.console.IConsoleView) + */ + @Override public IPageBookViewPage createPage(IConsoleView view) { - return new TextConsolePage(this, view); - } + return new TextConsolePage(this, view); + } /** * Returns this console's document. - * <p> - * Note that a console may or may not support direct manipulation of its document. - * For example, an I/O console document and its partitions are produced from the - * streams connected to it, and clients are not intended to modify the document's - * contents. - * </p> + * <p> + * Note that a console may or may not support direct manipulation of its document. + * For example, an I/O console document and its partitions are produced from the + * streams connected to it, and clients are not intended to modify the document's + * contents. + * </p> * * @return this console's document */ - public IDocument getDocument() { - return fDocument; - } - - /** - * Returns the current width of this console. A value of zero of less - * indicates this console has no fixed width. - * - * @return the current width of this console - */ - public int getConsoleWidth() { - return fConsoleWidth; - } - - /** - * Sets the width of this console in characters. Any value greater than zero - * will cause this console to have a fixed width. - * - * @param width the width to make this console. Values of 0 or less imply - * the console does not have any fixed width. - */ - public void setConsoleWidth(int width) { - if (fConsoleWidth != width) { - int old = fConsoleWidth; - fConsoleWidth = width; - - firePropertyChange(this, IConsoleConstants.P_CONSOLE_WIDTH, Integer.valueOf(old), Integer.valueOf(fConsoleWidth)); - } - } + public IDocument getDocument() { + return fDocument; + } + + /** + * Returns the current width of this console. A value of zero of less + * indicates this console has no fixed width. + * + * @return the current width of this console + */ + public int getConsoleWidth() { + return fConsoleWidth; + } + + /** + * Sets the width of this console in characters. Any value greater than zero + * will cause this console to have a fixed width. + * + * @param width the width to make this console. Values of 0 or less imply + * the console does not have any fixed width. + */ + public void setConsoleWidth(int width) { + if (fConsoleWidth != width) { + int old = fConsoleWidth; + fConsoleWidth = width; + + firePropertyChange(this, IConsoleConstants.P_CONSOLE_WIDTH, Integer.valueOf(old), Integer.valueOf(fConsoleWidth)); + } + } /** * Sets the tab width used in this console. * * @param newTabWidth the tab width */ - public void setTabWidth(final int newTabWidth) { - if (fTabWidth != newTabWidth) { - final int oldTabWidth = fTabWidth; - fTabWidth = newTabWidth; - ConsolePlugin.getStandardDisplay().asyncExec(new Runnable() { - @Override + public void setTabWidth(final int newTabWidth) { + if (fTabWidth != newTabWidth) { + final int oldTabWidth = fTabWidth; + fTabWidth = newTabWidth; + ConsolePlugin.getStandardDisplay().asyncExec(new Runnable() { + @Override public void run() { - firePropertyChange(TextConsole.this, IConsoleConstants.P_TAB_SIZE, Integer.valueOf(oldTabWidth), Integer.valueOf(fTabWidth)); - } - }); - } - } + firePropertyChange(TextConsole.this, IConsoleConstants.P_TAB_SIZE, Integer.valueOf(oldTabWidth), Integer.valueOf(fTabWidth)); + } + }); + } + } /** * Returns the tab width used in this console. * * @return tab width used in this console */ - public int getTabWidth() { - return fTabWidth; - } + public int getTabWidth() { + return fTabWidth; + } - /** + /** * Returns the font used by this console. Must be called in the UI thread. * * @return font used by this console */ - public Font getFont() { - if (fFont == null) { - fFont = getDefaultFont(); - } - return fFont; - } + public Font getFont() { + if (fFont == null) { + fFont = getDefaultFont(); + } + return fFont; + } - /** - * Returns the default text font. - * - * @return the default text font - */ - private Font getDefaultFont() { - return JFaceResources.getFont(JFaceResources.TEXT_FONT); - } + /** + * Returns the default text font. + * + * @return the default text font + */ + private Font getDefaultFont() { + return JFaceResources.getFont(JFaceResources.TEXT_FONT); + } /** * Sets the font used by this console. Specify <code>null</code> to use @@ -230,21 +230,21 @@ public abstract class TextConsole extends AbstractConsole { * * @param newFont font, or <code>null</code> to indicate the default font */ - public void setFont(Font newFont) { - // ensure font is initialized - getFont(); - // translate null to default font + public void setFont(Font newFont) { + // ensure font is initialized + getFont(); + // translate null to default font Font font = newFont; if (font == null) { font = getDefaultFont(); - } - // fire property change if required + } + // fire property change if required if (!fFont.equals(font)) { - Font old = fFont; + Font old = fFont; fFont = font; - firePropertyChange(this, IConsoleConstants.P_FONT, old, fFont); - } - } + firePropertyChange(this, IConsoleConstants.P_FONT, old, fFont); + } + } /** * Sets the background color used by this console. Specify <code>null</code> to use @@ -256,8 +256,8 @@ public abstract class TextConsole extends AbstractConsole { */ @Deprecated public void setBackgrond(Color background) { - setBackground(background); - } + setBackground(background); + } /** * Sets the background color used by this console. Specify <code>null</code> to use @@ -266,91 +266,91 @@ public abstract class TextConsole extends AbstractConsole { * @param background background color or <code>null</code> for default * @since 3.3 */ - public void setBackground(Color background) { - if (fBackground == null) { - if (background == null) { - return; - } - } else if (fBackground.equals(background)){ - return; - } - Color old = fBackground; - fBackground = background; - firePropertyChange(this, IConsoleConstants.P_BACKGROUND_COLOR, old, fBackground); - } - - /** - * Returns the background color to use for this console or <code>null</code> for the - * default background color. - * - * @return background color or <code>null</code> for default - * @since 3.3 - */ - public Color getBackground() { - return fBackground; - } - - /** - * Clears the console. - * <p> - * Since a console may or may not support direct manipulation - * of its document's contents, this method should be called to clear a text console's - * document. The default implementation sets this console's document content - * to the empty string directly. Subclasses should override as required. - * </p> - */ - public void clearConsole() { - IDocument document = getDocument(); - if (document != null) { - document.set(""); //$NON-NLS-1$ - } - } - - /** - * Returns the console's document partitioner. - * @return The console's document partitioner - */ - protected abstract IConsoleDocumentPartitioner getPartitioner(); - - /** - * Returns all hyperlinks in this console. - * - * @return all hyperlinks in this console - */ - public IHyperlink[] getHyperlinks() { - try { - Position[] positions = getDocument().getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); - IHyperlink[] hyperlinks = new IHyperlink[positions.length]; - for (int i = 0; i < positions.length; i++) { - ConsoleHyperlinkPosition position = (ConsoleHyperlinkPosition) positions[i]; - hyperlinks[i] = position.getHyperLink(); - } - return hyperlinks; - } catch (BadPositionCategoryException e) { - return new IHyperlink[0]; - } - } - - /** - * Returns the hyperlink at the given offset of <code>null</code> if none. - * - * @param offset offset for which a hyperlink is requested - * @return the hyperlink at the given offset of <code>null</code> if none - */ - public IHyperlink getHyperlink(int offset) { - try { - IDocument document = getDocument(); - if (document != null) { - Position[] positions = document.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); - Position position = findPosition(offset, positions); - if (position instanceof ConsoleHyperlinkPosition) { - return ((ConsoleHyperlinkPosition) position).getHyperLink(); - } - } - } catch (BadPositionCategoryException e) { - } - return null; - } + public void setBackground(Color background) { + if (fBackground == null) { + if (background == null) { + return; + } + } else if (fBackground.equals(background)){ + return; + } + Color old = fBackground; + fBackground = background; + firePropertyChange(this, IConsoleConstants.P_BACKGROUND_COLOR, old, fBackground); + } + + /** + * Returns the background color to use for this console or <code>null</code> for the + * default background color. + * + * @return background color or <code>null</code> for default + * @since 3.3 + */ + public Color getBackground() { + return fBackground; + } + + /** + * Clears the console. + * <p> + * Since a console may or may not support direct manipulation + * of its document's contents, this method should be called to clear a text console's + * document. The default implementation sets this console's document content + * to the empty string directly. Subclasses should override as required. + * </p> + */ + public void clearConsole() { + IDocument document = getDocument(); + if (document != null) { + document.set(""); //$NON-NLS-1$ + } + } + + /** + * Returns the console's document partitioner. + * @return The console's document partitioner + */ + protected abstract IConsoleDocumentPartitioner getPartitioner(); + + /** + * Returns all hyperlinks in this console. + * + * @return all hyperlinks in this console + */ + public IHyperlink[] getHyperlinks() { + try { + Position[] positions = getDocument().getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); + IHyperlink[] hyperlinks = new IHyperlink[positions.length]; + for (int i = 0; i < positions.length; i++) { + ConsoleHyperlinkPosition position = (ConsoleHyperlinkPosition) positions[i]; + hyperlinks[i] = position.getHyperLink(); + } + return hyperlinks; + } catch (BadPositionCategoryException e) { + return new IHyperlink[0]; + } + } + + /** + * Returns the hyperlink at the given offset of <code>null</code> if none. + * + * @param offset offset for which a hyperlink is requested + * @return the hyperlink at the given offset of <code>null</code> if none + */ + public IHyperlink getHyperlink(int offset) { + try { + IDocument document = getDocument(); + if (document != null) { + Position[] positions = document.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); + Position position = findPosition(offset, positions); + if (position instanceof ConsoleHyperlinkPosition) { + return ((ConsoleHyperlinkPosition) position).getHyperLink(); + } + } + } catch (BadPositionCategoryException e) { + } + return null; + } /** * Binary search for the position at a given offset. @@ -398,133 +398,133 @@ public abstract class TextConsole extends AbstractConsole { return null; } - /** - * Adds the given pattern match listener to this console. The listener will - * be connected and receive match notifications. Has no effect if an identical - * listener has already been added. - * - * @param listener the listener to add - */ - public void addPatternMatchListener(IPatternMatchListener listener) { - fPatternMatcher.addPatternMatchListener(listener); - } - - /** - * Removes the given pattern match listener from this console. The listener will be - * disconnected and will no longer receive match notifications. Has no effect - * if the listener was not previously added. - * - * @param listener the pattern match listener to remove - */ - public void removePatternMatchListener(IPatternMatchListener listener) { - fPatternMatcher.removePatternMatchListener(listener); - } - - - /** - * Job scheduling rule that prevent the job from running if the console's PatternMatcher - * is active. - */ - private class MatcherSchedulingRule implements ISchedulingRule { - @Override + /** + * Adds the given pattern match listener to this console. The listener will + * be connected and receive match notifications. Has no effect if an identical + * listener has already been added. + * + * @param listener the listener to add + */ + public void addPatternMatchListener(IPatternMatchListener listener) { + fPatternMatcher.addPatternMatchListener(listener); + } + + /** + * Removes the given pattern match listener from this console. The listener will be + * disconnected and will no longer receive match notifications. Has no effect + * if the listener was not previously added. + * + * @param listener the pattern match listener to remove + */ + public void removePatternMatchListener(IPatternMatchListener listener) { + fPatternMatcher.removePatternMatchListener(listener); + } + + + /** + * Job scheduling rule that prevent the job from running if the console's PatternMatcher + * is active. + */ + private class MatcherSchedulingRule implements ISchedulingRule { + @Override public boolean contains(ISchedulingRule rule) { - return rule == this; - } + return rule == this; + } - @Override + @Override public boolean isConflicting(ISchedulingRule rule) { - if (contains(rule)) { - return true; - } - if (rule != this && rule instanceof MatcherSchedulingRule) { - return (((MatcherSchedulingRule)rule).getConsole() == TextConsole.this); - } - return false; - } - - public TextConsole getConsole() { - return TextConsole.this; - } - } - - /** - * Returns a scheduling rule which can be used to prevent jobs from running - * while this console's pattern matcher is active. - * <p> - * Although this scheduling rule prevents jobs from running at the same time as - * pattern matching jobs for this console, it does not enforce any ordering of jobs. - * Since 3.2, pattern matching jobs belong to the job family identified by the console - * object that matching is occurring on. To ensure a job runs after all scheduled pattern - * matching is complete, clients must join on this console's job family. - * </p> - * @return a scheduling rule which can be used to prevent jobs from running - * while this console's pattern matcher is active - */ - public ISchedulingRule getSchedulingRule() { - return new MatcherSchedulingRule(); - } - - /** - * This console's partitioner should call this method when it is not expecting any new data - * to be appended to the document. - */ - public void partitionerFinished() { - fPatternMatcher.forceFinalMatching(); - fPartitionerFinished = true; - checkFinished(); - } - - /** - * Called by this console's pattern matcher when matching is complete. - * <p> - * Clients should not call this method. - * <p> - */ - public void matcherFinished() { - fMatcherFinished = true; - fDocument.removeDocumentListener(fPatternMatcher); - checkFinished(); - } - - /** - * Fires the console output complete property change event. - */ - private synchronized void checkFinished() { - if (!fCompleteFired && fPartitionerFinished && fMatcherFinished ) { - fCompleteFired = true; - firePropertyChange(this, IConsoleConstants.P_CONSOLE_OUTPUT_COMPLETE, null, null); - } - } - - /** - * Adds a hyperlink to this console. - * - * @param hyperlink the hyperlink to add - * @param offset the offset in the console document at which the hyperlink should be added - * @param length the length of the text which should be hyperlinked - * @throws BadLocationException if the specified location is not valid. - */ - public void addHyperlink(IHyperlink hyperlink, int offset, int length) throws BadLocationException { - IDocument document = getDocument(); + if (contains(rule)) { + return true; + } + if (rule != this && rule instanceof MatcherSchedulingRule) { + return (((MatcherSchedulingRule)rule).getConsole() == TextConsole.this); + } + return false; + } + + public TextConsole getConsole() { + return TextConsole.this; + } + } + + /** + * Returns a scheduling rule which can be used to prevent jobs from running + * while this console's pattern matcher is active. + * <p> + * Although this scheduling rule prevents jobs from running at the same time as + * pattern matching jobs for this console, it does not enforce any ordering of jobs. + * Since 3.2, pattern matching jobs belong to the job family identified by the console + * object that matching is occurring on. To ensure a job runs after all scheduled pattern + * matching is complete, clients must join on this console's job family. + * </p> + * @return a scheduling rule which can be used to prevent jobs from running + * while this console's pattern matcher is active + */ + public ISchedulingRule getSchedulingRule() { + return new MatcherSchedulingRule(); + } + + /** + * This console's partitioner should call this method when it is not expecting any new data + * to be appended to the document. + */ + public void partitionerFinished() { + fPatternMatcher.forceFinalMatching(); + fPartitionerFinished = true; + checkFinished(); + } + + /** + * Called by this console's pattern matcher when matching is complete. + * <p> + * Clients should not call this method. + * <p> + */ + public void matcherFinished() { + fMatcherFinished = true; + fDocument.removeDocumentListener(fPatternMatcher); + checkFinished(); + } + + /** + * Fires the console output complete property change event. + */ + private synchronized void checkFinished() { + if (!fCompleteFired && fPartitionerFinished && fMatcherFinished ) { + fCompleteFired = true; + firePropertyChange(this, IConsoleConstants.P_CONSOLE_OUTPUT_COMPLETE, null, null); + } + } + + /** + * Adds a hyperlink to this console. + * + * @param hyperlink the hyperlink to add + * @param offset the offset in the console document at which the hyperlink should be added + * @param length the length of the text which should be hyperlinked + * @throws BadLocationException if the specified location is not valid. + */ + public void addHyperlink(IHyperlink hyperlink, int offset, int length) throws BadLocationException { + IDocument document = getDocument(); ConsoleHyperlinkPosition hyperlinkPosition = new ConsoleHyperlinkPosition(hyperlink, offset, length); try { document.addPosition(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY, hyperlinkPosition); - fConsoleManager.refresh(this); + fConsoleManager.refresh(this); } catch (BadPositionCategoryException e) { ConsolePlugin.log(e); } - } - - /** - * Returns the region associated with the given hyperlink. - * - * @param link hyperlink - * @return the region associated with the hyperlink or null if the hyperlink is not found. - */ - public IRegion getRegion(IHyperlink link) { + } + + /** + * Returns the region associated with the given hyperlink. + * + * @param link hyperlink + * @return the region associated with the hyperlink or null if the hyperlink is not found. + */ + public IRegion getRegion(IHyperlink link) { try { - IDocument doc = getDocument(); - if (doc != null) { + IDocument doc = getDocument(); + if (doc != null) { Position[] positions = doc.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); for (int i = 0; i < positions.length; i++) { ConsoleHyperlinkPosition position = (ConsoleHyperlinkPosition)positions[i]; @@ -532,33 +532,33 @@ public abstract class TextConsole extends AbstractConsole { return new Region(position.getOffset(), position.getLength()); } } - } + } } catch (BadPositionCategoryException e) { } return null; - } - - /** - * Returns the attribute associated with the specified key. - * - * @param key attribute key - * @return the attribute associated with the specified key - */ - public Object getAttribute(String key) { - synchronized (fAttributes) { - return fAttributes.get(key); - } - } - - /** - * Sets an attribute value. Intended for client data. - * - * @param key attribute key - * @param value attribute value - */ - public void setAttribute(String key, Object value) { - synchronized(fAttributes) { - fAttributes.put(key, value); - } - } + } + + /** + * Returns the attribute associated with the specified key. + * + * @param key attribute key + * @return the attribute associated with the specified key + */ + public Object getAttribute(String key) { + synchronized (fAttributes) { + return fAttributes.get(key); + } + } + + /** + * Sets an attribute value. Intended for client data. + * + * @param key attribute key + * @param value attribute value + */ + public void setAttribute(String key, Object value) { + synchronized(fAttributes) { + fAttributes.put(key, value); + } + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java index c23bcd145..a0fefa943 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java @@ -70,14 +70,14 @@ import org.eclipse.ui.texteditor.IUpdate; * @since 3.1 */ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListener, IAdaptable { - private IPageSite fSite; - private TextConsole fConsole; - private IConsoleView fConsoleView; - private TextConsoleViewer fViewer; - private MenuManager fMenuManager; + private IPageSite fSite; + private TextConsole fConsole; + private IConsoleView fConsoleView; + private TextConsoleViewer fViewer; + private MenuManager fMenuManager; protected Map<String, IAction> fGlobalActions = new HashMap<String, IAction>(); protected ArrayList<String> fSelectionActions = new ArrayList<String>(); - protected ClearOutputAction fClearOutputAction; + protected ClearOutputAction fClearOutputAction; // text selection listener, used to update selection dependent actions on selection changes private ISelectionChangedListener selectionChangedListener = new ISelectionChangedListener() { @@ -89,7 +89,7 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen // updates the find replace action and the clear action if the document length is > 0 private ITextListener textListener = new ITextListener() { - @Override + @Override public void textChanged(TextEvent event) { IUpdate findReplace = (IUpdate)fGlobalActions.get(ActionFactory.FIND.getId()); if (findReplace != null) { @@ -105,61 +105,61 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen } }; - /** - * Constructs a text console page for the given console in the given view. - * - * @param console text console - * @param view console view the page is contained in - */ + /** + * Constructs a text console page for the given console in the given view. + * + * @param console text console + * @param view console view the page is contained in + */ public TextConsolePage(TextConsole console, IConsoleView view) { - fConsole = console; - fConsoleView = view; + fConsole = console; + fConsoleView = view; } - /** - * Returns a viewer used to display the contents of this page's console. - * - * @param parent container for the viewer - * @return a viewer used to display the contents of this page's console - */ + /** + * Returns a viewer used to display the contents of this page's console. + * + * @param parent container for the viewer + * @return a viewer used to display the contents of this page's console + */ protected TextConsoleViewer createViewer(Composite parent) { return new TextConsoleViewer(parent, fConsole, fConsoleView); } - /* - * (non-Javadoc) - * @see org.eclipse.ui.part.IPageBookViewPage#getSite() - */ - @Override + /* + * (non-Javadoc) + * @see org.eclipse.ui.part.IPageBookViewPage#getSite() + */ + @Override public IPageSite getSite() { - return fSite; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.part.IPageBookViewPage#init(org.eclipse.ui.part.IPageSite) - */ - @Override + return fSite; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.part.IPageBookViewPage#init(org.eclipse.ui.part.IPageSite) + */ + @Override public void init(IPageSite pageSite) throws PartInitException { - fSite = pageSite; - } + fSite = pageSite; + } - /** - * Updates selection dependent actions. - */ - protected void updateSelectionDependentActions() { + /** + * Updates selection dependent actions. + */ + protected void updateSelectionDependentActions() { for (String string : fSelectionActions) { updateAction(string); } } - /* - * (non-Javadoc) - * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) - */ + /* + * (non-Javadoc) + * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) + */ @Override public void createControl(Composite parent) { - fViewer = createViewer(parent); + fViewer = createViewer(parent); fViewer.setConsoleWidth(fConsole.getConsoleWidth()); fViewer.setTabWidth(fConsole.getTabWidth()); fConsole.addPropertyChangeListener(this); @@ -167,7 +167,7 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen String id = "#ContextMenu"; //$NON-NLS-1$ if (getConsole().getType() != null) { - id = getConsole().getType() + "." + id; //$NON-NLS-1$ + id = getConsole().getType() + "." + id; //$NON-NLS-1$ } fMenuManager= new MenuManager("#ContextMenu", id); //$NON-NLS-1$ fMenuManager.setRemoveAllWhenShown(true); @@ -188,90 +188,90 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen fViewer.getSelectionProvider().addSelectionChangedListener(selectionChangedListener); fViewer.addTextListener(textListener); - } + } - /* - * (non-Javadoc) - * @see org.eclipse.ui.part.IPage#dispose() - */ - @Override + /* + * (non-Javadoc) + * @see org.eclipse.ui.part.IPage#dispose() + */ + @Override public void dispose() { - fConsole.removePropertyChangeListener(this); - JFaceResources.getFontRegistry().removeListener(this); - - if (fMenuManager != null) { - fMenuManager.dispose(); - } - fClearOutputAction = null; - fSelectionActions.clear(); - fGlobalActions.clear(); - - fViewer.getSelectionProvider().removeSelectionChangedListener(selectionChangedListener); - fViewer.removeTextListener(textListener); - fViewer = null; - } - - - /* - * (non-Javadoc) - * @see org.eclipse.ui.part.IPage#getControl() - */ - @Override + fConsole.removePropertyChangeListener(this); + JFaceResources.getFontRegistry().removeListener(this); + + if (fMenuManager != null) { + fMenuManager.dispose(); + } + fClearOutputAction = null; + fSelectionActions.clear(); + fGlobalActions.clear(); + + fViewer.getSelectionProvider().removeSelectionChangedListener(selectionChangedListener); + fViewer.removeTextListener(textListener); + fViewer = null; + } + + + /* + * (non-Javadoc) + * @see org.eclipse.ui.part.IPage#getControl() + */ + @Override public Control getControl() { - return fViewer != null ? fViewer.getControl() : null; - } + return fViewer != null ? fViewer.getControl() : null; + } - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) + */ + @Override public void setActionBars(IActionBars actionBars) { - } + } - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setFocus() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.part.IPage#setFocus() + */ + @Override public void setFocus() { - if (fViewer != null) { - fViewer.getTextWidget().setFocus(); + if (fViewer != null) { + fViewer.getTextWidget().setFocus(); updateAction(ActionFactory.FIND.getId()); - } - } + } + } /* * (non-Javadoc) * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ - @Override + @Override public void propertyChange(PropertyChangeEvent event) { - if (fViewer != null) { + if (fViewer != null) { Object source = event.getSource(); String property = event.getProperty(); if (source.equals(fConsole) && IConsoleConstants.P_FONT.equals(property)) { fViewer.setFont(fConsole.getFont()); } else if (IConsoleConstants.P_FONT_STYLE.equals(property)) { - fViewer.getTextWidget().redraw(); + fViewer.getTextWidget().redraw(); } else if (property.equals(IConsoleConstants.P_STREAM_COLOR)) { - fViewer.getTextWidget().redraw(); + fViewer.getTextWidget().redraw(); } else if (source.equals(fConsole) && property.equals(IConsoleConstants.P_TAB_SIZE)) { - Integer tabSize = (Integer)event.getNewValue(); - fViewer.setTabWidth(tabSize.intValue()); + Integer tabSize = (Integer)event.getNewValue(); + fViewer.setTabWidth(tabSize.intValue()); } else if (source.equals(fConsole) && property.equals(IConsoleConstants.P_CONSOLE_WIDTH)) { - fViewer.setConsoleWidth(fConsole.getConsoleWidth()); + fViewer.setConsoleWidth(fConsole.getConsoleWidth()); } else if (IConsoleConstants.P_BACKGROUND_COLOR.equals(property)) { fViewer.getTextWidget().setBackground(fConsole.getBackground()); } - } + } } - /** - * Creates actions. - */ - protected void createActions() { - IActionBars actionBars= getSite().getActionBars(); - TextViewerAction action= new TextViewerAction(fViewer, ITextOperationTarget.SELECT_ALL); + /** + * Creates actions. + */ + protected void createActions() { + IActionBars actionBars= getSite().getActionBars(); + TextViewerAction action= new TextViewerAction(fViewer, ITextOperationTarget.SELECT_ALL); action.configureAction(ConsoleMessages.TextConsolePage_SelectAllText, ConsoleMessages.TextConsolePage_SelectAllDescrip, ConsoleMessages.TextConsolePage_SelectAllDescrip); action.setActionDefinitionId(ActionFactory.SELECT_ALL.getCommandId()); PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IConsoleHelpContextIds.CONSOLE_SELECT_ALL_ACTION); @@ -300,9 +300,9 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen fClearOutputAction = new ClearOutputAction(fConsole); - ResourceBundle bundle = ConsoleResourceBundleMessages.getBundle(); - FindReplaceAction fraction = new FindReplaceAction(bundle, "find_replace_action_", fConsoleView); //$NON-NLS-1$ - PlatformUI.getWorkbench().getHelpSystem().setHelp(fraction, IConsoleHelpContextIds.CONSOLE_FIND_REPLACE_ACTION); + ResourceBundle bundle = ConsoleResourceBundleMessages.getBundle(); + FindReplaceAction fraction = new FindReplaceAction(bundle, "find_replace_action_", fConsoleView); //$NON-NLS-1$ + PlatformUI.getWorkbench().getHelpSystem().setHelp(fraction, IConsoleHelpContextIds.CONSOLE_FIND_REPLACE_ACTION); setGlobalAction(actionBars, ActionFactory.FIND.getId(), fraction); fSelectionActions.add(ActionFactory.CUT.getId()); @@ -311,23 +311,23 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen fSelectionActions.add(ActionFactory.FIND.getId()); actionBars.updateActionBars(); - } - - /** - * Configures an action for key bindings. - * - * @param actionBars action bars for this page - * @param actionID action definition id - * @param action associated action - */ - protected void setGlobalAction(IActionBars actionBars, String actionID, IAction action) { - fGlobalActions.put(actionID, action); - actionBars.setGlobalActionHandler(actionID, action); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ + } + + /** + * Configures an action for key bindings. + * + * @param actionBars action bars for this page + * @param actionID action definition id + * @param action associated action + */ + protected void setGlobalAction(IActionBars actionBars, String actionID, IAction action) { + fGlobalActions.put(actionID, action); + actionBars.setGlobalActionHandler(actionID, action); + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) + */ @SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> required) { @@ -338,9 +338,9 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen return (T) fViewer.getTextWidget(); } return null; - } + } - /** + /** * Returns the view this page is contained in. * * @return the view this page is contained in @@ -358,11 +358,11 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen return fConsole; } - /** - * Updates the global action with the given id - * - * @param actionId action definition id - */ + /** + * Updates the global action with the given id + * + * @param actionId action definition id + */ protected void updateAction(String actionId) { IAction action= fGlobalActions.get(actionId); if (action instanceof IUpdate) { @@ -400,21 +400,21 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen } - /** - * Returns the viewer contained in this page. - * - * @return the viewer contained in this page - */ - public TextConsoleViewer getViewer() { - return fViewer; - } - - /** - * Sets the viewer contained in this page. - * - * @param viewer text viewer - */ - public void setViewer(TextConsoleViewer viewer) { - this.fViewer = viewer; - } + /** + * Returns the viewer contained in this page. + * + * @return the viewer contained in this page + */ + public TextConsoleViewer getViewer() { + return fViewer; + } + + /** + * Sets the viewer contained in this page. + * + * @param viewer text viewer + */ + public void setViewer(TextConsoleViewer viewer) { + this.fViewer = viewer; + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java index fe5b069af..0b28a96e1 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java @@ -74,64 +74,64 @@ import org.eclipse.ui.progress.WorkbenchJob; * @since 3.1 */ public class TextConsoleViewer extends SourceViewer implements LineStyleListener, LineBackgroundListener, MouseTrackListener, MouseMoveListener, MouseListener { - /** - * Adapts document to the text widget. - */ - private ConsoleDocumentAdapter documentAdapter; + /** + * Adapts document to the text widget. + */ + private ConsoleDocumentAdapter documentAdapter; - private IHyperlink hyperlink; + private IHyperlink hyperlink; - private Cursor handCursor; + private Cursor handCursor; - private Cursor textCursor; + private Cursor textCursor; - private int consoleWidth = -1; + private int consoleWidth = -1; - private TextConsole console; + private TextConsole console; - private IPropertyChangeListener propertyChangeListener; + private IPropertyChangeListener propertyChangeListener; private IScrollLockStateProvider scrollLockStateProvider; - private IDocumentListener documentListener = new IDocumentListener() { - @Override + private IDocumentListener documentListener = new IDocumentListener() { + @Override public void documentAboutToBeChanged(DocumentEvent event) { - } + } - @Override + @Override public void documentChanged(DocumentEvent event) { - updateLinks(event.fOffset); - } - }; - // event listener used to send event to hyperlink for IHyperlink2 - private Listener mouseUpListener = new Listener() { + updateLinks(event.fOffset); + } + }; + // event listener used to send event to hyperlink for IHyperlink2 + private Listener mouseUpListener = new Listener() { @Override public void handleEvent(Event event) { - if (hyperlink != null) { - String selection = getTextWidget().getSelectionText(); - if (selection.length() <= 0) { - if (event.button == 1) { - if (hyperlink instanceof IHyperlink2) { + if (hyperlink != null) { + String selection = getTextWidget().getSelectionText(); + if (selection.length() <= 0) { + if (event.button == 1) { + if (hyperlink instanceof IHyperlink2) { ((IHyperlink2) hyperlink).linkActivated(event); } else { hyperlink.linkActivated(); } - } - } - } + } + } + } } }; // to store to user scroll lock action private AtomicBoolean userHoldsScrollLock = new AtomicBoolean(false); - WorkbenchJob revealJob = new WorkbenchJob("Reveal End of Document") {//$NON-NLS-1$ - @Override + WorkbenchJob revealJob = new WorkbenchJob("Reveal End of Document") {//$NON-NLS-1$ + @Override public IStatus runInUIThread(IProgressMonitor monitor) { scrollToEndOfDocument(); - return Status.OK_STATUS; - } - }; + return Status.OK_STATUS; + } + }; // reveal the end of the document private void scrollToEndOfDocument() { @@ -171,29 +171,29 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener return false; } - private IPositionUpdater positionUpdater = new IPositionUpdater() { - @Override + private IPositionUpdater positionUpdater = new IPositionUpdater() { + @Override public void update(DocumentEvent event) { - try { - IDocument document = getDocument(); - if (document != null) { - Position[] positions = document.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); - for (int i = 0; i < positions.length; i++) { - Position position = positions[i]; - if (position.offset == event.fOffset && position.length<=event.fLength) { - position.delete(); - } - if (position.isDeleted) { - document.removePosition(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY, position); - } - } - } - } catch (BadPositionCategoryException e) { - } - } - }; - - /** + try { + IDocument document = getDocument(); + if (document != null) { + Position[] positions = document.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); + for (int i = 0; i < positions.length; i++) { + Position position = positions[i]; + if (position.offset == event.fOffset && position.length<=event.fLength) { + position.delete(); + } + if (position.isDeleted) { + document.removePosition(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY, position); + } + } + } + } catch (BadPositionCategoryException e) { + } + } + }; + + /** * Constructs a new viewer in the given parent for the specified console. * * @param parent the containing composite @@ -214,22 +214,22 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener * @param parent containing widget * @param console text console */ - public TextConsoleViewer(Composite parent, TextConsole console) { - super(parent, null, SWT.V_SCROLL | SWT.H_SCROLL); - this.console = console; - - IDocument document = console.getDocument(); - setDocument(document); - - StyledText styledText = getTextWidget(); - styledText.setDoubleClickEnabled(true); - styledText.addLineStyleListener(this); - styledText.addLineBackgroundListener(this); - styledText.setEditable(true); - styledText.setBackground(console.getBackground()); - setFont(console.getFont()); - styledText.addMouseTrackListener(this); - styledText.addListener(SWT.MouseUp, mouseUpListener); + public TextConsoleViewer(Composite parent, TextConsole console) { + super(parent, null, SWT.V_SCROLL | SWT.H_SCROLL); + this.console = console; + + IDocument document = console.getDocument(); + setDocument(document); + + StyledText styledText = getTextWidget(); + styledText.setDoubleClickEnabled(true); + styledText.addLineStyleListener(this); + styledText.addLineBackgroundListener(this); + styledText.setEditable(true); + styledText.setBackground(console.getBackground()); + setFont(console.getFont()); + styledText.addMouseTrackListener(this); + styledText.addListener(SWT.MouseUp, mouseUpListener); // event listener used to send event to vertical scroll bar styledText.getVerticalBar().addSelectionListener(new SelectionAdapter() { @Override @@ -277,7 +277,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener } else if (e.keyCode == SWT.END || e.keyCode == SWT.BOTTOM) { setScrollLock(false);// selecting END makes it reveal the - // end + // end } else if ((e.keyCode == SWT.PAGE_DOWN || e.keyCode == SWT.ARROW_DOWN) && checkEndOfDocument()) { // unlock if Down at the end of document setScrollLock(false); @@ -311,543 +311,543 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener } }); - ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); - propertyChangeListener = new HyperlinkColorChangeListener(); - colorRegistry.addListener(propertyChangeListener); - - revealJob.setSystem(true); - document.addDocumentListener(documentListener); - document.addPositionUpdater(positionUpdater); - } - - /** - * Sets the tab width used by this viewer. - * - * @param tabWidth - * the tab width used by this viewer - */ - public void setTabWidth(int tabWidth) { - StyledText styledText = getTextWidget(); - int oldWidth = styledText.getTabs(); - if (tabWidth != oldWidth) { - styledText.setTabs(tabWidth); - } - } - - /** - * Sets the font used by this viewer. - * - * @param font - * the font used by this viewer - */ - public void setFont(Font font) { - StyledText styledText = getTextWidget(); - Font oldFont = styledText.getFont(); - if (oldFont == font) { - return; - } - if (font == null || !(font.equals(oldFont))) { - styledText.setFont(font); - } - } - - /** - * Positions the cursor at the end of the document. - */ - protected void revealEndOfDocument() { - revealJob.schedule(50); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.custom.LineStyleListener#lineGetStyle(org.eclipse.swt.custom.LineStyleEvent) - */ - @Override + ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); + propertyChangeListener = new HyperlinkColorChangeListener(); + colorRegistry.addListener(propertyChangeListener); + + revealJob.setSystem(true); + document.addDocumentListener(documentListener); + document.addPositionUpdater(positionUpdater); + } + + /** + * Sets the tab width used by this viewer. + * + * @param tabWidth + * the tab width used by this viewer + */ + public void setTabWidth(int tabWidth) { + StyledText styledText = getTextWidget(); + int oldWidth = styledText.getTabs(); + if (tabWidth != oldWidth) { + styledText.setTabs(tabWidth); + } + } + + /** + * Sets the font used by this viewer. + * + * @param font + * the font used by this viewer + */ + public void setFont(Font font) { + StyledText styledText = getTextWidget(); + Font oldFont = styledText.getFont(); + if (oldFont == font) { + return; + } + if (font == null || !(font.equals(oldFont))) { + styledText.setFont(font); + } + } + + /** + * Positions the cursor at the end of the document. + */ + protected void revealEndOfDocument() { + revealJob.schedule(50); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.custom.LineStyleListener#lineGetStyle(org.eclipse.swt.custom.LineStyleEvent) + */ + @Override public void lineGetStyle(LineStyleEvent event) { - IDocument document = getDocument(); - if (document != null && document.getLength() > 0) { + IDocument document = getDocument(); + if (document != null && document.getLength() > 0) { ArrayList<StyleRange> ranges = new ArrayList<StyleRange>(); - int offset = event.lineOffset; - int length = event.lineText.length(); - - StyleRange[] partitionerStyles = ((IConsoleDocumentPartitioner) document.getDocumentPartitioner()).getStyleRanges(event.lineOffset, event.lineText.length()); - if (partitionerStyles != null) { - for (int i = 0; i < partitionerStyles.length; i++) { - ranges.add(partitionerStyles[i]); - } - } else { - ranges.add(new StyleRange(offset, length, null, null)); - } - - try { - Position[] positions = getDocument().getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); - Position[] overlap = findPosition(offset, length, positions); - Color color = JFaceColors.getHyperlinkText(Display.getCurrent()); - if (overlap != null) { - for (int i = 0; i < overlap.length; i++) { - Position position = overlap[i]; - StyleRange linkRange = new StyleRange(position.offset, position.length, color, null); - linkRange.underline = true; - override(ranges, linkRange); - } - } - } catch (BadPositionCategoryException e) { - } - - if (ranges.size() > 0) { - event.styles = ranges.toArray(new StyleRange[ranges.size()]); - } - } - } + int offset = event.lineOffset; + int length = event.lineText.length(); + + StyleRange[] partitionerStyles = ((IConsoleDocumentPartitioner) document.getDocumentPartitioner()).getStyleRanges(event.lineOffset, event.lineText.length()); + if (partitionerStyles != null) { + for (int i = 0; i < partitionerStyles.length; i++) { + ranges.add(partitionerStyles[i]); + } + } else { + ranges.add(new StyleRange(offset, length, null, null)); + } + + try { + Position[] positions = getDocument().getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); + Position[] overlap = findPosition(offset, length, positions); + Color color = JFaceColors.getHyperlinkText(Display.getCurrent()); + if (overlap != null) { + for (int i = 0; i < overlap.length; i++) { + Position position = overlap[i]; + StyleRange linkRange = new StyleRange(position.offset, position.length, color, null); + linkRange.underline = true; + override(ranges, linkRange); + } + } + } catch (BadPositionCategoryException e) { + } + + if (ranges.size() > 0) { + event.styles = ranges.toArray(new StyleRange[ranges.size()]); + } + } + } private void override(List<StyleRange> ranges, StyleRange newRange) { - if (ranges.isEmpty()) { - ranges.add(newRange); - return; - } - - int start = newRange.start; - int end = start + newRange.length; - for (int i = 0; i < ranges.size(); i++) { - StyleRange existingRange = ranges.get(i); - int rEnd = existingRange.start + existingRange.length; - if (end <= existingRange.start || start >= rEnd) { - continue; - } - - if (start < existingRange.start && end > existingRange.start) { - start = existingRange.start; - } - - if (start >= existingRange.start && end <= rEnd) { - existingRange.length = start - existingRange.start; - ranges.add(++i, newRange); - if (end != rEnd) { - ranges.add(++i, new StyleRange(end, rEnd - end - 1, existingRange.foreground, existingRange.background)); - } - return; - } else if (start >= existingRange.start && start < rEnd) { - existingRange.length = start - existingRange.start; - ranges.add(++i, newRange); - } else if (end >= rEnd) { - ranges.remove(i); - } else { - ranges.add(++i, new StyleRange(end + 1, rEnd - end + 1, existingRange.foreground, existingRange.background)); - } - } - } - - /** - * Binary search for the positions overlapping the given range - * - * @param offset - * the offset of the range - * @param length - * the length of the range - * @param positions - * the positions to search - * @return the positions overlapping the given range, or <code>null</code> - */ - private Position[] findPosition(int offset, int length, Position[] positions) { - - if (positions.length == 0) { + if (ranges.isEmpty()) { + ranges.add(newRange); + return; + } + + int start = newRange.start; + int end = start + newRange.length; + for (int i = 0; i < ranges.size(); i++) { + StyleRange existingRange = ranges.get(i); + int rEnd = existingRange.start + existingRange.length; + if (end <= existingRange.start || start >= rEnd) { + continue; + } + + if (start < existingRange.start && end > existingRange.start) { + start = existingRange.start; + } + + if (start >= existingRange.start && end <= rEnd) { + existingRange.length = start - existingRange.start; + ranges.add(++i, newRange); + if (end != rEnd) { + ranges.add(++i, new StyleRange(end, rEnd - end - 1, existingRange.foreground, existingRange.background)); + } + return; + } else if (start >= existingRange.start && start < rEnd) { + existingRange.length = start - existingRange.start; + ranges.add(++i, newRange); + } else if (end >= rEnd) { + ranges.remove(i); + } else { + ranges.add(++i, new StyleRange(end + 1, rEnd - end + 1, existingRange.foreground, existingRange.background)); + } + } + } + + /** + * Binary search for the positions overlapping the given range + * + * @param offset + * the offset of the range + * @param length + * the length of the range + * @param positions + * the positions to search + * @return the positions overlapping the given range, or <code>null</code> + */ + private Position[] findPosition(int offset, int length, Position[] positions) { + + if (positions.length == 0) { return null; } - int rangeEnd = offset + length; - int left = 0; - int right = positions.length - 1; - int mid = 0; - Position position = null; + int rangeEnd = offset + length; + int left = 0; + int right = positions.length - 1; + int mid = 0; + Position position = null; - while (left < right) { + while (left < right) { - mid = (left + right) / 2; + mid = (left + right) / 2; - position = positions[mid]; - if (rangeEnd < position.getOffset()) { - if (left == mid) { + position = positions[mid]; + if (rangeEnd < position.getOffset()) { + if (left == mid) { right = left; } else { right = mid - 1; } - } else if (offset > (position.getOffset() + position.getLength() - 1)) { - if (right == mid) { + } else if (offset > (position.getOffset() + position.getLength() - 1)) { + if (right == mid) { left = right; } else { left = mid + 1; } - } else { - left = right = mid; - } - } + } else { + left = right = mid; + } + } List<Position> list = new ArrayList<Position>(); - int index = left - 1; - if (index >= 0) { - position = positions[index]; - while (index >= 0 && (position.getOffset() + position.getLength()) > offset) { - index--; - if (index > 0) { - position = positions[index]; - } - } - } - index++; - position = positions[index]; - while (index < positions.length && (position.getOffset() < rangeEnd)) { - list.add(position); - index++; - if (index < positions.length) { - position = positions[index]; - } - } - - if (list.isEmpty()) { - return null; - } - return list.toArray(new Position[list.size()]); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.custom.LineBackgroundListener#lineGetBackground(org.eclipse.swt.custom.LineBackgroundEvent) - */ - @Override + int index = left - 1; + if (index >= 0) { + position = positions[index]; + while (index >= 0 && (position.getOffset() + position.getLength()) > offset) { + index--; + if (index > 0) { + position = positions[index]; + } + } + } + index++; + position = positions[index]; + while (index < positions.length && (position.getOffset() < rangeEnd)) { + list.add(position); + index++; + if (index < positions.length) { + position = positions[index]; + } + } + + if (list.isEmpty()) { + return null; + } + return list.toArray(new Position[list.size()]); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.custom.LineBackgroundListener#lineGetBackground(org.eclipse.swt.custom.LineBackgroundEvent) + */ + @Override public void lineGetBackground(LineBackgroundEvent event) { - event.lineBackground = null; - } - - /** - * Returns the hand cursor. - * - * @return the hand cursor - */ - protected Cursor getHandCursor() { - if (handCursor == null) { - handCursor = new Cursor(ConsolePlugin.getStandardDisplay(), SWT.CURSOR_HAND); - } - return handCursor; - } - - /** - * Returns the text cursor. - * - * @return the text cursor - */ - protected Cursor getTextCursor() { - if (textCursor == null) { - textCursor = new Cursor(ConsolePlugin.getStandardDisplay(), SWT.CURSOR_IBEAM); - } - return textCursor; - } - - /** - * Notification a hyperlink has been entered. - * - * @param link - * the link that was entered - */ - protected void linkEntered(IHyperlink link) { - Control control = getTextWidget(); - if (hyperlink != null) { - linkExited(hyperlink); - } - hyperlink = link; - hyperlink.linkEntered(); - control.setCursor(getHandCursor()); - control.redraw(); - control.addMouseListener(this); - } - - /** - * Notification a link was exited. - * - * @param link - * the link that was exited - */ - protected void linkExited(IHyperlink link) { - link.linkExited(); - hyperlink = null; - Control control = getTextWidget(); - control.setCursor(getTextCursor()); - control.redraw(); - control.removeMouseListener(this); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent) - */ - @Override + event.lineBackground = null; + } + + /** + * Returns the hand cursor. + * + * @return the hand cursor + */ + protected Cursor getHandCursor() { + if (handCursor == null) { + handCursor = new Cursor(ConsolePlugin.getStandardDisplay(), SWT.CURSOR_HAND); + } + return handCursor; + } + + /** + * Returns the text cursor. + * + * @return the text cursor + */ + protected Cursor getTextCursor() { + if (textCursor == null) { + textCursor = new Cursor(ConsolePlugin.getStandardDisplay(), SWT.CURSOR_IBEAM); + } + return textCursor; + } + + /** + * Notification a hyperlink has been entered. + * + * @param link + * the link that was entered + */ + protected void linkEntered(IHyperlink link) { + Control control = getTextWidget(); + if (hyperlink != null) { + linkExited(hyperlink); + } + hyperlink = link; + hyperlink.linkEntered(); + control.setCursor(getHandCursor()); + control.redraw(); + control.addMouseListener(this); + } + + /** + * Notification a link was exited. + * + * @param link + * the link that was exited + */ + protected void linkExited(IHyperlink link) { + link.linkExited(); + hyperlink = null; + Control control = getTextWidget(); + control.setCursor(getTextCursor()); + control.redraw(); + control.removeMouseListener(this); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent) + */ + @Override public void mouseEnter(MouseEvent e) { - getTextWidget().addMouseMoveListener(this); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent) - */ - @Override + getTextWidget().addMouseMoveListener(this); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent) + */ + @Override public void mouseExit(MouseEvent e) { - getTextWidget().removeMouseMoveListener(this); - if (hyperlink != null) { - linkExited(hyperlink); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent) - */ - @Override + getTextWidget().removeMouseMoveListener(this); + if (hyperlink != null) { + linkExited(hyperlink); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent) + */ + @Override public void mouseHover(MouseEvent e) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent) - */ - @Override + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent) + */ + @Override public void mouseMove(MouseEvent e) { - int offset = -1; - try { - Point p = new Point(e.x, e.y); - offset = getTextWidget().getOffsetAtLocation(p); - } catch (IllegalArgumentException ex) { - // out of the document range - } - updateLinks(offset); - } - - /** - * The cursor has just be moved to the given offset, the mouse has hovered - * over the given offset. Update link rendering. - * - * @param offset - */ - protected void updateLinks(int offset) { - if (offset >= 0) { - IHyperlink link = getHyperlink(offset); - if (link != null) { - if (link.equals(hyperlink)) { - return; - } - linkEntered(link); - return; - } - } - if (hyperlink != null) { - linkExited(hyperlink); - } - } - - /** - * Returns the currently active hyperlink or <code>null</code> if none. - * - * @return the currently active hyperlink or <code>null</code> if none - */ - public IHyperlink getHyperlink() { - return hyperlink; - } - - /** - * Returns the hyperlink at the specified offset, or <code>null</code> if - * none. - * - * @param offset - * offset at which a hyperlink has been requested - * @return hyperlink at the specified offset, or <code>null</code> if none - */ - public IHyperlink getHyperlink(int offset) { - if (offset >= 0 && console != null) { - return console.getHyperlink(offset); - } - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent) - */ - @Override + int offset = -1; + try { + Point p = new Point(e.x, e.y); + offset = getTextWidget().getOffsetAtLocation(p); + } catch (IllegalArgumentException ex) { + // out of the document range + } + updateLinks(offset); + } + + /** + * The cursor has just be moved to the given offset, the mouse has hovered + * over the given offset. Update link rendering. + * + * @param offset + */ + protected void updateLinks(int offset) { + if (offset >= 0) { + IHyperlink link = getHyperlink(offset); + if (link != null) { + if (link.equals(hyperlink)) { + return; + } + linkEntered(link); + return; + } + } + if (hyperlink != null) { + linkExited(hyperlink); + } + } + + /** + * Returns the currently active hyperlink or <code>null</code> if none. + * + * @return the currently active hyperlink or <code>null</code> if none + */ + public IHyperlink getHyperlink() { + return hyperlink; + } + + /** + * Returns the hyperlink at the specified offset, or <code>null</code> if + * none. + * + * @param offset + * offset at which a hyperlink has been requested + * @return hyperlink at the specified offset, or <code>null</code> if none + */ + public IHyperlink getHyperlink(int offset) { + if (offset >= 0 && console != null) { + return console.getHyperlink(offset); + } + return null; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent) + */ + @Override public void mouseDoubleClick(MouseEvent e) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent) - */ - @Override + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent) + */ + @Override public void mouseDown(MouseEvent e) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent) - */ - @Override + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent) + */ + @Override public void mouseUp(MouseEvent e) { - } + } - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.TextViewer#createDocumentAdapter() - */ + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.TextViewer#createDocumentAdapter() + */ @Override protected IDocumentAdapter createDocumentAdapter() { - if (documentAdapter == null) { - documentAdapter = new ConsoleDocumentAdapter(consoleWidth = -1); - } - return documentAdapter; - } - - /** - * Sets the console to have a fixed character width. Use -1 to indicate that - * a fixed width should not be used. - * - * @param width - * fixed character width of the console, or -1 - */ - public void setConsoleWidth(int width) { - if (consoleWidth != width) { - consoleWidth = width; - ConsolePlugin.getStandardDisplay().asyncExec(new Runnable() { - @Override + if (documentAdapter == null) { + documentAdapter = new ConsoleDocumentAdapter(consoleWidth = -1); + } + return documentAdapter; + } + + /** + * Sets the console to have a fixed character width. Use -1 to indicate that + * a fixed width should not be used. + * + * @param width + * fixed character width of the console, or -1 + */ + public void setConsoleWidth(int width) { + if (consoleWidth != width) { + consoleWidth = width; + ConsolePlugin.getStandardDisplay().asyncExec(new Runnable() { + @Override public void run() { - if (documentAdapter != null) { - documentAdapter.setWidth(consoleWidth); - } - } - }); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.TextViewer#handleDispose() - */ - @Override + if (documentAdapter != null) { + documentAdapter.setWidth(consoleWidth); + } + } + }); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.TextViewer#handleDispose() + */ + @Override protected void handleDispose() { - IDocument document = getDocument(); - if (document != null) { - document.removeDocumentListener(documentListener); - document.removePositionUpdater(positionUpdater); - } - - StyledText styledText = getTextWidget(); - styledText.removeLineStyleListener(this); - styledText.removeLineBackgroundListener(this); - styledText.removeMouseTrackListener(this); - - if(handCursor != null) { - handCursor.dispose(); - } - handCursor = null; - if(textCursor != null) { - textCursor.dispose(); - } - textCursor = null; - hyperlink = null; - console = null; - - ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); - colorRegistry.removeListener(propertyChangeListener); - - super.handleDispose(); - } - - class HyperlinkColorChangeListener implements IPropertyChangeListener { - @Override + IDocument document = getDocument(); + if (document != null) { + document.removeDocumentListener(documentListener); + document.removePositionUpdater(positionUpdater); + } + + StyledText styledText = getTextWidget(); + styledText.removeLineStyleListener(this); + styledText.removeLineBackgroundListener(this); + styledText.removeMouseTrackListener(this); + + if(handCursor != null) { + handCursor.dispose(); + } + handCursor = null; + if(textCursor != null) { + textCursor.dispose(); + } + textCursor = null; + hyperlink = null; + console = null; + + ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); + colorRegistry.removeListener(propertyChangeListener); + + super.handleDispose(); + } + + class HyperlinkColorChangeListener implements IPropertyChangeListener { + @Override public void propertyChange(PropertyChangeEvent event) { - if (event.getProperty().equals(JFacePreferences.ACTIVE_HYPERLINK_COLOR) || event.getProperty().equals(JFacePreferences.HYPERLINK_COLOR)) { - getTextWidget().redraw(); - } - } + if (event.getProperty().equals(JFacePreferences.ACTIVE_HYPERLINK_COLOR) || event.getProperty().equals(JFacePreferences.HYPERLINK_COLOR)) { + getTextWidget().redraw(); + } + } - } + } - /* - * work around to memory leak in TextViewer$WidgetCommand - */ - @Override + /* + * work around to memory leak in TextViewer$WidgetCommand + */ + @Override protected void updateTextListeners(WidgetCommand cmd) { - super.updateTextListeners(cmd); - cmd.preservedText = null; - cmd.event = null; - cmd.text = null; - } + super.updateTextListeners(cmd); + cmd.preservedText = null; + cmd.event = null; + cmd.text = null; + } - @Override + @Override protected void internalRevealRange(int start, int end) { - StyledText textWidget = getTextWidget(); - int startLine = documentAdapter.getLineAtOffset(start); - int endLine = documentAdapter.getLineAtOffset(end); + StyledText textWidget = getTextWidget(); + int startLine = documentAdapter.getLineAtOffset(start); + int endLine = documentAdapter.getLineAtOffset(end); - int top = textWidget.getTopIndex(); - if (top > -1) { - // scroll vertically + int top = textWidget.getTopIndex(); + if (top > -1) { + // scroll vertically @SuppressWarnings("deprecation") int lines = getVisibleLinesInViewport(); - int bottom = top + lines; - - // two lines at the top and the bottom should always be left - // if window is smaller than 5 lines, always center position is - // chosen - int bufferZone = 2; - if (startLine >= top + bufferZone && startLine <= bottom - bufferZone && endLine >= top + bufferZone && endLine <= bottom - bufferZone) { - - // do not scroll at all as it is already visible - } else { - int delta = Math.max(0, lines - (endLine - startLine)); - textWidget.setTopIndex(startLine - delta / 3); - updateViewportListeners(INTERNAL); - } - - // scroll horizontally - if (endLine < startLine) { - endLine += startLine; - startLine = endLine - startLine; - endLine -= startLine; - } - - int startPixel = -1; - int endPixel = -1; - - if (endLine > startLine) { - // reveal the beginning of the range in the start line - IRegion extent = getExtent(start, start); - startPixel = extent.getOffset() + textWidget.getHorizontalPixel(); - endPixel = startPixel; - } else { - IRegion extent = getExtent(start, end); - startPixel = extent.getOffset() + textWidget.getHorizontalPixel(); - endPixel = startPixel + extent.getLength(); - } - - int visibleStart = textWidget.getHorizontalPixel(); - int visibleEnd = visibleStart + textWidget.getClientArea().width; - - // scroll only if not yet visible - if (startPixel < visibleStart || visibleEnd < endPixel) { - // set buffer zone to 10 pixels - bufferZone = 10; - int newOffset = visibleStart; - int visibleWidth = visibleEnd - visibleStart; - int selectionPixelWidth = endPixel - startPixel; - - if (startPixel < visibleStart) { + int bottom = top + lines; + + // two lines at the top and the bottom should always be left + // if window is smaller than 5 lines, always center position is + // chosen + int bufferZone = 2; + if (startLine >= top + bufferZone && startLine <= bottom - bufferZone && endLine >= top + bufferZone && endLine <= bottom - bufferZone) { + + // do not scroll at all as it is already visible + } else { + int delta = Math.max(0, lines - (endLine - startLine)); + textWidget.setTopIndex(startLine - delta / 3); + updateViewportListeners(INTERNAL); + } + + // scroll horizontally + if (endLine < startLine) { + endLine += startLine; + startLine = endLine - startLine; + endLine -= startLine; + } + + int startPixel = -1; + int endPixel = -1; + + if (endLine > startLine) { + // reveal the beginning of the range in the start line + IRegion extent = getExtent(start, start); + startPixel = extent.getOffset() + textWidget.getHorizontalPixel(); + endPixel = startPixel; + } else { + IRegion extent = getExtent(start, end); + startPixel = extent.getOffset() + textWidget.getHorizontalPixel(); + endPixel = startPixel + extent.getLength(); + } + + int visibleStart = textWidget.getHorizontalPixel(); + int visibleEnd = visibleStart + textWidget.getClientArea().width; + + // scroll only if not yet visible + if (startPixel < visibleStart || visibleEnd < endPixel) { + // set buffer zone to 10 pixels + bufferZone = 10; + int newOffset = visibleStart; + int visibleWidth = visibleEnd - visibleStart; + int selectionPixelWidth = endPixel - startPixel; + + if (startPixel < visibleStart) { newOffset = startPixel; } else if (selectionPixelWidth + bufferZone < visibleWidth) { newOffset = endPixel + bufferZone - visibleWidth; @@ -855,13 +855,13 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener newOffset = startPixel; } - float index = ((float) newOffset) / ((float) getAverageCharWidth()); + float index = ((float) newOffset) / ((float) getAverageCharWidth()); - textWidget.setHorizontalIndex(Math.round(index)); - } + textWidget.setHorizontalIndex(Math.round(index)); + } - } - } + } + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/ClearOutputAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/ClearOutputAction.java index fd36d38f4..f2f568714 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/ClearOutputAction.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/ClearOutputAction.java @@ -70,8 +70,8 @@ public class ClearOutputAction extends Action { * @param viewer viewer whose document this action is associated with */ public ClearOutputAction(ITextViewer viewer) { - this(); - fViewer = viewer; + this(); + fViewer = viewer; } /* (non-Javadoc) @@ -82,15 +82,15 @@ public class ClearOutputAction extends Action { BusyIndicator.showWhile(ConsolePlugin.getStandardDisplay(), new Runnable() { @Override public void run() { - if (fIOConsole == null) { + if (fIOConsole == null) { IDocument document = fViewer.getDocument(); if (document != null) { document.set(""); //$NON-NLS-1$ } fViewer.setSelectedRange(0, 0); - } else { - fIOConsole.clearConsole(); - } + } else { + fIOConsole.clearConsole(); + } } }); } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/CloseConsoleAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/CloseConsoleAction.java index b1fc76517..88987c63f 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/CloseConsoleAction.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/CloseConsoleAction.java @@ -27,17 +27,17 @@ import org.eclipse.ui.internal.console.IInternalConsoleConstants; */ public class CloseConsoleAction extends Action { - private IConsole fConsole; + private IConsole fConsole; - public CloseConsoleAction(IConsole console) { - super(ConsoleMessages.CloseConsoleAction_0, ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_CLOSE)); + public CloseConsoleAction(IConsole console) { + super(ConsoleMessages.CloseConsoleAction_0, ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_CLOSE)); setDisabledImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_DLCL_CLOSE)); - setToolTipText(ConsoleMessages.CloseConsoleAction_1); - fConsole = console; - } + setToolTipText(ConsoleMessages.CloseConsoleAction_1); + fConsole = console; + } @Override public void run() { - ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[]{fConsole}); - } + ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[]{fConsole}); + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocument.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocument.java index 8eb24bb79..8fc6d0e63 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocument.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocument.java @@ -94,37 +94,37 @@ public class ConsoleDocument extends Document { /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#set(java.lang.String) */ - @Override + @Override public synchronized void set(String text) { - super.set(text); - } + super.set(text); + } /* (non-Javadoc) * @see org.eclipse.jface.text.AbstractDocument#completeInitialization() */ - @Override + @Override protected void completeInitialization() { - super.completeInitialization(); - addPositionUpdater(new HyperlinkUpdater()); - } + super.completeInitialization(); + addPositionUpdater(new HyperlinkUpdater()); + } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#addPosition(java.lang.String, org.eclipse.jface.text.Position) */ @Override public synchronized void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException { - super.addPosition(category, position); - } + super.addPosition(category, position); + } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#removePosition(java.lang.String, org.eclipse.jface.text.Position) */ - @Override + @Override public synchronized void removePosition(String category, Position position) throws BadPositionCategoryException { - super.removePosition(category, position); - } + super.removePosition(category, position); + } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#getPositions(java.lang.String) */ - @Override + @Override public synchronized Position[] getPositions(String category) throws BadPositionCategoryException { - return super.getPositions(category); - } + return super.getPositions(category); + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java index 486594d11..564074ac7 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java @@ -36,168 +36,168 @@ import org.eclipse.swt.custom.TextChangingEvent; */ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListener { - private int consoleWidth = -1; + private int consoleWidth = -1; private List<TextChangeListener> textChangeListeners; - private IDocument document; + private IDocument document; - int[] offsets = new int[5000]; - int[] lengths = new int[5000]; - private int regionCount = 1; - private Pattern pattern = Pattern.compile("$", Pattern.MULTILINE); //$NON-NLS-1$ + int[] offsets = new int[5000]; + int[] lengths = new int[5000]; + private int regionCount = 1; + private Pattern pattern = Pattern.compile("$", Pattern.MULTILINE); //$NON-NLS-1$ - public ConsoleDocumentAdapter(int width) { + public ConsoleDocumentAdapter(int width) { textChangeListeners = new ArrayList<TextChangeListener>(); - consoleWidth = width; - } - - /* - * repairs lines list from the beginning of the line containing the offset of any - * DocumentEvent, to the end of the Document. - */ - private void repairLines(int eventOffset) { - if (document == null) { - return; - } - try { - int docLine = document.getLineOfOffset(eventOffset); - int docLineOffset = document.getLineOffset(docLine); - int widgetLine = getLineAtOffset(docLineOffset); - - for (int i=regionCount-1; i>=widgetLine; i--) { - regionCount--; - } - - int numLinesInDoc = document.getNumberOfLines(); - - int nextOffset = document.getLineOffset(docLine); - for (int i = docLine; i<numLinesInDoc; i++) { - int offset = nextOffset; - int length = document.getLineLength(i); - nextOffset += length; - - if (length == 0) { - addRegion(offset, 0); - } else { - while (length > 0) { - int trimmedLength = length; - String lineDelimiter = document.getLineDelimiter(i); - int lineDelimiterLength = 0; - if (lineDelimiter != null) { - lineDelimiterLength = lineDelimiter.length(); - trimmedLength -= lineDelimiterLength; - } - - if (consoleWidth > 0 && consoleWidth < trimmedLength) { - addRegion(offset, consoleWidth); - offset += consoleWidth; - length -= consoleWidth; - } else { - addRegion(offset, length); - offset += length; - length -= length; - } - } - } - } - } catch (BadLocationException e) { - } - - if (regionCount == 0) { - addRegion(0, document.getLength()); - } - } - - private void addRegion(int offset, int length) { - if (regionCount == 0) { - offsets[0] = offset; - lengths[0] = length; - } else { - if (regionCount == offsets.length) { - growRegionArray(regionCount * 2); - } - offsets[regionCount] = offset; - lengths[regionCount] = length; - } - regionCount++; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocumentAdapter#setDocument(org.eclipse.jface.text.IDocument) - */ - @Override + consoleWidth = width; + } + + /* + * repairs lines list from the beginning of the line containing the offset of any + * DocumentEvent, to the end of the Document. + */ + private void repairLines(int eventOffset) { + if (document == null) { + return; + } + try { + int docLine = document.getLineOfOffset(eventOffset); + int docLineOffset = document.getLineOffset(docLine); + int widgetLine = getLineAtOffset(docLineOffset); + + for (int i=regionCount-1; i>=widgetLine; i--) { + regionCount--; + } + + int numLinesInDoc = document.getNumberOfLines(); + + int nextOffset = document.getLineOffset(docLine); + for (int i = docLine; i<numLinesInDoc; i++) { + int offset = nextOffset; + int length = document.getLineLength(i); + nextOffset += length; + + if (length == 0) { + addRegion(offset, 0); + } else { + while (length > 0) { + int trimmedLength = length; + String lineDelimiter = document.getLineDelimiter(i); + int lineDelimiterLength = 0; + if (lineDelimiter != null) { + lineDelimiterLength = lineDelimiter.length(); + trimmedLength -= lineDelimiterLength; + } + + if (consoleWidth > 0 && consoleWidth < trimmedLength) { + addRegion(offset, consoleWidth); + offset += consoleWidth; + length -= consoleWidth; + } else { + addRegion(offset, length); + offset += length; + length -= length; + } + } + } + } + } catch (BadLocationException e) { + } + + if (regionCount == 0) { + addRegion(0, document.getLength()); + } + } + + private void addRegion(int offset, int length) { + if (regionCount == 0) { + offsets[0] = offset; + lengths[0] = length; + } else { + if (regionCount == offsets.length) { + growRegionArray(regionCount * 2); + } + offsets[regionCount] = offset; + lengths[regionCount] = length; + } + regionCount++; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.text.IDocumentAdapter#setDocument(org.eclipse.jface.text.IDocument) + */ + @Override public void setDocument(IDocument doc) { - if (document != null) { - document.removeDocumentListener(this); - } + if (document != null) { + document.removeDocumentListener(this); + } - document = doc; + document = doc; - if (document != null) { - document.addDocumentListener(this); - repairLines(0); - } - } + if (document != null) { + document.addDocumentListener(this); + repairLines(0); + } + } - /* (non-Javadoc) - * @see org.eclipse.swt.custom.StyledTextContent#addTextChangeListener(org.eclipse.swt.custom.TextChangeListener) - */ + /* (non-Javadoc) + * @see org.eclipse.swt.custom.StyledTextContent#addTextChangeListener(org.eclipse.swt.custom.TextChangeListener) + */ @Override public synchronized void addTextChangeListener(TextChangeListener listener) { Assert.isNotNull(listener); if (!textChangeListeners.contains(listener)) { textChangeListeners.add(listener); } - } + } - /* (non-Javadoc) - * @see org.eclipse.swt.custom.StyledTextContent#removeTextChangeListener(org.eclipse.swt.custom.TextChangeListener) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.swt.custom.StyledTextContent#removeTextChangeListener(org.eclipse.swt.custom.TextChangeListener) + */ + @Override public synchronized void removeTextChangeListener(TextChangeListener listener) { - if(textChangeListeners != null) { - Assert.isNotNull(listener); - textChangeListeners.remove(listener); - } - } - - /* (non-Javadoc) - * @see org.eclipse.swt.custom.StyledTextContent#getCharCount() - */ - @Override + if(textChangeListeners != null) { + Assert.isNotNull(listener); + textChangeListeners.remove(listener); + } + } + + /* (non-Javadoc) + * @see org.eclipse.swt.custom.StyledTextContent#getCharCount() + */ + @Override public int getCharCount() { - return document.getLength(); - } + return document.getLength(); + } - /* (non-Javadoc) - * @see org.eclipse.swt.custom.StyledTextContent#getLine(int) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.swt.custom.StyledTextContent#getLine(int) + */ + @Override public String getLine(int lineIndex) { - try { - StringBuffer line = new StringBuffer(document.get(offsets[lineIndex], lengths[lineIndex])); - int index = line.length() - 1; - while(index > -1 && (line.charAt(index)=='\n' || line.charAt(index)=='\r')) { - index--; - } - return new String(line.substring(0, index+1)); - } catch (BadLocationException e) { - } - return ""; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.swt.custom.StyledTextContent#getLineAtOffset(int) - */ - @Override + try { + StringBuffer line = new StringBuffer(document.get(offsets[lineIndex], lengths[lineIndex])); + int index = line.length() - 1; + while(index > -1 && (line.charAt(index)=='\n' || line.charAt(index)=='\r')) { + index--; + } + return new String(line.substring(0, index+1)); + } catch (BadLocationException e) { + } + return ""; //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see org.eclipse.swt.custom.StyledTextContent#getLineAtOffset(int) + */ + @Override public int getLineAtOffset(int offset) { - if (offset == 0 || regionCount <= 1) { - return 0; - } + if (offset == 0 || regionCount <= 1) { + return 0; + } - if (offset == document.getLength()) { - return regionCount-1; - } + if (offset == document.getLength()) { + return regionCount-1; + } int left= 0; int right= regionCount-1; @@ -205,123 +205,123 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen while (left <= right) { if(left == right) { - return right; - } - midIndex = (left + right) / 2; - - if (offset < offsets[midIndex]) { - right = midIndex; - } else if (offset >= offsets[midIndex] + lengths[midIndex]) { - left = midIndex + 1; - } else { - return midIndex; - } + return right; + } + midIndex = (left + right) / 2; + + if (offset < offsets[midIndex]) { + right = midIndex; + } else if (offset >= offsets[midIndex] + lengths[midIndex]) { + left = midIndex + 1; + } else { + return midIndex; + } } return midIndex; - } + } - /* (non-Javadoc) - * @see org.eclipse.swt.custom.StyledTextContent#getLineCount() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.swt.custom.StyledTextContent#getLineCount() + */ + @Override public int getLineCount() { - return regionCount; - } + return regionCount; + } - /* (non-Javadoc) - * @see org.eclipse.swt.custom.StyledTextContent#getLineDelimiter() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.swt.custom.StyledTextContent#getLineDelimiter() + */ + @Override public String getLineDelimiter() { - return System.getProperty("line.separator"); //$NON-NLS-1$ - } + return System.getProperty("line.separator"); //$NON-NLS-1$ + } - /* (non-Javadoc) - * @see org.eclipse.swt.custom.StyledTextContent#getOffsetAtLine(int) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.swt.custom.StyledTextContent#getOffsetAtLine(int) + */ + @Override public int getOffsetAtLine(int lineIndex) { - return offsets[lineIndex]; - } + return offsets[lineIndex]; + } - /* (non-Javadoc) - * @see org.eclipse.swt.custom.StyledTextContent#getTextRange(int, int) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.swt.custom.StyledTextContent#getTextRange(int, int) + */ + @Override public String getTextRange(int start, int length) { - try { - return document.get(start, length); - } catch (BadLocationException e) { - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.swt.custom.StyledTextContent#replaceTextRange(int, int, java.lang.String) - */ - @Override + try { + return document.get(start, length); + } catch (BadLocationException e) { + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.swt.custom.StyledTextContent#replaceTextRange(int, int, java.lang.String) + */ + @Override public void replaceTextRange(int start, int replaceLength, String text) { - try { - document.replace(start, replaceLength, text); - } catch (BadLocationException e) { - } - } - - /* (non-Javadoc) - * @see org.eclipse.swt.custom.StyledTextContent#setText(java.lang.String) - */ - @Override + try { + document.replace(start, replaceLength, text); + } catch (BadLocationException e) { + } + } + + /* (non-Javadoc) + * @see org.eclipse.swt.custom.StyledTextContent#setText(java.lang.String) + */ + @Override public synchronized void setText(String text) { - TextChangedEvent changeEvent = new TextChangedEvent(this); + TextChangedEvent changeEvent = new TextChangedEvent(this); for (TextChangeListener listener : textChangeListeners) { listener.textSet(changeEvent); } - } + } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) + */ + @Override public synchronized void documentAboutToBeChanged(DocumentEvent event) { - if (document == null) { - return; - } - - TextChangingEvent changeEvent = new TextChangingEvent(this); - changeEvent.start = event.fOffset; - changeEvent.newText = (event.fText == null ? "" : event.fText); //$NON-NLS-1$ - changeEvent.replaceCharCount = event.fLength; - changeEvent.newCharCount = (event.fText == null ? 0 : event.fText.length()); - - int first = getLineAtOffset(event.fOffset); - int lOffset = Math.max(event.fOffset + event.fLength - 1, 0); + if (document == null) { + return; + } + + TextChangingEvent changeEvent = new TextChangingEvent(this); + changeEvent.start = event.fOffset; + changeEvent.newText = (event.fText == null ? "" : event.fText); //$NON-NLS-1$ + changeEvent.replaceCharCount = event.fLength; + changeEvent.newCharCount = (event.fText == null ? 0 : event.fText.length()); + + int first = getLineAtOffset(event.fOffset); + int lOffset = Math.max(event.fOffset + event.fLength - 1, 0); int last = getLineAtOffset(lOffset); - changeEvent.replaceLineCount = Math.max(last - first, 0); + changeEvent.replaceLineCount = Math.max(last - first, 0); - int newLineCount = countNewLines(event.fText); + int newLineCount = countNewLines(event.fText); changeEvent.newLineCount = newLineCount >= 0 ? newLineCount : 0; - if (changeEvent.newLineCount > offsets.length-regionCount) { - growRegionArray(changeEvent.newLineCount); - } + if (changeEvent.newLineCount > offsets.length-regionCount) { + growRegionArray(changeEvent.newLineCount); + } for (TextChangeListener listener : textChangeListeners) { listener.textChanging(changeEvent); } - } - - private void growRegionArray(int minSize) { - int size = Math.max(offsets.length*2, minSize*2); - int[] newOffsets = new int[size]; - System.arraycopy(offsets, 0, newOffsets, 0, regionCount); - offsets = newOffsets; - int[] newLengths = new int[size]; - System.arraycopy(lengths, 0, newLengths, 0, regionCount); - lengths = newLengths; - } - - private int countNewLines(String string) { + } + + private void growRegionArray(int minSize) { + int size = Math.max(offsets.length*2, minSize*2); + int[] newOffsets = new int[size]; + System.arraycopy(offsets, 0, newOffsets, 0, regionCount); + offsets = newOffsets; + int[] newLengths = new int[size]; + System.arraycopy(lengths, 0, newLengths, 0, regionCount); + lengths = newLengths; + } + + private int countNewLines(String string) { int count = 0; if (string.length() == 0) { @@ -372,36 +372,36 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) + */ + @Override public synchronized void documentChanged(DocumentEvent event) { - if (document == null) { - return; - } + if (document == null) { + return; + } - repairLines(event.fOffset); + repairLines(event.fOffset); - TextChangedEvent changeEvent = new TextChangedEvent(this); + TextChangedEvent changeEvent = new TextChangedEvent(this); for (TextChangeListener listener : textChangeListeners) { listener.textChanged(changeEvent); } - } - - /** - * sets consoleWidth, repairs line information, then fires event to the viewer text widget. - * @param width The console's width - */ - public void setWidth(int width) { - if (width != consoleWidth) { - consoleWidth = width; - repairLines(0); - TextChangedEvent changeEvent = new TextChangedEvent(this); + } + + /** + * sets consoleWidth, repairs line information, then fires event to the viewer text widget. + * @param width The console's width + */ + public void setWidth(int width) { + if (width != consoleWidth) { + consoleWidth = width; + repairLines(0); + TextChangedEvent changeEvent = new TextChangedEvent(this); for (TextChangeListener listener : textChangeListeners) { listener.textSet(changeEvent); } - } - } + } + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDropDownAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDropDownAction.java index 2aa907a4b..b510e9996 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDropDownAction.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDropDownAction.java @@ -100,8 +100,8 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList } private void addActionToMenu(Menu parent, Action action, int accelerator) { - if (accelerator < 10) { - StringBuffer label= new StringBuffer(); + if (accelerator < 10) { + StringBuffer label= new StringBuffer(); //add the numerical accelerator label.append('&'); label.append(accelerator); @@ -118,13 +118,13 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList */ @Override public void run() { - ConsoleView consoleView = (ConsoleView) fView; - boolean pinned = consoleView.isPinned(); - try { - if (pinned) { - consoleView.setPinned(false); - } - IConsole[] consoles = ConsolePlugin.getDefault().getConsoleManager().getConsoles(); + ConsoleView consoleView = (ConsoleView) fView; + boolean pinned = consoleView.isPinned(); + try { + if (pinned) { + consoleView.setPinned(false); + } + IConsole[] consoles = ConsolePlugin.getDefault().getConsoleManager().getConsoles(); IConsole current = fView.getConsole(); int idx = 0; for (int i = 0; i < consoles.length; i++) { @@ -134,16 +134,16 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList } } int next = idx+1; - if(next >= consoles.length) { - next = 0; - } - fView.display(consoles[next]); - } - finally { - if (pinned) { - consoleView.setPinned(true); - } - } + if(next >= consoles.length) { + next = 0; + } + fView.display(consoles[next]); + } + finally { + if (pinned) { + consoleView.setPinned(true); + } + } } /* (non-Javadoc) diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleFactoryExtension.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleFactoryExtension.java index b63793f7e..874f3f9fe 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleFactoryExtension.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleFactoryExtension.java @@ -36,84 +36,84 @@ import org.osgi.framework.Bundle; */ public class ConsoleFactoryExtension implements IPluginContribution { - private IConfigurationElement fConfig; - private Expression fEnablementExpression; - private String fLabel; - private ImageDescriptor fImageDescriptor; - private IConsoleFactory fFactory; - - ConsoleFactoryExtension(IConfigurationElement config) { - fConfig = config; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPluginContribution#getLocalId() - */ + private IConfigurationElement fConfig; + private Expression fEnablementExpression; + private String fLabel; + private ImageDescriptor fImageDescriptor; + private IConsoleFactory fFactory; + + ConsoleFactoryExtension(IConfigurationElement config) { + fConfig = config; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPluginContribution#getLocalId() + */ @Override public String getLocalId() { - return fConfig.getAttribute("id"); //$NON-NLS-1$ - } + return fConfig.getAttribute("id"); //$NON-NLS-1$ + } - /* (non-Javadoc) - * @see org.eclipse.ui.IPluginContribution#getPluginId() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.IPluginContribution#getPluginId() + */ + @Override public String getPluginId() { - return fConfig.getContributor().getName(); - } - - public boolean isEnabled() { - try { - Expression enablementExpression = getEnablementExpression(); - if (enablementExpression == null) { - return true; - } - EvaluationContext context = new EvaluationContext(null, this); - EvaluationResult evaluationResult = enablementExpression.evaluate(context); - return evaluationResult != EvaluationResult.FALSE; - } catch (CoreException e) { - ConsolePlugin.log(e); - return false; - } - } - - public Expression getEnablementExpression() throws CoreException { + return fConfig.getContributor().getName(); + } + + public boolean isEnabled() { + try { + Expression enablementExpression = getEnablementExpression(); + if (enablementExpression == null) { + return true; + } + EvaluationContext context = new EvaluationContext(null, this); + EvaluationResult evaluationResult = enablementExpression.evaluate(context); + return evaluationResult != EvaluationResult.FALSE; + } catch (CoreException e) { + ConsolePlugin.log(e); + return false; + } + } + + public Expression getEnablementExpression() throws CoreException { if (fEnablementExpression == null) { IConfigurationElement[] elements = fConfig.getChildren(ExpressionTagNames.ENABLEMENT); IConfigurationElement enablement = elements.length > 0 ? elements[0] : null; if (enablement != null) { - fEnablementExpression = ExpressionConverter.getDefault().perform(enablement); + fEnablementExpression = ExpressionConverter.getDefault().perform(enablement); } } return fEnablementExpression; - } - - public String getLabel() { - if (fLabel == null) { - fLabel = fConfig.getAttribute("label"); //$NON-NLS-1$ - } - return fLabel; - } - - public ImageDescriptor getImageDescriptor() { - if (fImageDescriptor == null) { - String path = fConfig.getAttribute("icon"); //$NON-NLS-1$ - if (path != null) { - Bundle bundle = Platform.getBundle(getPluginId()); - URL url = FileLocator.find(bundle, new Path(path), null); - if (url != null) { - fImageDescriptor = ImageDescriptor.createFromURL(url); - } - } - } - return fImageDescriptor; - } - - public IConsoleFactory createFactory() throws CoreException { - if (fFactory == null) { - fFactory = (IConsoleFactory) fConfig.createExecutableExtension("class"); //$NON-NLS-1$ - } - return fFactory; - } + } + + public String getLabel() { + if (fLabel == null) { + fLabel = fConfig.getAttribute("label"); //$NON-NLS-1$ + } + return fLabel; + } + + public ImageDescriptor getImageDescriptor() { + if (fImageDescriptor == null) { + String path = fConfig.getAttribute("icon"); //$NON-NLS-1$ + if (path != null) { + Bundle bundle = Platform.getBundle(getPluginId()); + URL url = FileLocator.find(bundle, new Path(path), null); + if (url != null) { + fImageDescriptor = ImageDescriptor.createFromURL(url); + } + } + } + return fImageDescriptor; + } + + public IConsoleFactory createFactory() throws CoreException { + if (fFactory == null) { + fFactory = (IConsoleFactory) fConfig.createExecutableExtension("class"); //$NON-NLS-1$ + } + return fFactory; + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java index 1ef4b9830..faaac740b 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleManager.java @@ -78,56 +78,56 @@ public class ConsoleManager implements IConsoleManager { private List<IConsoleView> fConsoleViews = new ArrayList<IConsoleView>(); - private boolean fWarnQueued = false; + private boolean fWarnQueued = false; - private RepaintJob fRepaintJob = new RepaintJob(); + private RepaintJob fRepaintJob = new RepaintJob(); - private class RepaintJob extends WorkbenchJob { + private class RepaintJob extends WorkbenchJob { private Set<IConsole> list = new HashSet<IConsole>(); - public RepaintJob() { - super("schedule redraw() of viewers"); //$NON-NLS-1$ - setSystem(true); - } + public RepaintJob() { + super("schedule redraw() of viewers"); //$NON-NLS-1$ + setSystem(true); + } - void addConsole(IConsole console) { - synchronized (list) { - list.add(console); + void addConsole(IConsole console) { + synchronized (list) { + list.add(console); } - } + } - @Override + @Override public IStatus runInUIThread(IProgressMonitor monitor) { - synchronized (list) { - if (list.isEmpty()) { - return Status.OK_STATUS; - } - - IWorkbenchWindow[] workbenchWindows = PlatformUI.getWorkbench().getWorkbenchWindows(); - for (int i = 0; i < workbenchWindows.length; i++) { - IWorkbenchWindow window = workbenchWindows[i]; - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - IViewPart part = page.findView(IConsoleConstants.ID_CONSOLE_VIEW); - if (part != null && part instanceof IConsoleView) { - ConsoleView view = (ConsoleView) part; - if (list.contains(view.getConsole())) { - Control control = view.getCurrentPage().getControl(); - if (!control.isDisposed()) { - control.redraw(); - } - } - } - - } - } - } - list.clear(); - } - return Status.OK_STATUS; - } - } + synchronized (list) { + if (list.isEmpty()) { + return Status.OK_STATUS; + } + + IWorkbenchWindow[] workbenchWindows = PlatformUI.getWorkbench().getWorkbenchWindows(); + for (int i = 0; i < workbenchWindows.length; i++) { + IWorkbenchWindow window = workbenchWindows[i]; + if (window != null) { + IWorkbenchPage page = window.getActivePage(); + if (page != null) { + IViewPart part = page.findView(IConsoleConstants.ID_CONSOLE_VIEW); + if (part != null && part instanceof IConsoleView) { + ConsoleView view = (ConsoleView) part; + if (list.contains(view.getConsole())) { + Control control = view.getCurrentPage().getControl(); + if (!control.isDisposed()) { + control.redraw(); + } + } + } + + } + } + } + list.clear(); + } + return Status.OK_STATUS; + } + } /** * Notifies a console listener of additions or removals @@ -178,7 +178,7 @@ public class ConsoleManager implements IConsoleManager { fType = update; for (IConsoleListener iConsoleListener : fListeners) { fListener = iConsoleListener; - SafeRunner.run(this); + SafeRunner.run(this); } fChanged = null; fListener = null; @@ -186,17 +186,17 @@ public class ConsoleManager implements IConsoleManager { } public void registerConsoleView(ConsoleView view) { - synchronized (fConsoleViews) { - fConsoleViews.add(view); - } + synchronized (fConsoleViews) { + fConsoleViews.add(view); + } + } + public void unregisterConsoleView(ConsoleView view) { + synchronized (fConsoleViews) { + fConsoleViews.remove(view); + } } - public void unregisterConsoleView(ConsoleView view) { - synchronized (fConsoleViews) { - fConsoleViews.remove(view); - } - } - /* (non-Javadoc) + /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleManager#addConsoleListener(org.eclipse.ui.console.IConsoleListener) */ @Override @@ -225,11 +225,11 @@ public class ConsoleManager implements IConsoleManager { List<IConsole> added = new ArrayList<IConsole>(consoles.length); synchronized (fConsoles) { for (int i = 0; i < consoles.length; i++) { - IConsole console = consoles[i]; - if(console instanceof TextConsole) { - TextConsole ioconsole = (TextConsole)console; - createPatternMatchListeners(ioconsole); - } + IConsole console = consoles[i]; + if(console instanceof TextConsole) { + TextConsole ioconsole = (TextConsole)console; + createPatternMatchListeners(ioconsole); + } if (!fConsoles.contains(console)) { fConsoles.add(console); added.add(console); @@ -409,96 +409,96 @@ public class ConsoleManager implements IConsoleManager { } } - /* (non-Javadoc) - * @see org.eclipse.ui.console.IConsoleManager#getPatternMatchListenerDelegates(org.eclipse.ui.console.IConsole) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.console.IConsoleManager#getPatternMatchListenerDelegates(org.eclipse.ui.console.IConsole) + */ + @Override public IPatternMatchListener[] createPatternMatchListeners(IConsole console) { - if (fPatternMatchListeners == null) { + if (fPatternMatchListeners == null) { fPatternMatchListeners = new ArrayList<PatternMatchListenerExtension>(); - IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.EXTENSION_POINT_CONSOLE_PATTERN_MATCH_LISTENERS); - IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); - for (int i = 0; i < elements.length; i++) { - IConfigurationElement config = elements[i]; - PatternMatchListenerExtension extension = new PatternMatchListenerExtension(config); - fPatternMatchListeners.add(extension); - } - } + IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.EXTENSION_POINT_CONSOLE_PATTERN_MATCH_LISTENERS); + IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); + for (int i = 0; i < elements.length; i++) { + IConfigurationElement config = elements[i]; + PatternMatchListenerExtension extension = new PatternMatchListenerExtension(config); + fPatternMatchListeners.add(extension); + } + } ArrayList<PatternMatchListener> list = new ArrayList<PatternMatchListener>(); for (Iterator<PatternMatchListenerExtension> i = fPatternMatchListeners.iterator(); i.hasNext();) { - PatternMatchListenerExtension extension = i.next(); - try { - if (extension.getEnablementExpression() == null) { - i.remove(); - continue; - } - - if (console instanceof TextConsole && extension.isEnabledFor(console)) { - TextConsole textConsole = (TextConsole) console; - PatternMatchListener patternMatchListener = new PatternMatchListener(extension); - try { - textConsole.addPatternMatchListener(patternMatchListener); - list.add(patternMatchListener); - } catch (PatternSyntaxException e) { - ConsolePlugin.log(e); - i.remove(); - } - } - } catch (CoreException e) { - ConsolePlugin.log(e); - } - } - return list.toArray(new PatternMatchListener[0]); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.console.IConsoleManager#getPageParticipants(org.eclipse.ui.console.IConsole) - */ - public IConsolePageParticipant[] getPageParticipants(IConsole console) { - if(fPageParticipants == null) { + PatternMatchListenerExtension extension = i.next(); + try { + if (extension.getEnablementExpression() == null) { + i.remove(); + continue; + } + + if (console instanceof TextConsole && extension.isEnabledFor(console)) { + TextConsole textConsole = (TextConsole) console; + PatternMatchListener patternMatchListener = new PatternMatchListener(extension); + try { + textConsole.addPatternMatchListener(patternMatchListener); + list.add(patternMatchListener); + } catch (PatternSyntaxException e) { + ConsolePlugin.log(e); + i.remove(); + } + } + } catch (CoreException e) { + ConsolePlugin.log(e); + } + } + return list.toArray(new PatternMatchListener[0]); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.console.IConsoleManager#getPageParticipants(org.eclipse.ui.console.IConsole) + */ + public IConsolePageParticipant[] getPageParticipants(IConsole console) { + if(fPageParticipants == null) { fPageParticipants = new ArrayList<ConsolePageParticipantExtension>(); - IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.EXTENSION_POINT_CONSOLE_PAGE_PARTICIPANTS); - IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); - for(int i = 0; i < elements.length; i++) { - IConfigurationElement config = elements[i]; - ConsolePageParticipantExtension extension = new ConsolePageParticipantExtension(config); - fPageParticipants.add(extension); - } - } + IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.EXTENSION_POINT_CONSOLE_PAGE_PARTICIPANTS); + IConfigurationElement[] elements = extensionPoint.getConfigurationElements(); + for(int i = 0; i < elements.length; i++) { + IConfigurationElement config = elements[i]; + ConsolePageParticipantExtension extension = new ConsolePageParticipantExtension(config); + fPageParticipants.add(extension); + } + } ArrayList<IConsolePageParticipant> list = new ArrayList<IConsolePageParticipant>(); for (Iterator<ConsolePageParticipantExtension> i = fPageParticipants.iterator(); i.hasNext();) { - ConsolePageParticipantExtension extension = i.next(); - try { - if (extension.isEnabledFor(console)) { - list.add(extension.createDelegate()); - } - } catch (CoreException e) { - ConsolePlugin.log(e); - } - } - return list.toArray(new IConsolePageParticipant[0]); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.console.IConsoleManager#getConsoleFactories() - */ - public ConsoleFactoryExtension[] getConsoleFactoryExtensions() { - if (fConsoleFactoryExtensions == null) { + ConsolePageParticipantExtension extension = i.next(); + try { + if (extension.isEnabledFor(console)) { + list.add(extension.createDelegate()); + } + } catch (CoreException e) { + ConsolePlugin.log(e); + } + } + return list.toArray(new IConsolePageParticipant[0]); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.console.IConsoleManager#getConsoleFactories() + */ + public ConsoleFactoryExtension[] getConsoleFactoryExtensions() { + if (fConsoleFactoryExtensions == null) { fConsoleFactoryExtensions = new ArrayList<ConsoleFactoryExtension>(); - IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.EXTENSION_POINT_CONSOLE_FACTORIES); - IConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements(); - for (int i = 0; i < configurationElements.length; i++) { - fConsoleFactoryExtensions.add(new ConsoleFactoryExtension(configurationElements[i])); - } - } - return fConsoleFactoryExtensions.toArray(new ConsoleFactoryExtension[0]); - } + IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.EXTENSION_POINT_CONSOLE_FACTORIES); + IConfigurationElement[] configurationElements = extensionPoint.getConfigurationElements(); + for (int i = 0; i < configurationElements.length; i++) { + fConsoleFactoryExtensions.add(new ConsoleFactoryExtension(configurationElements[i])); + } + } + return fConsoleFactoryExtensions.toArray(new ConsoleFactoryExtension[0]); + } - @Override + @Override public void refresh(final IConsole console) { - fRepaintJob.addConsole(console); - fRepaintJob.schedule(50); - } + fRepaintJob.addConsole(console); + fRepaintJob.schedule(50); + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleMessages.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleMessages.java index b91f1c849..7f3a13e92 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleMessages.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleMessages.java @@ -51,23 +51,23 @@ public class ConsoleMessages extends NLS { public static String CloseConsoleAction_0; public static String CloseConsoleAction_1; - public static String TextConsolePage_SelectAllDescrip; - public static String TextConsolePage_SelectAllText; - public static String TextConsolePage_CutText; - public static String TextConsolePage_CutDescrip; - public static String TextConsolePage_CopyText; - public static String TextConsolePage_CopyDescrip; - public static String TextConsolePage_PasteText; - public static String TextConsolePage_PasteDescrip; + public static String TextConsolePage_SelectAllDescrip; + public static String TextConsolePage_SelectAllText; + public static String TextConsolePage_CutText; + public static String TextConsolePage_CutDescrip; + public static String TextConsolePage_CopyText; + public static String TextConsolePage_CopyDescrip; + public static String TextConsolePage_PasteText; + public static String TextConsolePage_PasteDescrip; static { // load message values from bundle file NLS.initializeMessages(BUNDLE_NAME, ConsoleMessages.class); } - public static String PatternMatchListenerExtension_3; + public static String PatternMatchListenerExtension_3; - public static String PatternMatchListenerExtension_4; + public static String PatternMatchListenerExtension_4; - public static String PatternMatchListenerExtension_5; + public static String PatternMatchListenerExtension_5; } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePageParticipantExtension.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePageParticipantExtension.java index 9bf749569..a7d7e9f30 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePageParticipantExtension.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePageParticipantExtension.java @@ -23,53 +23,53 @@ import org.eclipse.ui.console.IConsolePageParticipant; public class ConsolePageParticipantExtension implements IPluginContribution { - private IConfigurationElement fConfig; - private Expression fEnablementExpression; + private IConfigurationElement fConfig; + private Expression fEnablementExpression; - public ConsolePageParticipantExtension(IConfigurationElement config) { - fConfig = config; - } + public ConsolePageParticipantExtension(IConfigurationElement config) { + fConfig = config; + } - /* (non-Javadoc) - * @see org.eclipse.ui.IPluginContribution#getLocalId() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.IPluginContribution#getLocalId() + */ + @Override public String getLocalId() { - return fConfig.getAttribute("id"); //$NON-NLS-1$ - } + return fConfig.getAttribute("id"); //$NON-NLS-1$ + } - /* (non-Javadoc) - * @see org.eclipse.ui.IPluginContribution#getPluginId() - */ + /* (non-Javadoc) + * @see org.eclipse.ui.IPluginContribution#getPluginId() + */ @Override public String getPluginId() { - return fConfig.getContributor().getName(); - } + return fConfig.getContributor().getName(); + } - public boolean isEnabledFor(IConsole console) throws CoreException { - EvaluationContext context = new EvaluationContext(null, console); - Expression expression = getEnablementExpression(); - if (expression != null){ - EvaluationResult evaluationResult = expression.evaluate(context); - return evaluationResult == EvaluationResult.TRUE; - } - return true; - } + public boolean isEnabledFor(IConsole console) throws CoreException { + EvaluationContext context = new EvaluationContext(null, console); + Expression expression = getEnablementExpression(); + if (expression != null){ + EvaluationResult evaluationResult = expression.evaluate(context); + return evaluationResult == EvaluationResult.TRUE; + } + return true; + } - public Expression getEnablementExpression() throws CoreException { + public Expression getEnablementExpression() throws CoreException { if (fEnablementExpression == null) { IConfigurationElement[] elements = fConfig.getChildren(ExpressionTagNames.ENABLEMENT); IConfigurationElement enablement = elements.length > 0 ? elements[0] : null; if (enablement != null) { - fEnablementExpression = ExpressionConverter.getDefault().perform(enablement); + fEnablementExpression = ExpressionConverter.getDefault().perform(enablement); } } return fEnablementExpression; - } + } - public IConsolePageParticipant createDelegate() throws CoreException { - return (IConsolePageParticipant) fConfig.createExecutableExtension("class"); //$NON-NLS-1$; - } + public IConsolePageParticipant createDelegate() throws CoreException { + return (IConsolePageParticipant) fConfig.createExecutableExtension("class"); //$NON-NLS-1$; + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java index 3289b751b..5344e375a 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsolePatternMatcher.java @@ -33,35 +33,35 @@ public class ConsolePatternMatcher implements IDocumentListener { private MatchJob fMatchJob; - /** - * Collection of compiled pattern match listeners - */ + /** + * Collection of compiled pattern match listeners + */ private ArrayList<CompiledPatternMatchListener> fPatterns = new ArrayList<CompiledPatternMatchListener>(); - private TextConsole fConsole; + private TextConsole fConsole; - private boolean fFinalMatch; + private boolean fFinalMatch; private boolean fScheduleFinal; - public ConsolePatternMatcher(TextConsole console) { - fConsole = console; + public ConsolePatternMatcher(TextConsole console) { + fConsole = console; fMatchJob = new MatchJob(); - } + } - private class MatchJob extends Job { - MatchJob() { - super("Match Job"); //$NON-NLS-1$ - setSystem(true); + private class MatchJob extends Job { + MatchJob() { + super("Match Job"); //$NON-NLS-1$ + setSystem(true); setRule(fConsole.getSchedulingRule()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override protected IStatus run(IProgressMonitor monitor) { IDocument doc = fConsole.getDocument(); String text = null; @@ -175,136 +175,136 @@ public class ConsolePatternMatcher implements IDocumentListener { @Override public boolean belongsTo(Object family) { - return family == fConsole; - } + return family == fConsole; + } - } + } - private class CompiledPatternMatchListener { - Pattern pattern; + private class CompiledPatternMatchListener { + Pattern pattern; - Pattern qualifier; + Pattern qualifier; - IPatternMatchListener listener; + IPatternMatchListener listener; - int end = 0; + int end = 0; - CompiledPatternMatchListener(Pattern pattern, Pattern qualifier, IPatternMatchListener matchListener) { - this.pattern = pattern; - this.listener = matchListener; - this.qualifier = qualifier; - } + CompiledPatternMatchListener(Pattern pattern, Pattern qualifier, IPatternMatchListener matchListener) { + this.pattern = pattern; + this.listener = matchListener; + this.qualifier = qualifier; + } - public void dispose() { - listener.disconnect(); - pattern = null; - qualifier = null; - listener = null; - } - } + public void dispose() { + listener.disconnect(); + pattern = null; + qualifier = null; + listener = null; + } + } - /** + /** * Adds the given pattern match listener to this console. The listener will * be connected and receive match notifications. * * @param matchListener * the pattern match listener to add */ - public void addPatternMatchListener(IPatternMatchListener matchListener) { - synchronized (fPatterns) { + public void addPatternMatchListener(IPatternMatchListener matchListener) { + synchronized (fPatterns) { for (CompiledPatternMatchListener listener : fPatterns) { if (listener.listener == matchListener) { return; } } - if (matchListener == null || matchListener.getPattern() == null) { - throw new IllegalArgumentException("Pattern cannot be null"); //$NON-NLS-1$ - } - - Pattern pattern = Pattern.compile(matchListener.getPattern(), matchListener.getCompilerFlags()); - String qualifier = matchListener.getLineQualifier(); - Pattern qPattern = null; - if (qualifier != null) { - qPattern = Pattern.compile(qualifier, matchListener.getCompilerFlags()); - } - CompiledPatternMatchListener notifier = new CompiledPatternMatchListener(pattern, qPattern, matchListener); - fPatterns.add(notifier); - matchListener.connect(fConsole); - fMatchJob.schedule(); - } - } - - /** - * Removes the given pattern match listener from this console. The listener - * will be disconnected and will no longer receive match notifications. - * - * @param matchListener - * the pattern match listener to remove. - */ - public void removePatternMatchListener(IPatternMatchListener matchListener) { - synchronized (fPatterns) { + if (matchListener == null || matchListener.getPattern() == null) { + throw new IllegalArgumentException("Pattern cannot be null"); //$NON-NLS-1$ + } + + Pattern pattern = Pattern.compile(matchListener.getPattern(), matchListener.getCompilerFlags()); + String qualifier = matchListener.getLineQualifier(); + Pattern qPattern = null; + if (qualifier != null) { + qPattern = Pattern.compile(qualifier, matchListener.getCompilerFlags()); + } + CompiledPatternMatchListener notifier = new CompiledPatternMatchListener(pattern, qPattern, matchListener); + fPatterns.add(notifier); + matchListener.connect(fConsole); + fMatchJob.schedule(); + } + } + + /** + * Removes the given pattern match listener from this console. The listener + * will be disconnected and will no longer receive match notifications. + * + * @param matchListener + * the pattern match listener to remove. + */ + public void removePatternMatchListener(IPatternMatchListener matchListener) { + synchronized (fPatterns) { for (Iterator<CompiledPatternMatchListener> iter = fPatterns.iterator(); iter.hasNext();) { - CompiledPatternMatchListener element = iter.next(); - if (element.listener == matchListener) { - iter.remove(); - matchListener.disconnect(); - } - } - } - } - - public void disconnect() { - fMatchJob.cancel(); - synchronized (fPatterns) { + CompiledPatternMatchListener element = iter.next(); + if (element.listener == matchListener) { + iter.remove(); + matchListener.disconnect(); + } + } + } + } + + public void disconnect() { + fMatchJob.cancel(); + synchronized (fPatterns) { for (CompiledPatternMatchListener listener : fPatterns) { listener.dispose(); } - fPatterns.clear(); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) - */ - @Override + fPatterns.clear(); + } + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) + */ + @Override public void documentAboutToBeChanged(DocumentEvent event) { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) - */ - @Override + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) + */ + @Override public void documentChanged(DocumentEvent event) { - if (event.fLength > 0) { - synchronized (fPatterns) { - if (event.fDocument.getLength() == 0) { - // document has been cleared, reset match listeners + if (event.fLength > 0) { + synchronized (fPatterns) { + if (event.fDocument.getLength() == 0) { + // document has been cleared, reset match listeners for (CompiledPatternMatchListener notifier : fPatterns) { notifier.end = 0; } - } else { - if (event.fOffset == 0) { - //document was trimmed + } else { + if (event.fOffset == 0) { + //document was trimmed for (CompiledPatternMatchListener notifier : fPatterns) { notifier.end = notifier.end > event.fLength ? notifier.end - event.fLength : 0; } - } - } - } - } - fMatchJob.schedule(); - } - - - public void forceFinalMatching() { - fScheduleFinal = true; - fMatchJob.schedule(); - } + } + } + } + } + fMatchJob.schedule(); + } + + + public void forceFinalMatching() { + fScheduleFinal = true; + fMatchJob.schedule(); + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleResourceBundleMessages.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleResourceBundleMessages.java index 1a8269a08..86382aafa 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleResourceBundleMessages.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleResourceBundleMessages.java @@ -14,22 +14,22 @@ import java.util.MissingResourceException; import java.util.ResourceBundle; public class ConsoleResourceBundleMessages { - private static final String BUNDLE_NAME = "org.eclipse.ui.internal.console.ConsoleResourceBundleMessages"; //$NON-NLS-1$ + private static final String BUNDLE_NAME = "org.eclipse.ui.internal.console.ConsoleResourceBundleMessages"; //$NON-NLS-1$ - private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - private ConsoleResourceBundleMessages() { - } + private ConsoleResourceBundleMessages() { + } - public static String getString(String key) { - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } - public static ResourceBundle getBundle() { - return RESOURCE_BUNDLE; - } + public static ResourceBundle getBundle() { + return RESOURCE_BUNDLE; + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleTypePropertyTester.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleTypePropertyTester.java index 2909471c5..928e36797 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleTypePropertyTester.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleTypePropertyTester.java @@ -20,14 +20,14 @@ import org.eclipse.ui.console.IConsole; */ public class ConsoleTypePropertyTester extends PropertyTester { - /* (non-Javadoc) - * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) - */ + /* (non-Javadoc) + * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) + */ @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - IConsole console = (IConsole) receiver; - String type = console.getType(); - return type != null ? type.equals(expectedValue) : false; - } + IConsole console = (IConsole) receiver; + String type = console.getType(); + return type != null ? type.equals(expectedValue) : false; + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java index 692f10219..02fac9708 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java @@ -115,7 +115,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL private OpenConsoleAction fOpenConsoleAction = null; - private boolean fScrollLock; + private boolean fScrollLock; private boolean fWordWrap; private boolean isAvailable() { @@ -146,45 +146,45 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL @Override protected void showPageRec(PageRec pageRec) { - // don't show the page when pinned, unless this is the first console to be added - // or its the default page - if (fActiveConsole != null && pageRec.page != getDefaultPage() && fPinned && fConsoleToPart.size() > 1) { - IConsole console = fPartToConsole.get(pageRec.part); - if (!fStack.contains(console)) { - fStack.add(console); - } - return; - } - - IConsole recConsole = fPartToConsole.get(pageRec.part); - if (recConsole!=null && recConsole.equals(fActiveConsole)) { - return; - } - - super.showPageRec(pageRec); - fActiveConsole = recConsole; - IConsole tos = null; - if (!fStack.isEmpty()) { - tos = fStack.get(0); - } - if (tos != null && !tos.equals(fActiveConsole) && fActive) { - deactivateParticipants(tos); - } - if (fActiveConsole != null && !fActiveConsole.equals(tos)) { - fStack.remove(fActiveConsole); - fStack.add(0,fActiveConsole); - activateParticipants(fActiveConsole); - } - updateTitle(); - updateHelp(); - // update console actions - if (fPinAction != null) { - fPinAction.update(); - } - IPage page = getCurrentPage(); - if (page instanceof IOConsolePage) { - ((IOConsolePage) page).setWordWrap(fWordWrap); - } + // don't show the page when pinned, unless this is the first console to be added + // or its the default page + if (fActiveConsole != null && pageRec.page != getDefaultPage() && fPinned && fConsoleToPart.size() > 1) { + IConsole console = fPartToConsole.get(pageRec.part); + if (!fStack.contains(console)) { + fStack.add(console); + } + return; + } + + IConsole recConsole = fPartToConsole.get(pageRec.part); + if (recConsole!=null && recConsole.equals(fActiveConsole)) { + return; + } + + super.showPageRec(pageRec); + fActiveConsole = recConsole; + IConsole tos = null; + if (!fStack.isEmpty()) { + tos = fStack.get(0); + } + if (tos != null && !tos.equals(fActiveConsole) && fActive) { + deactivateParticipants(tos); + } + if (fActiveConsole != null && !fActiveConsole.equals(tos)) { + fStack.remove(fActiveConsole); + fStack.add(0,fActiveConsole); + activateParticipants(fActiveConsole); + } + updateTitle(); + updateHelp(); + // update console actions + if (fPinAction != null) { + fPinAction.update(); + } + IPage page = getCurrentPage(); + if (page instanceof IOConsolePage) { + ((IOConsolePage) page).setWordWrap(fWordWrap); + } if (page != null) { page.setFocus(); } @@ -202,7 +202,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL if (listeners != null) { for (IConsolePageParticipant iConsolePageParticipant : listeners) { final IConsolePageParticipant participant = iConsolePageParticipant; - SafeRunner.run(new ISafeRunnable() { + SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { participant.activated(); @@ -213,7 +213,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL listeners.remove(participant); } }); - } + } } } } @@ -230,22 +230,22 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /** * Updates the view title based on the active console */ - protected void updateTitle() { - IConsole console = getConsole(); - if (console == null) { - setContentDescription(ConsoleMessages.ConsoleView_0); - } else { - String newName = console.getName(); - String oldName = getContentDescription(); - if (newName!=null && !(newName.equals(oldName))) { - setContentDescription(console.getName()); - } - } - } - - protected void updateHelp() { - IConsole console = getConsole(); - String helpContextId = null; + protected void updateTitle() { + IConsole console = getConsole(); + if (console == null) { + setContentDescription(ConsoleMessages.ConsoleView_0); + } else { + String newName = console.getName(); + String oldName = getContentDescription(); + if (newName!=null && !(newName.equals(oldName))) { + setContentDescription(console.getName()); + } + } + } + + protected void updateHelp() { + IConsole console = getConsole(); + String helpContextId = null; if (console instanceof AbstractConsole) { AbstractConsole abs = (AbstractConsole) console; helpContextId = abs.getHelpContextId(); @@ -254,18 +254,18 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL helpContextId = IConsoleHelpContextIds.CONSOLE_VIEW; } PlatformUI.getWorkbench().getHelpSystem().setHelp(getPageBook().getParent(), helpContextId); - } + } @Override protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) { - IConsole console = fPartToConsole.get(part); + IConsole console = fPartToConsole.get(part); // dispose page participants ListenerList<IConsolePageParticipant> listeners = fConsoleToPageParticipants.remove(console); if (listeners != null) { for (IConsolePageParticipant iConsolePageParticipant : listeners) { final IConsolePageParticipant participant = iConsolePageParticipant; - SafeRunner.run(new ISafeRunnable() { + SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { participant.dispose(); @@ -275,7 +275,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL ConsolePlugin.log(exception); } }); - } + } } IPage page = pageRecord.page; @@ -286,9 +286,9 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL // empty cross-reference cache fPartToConsole.remove(part); fConsoleToPart.remove(console); - if (fPartToConsole.isEmpty()) { - fActiveConsole = null; - } + if (fPartToConsole.isEmpty()) { + fActiveConsole = null; + } // update console actions fPinAction.update(); @@ -302,7 +302,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL * @return registered page participants or <code>null</code> */ private ListenerList<IConsolePageParticipant> getParticipants(IConsole console) { - return fConsoleToPageParticipants.get(console); + return fConsoleToPageParticipants.get(console); } @Override @@ -323,7 +323,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL fConsoleToPageParticipants.put(console, participants); for (IConsolePageParticipant iConsolePageParticipant : participants) { final IConsolePageParticipant participant = iConsolePageParticipant; - SafeRunner.run(new ISafeRunnable() { + SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { participant.init(page, console); @@ -334,7 +334,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL participants.remove(participant); } }); - } + } PageRec rec = new PageRec(dummyPart, page); return rec; @@ -352,9 +352,9 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL site.getPage().removePartListener((IPartListener2)this); } super.dispose(); - ConsoleManager consoleManager = (ConsoleManager) ConsolePlugin.getDefault().getConsoleManager(); - consoleManager.removeConsoleListener(this); - consoleManager.unregisterConsoleView(this); + ConsoleManager consoleManager = (ConsoleManager) ConsolePlugin.getDefault().getConsoleManager(); + consoleManager.removeConsoleListener(this); + consoleManager.unregisterConsoleView(this); if (fDisplayConsoleAction != null) { fDisplayConsoleAction.dispose(); fDisplayConsoleAction = null; @@ -364,11 +364,11 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /** * Returns the console manager. * - * @return the console manager - */ - private IConsoleManager getConsoleManager() { - return ConsolePlugin.getDefault().getConsoleManager(); - } + * @return the console manager + */ + private IConsoleManager getConsoleManager() { + return ConsolePlugin.getDefault().getConsoleManager(); + } @Override protected IPage createDefaultPage(PageBook book) { @@ -390,15 +390,15 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL // ensure it's still registered since this is done asynchronously IConsole[] allConsoles = getConsoleManager().getConsoles(); for (int j = 0; j < allConsoles.length; j++) { - IConsole registered = allConsoles[j]; - if (registered.equals(console)) { - ConsoleWorkbenchPart part = new ConsoleWorkbenchPart(console, getSite()); - fConsoleToPart.put(console, part); - fPartToConsole.put(part, console); - partActivated(part); - break; - } - } + IConsole registered = allConsoles[j]; + if (registered.equals(console)) { + ConsoleWorkbenchPart part = new ConsoleWorkbenchPart(console, getSite()); + fConsoleToPart.put(console, part); + fPartToConsole.put(part, console); + partActivated(part); + break; + } + } } } @@ -454,7 +454,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL fDisplayConsoleAction = new ConsoleDropDownAction(this); ConsoleFactoryExtension[] extensions = ((ConsoleManager)ConsolePlugin.getDefault().getConsoleManager()).getConsoleFactoryExtensions(); if (extensions.length > 0) { - fOpenConsoleAction = new OpenConsoleAction(); + fOpenConsoleAction = new OpenConsoleAction(); } } @@ -465,9 +465,9 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL mgr.add(fPinAction); mgr.add(fDisplayConsoleAction); if (fOpenConsoleAction != null) { - mgr.add(fOpenConsoleAction); - if (mgr instanceof ToolBarManager) { - ToolBarManager tbm= (ToolBarManager) mgr; + mgr.add(fOpenConsoleAction); + if (mgr instanceof ToolBarManager) { + ToolBarManager tbm= (ToolBarManager) mgr; final ToolBar tb= tbm.getControl(); tb.addMouseListener(new MouseAdapter() { @Override @@ -488,28 +488,28 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL } } }); - } + } } } @Override public void display(IConsole console) { - if (fPinned && fActiveConsole != null) { - return; - } - if (console.equals(fActiveConsole)) { - return; - } - ConsoleWorkbenchPart part = fConsoleToPart.get(console); - if (part != null) { - partActivated(part); - } + if (fPinned && fActiveConsole != null) { + return; + } + if (console.equals(fActiveConsole)) { + return; + } + ConsoleWorkbenchPart part = fConsoleToPart.get(console); + if (part != null) { + partActivated(part); + } } @Override public void setPinned(boolean pin) { - fPinned = pin; - if (fPinAction != null) { + fPinned = pin; + if (fPinAction != null) { fPinAction.update(); } } @@ -631,25 +631,25 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL @SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> key) { - Object adpater = super.getAdapter(key); - if (adpater == null) { - IConsole console = getConsole(); - if (console != null) { + Object adpater = super.getAdapter(key); + if (adpater == null) { + IConsole console = getConsole(); + if (console != null) { ListenerList<IConsolePageParticipant> listeners = getParticipants(console); - // an adapter can be asked for before the console participants are created - if (listeners != null) { + // an adapter can be asked for before the console participants are created + if (listeners != null) { for (IConsolePageParticipant iConsolePageParticipant : listeners) { IConsolePageParticipant participant = iConsolePageParticipant; - adpater = participant.getAdapter(key); - if (adpater != null) { + adpater = participant.getAdapter(key); + if (adpater != null) { return (T) adpater; - } - } - } - } - } + } + } + } + } + } return (T) adpater; - } + } @Override public void partActivated(IWorkbenchPartReference partRef) { @@ -673,40 +673,40 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL @Override public void partDeactivated(IWorkbenchPartReference partRef) { - if (isThisPart(partRef)) { + if (isThisPart(partRef)) { fActive = false; IContextService contextService = getSite().getService(IContextService.class); if(contextService != null) { contextService.deactivateContext(fActivatedContext); deactivateParticipants(fActiveConsole); } - } + } } - /** + /** * Returns if the specified part reference is to this view part (if the part * reference is the console view or not) * * @param partRef the workbench part reference * @return true if the specified part reference is the console view */ - protected boolean isThisPart(IWorkbenchPartReference partRef) { - if (partRef instanceof IViewReference) { - IViewReference viewRef = (IViewReference) partRef; - if (getViewSite() != null && viewRef.getId().equals(getViewSite().getId())) { - String secId = viewRef.getSecondaryId(); - String mySec = null; - if (getSite() instanceof IViewSite) { - mySec = ((IViewSite)getSite()).getSecondaryId(); - } - if (mySec == null) { - return secId == null; - } - return mySec.equals(secId); - } - } - return false; - } + protected boolean isThisPart(IWorkbenchPartReference partRef) { + if (partRef instanceof IViewReference) { + IViewReference viewRef = (IViewReference) partRef; + if (getViewSite() != null && viewRef.getId().equals(getViewSite().getId())) { + String secId = viewRef.getSecondaryId(); + String mySec = null; + if (getSite() instanceof IViewSite) { + mySec = ((IViewSite)getSite()).getSecondaryId(); + } + if (mySec == null) { + return secId == null; + } + return mySec.equals(secId); + } + } + return false; + } /** * Deactivates participants for the given console, if any. @@ -715,12 +715,12 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL */ private void deactivateParticipants(IConsole console) { // deactivate - if (console != null) { + if (console != null) { final ListenerList<IConsolePageParticipant> listeners = getParticipants(console); if (listeners != null) { for (IConsolePageParticipant iConsolePageParticipant : listeners) { final IConsolePageParticipant participant = iConsolePageParticipant; - SafeRunner.run(new ISafeRunnable() { + SafeRunner.run(new ISafeRunnable() { @Override public void run() throws Exception { participant.deactivated(); @@ -731,9 +731,9 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL listeners.remove(participant); } }); - } + } } - } + } } @Override @@ -752,20 +752,20 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL public void partInputChanged(IWorkbenchPartReference partRef) { } - @Override + @Override public void setScrollLock(boolean scrollLock) { - fScrollLock = scrollLock; + fScrollLock = scrollLock; - IPage page = getCurrentPage(); - if (page instanceof IOConsolePage) { - ((IOConsolePage)page).setAutoScroll(!scrollLock); - } - } + IPage page = getCurrentPage(); + if (page instanceof IOConsolePage) { + ((IOConsolePage)page).setAutoScroll(!scrollLock); + } + } - @Override + @Override public boolean getScrollLock() { - return fScrollLock; - } + return fScrollLock; + } @Override public void setWordWrap(boolean wordWrap) { @@ -785,18 +785,18 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL return fWordWrap; } - @Override + @Override public void pin(IConsole console) { - if (console == null) { - setPinned(false); - } else { - if (isPinned()) { - setPinned(false); - } - display(console); - setPinned(true); - } - } + if (console == null) { + setPinned(false); + } else { + if (isPinned()) { + setPinned(false); + } + display(console); + setPinned(true); + } + } @Override public void setAutoScrollLock(boolean scrollLock) { diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleViewConsoleFactory.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleViewConsoleFactory.java index 5fe80b8df..780d777c6 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleViewConsoleFactory.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleViewConsoleFactory.java @@ -20,28 +20,28 @@ import org.eclipse.ui.console.IConsoleFactory; public class ConsoleViewConsoleFactory implements IConsoleFactory { - int counter = 1; + int counter = 1; - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.console.IConsoleFactory#openConsole() - */ + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.console.IConsoleFactory#openConsole() + */ @Override public void openConsole() { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null) { - IWorkbenchPage page = window.getActivePage(); - if (page != null) { - try { - String secondaryId = "Console View #" + counter; //$NON-NLS-1$ - page.showView(IConsoleConstants.ID_CONSOLE_VIEW, secondaryId, 1); - counter++; - } catch (PartInitException e) { - ConsolePlugin.log(e); - } - } - } - } + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + IWorkbenchPage page = window.getActivePage(); + if (page != null) { + try { + String secondaryId = "Console View #" + counter; //$NON-NLS-1$ + page.showView(IConsoleConstants.ID_CONSOLE_VIEW, secondaryId, 1); + counter++; + } catch (PartInitException e) { + ConsolePlugin.log(e); + } + } + } + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleWorkbenchPart.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleWorkbenchPart.java index 400f7d528..ace7d4e07 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleWorkbenchPart.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleWorkbenchPart.java @@ -31,7 +31,7 @@ public class ConsoleWorkbenchPart implements IWorkbenchPart { @Override public boolean equals(Object obj) { return (obj instanceof ConsoleWorkbenchPart) && - fConsole.equals(((ConsoleWorkbenchPart)obj).fConsole); + fConsole.equals(((ConsoleWorkbenchPart)obj).fConsole); } /* (non-Javadoc) diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/FollowHyperlinkAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/FollowHyperlinkAction.java index 5a735ccf9..4d81df31d 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/FollowHyperlinkAction.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/FollowHyperlinkAction.java @@ -24,28 +24,28 @@ public class FollowHyperlinkAction extends Action { private TextConsoleViewer viewer; - /** + /** * Constructs a follow link action */ public FollowHyperlinkAction(TextConsoleViewer consoleViewer) { - super(ConsoleMessages.FollowHyperlinkAction_0); + super(ConsoleMessages.FollowHyperlinkAction_0); setToolTipText(ConsoleMessages.FollowHyperlinkAction_1); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_OPEN_LINK_ACTION); this.viewer = consoleViewer; } - /* (non-Javadoc) - * @see org.eclipse.jface.action.IAction#isEnabled() - */ + /* (non-Javadoc) + * @see org.eclipse.jface.action.IAction#isEnabled() + */ @Override public boolean isEnabled() { - return viewer.getHyperlink() != null; - } + return viewer.getHyperlink() != null; + } - /* - * (non-Javadoc) - * @see org.eclipse.jface.action.IAction#run() - */ + /* + * (non-Javadoc) + * @see org.eclipse.jface.action.IAction#run() + */ @Override public void run() { IHyperlink link = viewer.getHyperlink(); diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/HyperlinkUpdater.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/HyperlinkUpdater.java index 0c78ed550..43eeb6d45 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/HyperlinkUpdater.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/HyperlinkUpdater.java @@ -37,9 +37,9 @@ public class HyperlinkUpdater extends DefaultPositionUpdater { int positionEnd = fPosition.offset + fPosition.length - 1; int editEnd = fOffset + fLength - 1; if ((fOffset <= fPosition.offset && (editEnd > fPosition.offset)) || - (fOffset < positionEnd && (editEnd > positionEnd)) || - (fOffset >= fPosition.offset && fOffset <= positionEnd) || - (editEnd >= fPosition.offset && editEnd <= positionEnd)) { + (fOffset < positionEnd && (editEnd > positionEnd)) || + (fOffset >= fPosition.offset && fOffset <= positionEnd) || + (editEnd >= fPosition.offset && editEnd <= positionEnd)) { fPosition.delete(); diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IInternalConsoleConstants.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IInternalConsoleConstants.java index 1465ca8ec..d29005b43 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IInternalConsoleConstants.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IInternalConsoleConstants.java @@ -32,5 +32,5 @@ public interface IInternalConsoleConstants { public static final String IMG_ELCL_LOCK = "IMG_ELCL_LOCK"; //$NON-NLS-1$ public static final String IMG_ELCL_WRAP = "IMG_ELCL_WRAP"; //$NON-NLS-1$ public static final String IMG_ELCL_CLOSE = "IMG_ELCL_CLOSE"; //$NON-NLS-1$ - public static final String IMG_ELCL_NEW_CON = "IMG_ELCL_NEW_CON"; //$NON-NLS-1$ + public static final String IMG_ELCL_NEW_CON = "IMG_ELCL_NEW_CON"; //$NON-NLS-1$ } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePage.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePage.java index 1b876a93e..0afc425f6 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePage.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePage.java @@ -31,54 +31,54 @@ import org.eclipse.ui.console.TextConsoleViewer; */ public class IOConsolePage extends TextConsolePage { - private ScrollLockAction fScrollLockAction; - private WordWrapAction fWordWrapAction; + private ScrollLockAction fScrollLockAction; + private WordWrapAction fWordWrapAction; - private boolean fReadOnly; + private boolean fReadOnly; - private IPropertyChangeListener fPropertyChangeListener; + private IPropertyChangeListener fPropertyChangeListener; private IConsoleView fView; - public IOConsolePage(TextConsole console, IConsoleView view) { - super(console, view); + public IOConsolePage(TextConsole console, IConsoleView view) { + super(console, view); fView = view; - fPropertyChangeListener = new IPropertyChangeListener() { - @Override + fPropertyChangeListener = new IPropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent event) { - String property = event.getProperty(); - if (property.equals(IConsoleConstants.P_CONSOLE_OUTPUT_COMPLETE)) { - setReadOnly(); - } - } - }; - console.addPropertyChangeListener(fPropertyChangeListener); - } - - @Override + String property = event.getProperty(); + if (property.equals(IConsoleConstants.P_CONSOLE_OUTPUT_COMPLETE)) { + setReadOnly(); + } + } + }; + console.addPropertyChangeListener(fPropertyChangeListener); + } + + @Override public void createControl(Composite parent) { - super.createControl(parent); - if (fReadOnly) { - IOConsoleViewer viewer = (IOConsoleViewer) getViewer(); - viewer.setReadOnly(); - } - } - - @Override + super.createControl(parent); + if (fReadOnly) { + IOConsoleViewer viewer = (IOConsoleViewer) getViewer(); + viewer.setReadOnly(); + } + } + + @Override protected TextConsoleViewer createViewer(Composite parent) { return new IOConsoleViewer(parent, (TextConsole) getConsole(), fView); - } + } - public void setAutoScroll(boolean scroll) { - IOConsoleViewer viewer = (IOConsoleViewer) getViewer(); - if (viewer != null) { - viewer.setAutoScroll(scroll); - fScrollLockAction.setChecked(!scroll); - } - } + public void setAutoScroll(boolean scroll) { + IOConsoleViewer viewer = (IOConsoleViewer) getViewer(); + if (viewer != null) { + viewer.setAutoScroll(scroll); + fScrollLockAction.setChecked(!scroll); + } + } - public boolean isAutoScroll() { + public boolean isAutoScroll() { IOConsoleViewer viewer = (IOConsoleViewer) getViewer(); if (viewer != null) { return viewer.isAutoScroll(); @@ -86,65 +86,65 @@ public class IOConsolePage extends TextConsolePage { } return false; } - public void setWordWrap(boolean wordwrap) { - IOConsoleViewer viewer = (IOConsoleViewer) getViewer(); - if (viewer != null) { - viewer.setWordWrap(wordwrap); - fWordWrapAction.setChecked(wordwrap); - } - } - - /** - * Informs the viewer that it's text widget should not be editable. - */ - public void setReadOnly() { - fReadOnly = true; - IOConsoleViewer viewer = (IOConsoleViewer) getViewer(); - if (viewer != null) { - viewer.setReadOnly(); - } - } - - @Override + public void setWordWrap(boolean wordwrap) { + IOConsoleViewer viewer = (IOConsoleViewer) getViewer(); + if (viewer != null) { + viewer.setWordWrap(wordwrap); + fWordWrapAction.setChecked(wordwrap); + } + } + + /** + * Informs the viewer that it's text widget should not be editable. + */ + public void setReadOnly() { + fReadOnly = true; + IOConsoleViewer viewer = (IOConsoleViewer) getViewer(); + if (viewer != null) { + viewer.setReadOnly(); + } + } + + @Override protected void createActions() { - super.createActions(); - fScrollLockAction = new ScrollLockAction(getConsoleView()); - setAutoScroll(!fScrollLockAction.isChecked()); - fWordWrapAction = new WordWrapAction(getConsoleView()); - setWordWrap(fWordWrapAction.isChecked()); - } - - @Override + super.createActions(); + fScrollLockAction = new ScrollLockAction(getConsoleView()); + setAutoScroll(!fScrollLockAction.isChecked()); + fWordWrapAction = new WordWrapAction(getConsoleView()); + setWordWrap(fWordWrapAction.isChecked()); + } + + @Override protected void contextMenuAboutToShow(IMenuManager menuManager) { - super.contextMenuAboutToShow(menuManager); - menuManager.add(fScrollLockAction); - menuManager.add(fWordWrapAction); - IOConsoleViewer viewer = (IOConsoleViewer) getViewer(); - if (!viewer.isReadOnly()) { - menuManager.remove(ActionFactory.CUT.getId()); - menuManager.remove(ActionFactory.PASTE.getId()); - } - } + super.contextMenuAboutToShow(menuManager); + menuManager.add(fScrollLockAction); + menuManager.add(fWordWrapAction); + IOConsoleViewer viewer = (IOConsoleViewer) getViewer(); + if (!viewer.isReadOnly()) { + menuManager.remove(ActionFactory.CUT.getId()); + menuManager.remove(ActionFactory.PASTE.getId()); + } + } @Override protected void configureToolBar(IToolBarManager mgr) { - super.configureToolBar(mgr); - mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fScrollLockAction); - mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fWordWrapAction); - } + super.configureToolBar(mgr); + mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fScrollLockAction); + mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fWordWrapAction); + } - @Override + @Override public void dispose() { - if (fScrollLockAction != null) { - fScrollLockAction.dispose(); - fScrollLockAction = null; - } - if (fWordWrapAction != null) { - fWordWrapAction.dispose(); - fWordWrapAction = null; - } - fView = null; - getConsole().removePropertyChangeListener(fPropertyChangeListener); - super.dispose(); - } + if (fScrollLockAction != null) { + fScrollLockAction.dispose(); + fScrollLockAction = null; + } + if (fWordWrapAction != null) { + fWordWrapAction.dispose(); + fWordWrapAction = null; + } + fView = null; + getConsole().removePropertyChangeListener(fPropertyChangeListener); + super.dispose(); + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java index bd20169be..be353aaab 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java @@ -30,183 +30,183 @@ public class IOConsolePartition implements ITypedRegion { * The data contained by this partition. */ private StringBuffer buffer; - private String type; - private int offset; - /** - * Output partitions are all read only. - * Input partitions are read only once they have been appended to the console's input stream. - */ - private boolean readOnly; - - /** - * Only one of inputStream or outputStream will be null depending on the partitions type. - */ - private IOConsoleOutputStream outputStream; - private IOConsoleInputStream inputStream; - private int length; - - /** - * Creates a new partition to contain output to console. - */ - public IOConsolePartition(IOConsoleOutputStream outputStream, int length) { - this.outputStream = outputStream; - this.length = length; - this.type = OUTPUT_PARTITION_TYPE; - this.readOnly = true; - } - - /** - * Creates a new partition to contain input from a console - */ - public IOConsolePartition(IOConsoleInputStream inputStream, String text) { - this.inputStream = inputStream; - buffer = new StringBuffer(text); - length = text.length(); - this.type = INPUT_PARTITION_TYPE; - this.readOnly = false; - } - - /** - * Inserts a string into this partition. - * @param s The string to insert - * @param offset the offset in the partition - */ - public void insert(String s, int insertOffset) { - buffer.insert(insertOffset, s); - length += s.length(); - } - - /** - * Deletes data from this partition. - * @param delOffset - * @param delLength - */ - public void delete(int delOffset, int delLength) { - buffer.delete(delOffset, delOffset+delLength); - length -= delLength; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.text.ITypedRegion#getType() - */ - @Override + private String type; + private int offset; + /** + * Output partitions are all read only. + * Input partitions are read only once they have been appended to the console's input stream. + */ + private boolean readOnly; + + /** + * Only one of inputStream or outputStream will be null depending on the partitions type. + */ + private IOConsoleOutputStream outputStream; + private IOConsoleInputStream inputStream; + private int length; + + /** + * Creates a new partition to contain output to console. + */ + public IOConsolePartition(IOConsoleOutputStream outputStream, int length) { + this.outputStream = outputStream; + this.length = length; + this.type = OUTPUT_PARTITION_TYPE; + this.readOnly = true; + } + + /** + * Creates a new partition to contain input from a console + */ + public IOConsolePartition(IOConsoleInputStream inputStream, String text) { + this.inputStream = inputStream; + buffer = new StringBuffer(text); + length = text.length(); + this.type = INPUT_PARTITION_TYPE; + this.readOnly = false; + } + + /** + * Inserts a string into this partition. + * @param s The string to insert + * @param offset the offset in the partition + */ + public void insert(String s, int insertOffset) { + buffer.insert(insertOffset, s); + length += s.length(); + } + + /** + * Deletes data from this partition. + * @param delOffset + * @param delLength + */ + public void delete(int delOffset, int delLength) { + buffer.delete(delOffset, delOffset+delLength); + length -= delLength; + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.text.ITypedRegion#getType() + */ + @Override public String getType() { - return type; - } + return type; + } - /* - * (non-Javadoc) - * @see org.eclipse.jface.text.IRegion#getLength() - */ + /* + * (non-Javadoc) + * @see org.eclipse.jface.text.IRegion#getLength() + */ @Override public int getLength() { - return length; - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.text.IRegion#getOffset() - */ - @Override + return length; + } + + /* + * (non-Javadoc) + * @see org.eclipse.jface.text.IRegion#getOffset() + */ + @Override public int getOffset() { - return offset; - } - - /** - * Sets this partitions offset in the document. - * - * @param offset This partitions offset in the document. - */ - public void setOffset(int offset) { - this.offset = offset; - } - - /** - * Sets this partition's length. - * - * @param length - */ - public void setLength(int length) { - this.length = length; - } - - /** - * Returns the data contained in this partition. - * @return The data contained in this partition. - */ - public String getString() { - return buffer.toString(); - } - - /** - * Returns a StyleRange object which may be used for setting the style - * of this partition in a viewer. - */ - public StyleRange getStyleRange(int rangeOffset, int rangeLength) { - return new StyleRange(rangeOffset, rangeLength, getColor(), null, getFontStyle()); - } - - /** - * Returns the font of the input stream if the type of the partition - * is <code>INPUT_PARTITION_TYPE</code>, otherwise it returns the output - * stream font - * - * @return the font of one of the backing streams - */ - private int getFontStyle() { - if (type.equals(INPUT_PARTITION_TYPE)) { - return inputStream.getFontStyle(); - } - return outputStream.getFontStyle(); - } - - /** - * Returns the colour of the input stream if the type of the partition - * is <code>INPUT_PARTITION_TYPE</code>, otherwise it returns the output - * stream colour - * - * @return the colour of one of the backing streams - */ - public Color getColor() { - if (type.equals(INPUT_PARTITION_TYPE)) { - return inputStream.getColor(); - } - return outputStream.getColor(); - } - - /** - * Returns if this partition is read-only. - * - * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#isReadOnly(int) - * @return if this partition is read-only - */ - public boolean isReadOnly() { - return readOnly; - } - - /** - * Sets the read-only state of this partition to <code>true</code>. - * - * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#isReadOnly(int) - */ - public void setReadOnly() { - readOnly = true; - } - - /** - * Clears the contents of the buffer - */ - public void clearBuffer() { - buffer.setLength(0); - } - - /** - * Returns the underlying output stream - * - * @return the underlying output stream - */ - IOConsoleOutputStream getStream() { - return outputStream; - } + return offset; + } + + /** + * Sets this partitions offset in the document. + * + * @param offset This partitions offset in the document. + */ + public void setOffset(int offset) { + this.offset = offset; + } + + /** + * Sets this partition's length. + * + * @param length + */ + public void setLength(int length) { + this.length = length; + } + + /** + * Returns the data contained in this partition. + * @return The data contained in this partition. + */ + public String getString() { + return buffer.toString(); + } + + /** + * Returns a StyleRange object which may be used for setting the style + * of this partition in a viewer. + */ + public StyleRange getStyleRange(int rangeOffset, int rangeLength) { + return new StyleRange(rangeOffset, rangeLength, getColor(), null, getFontStyle()); + } + + /** + * Returns the font of the input stream if the type of the partition + * is <code>INPUT_PARTITION_TYPE</code>, otherwise it returns the output + * stream font + * + * @return the font of one of the backing streams + */ + private int getFontStyle() { + if (type.equals(INPUT_PARTITION_TYPE)) { + return inputStream.getFontStyle(); + } + return outputStream.getFontStyle(); + } + + /** + * Returns the colour of the input stream if the type of the partition + * is <code>INPUT_PARTITION_TYPE</code>, otherwise it returns the output + * stream colour + * + * @return the colour of one of the backing streams + */ + public Color getColor() { + if (type.equals(INPUT_PARTITION_TYPE)) { + return inputStream.getColor(); + } + return outputStream.getColor(); + } + + /** + * Returns if this partition is read-only. + * + * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#isReadOnly(int) + * @return if this partition is read-only + */ + public boolean isReadOnly() { + return readOnly; + } + + /** + * Sets the read-only state of this partition to <code>true</code>. + * + * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#isReadOnly(int) + */ + public void setReadOnly() { + readOnly = true; + } + + /** + * Clears the contents of the buffer + */ + public void clearBuffer() { + buffer.setLength(0); + } + + /** + * Returns the underlying output stream + * + * @return the underlying output stream + */ + IOConsoleOutputStream getStream() { + return outputStream; + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java index b18f518ba..d1555bad4 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java @@ -84,9 +84,9 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum private String[] lld; private int highWaterMark = -1; private int lowWaterMark = -1; - private boolean connected = false; + private boolean connected = false; - private IOConsole console; + private IOConsole console; private TrimJob trimJob = new TrimJob(); /** @@ -97,7 +97,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum private Object overflowLock = new Object(); - private int fBuffer; + private int fBuffer; public IOConsolePartitioner(IOConsoleInputStream inputStream, IOConsole console) { this.inputStream = inputStream; @@ -123,17 +123,17 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum inputPartitions = new ArrayList<IOConsolePartition>(); queueJob = new QueueProcessingJob(); queueJob.setSystem(true); - queueJob.setPriority(Job.INTERACTIVE); + queueJob.setPriority(Job.INTERACTIVE); queueJob.setRule(console.getSchedulingRule()); connected = true; } public int getHighWaterMark() { - return highWaterMark; + return highWaterMark; } public int getLowWaterMark() { - return lowWaterMark; + return lowWaterMark; } public void setWaterMarks(int low, int high) { @@ -150,13 +150,13 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum /** * Notification from the console that all of its streams have been closed. */ - public void streamsClosed() { - consoleClosedPartition = new PendingPartition(null, null); - synchronized (pendingPartitions) { - pendingPartitions.add(consoleClosedPartition); - } - queueJob.schedule(); //ensure that all pending partitions are processed. - } + public void streamsClosed() { + consoleClosedPartition = new PendingPartition(null, null); + synchronized (pendingPartitions) { + pendingPartitions.add(consoleClosedPartition); + } + queueJob.schedule(); //ensure that all pending partitions are processed. + } /* * (non-Javadoc) @@ -169,9 +169,9 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum partitions.clear(); connected = false; try { - inputStream.close(); - } catch (IOException e) { - } + inputStream.close(); + } catch (IOException e) { + } } } @@ -223,7 +223,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum IOConsolePartition position= null; if (left == right) { - return new IOConsolePartition[]{partitions.get(0)}; + return new IOConsolePartition[]{partitions.get(0)}; } while (left < right) { @@ -251,7 +251,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum List<IOConsolePartition> list = new ArrayList<IOConsolePartition>(); int index = left - 1; if (index >= 0) { - position= partitions.get(index); + position= partitions.get(index); while (index >= 0 && (position.getOffset() + position.getLength()) > offset) { index--; if (index >= 0) { @@ -309,10 +309,10 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum if (document != null && highWaterMark > 0) { int length = document.getLength(); if (length > highWaterMark) { - if (trimJob.getState() == Job.NONE) { //if the job isn't already running - trimJob.setOffset(length - lowWaterMark); - trimJob.schedule(); - } + if (trimJob.getState() == Job.NONE) { //if the job isn't already running + trimJob.setOffset(length - lowWaterMark); + trimJob.schedule(); + } } } } @@ -321,10 +321,10 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum * Clears the console */ public void clearBuffer() { - synchronized (overflowLock) { - trimJob.setOffset(-1); - trimJob.schedule(); - } + synchronized (overflowLock) { + trimJob.setOffset(-1); + trimJob.schedule(); + } } /* @@ -334,9 +334,9 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum */ @Override public IRegion documentChanged2(DocumentEvent event) { - if (document == null) { - return null; //another thread disconnected the partitioner - } + if (document == null) { + return null; //another thread disconnected the partitioner + } if (document.getLength() == 0) { //document cleared if (lastPartition != null && lastPartition.getType().equals(IOConsolePartition.INPUT_PARTITION_TYPE)) { synchronized (partitions) { @@ -354,20 +354,20 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum if (updatePartitions != null) { for (PendingPartition pp : updatePartitions) { if (pp == consoleClosedPartition) { - continue; - } - - int ppLen = pp.text.length(); - if (lastPartition != null && lastPartition.getStream() == pp.stream) { - int len = lastPartition.getLength(); - lastPartition.setLength(len + ppLen); - } else { - IOConsolePartition partition = new IOConsolePartition(pp.stream, ppLen); - partition.setOffset(firstOffset); - lastPartition = partition; - partitions.add(partition); - } - firstOffset += ppLen; + continue; + } + + int ppLen = pp.text.length(); + if (lastPartition != null && lastPartition.getStream() == pp.stream) { + int len = lastPartition.getLength(); + lastPartition.setLength(len + ppLen); + } else { + IOConsolePartition partition = new IOConsolePartition(pp.stream, ppLen); + partition.setOffset(firstOffset); + lastPartition = partition; + partitions.add(partition); + } + firstOffset += ppLen; } } } @@ -398,44 +398,44 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum String ld = lld[i]; int index = partitionText.lastIndexOf(ld); if (index != -1) { - index += ld.length(); + index += ld.length(); } if (index > lastLineDelimiter) { - lastLineDelimiter = index; + lastLineDelimiter = index; } } if (lastLineDelimiter != -1) { StringBuffer input = new StringBuffer(); Iterator<IOConsolePartition> it = inputPartitions.iterator(); while (it.hasNext()) { - IOConsolePartition partition = it.next(); - if (partition.getOffset() + partition.getLength() <= event.fOffset + lastLineDelimiter) { - if (partition == lastPartition) { - lastPartition = null; - } - input.append(partition.getString()); + IOConsolePartition partition = it.next(); + if (partition.getOffset() + partition.getLength() <= event.fOffset + lastLineDelimiter) { + if (partition == lastPartition) { + lastPartition = null; + } + input.append(partition.getString()); partition.clearBuffer(); partition.setReadOnly(); it.remove(); - } else { - //create a new partition containing everything up to the line delimiter - //and append that to the string buffer. - String contentBefore = partitionText.substring(0, lastLineDelimiter); - IOConsolePartition newPartition = new IOConsolePartition(inputStream, contentBefore); - newPartition.setOffset(partition.getOffset()); - newPartition.setReadOnly(); - newPartition.clearBuffer(); - int index = partitions.indexOf(partition); - partitions.add(index, newPartition); - input.append(contentBefore); - //delete everything that has been appended to the buffer. - partition.delete(0, lastLineDelimiter); - partition.setOffset(lastLineDelimiter + partition.getOffset()); - lastLineDelimiter = 0; - } + } else { + //create a new partition containing everything up to the line delimiter + //and append that to the string buffer. + String contentBefore = partitionText.substring(0, lastLineDelimiter); + IOConsolePartition newPartition = new IOConsolePartition(inputStream, contentBefore); + newPartition.setOffset(partition.getOffset()); + newPartition.setReadOnly(); + newPartition.clearBuffer(); + int index = partitions.indexOf(partition); + partitions.add(index, newPartition); + input.append(contentBefore); + //delete everything that has been appended to the buffer. + partition.delete(0, lastLineDelimiter); + partition.setOffset(lastLineDelimiter + partition.getOffset()); + lastLineDelimiter = 0; + } } if (input.length() > 0) { - inputStream.appendData(input.toString()); + inputStream.appendData(input.toString()); } } @@ -458,36 +458,36 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum * @param s The string that should be appended to the document. */ public void streamAppended(IOConsoleOutputStream stream, String s) throws IOException { - if (document == null) { - throw new IOException("Document is closed"); //$NON-NLS-1$ - } + if (document == null) { + throw new IOException("Document is closed"); //$NON-NLS-1$ + } synchronized(pendingPartitions) { PendingPartition last = pendingPartitions.size() > 0 ? pendingPartitions.get(pendingPartitions.size()-1) : null; if (last != null && last.stream == stream) { last.append(s); } else { pendingPartitions.add(new PendingPartition(stream, s)); - if (fBuffer > 1000) { - queueJob.schedule(); - } else { - queueJob.schedule(50); - } + if (fBuffer > 1000) { + queueJob.schedule(); + } else { + queueJob.schedule(50); + } } - if (fBuffer > 160000) { - if(Display.getCurrent() == null){ + if (fBuffer > 160000) { + if(Display.getCurrent() == null){ try { pendingPartitions.wait(); } catch (InterruptedException e) { } - } else { + } else { /* * if we are in UI thread we cannot lock it, so process * queued output. */ - processQueue(); - } - } + processQueue(); + } + } } } @@ -501,13 +501,13 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum PendingPartition(IOConsoleOutputStream stream, String text) { this.stream = stream; if (text != null) { - append(text); - } + append(text); + } } void append(String moreText) { text.append(moreText); - fBuffer += moreText.length(); + fBuffer += moreText.length(); } } @@ -517,39 +517,39 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum */ private class QueueProcessingJob extends UIJob { - QueueProcessingJob() { + QueueProcessingJob() { super("IOConsole Updater"); //$NON-NLS-1$ } - /* - * (non-Javadoc) - * @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override + /* + * (non-Javadoc) + * @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override public IStatus runInUIThread(IProgressMonitor monitor) { - processQueue(); - return Status.OK_STATUS; - } - - /* - * Job will process as much as it can each time it's run, but it gets - * scheduled everytime a PendingPartition is added to the list, meaning - * that this job could get scheduled unnecessarily in cases of heavy output. - * Note however, that schedule() will only reschedule a running/scheduled Job - * once even if it's called many times. - */ - @Override + processQueue(); + return Status.OK_STATUS; + } + + /* + * Job will process as much as it can each time it's run, but it gets + * scheduled everytime a PendingPartition is added to the list, meaning + * that this job could get scheduled unnecessarily in cases of heavy output. + * Note however, that schedule() will only reschedule a running/scheduled Job + * once even if it's called many times. + */ + @Override public boolean shouldRun() { - boolean shouldRun = connected && pendingPartitions != null && pendingPartitions.size() > 0; - return shouldRun; - } + boolean shouldRun = connected && pendingPartitions != null && pendingPartitions.size() > 0; + return shouldRun; + } } void processQueue() { - synchronized (overflowLock) { + synchronized (overflowLock) { ArrayList<PendingPartition> pendingCopy = new ArrayList<PendingPartition>(); - StringBuffer buffer = null; - boolean consoleClosed = false; + StringBuffer buffer = null; + boolean consoleClosed = false; synchronized(pendingPartitions) { pendingCopy.addAll(pendingPartitions); pendingPartitions.clear(); @@ -571,131 +571,131 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum consoleClosed = true; } } - if (connected) { - setUpdateInProgress(true); - updatePartitions = pendingCopy; - firstOffset = document.getLength(); - try { - if (buffer != null) { - document.replace(firstOffset, 0, buffer.toString()); - } - } catch (BadLocationException e) { - } - updatePartitions = null; - setUpdateInProgress(false); - } - if (consoleClosed) { - console.partitionerFinished(); - } - checkBufferSize(); - } + if (connected) { + setUpdateInProgress(true); + updatePartitions = pendingCopy; + firstOffset = document.getLength(); + try { + if (buffer != null) { + document.replace(firstOffset, 0, buffer.toString()); + } + } catch (BadLocationException e) { + } + updatePartitions = null; + setUpdateInProgress(false); + } + if (consoleClosed) { + console.partitionerFinished(); + } + checkBufferSize(); + } } - /** - * Job to trim the console document, runs in the UI thread. - */ - private class TrimJob extends WorkbenchJob { - - /** - * trims output up to the line containing the given offset, - * or all output if -1. - */ - private int truncateOffset; - - /** - * Creates a new job to trim the buffer. - */ - TrimJob() { - super("Trim Job"); //$NON-NLS-1$ - setSystem(true); - } - - /** - * Sets the trim offset. - * - * @param offset trims output up to the line containing the given offset - */ - public void setOffset(int offset) { - truncateOffset = offset; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override + /** + * Job to trim the console document, runs in the UI thread. + */ + private class TrimJob extends WorkbenchJob { + + /** + * trims output up to the line containing the given offset, + * or all output if -1. + */ + private int truncateOffset; + + /** + * Creates a new job to trim the buffer. + */ + TrimJob() { + super("Trim Job"); //$NON-NLS-1$ + setSystem(true); + } + + /** + * Sets the trim offset. + * + * @param offset trims output up to the line containing the given offset + */ + public void setOffset(int offset) { + truncateOffset = offset; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) + */ + @Override public IStatus runInUIThread(IProgressMonitor monitor) { - if (document == null) { - return Status.OK_STATUS; - } - - int length = document.getLength(); - if (truncateOffset < length) { - synchronized (overflowLock) { - try { - if (truncateOffset < 0) { - // clear - setUpdateInProgress(true); - document.set(""); //$NON-NLS-1$ - setUpdateInProgress(false); - partitions.clear(); - } else { - // overflow - int cutoffLine = document.getLineOfOffset(truncateOffset); - int cutOffset = document.getLineOffset(cutoffLine); - - - // set the new length of the first partition - IOConsolePartition partition = (IOConsolePartition) getPartition(cutOffset); - partition.setLength(partition.getOffset() + partition.getLength() - cutOffset); - - setUpdateInProgress(true); - document.replace(0, cutOffset, ""); //$NON-NLS-1$ - setUpdateInProgress(false); - - //remove partitions and reset Partition offsets - int index = partitions.indexOf(partition); - for (int i = 0; i < index; i++) { - partitions.remove(0); - } - - int offset = 0; + if (document == null) { + return Status.OK_STATUS; + } + + int length = document.getLength(); + if (truncateOffset < length) { + synchronized (overflowLock) { + try { + if (truncateOffset < 0) { + // clear + setUpdateInProgress(true); + document.set(""); //$NON-NLS-1$ + setUpdateInProgress(false); + partitions.clear(); + } else { + // overflow + int cutoffLine = document.getLineOfOffset(truncateOffset); + int cutOffset = document.getLineOffset(cutoffLine); + + + // set the new length of the first partition + IOConsolePartition partition = (IOConsolePartition) getPartition(cutOffset); + partition.setLength(partition.getOffset() + partition.getLength() - cutOffset); + + setUpdateInProgress(true); + document.replace(0, cutOffset, ""); //$NON-NLS-1$ + setUpdateInProgress(false); + + //remove partitions and reset Partition offsets + int index = partitions.indexOf(partition); + for (int i = 0; i < index; i++) { + partitions.remove(0); + } + + int offset = 0; for (IOConsolePartition p : partitions) { - p.setOffset(offset); - offset += p.getLength(); - } - } - } catch (BadLocationException e) { - } - } - } - return Status.OK_STATUS; - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#isReadOnly(int) - */ - @Override + p.setOffset(offset); + offset += p.getLength(); + } + } + } catch (BadLocationException e) { + } + } + } + return Status.OK_STATUS; + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#isReadOnly(int) + */ + @Override public boolean isReadOnly(int offset) { - return ((IOConsolePartition)getPartition(offset)).isReadOnly(); - } + return ((IOConsolePartition)getPartition(offset)).isReadOnly(); + } - /* (non-Javadoc) - * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#computeStyleRange(int, int) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#computeStyleRange(int, int) + */ + @Override public StyleRange[] getStyleRanges(int offset, int length) { - if (!connected) { - return new StyleRange[0]; - } - IOConsolePartition[] computedPartitions = (IOConsolePartition[])computePartitioning(offset, length); - StyleRange[] styles = new StyleRange[computedPartitions.length]; - for (int i = 0; i < computedPartitions.length; i++) { - int rangeStart = Math.max(computedPartitions[i].getOffset(), offset); - int rangeLength = computedPartitions[i].getLength(); - styles[i] = computedPartitions[i].getStyleRange(rangeStart, rangeLength); - } - return styles; - } + if (!connected) { + return new StyleRange[0]; + } + IOConsolePartition[] computedPartitions = (IOConsolePartition[])computePartitioning(offset, length); + StyleRange[] styles = new StyleRange[computedPartitions.length]; + for (int i = 0; i < computedPartitions.length; i++) { + int rangeStart = Math.max(computedPartitions[i].getOffset(), offset); + int rangeLength = computedPartitions[i].getLength(); + styles[i] = computedPartitions[i].getStyleRange(rangeStart, rangeLength); + } + return styles; + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsoleViewer.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsoleViewer.java index 65a0e8899..432f86a6f 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsoleViewer.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsoleViewer.java @@ -31,18 +31,18 @@ import org.eclipse.ui.console.TextConsoleViewer; * @since 3.1 */ public class IOConsoleViewer extends TextConsoleViewer { - /** - * will always scroll with output if value is true. - */ - private boolean fAutoScroll = true; + /** + * will always scroll with output if value is true. + */ + private boolean fAutoScroll = true; - private boolean fWordWrap = false; + private boolean fWordWrap = false; - private IDocumentListener fDocumentListener; + private IDocumentListener fDocumentListener; - public IOConsoleViewer(Composite parent, TextConsole console) { - super(parent, console); - } + public IOConsoleViewer(Composite parent, TextConsole console) { + super(parent, console); + } /** * Constructs a new viewer in the given parent for the specified console. @@ -56,65 +56,65 @@ public class IOConsoleViewer extends TextConsoleViewer { super(parent, console, scrollLockStateProvider); } - public boolean isAutoScroll() { - return fAutoScroll; - } + public boolean isAutoScroll() { + return fAutoScroll; + } - public void setAutoScroll(boolean scroll) { - fAutoScroll = scroll; - } + public void setAutoScroll(boolean scroll) { + fAutoScroll = scroll; + } - public boolean isWordWrap() { - return fWordWrap; - } + public boolean isWordWrap() { + return fWordWrap; + } - public void setWordWrap(boolean wordwrap) { - fWordWrap = wordwrap; - getTextWidget().setWordWrap(wordwrap); - } + public void setWordWrap(boolean wordwrap) { + fWordWrap = wordwrap; + getTextWidget().setWordWrap(wordwrap); + } - @Override + @Override protected void handleVerifyEvent(VerifyEvent e) { - IDocument doc = getDocument(); - String[] legalLineDelimiters = doc.getLegalLineDelimiters(); - String eventString = e.text; - try { - IConsoleDocumentPartitioner partitioner = (IConsoleDocumentPartitioner) doc.getDocumentPartitioner(); - if (!partitioner.isReadOnly(e.start)) { - boolean isCarriageReturn = false; - for (int i = 0; i < legalLineDelimiters.length; i++) { - if (e.text.equals(legalLineDelimiters[i])) { - isCarriageReturn = true; - break; - } - } - - if (!isCarriageReturn) { - super.handleVerifyEvent(e); - return; - } - } - - int length = doc.getLength(); - if (e.start == length) { - super.handleVerifyEvent(e); - } else { - try { - doc.replace(length, 0, eventString); - updateWidgetCaretLocation(length); - } catch (BadLocationException e1) { - } - e.doit = false; - } - } finally { - StyledText text = (StyledText) e.widget; - text.setCaretOffset(text.getCharCount()); - } - } - - /* - * Update the Text widget location to new location - */ + IDocument doc = getDocument(); + String[] legalLineDelimiters = doc.getLegalLineDelimiters(); + String eventString = e.text; + try { + IConsoleDocumentPartitioner partitioner = (IConsoleDocumentPartitioner) doc.getDocumentPartitioner(); + if (!partitioner.isReadOnly(e.start)) { + boolean isCarriageReturn = false; + for (int i = 0; i < legalLineDelimiters.length; i++) { + if (e.text.equals(legalLineDelimiters[i])) { + isCarriageReturn = true; + break; + } + } + + if (!isCarriageReturn) { + super.handleVerifyEvent(e); + return; + } + } + + int length = doc.getLength(); + if (e.start == length) { + super.handleVerifyEvent(e); + } else { + try { + doc.replace(length, 0, eventString); + updateWidgetCaretLocation(length); + } catch (BadLocationException e1) { + } + e.doit = false; + } + } finally { + StyledText text = (StyledText) e.widget; + text.setCaretOffset(text.getCharCount()); + } + } + + /* + * Update the Text widget location to new location + */ private void updateWidgetCaretLocation(int documentCaret) { int widgetCaret = modelOffset2WidgetOffset(documentCaret); if (widgetCaret == -1) { @@ -135,57 +135,57 @@ public class IOConsoleViewer extends TextConsoleViewer { } } - /** - * makes the associated text widget uneditable. - */ - public void setReadOnly() { - ConsolePlugin.getStandardDisplay().asyncExec(new Runnable() { - @Override + /** + * makes the associated text widget uneditable. + */ + public void setReadOnly() { + ConsolePlugin.getStandardDisplay().asyncExec(new Runnable() { + @Override public void run() { - StyledText text = getTextWidget(); - if (text != null && !text.isDisposed()) { - text.setEditable(false); - } - } - }); - } - - /** - * @return <code>false</code> if text is editable - */ - public boolean isReadOnly() { - return !getTextWidget().getEditable(); - } - - @Override + StyledText text = getTextWidget(); + if (text != null && !text.isDisposed()) { + text.setEditable(false); + } + } + }); + } + + /** + * @return <code>false</code> if text is editable + */ + public boolean isReadOnly() { + return !getTextWidget().getEditable(); + } + + @Override public void setDocument(IDocument document) { - IDocument oldDocument= getDocument(); + IDocument oldDocument= getDocument(); - super.setDocument(document); + super.setDocument(document); - if (oldDocument != null) { - oldDocument.removeDocumentListener(getDocumentListener()); - } - if (document != null) { - document.addDocumentListener(getDocumentListener()); - } - } + if (oldDocument != null) { + oldDocument.removeDocumentListener(getDocumentListener()); + } + if (document != null) { + document.addDocumentListener(getDocumentListener()); + } + } - private IDocumentListener getDocumentListener() { - if (fDocumentListener == null) { - fDocumentListener= new IDocumentListener() { + private IDocumentListener getDocumentListener() { + if (fDocumentListener == null) { + fDocumentListener= new IDocumentListener() { @Override public void documentAboutToBeChanged(DocumentEvent event) { - } + } - @Override + @Override public void documentChanged(DocumentEvent event) { - if (fAutoScroll) { - revealEndOfDocument(); - } - } - }; - } - return fDocumentListener; - } + if (fAutoScroll) { + revealEndOfDocument(); + } + } + }; + } + return fDocumentListener; + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java index e895fe91a..d3ed73344 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java @@ -31,71 +31,71 @@ import org.eclipse.ui.console.IConsoleFactory; */ public class OpenConsoleAction extends Action implements IMenuCreator { - private ConsoleFactoryExtension[] fFactoryExtensions; - private Menu fMenu; + private ConsoleFactoryExtension[] fFactoryExtensions; + private Menu fMenu; - public OpenConsoleAction() { - fFactoryExtensions = ((ConsoleManager)ConsolePlugin.getDefault().getConsoleManager()).getConsoleFactoryExtensions(); + public OpenConsoleAction() { + fFactoryExtensions = ((ConsoleManager)ConsolePlugin.getDefault().getConsoleManager()).getConsoleFactoryExtensions(); setText(ConsoleMessages.OpenConsoleAction_0); setToolTipText(ConsoleMessages.OpenConsoleAction_1); setImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_NEW_CON)); setDisabledImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_DLCL_NEW_CON)); setMenuCreator(this); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_OPEN_CONSOLE_ACTION); - } + } - /* (non-Javadoc) - * @see org.eclipse.jface.action.IMenuCreator#dispose() - */ + /* (non-Javadoc) + * @see org.eclipse.jface.action.IMenuCreator#dispose() + */ @Override public void dispose() { - fFactoryExtensions = null; - } - - /* - * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event) - * @since 3.5 - */ - @Override + fFactoryExtensions = null; + } + + /* + * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event) + * @since 3.5 + */ + @Override public void runWithEvent(Event event) { - if (event.widget instanceof ToolItem) { + if (event.widget instanceof ToolItem) { ToolItem toolItem= (ToolItem) event.widget; Control control= toolItem.getParent(); - Menu menu= getMenu(control); - - Rectangle bounds= toolItem.getBounds(); - Point topLeft= new Point(bounds.x, bounds.y + bounds.height); - menu.setLocation(control.toDisplay(topLeft)); - menu.setVisible(true); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control) - */ - @Override + Menu menu= getMenu(control); + + Rectangle bounds= toolItem.getBounds(); + Point topLeft= new Point(bounds.x, bounds.y + bounds.height); + menu.setLocation(control.toDisplay(topLeft)); + menu.setVisible(true); + } + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control) + */ + @Override public Menu getMenu(Control parent) { - if (fMenu != null) { - fMenu.dispose(); - } - - fMenu= new Menu(parent); - int accel = 1; - for (int i = 0; i < fFactoryExtensions.length; i++) { - ConsoleFactoryExtension extension = fFactoryExtensions[i]; - if (!WorkbenchActivityHelper.filterItem(extension) && extension.isEnabled()) { - String label = extension.getLabel(); - ImageDescriptor image = extension.getImageDescriptor(); - addActionToMenu(fMenu, new ConsoleFactoryAction(label, image, extension), accel); - accel++; - } - } - return fMenu; - } + if (fMenu != null) { + fMenu.dispose(); + } + + fMenu= new Menu(parent); + int accel = 1; + for (int i = 0; i < fFactoryExtensions.length; i++) { + ConsoleFactoryExtension extension = fFactoryExtensions[i]; + if (!WorkbenchActivityHelper.filterItem(extension) && extension.isEnabled()) { + String label = extension.getLabel(); + ImageDescriptor image = extension.getImageDescriptor(); + addActionToMenu(fMenu, new ConsoleFactoryAction(label, image, extension), accel); + accel++; + } + } + return fMenu; + } private void addActionToMenu(Menu parent, Action action, int accelerator) { if (accelerator < 10) { - StringBuffer label= new StringBuffer(); + StringBuffer label= new StringBuffer(); //add the numerical accelerator label.append('&'); label.append(accelerator); @@ -108,50 +108,50 @@ public class OpenConsoleAction extends Action implements IMenuCreator { item.fill(parent, -1); } - /* (non-Javadoc) - * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu) + */ + @Override public Menu getMenu(Menu parent) { - return null; - } + return null; + } - private class ConsoleFactoryAction extends Action { + private class ConsoleFactoryAction extends Action { - private ConsoleFactoryExtension fConfig; - private IConsoleFactory fFactory; + private ConsoleFactoryExtension fConfig; + private IConsoleFactory fFactory; - public ConsoleFactoryAction(String label, ImageDescriptor image, ConsoleFactoryExtension extension) { - setText(label); - if (image != null) { - setImageDescriptor(image); - } - fConfig = extension; - } + public ConsoleFactoryAction(String label, ImageDescriptor image, ConsoleFactoryExtension extension) { + setText(label); + if (image != null) { + setImageDescriptor(image); + } + fConfig = extension; + } - /* (non-Javadoc) - * @see org.eclipse.jface.action.IAction#run() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.jface.action.IAction#run() + */ + @Override public void run() { - try { - if (fFactory == null) { - fFactory = fConfig.createFactory(); - } - - fFactory.openConsole(); - } catch (CoreException e) { - ConsolePlugin.log(e); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.IAction#runWithEvent(org.eclipse.swt.widgets.Event) - */ - @Override + try { + if (fFactory == null) { + fFactory = fConfig.createFactory(); + } + + fFactory.openConsole(); + } catch (CoreException e) { + ConsolePlugin.log(e); + } + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.IAction#runWithEvent(org.eclipse.swt.widgets.Event) + */ + @Override public void runWithEvent(Event event) { - run(); - } - } + run(); + } + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListener.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListener.java index aaf415555..d61662577 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListener.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListener.java @@ -18,53 +18,53 @@ import org.eclipse.ui.console.TextConsole; public class PatternMatchListener implements IPatternMatchListener { - private PatternMatchListenerExtension fExtension; - private IPatternMatchListenerDelegate fDelegate; + private PatternMatchListenerExtension fExtension; + private IPatternMatchListenerDelegate fDelegate; - public PatternMatchListener(PatternMatchListenerExtension extension) throws CoreException { - fExtension = extension; - fDelegate = fExtension.createDelegate(); - } + public PatternMatchListener(PatternMatchListenerExtension extension) throws CoreException { + fExtension = extension; + fDelegate = fExtension.createDelegate(); + } - /* (non-Javadoc) - * @see org.eclipse.ui.console.IPatternMatchListener#getPattern() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.console.IPatternMatchListener#getPattern() + */ + @Override public String getPattern() { - return fExtension.getPattern(); - } + return fExtension.getPattern(); + } - /* (non-Javadoc) - * @see org.eclipse.ui.console.IPatternMatchListener#getCompilerFlags() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.console.IPatternMatchListener#getCompilerFlags() + */ + @Override public int getCompilerFlags() { - return fExtension.getCompilerFlags(); - } + return fExtension.getCompilerFlags(); + } - /* (non-Javadoc) - * @see org.eclipse.ui.console.IPatternMatchListener#matchFound(org.eclipse.ui.console.PatternMatchEvent) - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.console.IPatternMatchListener#matchFound(org.eclipse.ui.console.PatternMatchEvent) + */ + @Override public void matchFound(PatternMatchEvent event) { - fDelegate.matchFound(event); - } + fDelegate.matchFound(event); + } - /* (non-Javadoc) - * @see org.eclipse.ui.console.IPatternMatchListenerDelegate#connect(org.eclipse.ui.console.TextConsole) - */ + /* (non-Javadoc) + * @see org.eclipse.ui.console.IPatternMatchListenerDelegate#connect(org.eclipse.ui.console.TextConsole) + */ @Override public void connect(TextConsole console) { - fDelegate.connect(console); - } + fDelegate.connect(console); + } - /* (non-Javadoc) - * @see org.eclipse.ui.console.IPatternMatchListener#disconnect() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.console.IPatternMatchListener#disconnect() + */ + @Override public void disconnect() { - fDelegate.disconnect(); - } + fDelegate.disconnect(); + } /* (non-Javadoc) * @see org.eclipse.ui.console.IPatternMatchListener#getQuickPattern() diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java index 869129180..8faab5c46 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java @@ -31,125 +31,125 @@ import com.ibm.icu.text.MessageFormat; public class PatternMatchListenerExtension implements IPluginContribution { - private IConfigurationElement fConfig; - private Expression fEnablementExpression; - private String fPattern; - private String fQualifier; - private int fFlags = -1; - - public PatternMatchListenerExtension(IConfigurationElement extension) { - fConfig = extension; - } - - /* - * returns the integer value of the flags defined in java.util.regex.Pattern. - * Both <code>Pattern.MULTILINE</code> and <code>MULTILINE</code> will return - * the same value. - */ - public int parseFlags(String flagsElement) { - int val = 0; - if (flagsElement == null) { - return val; - } - - try { + private IConfigurationElement fConfig; + private Expression fEnablementExpression; + private String fPattern; + private String fQualifier; + private int fFlags = -1; + + public PatternMatchListenerExtension(IConfigurationElement extension) { + fConfig = extension; + } + + /* + * returns the integer value of the flags defined in java.util.regex.Pattern. + * Both <code>Pattern.MULTILINE</code> and <code>MULTILINE</code> will return + * the same value. + */ + public int parseFlags(String flagsElement) { + int val = 0; + if (flagsElement == null) { + return val; + } + + try { String flags = flagsElement.replaceAll("Pattern.", ""); //$NON-NLS-1$ //$NON-NLS-2$ String[] tokens = flags.split("\\s\\|\\s"); //$NON-NLS-1$ Class<?> clazz = Class.forName("java.util.regex.Pattern"); //$NON-NLS-1$ - for (int i = 0; i < tokens.length; i++) { - Field field = clazz.getDeclaredField(tokens[i]); - val |= field.getInt(null); - } - } catch (ClassNotFoundException e) { - ConsolePlugin.log(e); - } catch (NoSuchFieldException e) { - ConsolePlugin.log(e); - } catch (IllegalAccessException e) { - ConsolePlugin.log(e); - } - return val; - } - - public boolean isEnabledFor(IConsole console) throws CoreException { - EvaluationContext context = new EvaluationContext(null, console); - EvaluationResult evaluationResult = getEnablementExpression().evaluate(context); - return evaluationResult == EvaluationResult.TRUE; - } - - public IPatternMatchListenerDelegate createDelegate() throws CoreException { - return (IPatternMatchListenerDelegate) fConfig.createExecutableExtension("class"); //$NON-NLS-1$ - } - - public Expression getEnablementExpression() throws CoreException { + for (int i = 0; i < tokens.length; i++) { + Field field = clazz.getDeclaredField(tokens[i]); + val |= field.getInt(null); + } + } catch (ClassNotFoundException e) { + ConsolePlugin.log(e); + } catch (NoSuchFieldException e) { + ConsolePlugin.log(e); + } catch (IllegalAccessException e) { + ConsolePlugin.log(e); + } + return val; + } + + public boolean isEnabledFor(IConsole console) throws CoreException { + EvaluationContext context = new EvaluationContext(null, console); + EvaluationResult evaluationResult = getEnablementExpression().evaluate(context); + return evaluationResult == EvaluationResult.TRUE; + } + + public IPatternMatchListenerDelegate createDelegate() throws CoreException { + return (IPatternMatchListenerDelegate) fConfig.createExecutableExtension("class"); //$NON-NLS-1$ + } + + public Expression getEnablementExpression() throws CoreException { if (fEnablementExpression == null) { IConfigurationElement[] elements = fConfig.getChildren(ExpressionTagNames.ENABLEMENT); - if (elements.length == 0) { + if (elements.length == 0) { String message = MessageFormat.format("{0} " + getLocalId() + " {1} " + getPluginId() + " {2}", new Object[] { ConsoleMessages.PatternMatchListenerExtension_3, ConsoleMessages.PatternMatchListenerExtension_4, ConsoleMessages.PatternMatchListenerExtension_5 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - ConsolePlugin.log(new Status(IStatus.WARNING, ConsolePlugin.getUniqueIdentifier(), IStatus.OK, message, null)); - } + ConsolePlugin.log(new Status(IStatus.WARNING, ConsolePlugin.getUniqueIdentifier(), IStatus.OK, message, null)); + } IConfigurationElement enablement = elements.length > 0 ? elements[0] : null; if (enablement != null) { - fEnablementExpression = ExpressionConverter.getDefault().perform(enablement); + fEnablementExpression = ExpressionConverter.getDefault().perform(enablement); } } return fEnablementExpression; - } - - /* - * returns the regular expression to be matched. - */ - public String getPattern() { - if (fPattern == null) { - fPattern = fConfig.getAttribute("regex"); //$NON-NLS-1$ - try { - fPattern = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(fPattern, false); - } catch (CoreException e) { - ConsolePlugin.log(e); - } - } - return fPattern; - } - - /* - * returns the flags to be used by <code>Pattern.compile(pattern, flags)</code> - */ - public int getCompilerFlags() { - if(fFlags < 0) { - String flagsAttribute = fConfig.getAttribute("flags"); //$NON-NLS-1$ - fFlags = parseFlags(flagsAttribute); - } - return fFlags; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPluginContribution#getLocalId() - */ + } + + /* + * returns the regular expression to be matched. + */ + public String getPattern() { + if (fPattern == null) { + fPattern = fConfig.getAttribute("regex"); //$NON-NLS-1$ + try { + fPattern = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(fPattern, false); + } catch (CoreException e) { + ConsolePlugin.log(e); + } + } + return fPattern; + } + + /* + * returns the flags to be used by <code>Pattern.compile(pattern, flags)</code> + */ + public int getCompilerFlags() { + if(fFlags < 0) { + String flagsAttribute = fConfig.getAttribute("flags"); //$NON-NLS-1$ + fFlags = parseFlags(flagsAttribute); + } + return fFlags; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IPluginContribution#getLocalId() + */ @Override public String getLocalId() { - return fConfig.getAttribute("id"); //$NON-NLS-1$ - } + return fConfig.getAttribute("id"); //$NON-NLS-1$ + } - /* (non-Javadoc) - * @see org.eclipse.ui.IPluginContribution#getPluginId() - */ - @Override + /* (non-Javadoc) + * @see org.eclipse.ui.IPluginContribution#getPluginId() + */ + @Override public String getPluginId() { - return fConfig.getContributor().getName(); - } - - public String getQuickPattern() { - if (fQualifier == null) { - fQualifier = fConfig.getAttribute("qualifier"); //$NON-NLS-1$ - try { - if (fQualifier != null) { - fQualifier = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(fQualifier, false); - } + return fConfig.getContributor().getName(); + } + + public String getQuickPattern() { + if (fQualifier == null) { + fQualifier = fConfig.getAttribute("qualifier"); //$NON-NLS-1$ + try { + if (fQualifier != null) { + fQualifier = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(fQualifier, false); + } } catch (CoreException e) { ConsolePlugin.log(e); } - } - return fQualifier; - } + } + return fQualifier; + } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PinConsoleAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PinConsoleAction.java index 94e5d51e0..f3d60295b 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PinConsoleAction.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PinConsoleAction.java @@ -42,7 +42,7 @@ public class PinConsoleAction extends Action implements IUpdate { */ @Override public void run() { - fView.setPinned(isChecked()); + fView.setPinned(isChecked()); } /* (non-Javadoc) diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ScrollLockAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ScrollLockAction.java index 07d13c7b8..41cd0f90a 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ScrollLockAction.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ScrollLockAction.java @@ -21,17 +21,17 @@ import org.eclipse.ui.console.IConsoleView; */ public class ScrollLockAction extends Action { - private IConsoleView fConsoleView; + private IConsoleView fConsoleView; public ScrollLockAction(IConsoleView consoleView) { super(ConsoleMessages.ScrollLockAction_0); - fConsoleView = consoleView; + fConsoleView = consoleView; setToolTipText(ConsoleMessages.ScrollLockAction_1); setHoverImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_LCL_LOCK)); setDisabledImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_DLCL_LOCK)); setImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_LOCK)); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_SCROLL_LOCK_ACTION); + PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_SCROLL_LOCK_ACTION); boolean checked = fConsoleView.getScrollLock(); setChecked(checked); } @@ -41,11 +41,11 @@ public class ScrollLockAction extends Action { */ @Override public void run() { - fConsoleView.setScrollLock(isChecked()); + fConsoleView.setScrollLock(isChecked()); } public void dispose() { - fConsoleView = null; + fConsoleView = null; } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java index ea09fb14e..1dd0b2ca2 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java @@ -38,14 +38,14 @@ public class ShowConsoleAction extends Action { */ public static void showConsole(IConsole console, IConsoleView consoleView) { if (!console.equals(consoleView.getConsole())) { - boolean pinned = consoleView.isPinned(); - if (pinned) { - consoleView.setPinned(false); - } - consoleView.display(console); - if (pinned) { - consoleView.setPinned(true); - } + boolean pinned = consoleView.isPinned(); + if (pinned) { + consoleView.setPinned(false); + } + consoleView.display(console); + if (pinned) { + consoleView.setPinned(true); + } } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/WordWrapAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/WordWrapAction.java index 6e6eddd63..c4196e7de 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/WordWrapAction.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/WordWrapAction.java @@ -47,4 +47,4 @@ public class WordWrapAction extends Action { public void dispose() { fConsoleView = null; } -}
\ No newline at end of file +} |