diff options
author | Mike Rennie | 2013-07-31 16:44:16 +0000 |
---|---|---|
committer | Mike Rennie | 2013-07-31 16:44:16 +0000 |
commit | d975f27f12707ae6598994c5e3c6bd5e271d46c4 (patch) | |
tree | c7d1b2b1a202e19c0c2ccaaff959f4dd25286f0d /org.eclipse.ui.console | |
parent | 4fcde1ffaf34791bd406d47ce72d17e2801432a3 (diff) | |
download | eclipse.platform.debug-d975f27f12707ae6598994c5e3c6bd5e271d46c4.tar.gz eclipse.platform.debug-d975f27f12707ae6598994c5e3c6bd5e271d46c4.tar.xz eclipse.platform.debug-d975f27f12707ae6598994c5e3c6bd5e271d46c4.zip |
Bug 352626 - Move platform debug to Java 1.6 BREE
Diffstat (limited to 'org.eclipse.ui.console')
43 files changed, 1445 insertions, 1200 deletions
diff --git a/org.eclipse.ui.console/.classpath b/org.eclipse.ui.console/.classpath index ce7393340..ad32c83a7 100644 --- a/org.eclipse.ui.console/.classpath +++ b/org.eclipse.ui.console/.classpath @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/org.eclipse.ui.console/.settings/.api_filters b/org.eclipse.ui.console/.settings/.api_filters new file mode 100644 index 000000000..2542cfd89 --- /dev/null +++ b/org.eclipse.ui.console/.settings/.api_filters @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<component id="org.eclipse.ui.console" version="2"> + <resource path="src/org/eclipse/ui/console/TextConsolePage.java" type="org.eclipse.ui.console.TextConsolePage"> + <filter comment="Known illegal use" id="574668824"> + <message_arguments> + <message_argument value="IPageBookViewPage"/> + <message_argument value="TextConsolePage"/> + <message_argument value="IPage"/> + </message_arguments> + </filter> + </resource> +</component> diff --git a/org.eclipse.ui.console/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.ui.console/.settings/org.eclipse.jdt.core.prefs index 5d7a22fe3..74c3aeb02 100644 --- a/org.eclipse.ui.console/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.ui.console/.settings/org.eclipse.jdt.core.prefs @@ -14,17 +14,17 @@ org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonN org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning org.eclipse.jdt.core.compiler.problem.deadCode=warning @@ -33,9 +33,9 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning -org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=error org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore @@ -53,10 +53,10 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled -org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public @@ -65,7 +65,7 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore @@ -78,11 +78,11 @@ org.eclipse.jdt.core.compiler.problem.nullReference=error org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning -org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=error org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore @@ -91,18 +91,18 @@ org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=error org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=error org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=error org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning @@ -119,9 +119,9 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=di org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=error org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.3 +org.eclipse.jdt.core.compiler.source=1.6 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,NORMAL,HIGH,HIGH org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX,EXPERIMENTAL,CONTEXTLAUNCHING diff --git a/org.eclipse.ui.console/META-INF/MANIFEST.MF b/org.eclipse.ui.console/META-INF/MANIFEST.MF index 21638453f..2eaa3af35 100644 --- a/org.eclipse.ui.console/META-INF/MANIFEST.MF +++ b/org.eclipse.ui.console/META-INF/MANIFEST.MF @@ -14,7 +14,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.5.0,4.0.0)", org.eclipse.ui.workbench.texteditor;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)", - org.eclipse.core.variables;bundle-version="[3.2.0,4.0.0)" + org.eclipse.core.variables;bundle-version="[3.2.800,4.0.0)" Bundle-ActivationPolicy: lazy Import-Package: com.ibm.icu.text -Bundle-RequiredExecutionEnvironment: J2SE-1.4 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 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 99fb78418..772f7c15f 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -29,34 +29,35 @@ import org.eclipse.ui.internal.console.ConsoleMessages; * @since 3.0 */ public abstract class AbstractConsole implements IConsole { - + // property listeners private ListenerList fListeners; - + /** * Console name */ private String fName = null; - + /** * Console image descriptor */ private ImageDescriptor fImageDescriptor = null; - + /** * Console type identifier */ private String fType = null; - + /** * Used to notify this console of lifecycle methods <code>init()</code> * and <code>dispose()</code>. */ class Lifecycle implements IConsoleListener { - + /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleListener#consolesAdded(org.eclipse.ui.console.IConsole[]) */ + @Override public void consolesAdded(IConsole[] consoles) { for (int i = 0; i < consoles.length; i++) { IConsole console = consoles[i]; @@ -70,6 +71,7 @@ public abstract class AbstractConsole implements IConsole { /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleListener#consolesRemoved(org.eclipse.ui.console.IConsole[]) */ + @Override public void consolesRemoved(IConsole[] consoles) { for (int i = 0; i < consoles.length; i++) { IConsole console = consoles[i]; @@ -80,33 +82,35 @@ public abstract class AbstractConsole implements IConsole { } } } - + /** * Notifies listeners of property changes, handling any exceptions */ class PropertyNotifier implements ISafeRunnable { - + private IPropertyChangeListener fListener; private PropertyChangeEvent fEvent; - + /** * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable) */ + @Override public void handleException(Throwable exception) { - IStatus status = new Status(IStatus.ERROR, ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.INTERNAL_ERROR, ConsoleMessages.AbstractConsole_0, exception); + IStatus status = new Status(IStatus.ERROR, ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.INTERNAL_ERROR, ConsoleMessages.AbstractConsole_0, exception); ConsolePlugin.log(status); } /** * @see org.eclipse.core.runtime.ISafeRunnable#run() */ + @Override public void run() throws Exception { fListener.propertyChange(fEvent); } /** * Notifies listeners of the property change - * + * * @param event the event that describes the property that has changed */ public void notify(PropertyChangeEvent event) { @@ -118,14 +122,14 @@ public abstract class AbstractConsole implements IConsole { for (int i= 0; i < copiedListeners.length; i++) { fListener = (IPropertyChangeListener)copiedListeners[i]; SafeRunner.run(this); - } - fListener = null; + } + fListener = null; } - } - + } + /** * Constructs a new console with the given name and image. - * + * * @param name console name, cannot be <code>null</code> * @param imageDescriptor image descriptor, or <code>null</code> if none * @param autoLifecycle whether this console's lifecycle methods should be called @@ -137,10 +141,10 @@ public abstract class AbstractConsole implements IConsole { public AbstractConsole(String name, ImageDescriptor imageDescriptor, boolean autoLifecycle) { this(name, null, imageDescriptor, autoLifecycle); } - + /** * Constructs a new console with the given name, type, image and lifecycle. - * + * * @param name console name, cannot be <code>null</code> * @param type console type identifier or <code>null</code> * @param imageDescriptor image descriptor, or <code>null</code> if none @@ -157,13 +161,13 @@ public abstract class AbstractConsole implements IConsole { if (autoLifecycle) { ConsolePlugin.getDefault().getConsoleManager().addConsoleListener(new Lifecycle()); } - } - + } + /** * Constructs a new console with the given name and image. The console's lifecycle * methods <code>init()</code> and <code>dispose()</code> will be called when the * console is added and removed from the console manager. - * + * * @param name console name, cannot be <code>null</code> * @param imageDescriptor image descriptor, or <code>null</code> if none */ @@ -174,6 +178,7 @@ public abstract class AbstractConsole implements IConsole { /* (non-Javadoc) * @see org.eclipse.ui.console.IConsole#getName() */ + @Override public String getName() { return fName; } @@ -181,7 +186,7 @@ public abstract class AbstractConsole implements IConsole { /** * Sets the name of this console to the specified value and notifies * property listeners of the change. - * + * * @param name the new name */ protected void setName(String name) { @@ -191,39 +196,42 @@ public abstract class AbstractConsole implements IConsole { firePropertyChange(this, IBasicPropertyConstants.P_TEXT, old, name); } } - + /* (non-Javadoc) * @see org.eclipse.ui.console.IConsole#getImageDescriptor() */ + @Override public ImageDescriptor getImageDescriptor() { return fImageDescriptor; } - + /** * Sets the image descriptor for this console to the specified value and notifies * property listeners of the change. - * + * * @param imageDescriptor the new image descriptor */ protected void setImageDescriptor(ImageDescriptor imageDescriptor) { ImageDescriptor old = fImageDescriptor; fImageDescriptor =imageDescriptor; firePropertyChange(this, IBasicPropertyConstants.P_IMAGE, old, imageDescriptor); - } + } /* (non-Javadoc) * @see org.eclipse.ui.console.IConsole#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) */ + @Override public void addPropertyChangeListener(IPropertyChangeListener listener) { if (fListeners == null) { fListeners = new ListenerList(); } - fListeners.add(listener); + fListeners.add(listener); } /* (non-Javadoc) * @see org.eclipse.ui.console.IConsole#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) */ + @Override public void removePropertyChangeListener(IPropertyChangeListener listener) { if (fListeners != null) { fListeners.remove(listener); @@ -232,8 +240,8 @@ public abstract class AbstractConsole implements IConsole { /** * Notify all listeners that the given property has changed. - * - * @param source the object on which a property has changed + * + * @param source the object on which a property has changed * @param property identifier of the property that has changed * @param oldValue the old value of the property, or <code>null</code> * @param newValue the new value of the property, or <code>null</code> @@ -245,19 +253,19 @@ public abstract class AbstractConsole implements IConsole { PropertyNotifier notifier = new PropertyNotifier(); notifier.notify(new PropertyChangeEvent(source, property, oldValue, newValue)); } - + /** * Initializes this console. This method should only be called by clients managing a * console's lifecycle, otherwise this method will be called automatically when this console * is added to the console manager. The method is called once to initialize this console, * marking the beginning of its lifecycle. - * + * * @since 3.1 */ public final void initialize() { init(); } - + /** * Called when this console is added to the console manager. Default * implementation does nothing. Subclasses may override. @@ -268,19 +276,19 @@ public abstract class AbstractConsole implements IConsole { */ protected void init() { } - + /** * Disposes this console. This method should only be called by clients managing a * console's lifecycle, otherwise this method will be called automatically when this * console is removed from the console manager. The method is called once to dispose - * this console, after which this console will no longer be used. - * + * this console, after which this console will no longer be used. + * * @since 3.1 */ public final void destroy() { dispose(); } - + /** * Called when this console is removed from the console manager. Default * implementation does nothing. Subclasses may override. @@ -291,45 +299,46 @@ public abstract class AbstractConsole implements IConsole { */ protected void dispose() { } - + /** * Shows this console in all console views. This console will be become visible - * if another console is currently pinned. - * + * if another console is currently pinned. + * * @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 + * + * @param typeIdentifier the type identifier for this console * @since 3.1 */ protected void setType(String typeIdentifier) { fType = typeIdentifier; } - + /** * @see org.eclipse.ui.console.IConsole#getType() * @since 3.1 */ - public String getType() { + @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; } - + } 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 df35a076f..67be06052 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -27,14 +27,14 @@ import org.osgi.framework.BundleContext; /** * The console plug-in class. - * + * * @since 3.0 * @noinstantiate This class is not intended to be instantiated by clients. * @noextend This class is not intended to be subclassed by clients. */ public class ConsolePlugin extends AbstractUIPlugin { - + /** * Singleton console manager */ @@ -44,13 +44,13 @@ public class ConsolePlugin extends AbstractUIPlugin { * The singleton console plug-in instance */ private static ConsolePlugin fgPlugin= null; - + /** * Unique identifier constant (value <code>"org.eclipse.ui.console"</code>) * for the UI Console plug-in. */ private static final String PI_UI_CONSOLE = "org.eclipse.ui.console"; //$NON-NLS-1$ - + /** * Returns the singleton instance of the console plug-in. */ @@ -62,7 +62,7 @@ public class ConsolePlugin extends AbstractUIPlugin { super(); fgPlugin = this; } - + /** * Convenience method which returns the unique identifier of this plug-in. */ @@ -72,7 +72,7 @@ public class ConsolePlugin extends AbstractUIPlugin { /** * Logs the specified status with this plug-in's log. - * + * * @param status status to log */ public static void log(IStatus status) { @@ -81,8 +81,8 @@ public class ConsolePlugin extends AbstractUIPlugin { /** * Logs the specified throwable with this plug-in's log. - * - * @param t throwable to log + * + * @param t throwable to log */ public static void log(Throwable t) { if (t instanceof CoreException) { @@ -91,7 +91,7 @@ public class ConsolePlugin extends AbstractUIPlugin { log(newErrorStatus("Error logged from Console plug-in: ", t)); //$NON-NLS-1$ } } - + /** * Returns a new error status for this plug-in with the given message * @param message the message to be included in the status @@ -101,11 +101,11 @@ public class ConsolePlugin extends AbstractUIPlugin { public static IStatus newErrorStatus(String message, Throwable exception) { return new Status(IStatus.ERROR, getUniqueIdentifier(), IConsoleConstants.INTERNAL_ERROR, message, exception); } - + /** - * Returns the console manager. The manager will be created lazily on + * Returns the console manager. The manager will be created lazily on * the first access. - * + * * @return IConsoleManager */ public IConsoleManager getConsoleManager() { @@ -119,9 +119,9 @@ public class ConsolePlugin extends AbstractUIPlugin { * Returns the workbench display. */ public static Display getStandardDisplay() { - return PlatformUI.getWorkbench().getDisplay(); + return PlatformUI.getWorkbench().getDisplay(); } - + /** * Utility method with conventions */ @@ -132,19 +132,20 @@ public class ConsolePlugin extends AbstractUIPlugin { // if the 'message' resource string and the IStatus' message are the same, // don't show both in the dialog if (status != null && message.equals(status.getMessage())) { - message= null; + ErrorDialog.openError(shell, title, null, status); + return; } } else { status= new Status(IStatus.ERROR, getUniqueIdentifier(), IConsoleConstants.INTERNAL_ERROR, "Error within Debug UI: ", t); //$NON-NLS-1$ - log(status); + log(status); } 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 @@ -152,11 +153,11 @@ public class ConsolePlugin extends AbstractUIPlugin { 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 @@ -164,11 +165,12 @@ public class ConsolePlugin extends AbstractUIPlugin { public static ImageDescriptor getImageDescriptor(String key) { return ConsolePluginImages.getImageDescriptor(key); } - + /* (non-Javadoc) * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ - public void stop(BundleContext context) throws Exception { + @Override + public void stop(BundleContext context) throws Exception { if (fConsoleManager != null) { IConsole[] consoles = fConsoleManager.getConsoles(); if (consoles != null) { @@ -176,7 +178,7 @@ public class ConsolePlugin extends AbstractUIPlugin { } } 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 06d04d14b..dbf506f10 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -13,18 +13,18 @@ package org.eclipse.ui.console; /** * Constants relating to the console plug-in. - * + * * @since 3.0 * @noimplement This interface is not intended to be implemented by clients. * @noextend This interface is not intended to be extended by clients. */ public interface IConsoleConstants { - + /** * Console plug-in identifier (value <code>"org.eclipse.ui.console"</code>). */ public static final String PLUGIN_ID = ConsolePlugin.getUniqueIdentifier(); - + /** * Console view identifier (value <code>"org.eclipse.ui.console.ConsoleView"</code>). */ @@ -35,16 +35,17 @@ public interface IConsoleConstants { * @since 3.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>). - * + * * @deprecated When a console is created, its font is set to the default text font as specified * by <code>JFaceResources.TEXT_FONT</code>. Clients must provide their own infrastructure to - * manage console specific fonts. - */ + * manage console specific fonts. + */ + @Deprecated public static final String CONSOLE_FONT= "org.eclipse.ui.console.ConsoleFont"; //$NON-NLS-1$ - + /** * Menu group identifier for the console view context menu and toolbar, for actions pertaining to * launching (value <code>"launchGroup"</code>). @@ -55,18 +56,18 @@ public interface IConsoleConstants { * Menu group identifier for the console view context menu and toolbar, for actions pertaining to * console output. (value<code>"outputGroup"</code>). */ - public static final String OUTPUT_GROUP = "outputGroup"; //$NON-NLS-1$ - - /** + public static final String OUTPUT_GROUP = "outputGroup"; //$NON-NLS-1$ + + /** * Console view image identifier. */ public static final String IMG_VIEW_CONSOLE= "IMG_VIEW_CONSOLE"; //$NON-NLS-1$ - - /** - * Clear action image identifier. + + /** + * Clear action image identifier. */ public static final String IMG_LCL_CLEAR= "IMG_LCL_CLEAR"; //$NON-NLS-1$ - + /** * Status code indicating an unexpected internal error. */ @@ -75,15 +76,15 @@ public interface IConsoleConstants { /** * Console pattern match listeners extension point identifier * (value <code>"consolePatternMatchListeners"</code>). - * - * @since 3.1 + * + * @since 3.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$ @@ -91,64 +92,64 @@ public interface IConsoleConstants { /** * 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. - * + * * @since 3.1 */ public static final String P_FONT = ConsolePlugin.getUniqueIdentifier() + ".P_FONT"; //$NON-NLS-1$ - + /** * Property constant indicating that a font style has changed - * + * * @since 3.1 */ public static final String P_FONT_STYLE = ConsolePlugin.getUniqueIdentifier() + ".P_FONT_STYLE"; //$NON-NLS-1$ - + /** * Property constant indicating the color of a stream has changed. - * + * * @since 3.1 */ public static final String P_STREAM_COLOR = ConsolePlugin.getUniqueIdentifier() + ".P_STREAM_COLOR"; //$NON-NLS-1$ - + /** * Property constant indicating tab size has changed - * + * * @since 3.1 */ public static final String P_TAB_SIZE = ConsolePlugin.getUniqueIdentifier() + ".P_TAB_SIZE"; //$NON-NLS-1$ - + /** * Property constant indicating the width of a fixed width console has changed. - * + * * @since 3.1 */ public static final String P_CONSOLE_WIDTH = ConsolePlugin.getUniqueIdentifier() + ".P_CONSOLE_WIDTH"; //$NON-NLS-1$ - + /** * Property constant indicating that all streams connected to this console have been closed * and that all queued output has been processed. - * + * * @since 3.1 */ public static final String P_CONSOLE_OUTPUT_COMPLETE = ConsolePlugin.getUniqueIdentifier() + ".P_CONSOLE_STREAMS_CLOSED"; //$NON-NLS-1$ - + /** * Property constant indicating the background color of a console has changed. - * + * * @since 3.3 */ - public static final String P_BACKGROUND_COLOR = ConsolePlugin.getUniqueIdentifier() + ".P_BACKGROUND_COLOR"; //$NON-NLS-1$ + 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; 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 e1bc354d6..709c2f7eb 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,72 +19,73 @@ import org.eclipse.ui.IViewPart; * @noextend This interface is not intended to be extended by clients. */ public interface IConsoleView extends IViewPart { - + /** * Displays the page for the given console in this console view. - * Has no effect if this console view has a pinned console. - * + * Has no effect if this console view has a pinned console. + * * @param console console to display, cannot be <code>null</code> */ public void display(IConsole console); - + /** * Pins this console view. No other console page will be displayed until * this console view is un-pinned. - * - * @param pin <code>true</code> to pin the current console to the + * + * @param pin <code>true</code> to pin the current console to the * 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> */ - public void pin(IConsole console); - + @Deprecated + public void pin(IConsole console); + /** * Returns whether this console view is currently pinned to a * specific console. - * + * * @return whether this console view is currently pinned to a * specific console */ public boolean isPinned(); - + /** * Returns the console currently being displayed, or <code>null</code> * if none - * + * * @return the console currently being displayed, or <code>null</code> * if none */ public IConsole getConsole(); - + /** * Warns that the content of the given console has changed. - * + * * @param console the console that has changed */ - public void warnOfContentChange(IConsole console); - + 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 */ 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 */ 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 883332866..a28b64ded 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,8 +12,10 @@ package org.eclipse.ui.console; +import java.io.Closeable; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.eclipse.jface.resource.ImageDescriptor; @@ -36,27 +38,27 @@ public class IOConsole extends TextConsole { * The document partitioner */ private IOConsolePartitioner partitioner; - + /** * The stream from which user input may be read */ private IOConsoleInputStream inputStream; - + /** * A collection of open streams connected to this console. */ - private List openStreams; + private List<Closeable> openStreams = Collections.synchronizedList(new ArrayList<Closeable>()); /** * The encoding used to for displaying console output. */ private String fEncoding = WorkbenchEncoding.getWorkbenchDefaultEncoding(); - + /** * 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> @@ -69,7 +71,7 @@ public class IOConsole extends TextConsole { /** * 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> @@ -83,48 +85,48 @@ public class IOConsole extends TextConsole { if (encoding != null) { fEncoding = encoding; } - openStreams = new ArrayList(); - inputStream = new IOConsoleInputStream(this); synchronized (openStreams) { - openStreams.add(inputStream); + inputStream = new IOConsoleInputStream(this); + openStreams.add(inputStream); } - + partitioner = new IOConsolePartitioner(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 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) */ - public IPageBookViewPage createPage(IConsoleView view) { + @Override + public IPageBookViewPage createPage(IConsoleView 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 @@ -145,10 +147,10 @@ public class IOConsole extends TextConsole { } return outputStream; } - + /** * Returns the input stream connected to the keyboard. - * + * * @return the input stream connected to the keyboard. */ public IOConsoleInputStream getInputStream() { @@ -157,10 +159,11 @@ public class IOConsole extends TextConsole { /** * Returns this console's document partitioner. - * + * * @return this console's document partitioner */ - protected IConsoleDocumentPartitioner getPartitioner() { + @Override + protected IConsoleDocumentPartitioner getPartitioner() { return partitioner; } @@ -168,30 +171,30 @@ public class IOConsole extends TextConsole { * Returns the maximum number of characters that the console will display at * once. This is analogous to the size of the text buffer this console * maintains. - * + * * @return the maximum number of characters that the console will display */ public int getHighWaterMark() { return partitioner.getHighWaterMark(); } - + /** * Returns the number of characters that will remain in this console * when its high water mark is exceeded. - * + * * @return the number of characters that will remain in this console * when its high water mark is exceeded */ public int getLowWaterMark() { return partitioner.getLowWaterMark(); } - + /** * Sets the text buffer size for this console. The high water mark indicates * the maximum number of characters stored in the buffer. The low water mark * indicates the number of characters remaining in the buffer when the high * water mark is exceeded. - * + * * @param low the number of characters remaining in the buffer when the high * water mark is exceeded (if -1 the console does not limit output) * @param high the maximum number of characters this console will cache in @@ -209,17 +212,19 @@ public class IOConsole extends TextConsole { /** * Check if all streams connected to this console are closed. If so, - * notify the partitioner that this console is finished. + * notify the partitioner that this console is finished. */ private void checkFinished() { - if (openStreams.isEmpty()) { - partitioner.streamsClosed(); - } + synchronized (openStreams) { + 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) { @@ -228,10 +233,10 @@ public class IOConsole extends TextConsole { checkFinished(); } } - + /** * Notification that the input stream connected to this console has been closed. - * + * * @param stream stream that closed */ void streamClosed(IOConsoleInputStream stream) { @@ -240,49 +245,44 @@ public class IOConsole extends TextConsole { checkFinished(); } } - + /* (non-Javadoc) * @see org.eclipse.ui.console.TextConsole#clearConsole() */ - public void clearConsole() { + @Override + public void clearConsole() { if (partitioner != null) { partitioner.clearBuffer(); } } - + /** * Disposes this console. */ - protected void dispose() { + @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 + //a copy is needed as close the streams results in a callback that //removes the streams from the openStreams collection (bug 152794) - Object[] allStreams= openStreams.toArray(); - for (int i = 0; i < allStreams.length; i++) { - Object stream = allStreams[i]; - if (stream instanceof IOConsoleInputStream) { - IOConsoleInputStream is = (IOConsoleInputStream) stream; - try { - is.close(); - } catch (IOException e) { - } - } else if (stream instanceof IOConsoleOutputStream) { - IOConsoleOutputStream os = (IOConsoleOutputStream) stream; - try { - os.close(); - } catch (IOException e) { - } - } - } + synchronized (openStreams) { + List<Closeable> list = new ArrayList<Closeable>(openStreams); + for (Closeable closable : list) { + try { + closable.close(); + } catch (IOException e) { + // e.printStackTrace(); + } + } + } 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 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 f6933856b..b6da2a383 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,7 +18,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; /** - * InputStream used to read input from an {@link IOConsole}. + * InputStream used to read input from an {@link IOConsole}. * This stream will buffer input that it receives until it has been read. * An input stream is available from its {@link IOConsole}. * @since 3.1 @@ -31,44 +31,44 @@ public class IOConsoleInputStream extends InputStream { * 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 read from * this stream should come from. */ private int outPointer = 0; - + /** - * The number of bytes of real data currently in the buffer. + * 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 the stream has been closed. */ private boolean closed = false; - + /** * The console that this stream is connected to. */ private IOConsole console; - + /** * The color used to display input in the console. */ private Color color; - + /** * The font style used to decorate input in the console. */ @@ -77,23 +77,24 @@ public class IOConsoleInputStream extends InputStream { /** * 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) */ - public synchronized int read(byte[] b, int off, int len) throws IOException { + @Override + public synchronized int read(byte[] b, int off, int len) throws IOException { waitForData(); if (available() == -1) { return -1; } - + int toCopy = Math.min(len, size); if(input.length-outPointer > toCopy) { System.arraycopy(input, outPointer, b, off, toCopy); @@ -108,12 +109,13 @@ public class IOConsoleInputStream extends InputStream { } return toCopy; } - + /* * (non-Javadoc) * @see java.io.InputStream#read(byte[]) */ - public int read(byte[] b) throws IOException { + @Override + public int read(byte[] b) throws IOException { return read(b, 0, b.length); } @@ -121,12 +123,13 @@ public class IOConsoleInputStream extends InputStream { * (non-Javadoc) * @see java.io.InputStream#read() */ - public synchronized int read() throws IOException { + @Override + public synchronized int read() throws IOException { waitForData(); - if (available() == -1) { + if (available() == -1) { return -1; } - + byte b = input[outPointer]; outPointer++; if (outPointer == input.length) { @@ -135,7 +138,7 @@ public class IOConsoleInputStream extends InputStream { size -= 1; return b; } - + /** * Blocks until data is available to be read. * Ensure that the monitor for this object is obtained before @@ -152,25 +155,26 @@ public class IOConsoleInputStream extends InputStream { /** * 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) + if (encoding!=null) { try { newData = text.getBytes(encoding); } catch (UnsupportedEncodingException e) { - newData = text.getBytes(); + newData = text.getBytes(); } - else - newData = text.getBytes(); - + } else { + newData = text.getBytes(); + } + while(input.length-size < newData.length) { growArray(); } - + if (size == 0) { //inPointer == outPointer System.arraycopy(newData, 0, input, 0, newData.length); inPointer = newData.length; @@ -186,13 +190,13 @@ public class IOConsoleInputStream extends InputStream { inPointer = newData.length-(input.length-inPointer); size += newData.length; } - + if (inPointer == input.length) { inPointer = 0; } notifyAll(); } - + /** * Enlarges the buffer. */ @@ -212,7 +216,7 @@ public class IOConsoleInputStream extends InputStream { /** * Returns this stream's font style. - * + * * @return the font style used to decorate input in the associated console */ public int getFontStyle() { @@ -221,7 +225,7 @@ public class IOConsoleInputStream extends InputStream { /** * 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) { @@ -231,10 +235,10 @@ public class IOConsoleInputStream extends InputStream { console.firePropertyChange(this, IConsoleConstants.P_FONT_STYLE, new Integer(old), new Integer(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) { @@ -244,37 +248,39 @@ public class IOConsoleInputStream extends InputStream { 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; } - + /* (non-Javadoc) * @see java.io.InputStream#available() */ - public int available() throws IOException { + @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$ } - + return size; } - + /* (non-Javadoc) * @see java.io.InputStream#close() */ - public synchronized void close() throws IOException { + @Override + public synchronized void close() throws IOException { if(closed) { throw new IOException("Input Stream Closed"); //$NON-NLS-1$ } 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 43e599c11..125c5f26d 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 @@ -14,7 +14,6 @@ import java.io.IOException; import java.io.OutputStream; import org.eclipse.swt.graphics.Color; - import org.eclipse.ui.WorkbenchEncoding; import org.eclipse.ui.internal.console.IOConsolePartitioner; @@ -22,7 +21,7 @@ import org.eclipse.ui.internal.console.IOConsolePartitioner; * OutputStream used to write to an IOConsole. * <p> * Clients are not intended to instantiate this class directly, instead - * use <code>IOConsole.newOutputStream()</code>. + * use <code>IOConsole.newOutputStream()</code>. * </p> * <p> * Clients should avoid writing large amounts of output to this stream in the UI @@ -44,23 +43,23 @@ public class IOConsoleOutputStream extends OutputStream { * The console's document partitioner. */ private IOConsolePartitioner partitioner; - + /** * 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; - + /** * The color used to decorate data written to this stream. */ private Color color; - + /** * The font style used to decorate data written to this stream. */ @@ -72,10 +71,10 @@ public class IOConsoleOutputStream extends OutputStream { private boolean fNeedsEncoding = false; private boolean prependCR; - + /** * Constructs a new output stream on the given console. - * + * * @param console I/O console */ IOConsoleOutputStream(IOConsole console) { @@ -85,16 +84,16 @@ public class IOConsoleOutputStream extends OutputStream { /** * 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) { @@ -104,11 +103,11 @@ public class IOConsoleOutputStream extends OutputStream { console.firePropertyChange(this, IConsoleConstants.P_FONT_STYLE, new Integer(old), new Integer(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. */ @@ -119,18 +118,18 @@ public class IOConsoleOutputStream extends OutputStream { /** * 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. - * + * * @param newColor color of this stream, or <code>null</code> */ public void setColor(Color newColor) { @@ -140,17 +139,17 @@ public class IOConsoleOutputStream extends OutputStream { console.firePropertyChange(this, IConsoleConstants.P_STREAM_COLOR, old, newColor); } } - + /** * Returns the color of this stream, or <code>null</code> * if default. - * + * * @return the color of this stream, or <code>null</code> */ public Color getColor() { return color; } - + /** * Returns true if the stream has been closed * @return true is the stream has been closed, false otherwise. @@ -158,12 +157,13 @@ public class IOConsoleOutputStream extends OutputStream { public synchronized boolean isClosed() { return closed; } - + /* * (non-Javadoc) * @see java.io.OutputStream#close() */ - public synchronized void close() throws IOException { + @Override + public synchronized void close() throws IOException { if(closed) { throw new IOException("Output Stream is closed"); //$NON-NLS-1$ } @@ -180,17 +180,19 @@ public class IOConsoleOutputStream extends OutputStream { * (non-Javadoc) * @see java.io.OutputStream#flush() */ - public void flush() throws IOException { + @Override + public void flush() throws IOException { if(closed) { throw new IOException("Output Stream is closed"); //$NON-NLS-1$ } } - + /* * (non-Javadoc) * @see java.io.OutputStream#write(byte[], int, int) */ - public void write(byte[] b, int off, int len) throws IOException { + @Override + public void write(byte[] b, int off, int len) throws IOException { if (fNeedsEncoding) { encodedWrite(new String(b, off, len, fEncoding)); } else { @@ -201,40 +203,43 @@ public class IOConsoleOutputStream extends OutputStream { * (non-Javadoc) * @see java.io.OutputStream#write(byte[]) */ - public void write(byte[] b) throws IOException { + @Override + public void write(byte[] b) throws IOException { write(b, 0, b.length); } /* * (non-Javadoc) * @see java.io.OutputStream#write(int) */ - public void write(int b) throws IOException { + @Override + public void write(int b) throws IOException { write(new byte[] {(byte)b}, 0, 1); - } - + } + /** * 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); } - + 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){ - encodedString="\r"+encodedString; //$NON-NLS-1$ + newencoding = "\r" + newencoding; //$NON-NLS-1$ prependCR=false; } - if (encodedString.endsWith("\r")) { //$NON-NLS-1$ + if (newencoding.endsWith("\r")) { //$NON-NLS-1$ prependCR = true; - encodedString = new String(encodedString.substring(0, encodedString.length()-1)); + newencoding = new String(newencoding.substring(0, newencoding.length() - 1)); } - notifyParitioner(encodedString); + notifyParitioner(newencoding); } private void notifyParitioner(String encodedString) throws IOException { @@ -255,8 +260,8 @@ public class IOConsoleOutputStream extends OutputStream { } /** - * Sets the character encoding used to interpret characters written to this steam. - * + * Sets the character encoding used to interpret characters written to this steam. + * * @param encoding encoding identifier */ public void setEncoding(String encoding) { 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 b9f3071bf..d7ea0d0f2 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,7 +17,7 @@ import org.eclipse.ui.part.IPageBookViewPage; /** * A console that displays messages. A message console may have one or * more streams connected to it (<code>MessageConsoleStream</code>). - * Text written to streams is buffered and processed in a Job by the + * Text written to streams is buffered and processed in a Job by the * console's document partitioner. * <p> * Clients may instantiate this class. @@ -26,48 +26,52 @@ import org.eclipse.ui.part.IPageBookViewPage; * @noextend This class is not intended to be subclassed by clients. */ public class MessageConsole extends IOConsole { - + /** - * Property constant indicating the font of this console has changed. - * - * @deprecated use {@link IConsoleConstants#P_FONT} + * Property constant indicating the font of this console has changed. + * + * @deprecated use {@link IConsoleConstants#P_FONT} */ + @Deprecated public static final String P_FONT = IConsoleConstants.P_FONT; - + /** - * Property constant indicating the color of a stream has changed. - * - * @deprecated use {@link IConsoleConstants#P_STREAM_COLOR} + * Property constant indicating the color of a stream has changed. + * + * @deprecated use {@link IConsoleConstants#P_STREAM_COLOR} */ + @Deprecated public static final String P_STREAM_COLOR = IConsoleConstants.P_STREAM_COLOR; - + /** * Property constant indicating tab size has changed - * + * * @deprecated use {@link IConsoleConstants#P_TAB_SIZE} */ + @Deprecated public static final String P_TAB_SIZE = IConsoleConstants.P_TAB_SIZE; - + /** * The default tab size - * + * * @deprecated use {@link IConsoleConstants#DEFAULT_TAB_SIZE} */ - public static final int DEFAULT_TAB_SIZE = IConsoleConstants.DEFAULT_TAB_SIZE; + @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> */ public MessageConsole(String name, ImageDescriptor imageDescriptor) { this(name, imageDescriptor, true); } - + /** * Constructs a message console. - * + * * @param name console name * @param imageDescriptor console image descriptor or <code>null</code> * @param autoLifecycle whether lifecycle methods should be called automatically @@ -77,25 +81,25 @@ public class MessageConsole extends IOConsole { public MessageConsole(String name, ImageDescriptor imageDescriptor, boolean autoLifecycle) { 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 * when added and removed from the console manager - * + * * @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> @@ -108,7 +112,7 @@ public class MessageConsole extends IOConsole { public MessageConsole(String name, String consoleType, ImageDescriptor imageDescriptor, String encoding, boolean autoLifecycle) { super(name, consoleType, imageDescriptor, encoding, autoLifecycle); } - + /** * Returns a new message stream connected to this console. * <p> @@ -126,28 +130,31 @@ public class MessageConsole extends IOConsole { /* (non-Javadoc) * @see org.eclipse.ui.console.IConsole#createPage(org.eclipse.ui.console.IConsoleView) */ - public IPageBookViewPage createPage(IConsoleView view) { + @Override + public IPageBookViewPage createPage(IConsoleView view) { IOConsolePage page = (IOConsolePage) super.createPage(view); page.setReadOnly(); return page; } - + /* (non-Javadoc) * @see org.eclipse.ui.console.IOConsole#getInputStream() */ - public IOConsoleInputStream getInputStream() { + @Override + public IOConsoleInputStream getInputStream() { throw new UnsupportedOperationException("Message Console does not support user input"); //$NON-NLS-1$ } - - - /** + + + /** * Appends the given message to this console, from the specified stream. - * + * * @param text message * @param stream stream the message belongs to * @deprecated since 3.1, this method should no longer be called, and has no effect. * Writing to a message console stream updates the document */ + @Deprecated protected void appendToDocument(String text, MessageConsoleStream stream) { - } + } } 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 81561f9ff..aaae641eb 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -53,55 +53,56 @@ public abstract class TextConsole extends AbstractConsole { * 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 Console's regular expression pattern matcher */ private ConsolePatternMatcher fPatternMatcher; - + /** * 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 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; - + /** * Map of client defined attributes */ - private HashMap fAttributes = new HashMap(); - + private HashMap<String, Object> fAttributes = new HashMap<String, Object>(); + private IConsoleManager fConsoleManager = ConsolePlugin.getDefault().getConsoleManager(); - - + + /* (non-Javadoc) * @see org.eclipse.ui.console.AbstractConsole#dispose() */ - protected void dispose() { + @Override + protected void dispose() { super.dispose(); fFont = null; synchronized(fAttributes) { @@ -110,7 +111,7 @@ public abstract class TextConsole extends AbstractConsole { } /** * 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> @@ -129,10 +130,11 @@ public abstract class TextConsole extends AbstractConsole { /* (non-Javadoc) * @see org.eclipse.ui.console.IConsole#createPage(org.eclipse.ui.console.IConsoleView) */ - public IPageBookViewPage createPage(IConsoleView view) { + @Override + public IPageBookViewPage createPage(IConsoleView view) { return new TextConsolePage(this, view); } - + /** * Returns this console's document. * <p> @@ -141,27 +143,27 @@ public abstract class TextConsole extends AbstractConsole { * 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 + * 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. */ @@ -169,40 +171,41 @@ public abstract class TextConsole extends AbstractConsole { if (fConsoleWidth != width) { int old = fConsoleWidth; fConsoleWidth = width; - + firePropertyChange(this, IConsoleConstants.P_CONSOLE_WIDTH, new Integer(old), new Integer(fConsoleWidth)); } } /** * Sets the tab width used in this console. - * - * @param newTabWidth the tab width + * + * @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() { - public void run() { - firePropertyChange(TextConsole.this, IConsoleConstants.P_TAB_SIZE, new Integer(oldTabWidth), new Integer(fTabWidth)); + @Override + public void run() { + firePropertyChange(TextConsole.this, IConsoleConstants.P_TAB_SIZE, new Integer(oldTabWidth), new Integer(fTabWidth)); } }); } } - + /** * Returns the tab width used in this console. - * + * * @return tab width used in this console */ 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() { @@ -211,53 +214,55 @@ public abstract class TextConsole extends AbstractConsole { } return fFont; } - + /** * 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 * the default text font. - * + * * @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 - if (newFont == null) { - newFont = getDefaultFont(); + Font font = newFont; + if (font == null) { + font = getDefaultFont(); } // fire property change if required - if (!fFont.equals(newFont)) { + if (!fFont.equals(font)) { Font old = fFont; - fFont = newFont; + fFont = font; firePropertyChange(this, IConsoleConstants.P_FONT, old, fFont); } } - + /** * Sets the background color used by this console. Specify <code>null</code> to use * the default background color. - * + * * @param background background color or <code>null</code> for default * @since 3.3 * @deprecated use setBackground(Color) instead */ - public void setBackgrond(Color background) { + @Deprecated + public void setBackgrond(Color background) { setBackground(background); - } - + } + /** * Sets the background color used by this console. Specify <code>null</code> to use * the default background color. - * + * * @param background background color or <code>null</code> for default * @since 3.3 */ @@ -272,19 +277,19 @@ public abstract class TextConsole extends AbstractConsole { 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 + * 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> @@ -306,10 +311,10 @@ public abstract class TextConsole extends AbstractConsole { * @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() { @@ -325,10 +330,10 @@ public abstract class TextConsole extends AbstractConsole { 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 */ @@ -343,7 +348,7 @@ public abstract class TextConsole extends AbstractConsole { } } } catch (BadPositionCategoryException e) { - } + } return null; } @@ -354,35 +359,38 @@ public abstract class TextConsole extends AbstractConsole { * @return the position containing the offset, or <code>null</code> */ private Position findPosition(int offset, Position[] positions) { - - if (positions.length == 0) + + if (positions.length == 0) { return null; - + } + int left= 0; int right= positions.length -1; int mid= 0; Position position= null; - + while (left < right) { - + mid= (left + right) / 2; - + position= positions[mid]; if (offset < position.getOffset()) { - if (left == mid) + if (left == mid) { right= left; - else + } else { right= mid -1; + } } else if (offset > (position.getOffset() + position.getLength() - 1)) { - if (right == mid) + if (right == mid) { left= right; - else + } else { left= mid +1; + } } else { left= right= mid; } } - + position= positions[left]; if (offset >= position.getOffset() && (offset < (position.getOffset() + position.getLength()))) { return position; @@ -394,49 +402,51 @@ public abstract class TextConsole extends AbstractConsole { * 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 { - public boolean contains(ISchedulingRule rule) { + @Override + public boolean contains(ISchedulingRule rule) { return rule == this; } - public boolean isConflicting(ISchedulingRule rule) { + @Override + public boolean isConflicting(ISchedulingRule rule) { if (contains(rule)) { return true; } if (rule != this && rule instanceof MatcherSchedulingRule) { - return (((MatcherSchedulingRule)rule).getConsole() == TextConsole.this); + 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. @@ -453,17 +463,17 @@ public abstract class TextConsole extends AbstractConsole { 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. + * 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> @@ -475,7 +485,7 @@ public abstract class TextConsole extends AbstractConsole { fDocument.removeDocumentListener(fPatternMatcher); checkFinished(); } - + /** * Fires the console output complete property change event. */ @@ -485,10 +495,10 @@ public abstract class TextConsole extends AbstractConsole { 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 @@ -496,18 +506,18 @@ public abstract class TextConsole extends AbstractConsole { */ public void addHyperlink(IHyperlink hyperlink, int offset, int length) throws BadLocationException { IDocument document = getDocument(); - ConsoleHyperlinkPosition hyperlinkPosition = new ConsoleHyperlinkPosition(hyperlink, offset, length); + ConsoleHyperlinkPosition hyperlinkPosition = new ConsoleHyperlinkPosition(hyperlink, offset, length); try { document.addPosition(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY, hyperlinkPosition); 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. */ @@ -527,10 +537,10 @@ public abstract class TextConsole extends AbstractConsole { } return null; } - + /** * Returns the attribute associated with the specified key. - * + * * @param key attribute key * @return the attribute associated with the specified key */ @@ -539,10 +549,10 @@ public abstract class TextConsole extends AbstractConsole { return fAttributes.get(key); } } - + /** * Sets an attribute value. Intended for client data. - * + * * @param key attribute key * @param value attribute 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 ae76fec0a..9a97a3085 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,17 +14,10 @@ package org.eclipse.ui.console; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.ResourceBundle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.Widget; - import org.eclipse.core.runtime.IAdaptable; - import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; @@ -32,17 +25,19 @@ import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; - import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IFindReplaceTarget; import org.eclipse.jface.text.ITextListener; import org.eclipse.jface.text.ITextOperationTarget; import org.eclipse.jface.text.TextEvent; - +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Widget; import org.eclipse.ui.IActionBars; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IWorkbenchActionConstants; @@ -57,7 +52,6 @@ import org.eclipse.ui.internal.console.FollowHyperlinkAction; import org.eclipse.ui.internal.console.IConsoleHelpContextIds; import org.eclipse.ui.part.IPageBookViewPage; import org.eclipse.ui.part.IPageSite; - import org.eclipse.ui.texteditor.FindReplaceAction; import org.eclipse.ui.texteditor.IUpdate; @@ -81,25 +75,27 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen private IConsoleView fConsoleView; private TextConsoleViewer fViewer; private MenuManager fMenuManager; - protected Map fGlobalActions = new HashMap(); - protected ArrayList fSelectionActions = new ArrayList(); + protected Map<String, IAction> fGlobalActions = new HashMap<String, IAction>(); + protected ArrayList<String> fSelectionActions = new ArrayList<String>(); protected ClearOutputAction fClearOutputAction; - + // text selection listener, used to update selection dependent actions on selection changes private ISelectionChangedListener selectionChangedListener = new ISelectionChangedListener() { + @Override public void selectionChanged(SelectionChangedEvent event) { updateSelectionDependentActions(); } }; - + // updates the find replace action and the clear action if the document length is > 0 private ITextListener textListener = new ITextListener() { - public void textChanged(TextEvent event) { + @Override + public void textChanged(TextEvent event) { IUpdate findReplace = (IUpdate)fGlobalActions.get(ActionFactory.FIND.getId()); if (findReplace != null) { findReplace.update(); } - + if (fClearOutputAction != null) { IDocument doc = fViewer.getDocument(); if(doc != null) { @@ -108,10 +104,10 @@ 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 */ @@ -119,30 +115,32 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen 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 */ protected TextConsoleViewer createViewer(Composite parent) { return new TextConsoleViewer(parent, fConsole); } - + /* * (non-Javadoc) * @see org.eclipse.ui.part.IPageBookViewPage#getSite() */ - public IPageSite getSite() { + @Override + public IPageSite getSite() { return fSite; } - + /* * (non-Javadoc) * @see org.eclipse.ui.part.IPageBookViewPage#init(org.eclipse.ui.part.IPageSite) */ - public void init(IPageSite pageSite) throws PartInitException { + @Override + public void init(IPageSite pageSite) throws PartInitException { fSite = pageSite; } @@ -150,9 +148,8 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen * Updates selection dependent actions. */ protected void updateSelectionDependentActions() { - Iterator iterator= fSelectionActions.iterator(); - while (iterator.hasNext()) { - updateAction((String)iterator.next()); + for (String string : fSelectionActions) { + updateAction(string); } } @@ -160,13 +157,14 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen * (non-Javadoc) * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) */ - public void createControl(Composite parent) { + @Override + public void createControl(Composite parent) { fViewer = createViewer(parent); fViewer.setConsoleWidth(fConsole.getConsoleWidth()); fViewer.setTabWidth(fConsole.getTabWidth()); fConsole.addPropertyChangeListener(this); JFaceResources.getFontRegistry().addListener(this); - + String id = "#ContextMenu"; //$NON-NLS-1$ if (getConsole().getType() != null) { id = getConsole().getType() + "." + id; //$NON-NLS-1$ @@ -174,19 +172,20 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen fMenuManager= new MenuManager("#ContextMenu", id); //$NON-NLS-1$ fMenuManager.setRemoveAllWhenShown(true); fMenuManager.addMenuListener(new IMenuListener() { + @Override public void menuAboutToShow(IMenuManager m) { contextMenuAboutToShow(m); } }); Menu menu = fMenuManager.createContextMenu(getControl()); getControl().setMenu(menu); - + createActions(); configureToolBar(getSite().getActionBars().getToolBarManager()); - + getSite().registerContextMenu(id, fMenuManager, fViewer); getSite().setSelectionProvider(fViewer); - + fViewer.getSelectionProvider().addSelectionChangedListener(selectionChangedListener); fViewer.addTextListener(textListener); } @@ -195,17 +194,18 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen * (non-Javadoc) * @see org.eclipse.ui.part.IPage#dispose() */ - public void 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; @@ -216,20 +216,23 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen * (non-Javadoc) * @see org.eclipse.ui.part.IPage#getControl() */ - public Control getControl() { + @Override + public Control getControl() { return fViewer != null ? fViewer.getControl() : null; } /* (non-Javadoc) * @see org.eclipse.ui.part.IPage#setActionBars(org.eclipse.ui.IActionBars) */ - public void setActionBars(IActionBars actionBars) { + @Override + public void setActionBars(IActionBars actionBars) { } /* (non-Javadoc) * @see org.eclipse.ui.part.IPage#setFocus() */ - public void setFocus() { + @Override + public void setFocus() { if (fViewer != null) { fViewer.getTextWidget().setFocus(); } @@ -239,11 +242,12 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen * (non-Javadoc) * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ - public void propertyChange(PropertyChangeEvent event) { + @Override + public void propertyChange(PropertyChangeEvent event) { 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)) { @@ -271,30 +275,30 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen action.setActionDefinitionId(ActionFactory.SELECT_ALL.getCommandId()); PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IConsoleHelpContextIds.CONSOLE_SELECT_ALL_ACTION); setGlobalAction(actionBars, ActionFactory.SELECT_ALL.getId(), action); - + action= new TextViewerAction(fViewer, ITextOperationTarget.CUT); action.configureAction(ConsoleMessages.TextConsolePage_CutText, ConsoleMessages.TextConsolePage_CutDescrip, ConsoleMessages.TextConsolePage_CutDescrip); action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_CUT)); action.setActionDefinitionId(ActionFactory.CUT.getCommandId()); PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IConsoleHelpContextIds.CONSOLE_CUT_ACTION); setGlobalAction(actionBars, ActionFactory.CUT.getId(), action); - + action= new TextViewerAction(fViewer, ITextOperationTarget.COPY); action.configureAction(ConsoleMessages.TextConsolePage_CopyText, ConsoleMessages.TextConsolePage_CopyDescrip, ConsoleMessages.TextConsolePage_CopyDescrip); action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); action.setActionDefinitionId(ActionFactory.COPY.getCommandId()); PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IConsoleHelpContextIds.CONSOLE_COPY_ACTION); setGlobalAction(actionBars, ActionFactory.COPY.getId(), action); - + action= new TextViewerAction(fViewer, ITextOperationTarget.PASTE); action.configureAction(ConsoleMessages.TextConsolePage_PasteText, ConsoleMessages.TextConsolePage_PasteDescrip, ConsoleMessages.TextConsolePage_PasteDescrip); action.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_PASTE)); action.setActionDefinitionId(ActionFactory.PASTE.getCommandId()); PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IConsoleHelpContextIds.CONSOLE_PASTE_ACTION); setGlobalAction(actionBars, ActionFactory.PASTE.getId(), action); - + 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); @@ -304,13 +308,13 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen fSelectionActions.add(ActionFactory.COPY.getId()); fSelectionActions.add(ActionFactory.PASTE.getId()); 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 @@ -323,7 +327,8 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen /* (non-Javadoc) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ - public Object getAdapter(Class required) { + @Override + public Object getAdapter(Class required) { if (IFindReplaceTarget.class.equals(required)) { return fViewer.getFindReplaceTarget(); } @@ -332,41 +337,41 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen } return null; } - + /** * Returns the view this page is contained in. - * + * * @return the view this page is contained in */ protected IConsoleView getConsoleView() { return fConsoleView; } - + /** * Returns the console this page is displaying. - * + * * @return the console this page is displaying */ protected IConsole getConsole() { return fConsole; } - + /** * Updates the global action with the given id - * + * * @param actionId action definition id */ protected void updateAction(String actionId) { - IAction action= (IAction)fGlobalActions.get(actionId); + IAction action= fGlobalActions.get(actionId); if (action instanceof IUpdate) { ((IUpdate) action).update(); } } - + /** * Fill the context menu - * + * * @param menuManager menu */ protected void contextMenuAboutToShow(IMenuManager menuManager) { @@ -375,16 +380,16 @@ public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListen return; } - menuManager.add((IAction)fGlobalActions.get(ActionFactory.CUT.getId())); - menuManager.add((IAction)fGlobalActions.get(ActionFactory.COPY.getId())); - menuManager.add((IAction)fGlobalActions.get(ActionFactory.PASTE.getId())); - menuManager.add((IAction)fGlobalActions.get(ActionFactory.SELECT_ALL.getId())); - + menuManager.add(fGlobalActions.get(ActionFactory.CUT.getId())); + menuManager.add(fGlobalActions.get(ActionFactory.COPY.getId())); + menuManager.add(fGlobalActions.get(ActionFactory.PASTE.getId())); + menuManager.add(fGlobalActions.get(ActionFactory.SELECT_ALL.getId())); + menuManager.add(new Separator("FIND")); //$NON-NLS-1$ - menuManager.add((IAction)fGlobalActions.get(ActionFactory.FIND.getId())); + menuManager.add(fGlobalActions.get(ActionFactory.FIND.getId())); menuManager.add(new FollowHyperlinkAction(fViewer)); menuManager.add(fClearOutputAction); - + menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); } @@ -395,16 +400,16 @@ 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) { 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 68d61651a..82b775b8b 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -61,7 +61,7 @@ import org.eclipse.ui.progress.WorkbenchJob; * <p> * Clients may subclass this class. * </p> - * + * * @since 3.1 */ public class TextConsoleViewer extends SourceViewer implements LineStyleListener, LineBackgroundListener, MouseTrackListener, MouseMoveListener, MouseListener { @@ -83,15 +83,18 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener private IPropertyChangeListener propertyChangeListener; private IDocumentListener documentListener = new IDocumentListener() { - public void documentAboutToBeChanged(DocumentEvent event) { + @Override + public void documentAboutToBeChanged(DocumentEvent event) { } - public void documentChanged(DocumentEvent event) { + @Override + public void documentChanged(DocumentEvent event) { 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(); @@ -109,7 +112,8 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener }; WorkbenchJob revealJob = new WorkbenchJob("Reveal End of Document") {//$NON-NLS-1$ - public IStatus runInUIThread(IProgressMonitor monitor) { + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { StyledText textWidget = getTextWidget(); if (textWidget != null && !textWidget.isDisposed()) { int lineCount = textWidget.getLineCount(); @@ -118,9 +122,10 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener return Status.OK_STATUS; } }; - + private IPositionUpdater positionUpdater = new IPositionUpdater() { - public void update(DocumentEvent event) { + @Override + public void update(DocumentEvent event) { try { IDocument document = getDocument(); if (document != null) { @@ -142,7 +147,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /** * Constructs a new viewer in the given parent for the specified console. - * + * * @param parent * containing widget * @param console @@ -176,7 +181,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /** * Sets the tab width used by this viewer. - * + * * @param tabWidth * the tab width used by this viewer */ @@ -190,7 +195,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /** * Sets the font used by this viewer. - * + * * @param font * the font used by this viewer */ @@ -214,13 +219,14 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /* * (non-Javadoc) - * + * * @see org.eclipse.swt.custom.LineStyleListener#lineGetStyle(org.eclipse.swt.custom.LineStyleEvent) */ - public void lineGetStyle(LineStyleEvent event) { + @Override + public void lineGetStyle(LineStyleEvent event) { IDocument document = getDocument(); if (document != null && document.getLength() > 0) { - ArrayList ranges = new ArrayList(); + ArrayList<StyleRange> ranges = new ArrayList<StyleRange>(); int offset = event.lineOffset; int length = event.lineText.length(); @@ -249,12 +255,12 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener } if (ranges.size() > 0) { - event.styles = (StyleRange[]) ranges.toArray(new StyleRange[ranges.size()]); + event.styles = ranges.toArray(new StyleRange[ranges.size()]); } } } - private void override(List ranges, StyleRange newRange) { + private void override(List<StyleRange> ranges, StyleRange newRange) { if (ranges.isEmpty()) { ranges.add(newRange); return; @@ -263,7 +269,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener int start = newRange.start; int end = start + newRange.length; for (int i = 0; i < ranges.size(); i++) { - StyleRange existingRange = (StyleRange) ranges.get(i); + StyleRange existingRange = ranges.get(i); int rEnd = existingRange.start + existingRange.length; if (end <= existingRange.start || start >= rEnd) { continue; @@ -293,7 +299,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /** * Binary search for the positions overlapping the given range - * + * * @param offset * the offset of the range * @param length @@ -304,8 +310,9 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener */ private Position[] findPosition(int offset, int length, Position[] positions) { - if (positions.length == 0) - return null; + if (positions.length == 0) { + return null; + } int rangeEnd = offset + length; int left = 0; @@ -319,21 +326,23 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener position = positions[mid]; if (rangeEnd < position.getOffset()) { - if (left == mid) - right = left; - else - right = mid - 1; + if (left == mid) { + right = left; + } else { + right = mid - 1; + } } else if (offset > (position.getOffset() + position.getLength() - 1)) { - if (right == mid) - left = right; - else - left = mid + 1; + if (right == mid) { + left = right; + } else { + left = mid + 1; + } } else { left = right = mid; } } - List list = new ArrayList(); + List<Position> list = new ArrayList<Position>(); int index = left - 1; if (index >= 0) { position = positions[index]; @@ -357,21 +366,22 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener if (list.isEmpty()) { return null; } - return (Position[]) list.toArray(new Position[list.size()]); + return list.toArray(new Position[list.size()]); } /* * (non-Javadoc) - * + * * @see org.eclipse.swt.custom.LineBackgroundListener#lineGetBackground(org.eclipse.swt.custom.LineBackgroundEvent) */ - public void lineGetBackground(LineBackgroundEvent event) { + @Override + public void lineGetBackground(LineBackgroundEvent event) { event.lineBackground = null; } /** * Returns the hand cursor. - * + * * @return the hand cursor */ protected Cursor getHandCursor() { @@ -383,7 +393,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /** * Returns the text cursor. - * + * * @return the text cursor */ protected Cursor getTextCursor() { @@ -395,7 +405,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /** * Notification a hyperlink has been entered. - * + * * @param link * the link that was entered */ @@ -413,7 +423,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /** * Notification a link was exited. - * + * * @param link * the link that was exited */ @@ -428,19 +438,21 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /* * (non-Javadoc) - * + * * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent) */ - public void mouseEnter(MouseEvent e) { + @Override + public void mouseEnter(MouseEvent e) { getTextWidget().addMouseMoveListener(this); } /* * (non-Javadoc) - * + * * @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent) */ - public void mouseExit(MouseEvent e) { + @Override + public void mouseExit(MouseEvent e) { getTextWidget().removeMouseMoveListener(this); if (hyperlink != null) { linkExited(hyperlink); @@ -449,18 +461,20 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /* * (non-Javadoc) - * + * * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent) */ - public void mouseHover(MouseEvent e) { + @Override + public void mouseHover(MouseEvent e) { } /* * (non-Javadoc) - * + * * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent) */ - public void mouseMove(MouseEvent e) { + @Override + public void mouseMove(MouseEvent e) { int offset = -1; try { Point p = new Point(e.x, e.y); @@ -474,7 +488,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /** * 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) { @@ -495,7 +509,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /** * 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() { @@ -505,7 +519,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /** * 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 @@ -519,34 +533,38 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /* * (non-Javadoc) - * + * * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent) */ - public void mouseDoubleClick(MouseEvent e) { + @Override + public void mouseDoubleClick(MouseEvent e) { } /* * (non-Javadoc) - * + * * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent) */ - public void mouseDown(MouseEvent e) { + @Override + public void mouseDown(MouseEvent e) { } /* * (non-Javadoc) - * + * * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent) */ - public void mouseUp(MouseEvent e) { + @Override + public void mouseUp(MouseEvent e) { } /* * (non-Javadoc) - * + * * @see org.eclipse.jface.text.TextViewer#createDocumentAdapter() */ - protected IDocumentAdapter createDocumentAdapter() { + @Override + protected IDocumentAdapter createDocumentAdapter() { if (documentAdapter == null) { documentAdapter = new ConsoleDocumentAdapter(consoleWidth = -1); } @@ -556,7 +574,7 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /** * 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 */ @@ -564,7 +582,8 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener if (consoleWidth != width) { consoleWidth = width; ConsolePlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { + @Override + public void run() { if (documentAdapter != null) { documentAdapter.setWidth(consoleWidth); } @@ -575,10 +594,11 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /* * (non-Javadoc) - * + * * @see org.eclipse.jface.text.TextViewer#handleDispose() */ - protected void handleDispose() { + @Override + protected void handleDispose() { IDocument document = getDocument(); if (document != null) { document.removeDocumentListener(documentListener); @@ -603,12 +623,13 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); colorRegistry.removeListener(propertyChangeListener); - + super.handleDispose(); } class HyperlinkColorChangeListener implements IPropertyChangeListener { - public void propertyChange(PropertyChangeEvent event) { + @Override + public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(JFacePreferences.ACTIVE_HYPERLINK_COLOR) || event.getProperty().equals(JFacePreferences.HYPERLINK_COLOR)) { getTextWidget().redraw(); } @@ -619,14 +640,16 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener /* * work around to memory leak in TextViewer$WidgetCommand */ - protected void updateTextListeners(WidgetCommand cmd) { + @Override + protected void updateTextListeners(WidgetCommand cmd) { super.updateTextListeners(cmd); cmd.preservedText = null; cmd.event = null; cmd.text = null; } - protected void internalRevealRange(int start, int end) { + @Override + protected void internalRevealRange(int start, int end) { StyledText textWidget = getTextWidget(); int startLine = documentAdapter.getLineAtOffset(start); int endLine = documentAdapter.getLineAtOffset(end); @@ -634,7 +657,8 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener int top = textWidget.getTopIndex(); if (top > -1) { // scroll vertically - int lines = getVisibleLinesInViewport(); + @SuppressWarnings("deprecation") + int lines = getVisibleLinesInViewport(); int bottom = top + lines; // two lines at the top and the bottom should always be left @@ -682,12 +706,13 @@ public class TextConsoleViewer extends SourceViewer implements LineStyleListener int visibleWidth = visibleEnd - visibleStart; int selectionPixelWidth = endPixel - startPixel; - if (startPixel < visibleStart) - newOffset = startPixel; - else if (selectionPixelWidth + bufferZone < visibleWidth) - newOffset = endPixel + bufferZone - visibleWidth; - else - newOffset = startPixel; + if (startPixel < visibleStart) { + newOffset = startPixel; + } else if (selectionPixelWidth + bufferZone < visibleWidth) { + newOffset = endPixel + bufferZone - visibleWidth; + } else { + newOffset = startPixel; + } float index = ((float) newOffset) / ((float) getAverageCharWidth()); 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 a1de229b5..fd36d38f4 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -39,23 +39,23 @@ public class ClearOutputAction extends Action { /** * Constructs a clear output action. - * + * * @since 3.1 */ private ClearOutputAction() { - super(ConsoleMessages.ClearOutputAction_title); - setToolTipText(ConsoleMessages.ClearOutputAction_toolTipText); - setHoverImageDescriptor(ConsolePluginImages.getImageDescriptor(IConsoleConstants.IMG_LCL_CLEAR)); + super(ConsoleMessages.ClearOutputAction_title); + setToolTipText(ConsoleMessages.ClearOutputAction_toolTipText); + setHoverImageDescriptor(ConsolePluginImages.getImageDescriptor(IConsoleConstants.IMG_LCL_CLEAR)); setDisabledImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_DLCL_CLEAR)); setImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_CLEAR)); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CLEAR_CONSOLE_ACTION); + PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CLEAR_CONSOLE_ACTION); } - + /** * Constructs a clear output action for an I/O console. Clearing an I/O console * is performed via API on the <code>IOConsole</code>, rather than clearing * its document directly. - * + * * @param ioConsole I/O console the action is associated with * @since 3.1 */ @@ -63,11 +63,11 @@ public class ClearOutputAction extends Action { this(); fIOConsole = ioConsole; } - + /** * Constructs an action to clear the document associated with a text viewer. - * - * @param viewer viewer whose document this action is associated with + * + * @param viewer viewer whose document this action is associated with */ public ClearOutputAction(ITextViewer viewer) { this(); @@ -77,8 +77,10 @@ public class ClearOutputAction extends Action { /* (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ + @Override public void run() { BusyIndicator.showWhile(ConsolePlugin.getStandardDisplay(), new Runnable() { + @Override public void run() { if (fIOConsole == null) { IDocument document = fViewer.getDocument(); 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 8691ac226..f3a50bff2 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -26,16 +26,17 @@ import org.eclipse.ui.internal.console.IInternalConsoleConstants; * @noextend This class is not intended to be subclassed by clients. */ public class CloseConsoleAction extends Action { - + private IConsole fConsole; - + public CloseConsoleAction(IConsole console) { - super(ConsoleMessages.CloseConsoleAction_0, ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_CLOSE)); - setToolTipText(ConsoleMessages.CloseConsoleAction_1); + super(ConsoleMessages.CloseConsoleAction_0, ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_CLOSE)); + setToolTipText(ConsoleMessages.CloseConsoleAction_1); fConsole = console; } - public void run() { + @Override + public void run() { ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[]{fConsole}); } } diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerAction.java index b3809ea13..fabd9bb48 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerAction.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerAction.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -31,7 +31,7 @@ public class TextViewerAction extends Action implements IUpdate { /** * Constructs a new action in the given text viewer with * the specified operation code. - * + * * @param viewer * @param operationCode */ @@ -43,12 +43,13 @@ public class TextViewerAction extends Action implements IUpdate { /* (non-Javadoc) * @see org.eclipse.ui.texteditor.IUpdate#update() - * + * * Updates the enabled state of the action. * Fires a property change if the enabled state changes. - * + * * @see org.eclipse.jface.action.Action#firePropertyChange(String, Object, Object) */ + @Override public void update() { boolean wasEnabled= isEnabled(); @@ -59,19 +60,20 @@ public class TextViewerAction extends Action implements IUpdate { firePropertyChange(ENABLED, wasEnabled ? Boolean.TRUE : Boolean.FALSE, isEnabled ? Boolean.TRUE : Boolean.FALSE); } } - + /* (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ + @Override public void run() { if (fOperationCode != -1 && fOperationTarget != null) { fOperationTarget.doOperation(fOperationCode); } } - + /** * Configures this action with a label, tool tip, and description. - * + * * @param text action label * @param toolTipText action tool tip * @param description action description diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerGotoLineAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerGotoLineAction.java index b029804f5..020ae3b98 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerGotoLineAction.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerGotoLineAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,8 +11,6 @@ package org.eclipse.ui.console.actions; -import com.ibm.icu.text.MessageFormat; - import org.eclipse.jface.dialogs.IInputValidator; import org.eclipse.jface.dialogs.InputDialog; import org.eclipse.jface.text.BadLocationException; @@ -24,6 +22,8 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.internal.console.ConsoleMessages; +import com.ibm.icu.text.MessageFormat; + /** * Action to position a text viewer to a specific line. * <p> @@ -36,19 +36,21 @@ public class TextViewerGotoLineAction extends TextViewerAction { /** * Validates whether the text found in the input field of the - * dialog forms a valid line number, i.e. one to which can be + * dialog forms a valid line number, i.e. one to which can be * jumped. */ class NumberValidator implements IInputValidator { + @Override public String isValid(String input) { try { int i= Integer.parseInt(input); - if (i <= 0 || fLastLine < i) - return ConsoleMessages.TextViewerGotoLineAction_Line_number_out_of_range_1; + if (i <= 0 || fLastLine < i) { + return ConsoleMessages.TextViewerGotoLineAction_Line_number_out_of_range_1; + } } catch (NumberFormatException x) { - return ConsoleMessages.TextViewerGotoLineAction_Not_a_number_2; + return ConsoleMessages.TextViewerGotoLineAction_Not_a_number_2; } return null; @@ -57,21 +59,22 @@ public class TextViewerGotoLineAction extends TextViewerAction { protected int fLastLine; protected ITextViewer fTextViewer; - + /** * Constructs a goto line action for the viewer using the provided resource bundle */ public TextViewerGotoLineAction(ITextViewer viewer) { super(viewer, -1); fTextViewer= viewer; - setText(ConsoleMessages.TextViewerGotoLineAction_Go_to__Line____Ctrl_L_4); - setToolTipText(ConsoleMessages.TextViewerGotoLineAction_Go_To_Line_1); - setDescription(ConsoleMessages.TextViewerGotoLineAction_Go_To_Line_1); + setText(ConsoleMessages.TextViewerGotoLineAction_Go_to__Line____Ctrl_L_4); + setToolTipText(ConsoleMessages.TextViewerGotoLineAction_Go_To_Line_1); + setDescription(ConsoleMessages.TextViewerGotoLineAction_Go_To_Line_1); } - + /** * @see TextViewerAction#update() */ + @Override public void update() { } @@ -87,21 +90,22 @@ public class TextViewerGotoLineAction extends TextViewerAction { fTextViewer.getTextWidget().setSelection(start, start + length); fTextViewer.revealRange(start, length); } catch (BadLocationException x) { - ConsolePlugin.errorDialog(fTextViewer.getTextWidget().getShell(), ConsoleMessages.TextViewerGotoLineAction_Go_To_Line_1, ConsoleMessages.TextViewerGotoLineAction_Exceptions_occurred_attempt_to_go_to_line_2, x); // + ConsolePlugin.errorDialog(fTextViewer.getTextWidget().getShell(), ConsoleMessages.TextViewerGotoLineAction_Go_To_Line_1, ConsoleMessages.TextViewerGotoLineAction_Exceptions_occurred_attempt_to_go_to_line_2, x); // } } /* (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ + @Override public void run() { try { Point selection= fTextViewer.getTextWidget().getSelection(); IDocument document= fTextViewer.getDocument(); fLastLine= document.getLineOfOffset(document.getLength()) + 1; int startLine= selection == null ? 1 : fTextViewer.getTextWidget().getLineAtOffset(selection.x) + 1; - String title= ConsoleMessages.TextViewerGotoLineAction_Go_To_Line_1; - String message= MessageFormat.format(ConsoleMessages.TextViewerGotoLineAction_Enter_line_number__8, new Object[] {new Integer(fLastLine)}); + String title= ConsoleMessages.TextViewerGotoLineAction_Go_To_Line_1; + String message= MessageFormat.format(ConsoleMessages.TextViewerGotoLineAction_Enter_line_number__8, new Object[] {new Integer(fLastLine)}); String value= Integer.toString(startLine); Shell activeShell= fTextViewer.getTextWidget().getShell(); InputDialog d= new InputDialog(activeShell, title, message, value, new NumberValidator()); @@ -110,11 +114,11 @@ public class TextViewerGotoLineAction extends TextViewerAction { int line= Integer.parseInt(d.getValue()); gotoLine(line - 1); } catch (NumberFormatException x) { - ConsolePlugin.errorDialog(activeShell, ConsoleMessages.TextViewerGotoLineAction_Go_To_Line_1, ConsoleMessages.TextViewerGotoLineAction_Exceptions_occurred_attempt_to_go_to_line_2, x); // + ConsolePlugin.errorDialog(activeShell, ConsoleMessages.TextViewerGotoLineAction_Go_To_Line_1, ConsoleMessages.TextViewerGotoLineAction_Exceptions_occurred_attempt_to_go_to_line_2, x); // } } } catch (BadLocationException x) { - ConsolePlugin.errorDialog(fTextViewer.getTextWidget().getShell(), ConsoleMessages.TextViewerGotoLineAction_Go_To_Line_1, ConsoleMessages.TextViewerGotoLineAction_Exceptions_occurred_attempt_to_go_to_line_2, x); // + ConsolePlugin.errorDialog(fTextViewer.getTextWidget().getShell(), ConsoleMessages.TextViewerGotoLineAction_Go_To_Line_1, ConsoleMessages.TextViewerGotoLineAction_Exceptions_occurred_attempt_to_go_to_line_2, x); // return; } } 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 ddf2491c6..8eb24bb79 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -24,92 +24,107 @@ public class ConsoleDocument extends Document { /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#get(int, int) */ + @Override public synchronized String get(int pos, int length) throws BadLocationException { return super.get(pos, length); } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#getLength() */ + @Override public synchronized int getLength() { return super.getLength(); } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#getLineDelimiter(int) */ + @Override public synchronized String getLineDelimiter(int line) throws BadLocationException { return super.getLineDelimiter(line); } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#getLineInformation(int) */ + @Override public synchronized IRegion getLineInformation(int line) throws BadLocationException { return super.getLineInformation(line); } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#getLineInformationOfOffset(int) */ + @Override public synchronized IRegion getLineInformationOfOffset(int offset) throws BadLocationException { return super.getLineInformationOfOffset(offset); } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#getLineLength(int) */ + @Override public synchronized int getLineLength(int line) throws BadLocationException { return super.getLineLength(line); } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#getLineOffset(int) */ + @Override public synchronized int getLineOffset(int line) throws BadLocationException { return super.getLineOffset(line); } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#getLineOfOffset(int) */ + @Override public int getLineOfOffset(int pos) throws BadLocationException { return super.getLineOfOffset(pos); } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#getNumberOfLines() */ + @Override public synchronized int getNumberOfLines() { return super.getNumberOfLines(); } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#replace(int, int, java.lang.String) */ + @Override public synchronized void replace(int pos, int length, String text) throws BadLocationException { super.replace(pos, length, text); } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#set(java.lang.String) */ - public synchronized void set(String text) { + @Override + public synchronized void set(String text) { super.set(text); } /* (non-Javadoc) * @see org.eclipse.jface.text.AbstractDocument#completeInitialization() */ - protected void completeInitialization() { + @Override + protected void completeInitialization() { super.completeInitialization(); addPositionUpdater(new HyperlinkUpdater()); } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#addPosition(java.lang.String, org.eclipse.jface.text.Position) - */ - public synchronized void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException { + */ + @Override + public synchronized void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException { super.addPosition(category, position); } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#removePosition(java.lang.String, org.eclipse.jface.text.Position) - */ - public synchronized void removePosition(String category, Position position) throws BadPositionCategoryException { + */ + @Override + public synchronized void removePosition(String category, Position position) throws BadPositionCategoryException { super.removePosition(category, position); } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocument#getPositions(java.lang.String) - */ - public synchronized Position[] getPositions(String category) throws BadPositionCategoryException { + */ + @Override + public synchronized Position[] getPositions(String category) throws BadPositionCategoryException { 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 2b00475d4..486594d11 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,51 +11,48 @@ package org.eclipse.ui.internal.console; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.swt.custom.TextChangeListener; -import org.eclipse.swt.custom.TextChangedEvent; -import org.eclipse.swt.custom.TextChangingEvent; - import org.eclipse.core.runtime.Assert; - import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentAdapter; import org.eclipse.jface.text.IDocumentListener; +import org.eclipse.swt.custom.TextChangeListener; +import org.eclipse.swt.custom.TextChangedEvent; +import org.eclipse.swt.custom.TextChangingEvent; /** * Adapts a Console's document to the viewer StyledText widget. Allows proper line * wrapping of fixed width consoles without having to add line delimiters to the StyledText. - * + * * By using this adapter, the offset of any character is the same in both the widget and the * document. - * + * * @since 3.1 */ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListener { - + private int consoleWidth = -1; - private List textChangeListeners; + private List<TextChangeListener> textChangeListeners; 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$ - - + + public ConsoleDocumentAdapter(int width) { - textChangeListeners = new ArrayList(); + textChangeListeners = new ArrayList<TextChangeListener>(); consoleWidth = width; } - + /* - * repairs lines list from the beginning of the line containing the offset of any + * 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) { @@ -66,11 +63,11 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen 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); @@ -78,7 +75,7 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen int offset = nextOffset; int length = document.getLineLength(i); nextOffset += length; - + if (length == 0) { addRegion(offset, 0); } else { @@ -87,7 +84,7 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen String lineDelimiter = document.getLineDelimiter(i); int lineDelimiterLength = 0; if (lineDelimiter != null) { - lineDelimiterLength = lineDelimiter.length(); + lineDelimiterLength = lineDelimiter.length(); trimmedLength -= lineDelimiterLength; } @@ -105,12 +102,12 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen } } catch (BadLocationException e) { } - + if (regionCount == 0) { addRegion(0, document.getLength()); } } - + private void addRegion(int offset, int length) { if (regionCount == 0) { offsets[0] = offset; @@ -124,17 +121,18 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen } regionCount++; } - + /* (non-Javadoc) * @see org.eclipse.jface.text.IDocumentAdapter#setDocument(org.eclipse.jface.text.IDocument) */ - public void setDocument(IDocument doc) { + @Override + public void setDocument(IDocument doc) { if (document != null) { document.removeDocumentListener(this); } - + document = doc; - + if (document != null) { document.addDocumentListener(this); repairLines(0); @@ -144,17 +142,19 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen /* (non-Javadoc) * @see org.eclipse.swt.custom.StyledTextContent#addTextChangeListener(org.eclipse.swt.custom.TextChangeListener) */ - public synchronized void addTextChangeListener(TextChangeListener listener) { + @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) */ - public synchronized void removeTextChangeListener(TextChangeListener listener) { + @Override + public synchronized void removeTextChangeListener(TextChangeListener listener) { if(textChangeListeners != null) { Assert.isNotNull(listener); textChangeListeners.remove(listener); @@ -164,14 +164,16 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen /* (non-Javadoc) * @see org.eclipse.swt.custom.StyledTextContent#getCharCount() */ - public int getCharCount() { + @Override + public int getCharCount() { return document.getLength(); } /* (non-Javadoc) * @see org.eclipse.swt.custom.StyledTextContent#getLine(int) */ - public String getLine(int lineIndex) { + @Override + public String getLine(int lineIndex) { try { StringBuffer line = new StringBuffer(document.get(offsets[lineIndex], lengths[lineIndex])); int index = line.length() - 1; @@ -181,31 +183,32 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen return new String(line.substring(0, index+1)); } catch (BadLocationException e) { } - return ""; //$NON-NLS-1$ + return ""; //$NON-NLS-1$ } /* (non-Javadoc) * @see org.eclipse.swt.custom.StyledTextContent#getLineAtOffset(int) */ - public int getLineAtOffset(int offset) { + @Override + public int getLineAtOffset(int offset) { if (offset == 0 || regionCount <= 1) { return 0; } - + if (offset == document.getLength()) { return regionCount-1; } - + int left= 0; int right= regionCount-1; int midIndex = 0; - + 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]) { @@ -214,35 +217,39 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen return midIndex; } } - + return midIndex; } /* (non-Javadoc) * @see org.eclipse.swt.custom.StyledTextContent#getLineCount() */ - public int getLineCount() { + @Override + public int getLineCount() { return regionCount; } /* (non-Javadoc) * @see org.eclipse.swt.custom.StyledTextContent#getLineDelimiter() */ - public String getLineDelimiter() { + @Override + public String getLineDelimiter() { return System.getProperty("line.separator"); //$NON-NLS-1$ } /* (non-Javadoc) * @see org.eclipse.swt.custom.StyledTextContent#getOffsetAtLine(int) */ - public int getOffsetAtLine(int lineIndex) { + @Override + public int getOffsetAtLine(int lineIndex) { return offsets[lineIndex]; } /* (non-Javadoc) * @see org.eclipse.swt.custom.StyledTextContent#getTextRange(int, int) */ - public String getTextRange(int start, int length) { + @Override + public String getTextRange(int start, int length) { try { return document.get(start, length); } catch (BadLocationException e) { @@ -253,7 +260,8 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen /* (non-Javadoc) * @see org.eclipse.swt.custom.StyledTextContent#replaceTextRange(int, int, java.lang.String) */ - public void replaceTextRange(int start, int replaceLength, String text) { + @Override + public void replaceTextRange(int start, int replaceLength, String text) { try { document.replace(start, replaceLength, text); } catch (BadLocationException e) { @@ -263,44 +271,44 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen /* (non-Javadoc) * @see org.eclipse.swt.custom.StyledTextContent#setText(java.lang.String) */ - public synchronized void setText(String text) { + @Override + public synchronized void setText(String text) { TextChangedEvent changeEvent = new TextChangedEvent(this); - for (Iterator iter = textChangeListeners.iterator(); iter.hasNext();) { - TextChangeListener element = (TextChangeListener) iter.next(); - element.textSet(changeEvent); - } + for (TextChangeListener listener : textChangeListeners) { + listener.textSet(changeEvent); + } } /* (non-Javadoc) * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) */ - public synchronized void documentAboutToBeChanged(DocumentEvent event) { + @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); int last = getLineAtOffset(lOffset); changeEvent.replaceLineCount = Math.max(last - first, 0); - + int newLineCount = countNewLines(event.fText); changeEvent.newLineCount = newLineCount >= 0 ? newLineCount : 0; if (changeEvent.newLineCount > offsets.length-regionCount) { growRegionArray(changeEvent.newLineCount); } - - for (Iterator iter = textChangeListeners.iterator(); iter.hasNext();) { - TextChangeListener element = (TextChangeListener) iter.next(); - element.textChanging(changeEvent); - } + + for (TextChangeListener listener : textChangeListeners) { + listener.textChanging(changeEvent); + } } private void growRegionArray(int minSize) { @@ -315,8 +323,10 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen private int countNewLines(String string) { int count = 0; - - if (string.length() == 0) return 0; + + if (string.length() == 0) { + return 0; + } // work around to // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4994840 @@ -328,29 +338,33 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen } // if offset == -1, the line was all '\r' and there is no string to search for matches (bug 207743) if (offset > -1) { - if (offset < (string.length() - 1)) { - string = string.substring(0, offset); + String str = string; + if (offset < (str.length() - 1)) { + str = str.substring(0, offset); } - + int lastIndex = 0; int index = 0; - - Matcher matcher = pattern.matcher(string); - + + Matcher matcher = pattern.matcher(str); + while (matcher.find()) { index = matcher.start(); - - if (index == 0) + + if (index == 0) { count++; - else if (index!=string.length()) + } else if (index != str.length()) { count++; - + } + if (consoleWidth > 0) { int lineLen = index - lastIndex + 1; - if (index == 0) lineLen += lengths[regionCount-1]; + if (index == 0) { + lineLen += lengths[regionCount-1]; + } count += lineLen/consoleWidth; } - + lastIndex = index; } } @@ -361,19 +375,19 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen /* (non-Javadoc) * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) */ - public synchronized void documentChanged(DocumentEvent event) { + @Override + public synchronized void documentChanged(DocumentEvent event) { if (document == null) { return; } - + repairLines(event.fOffset); - + TextChangedEvent changeEvent = new TextChangedEvent(this); - for (Iterator iter = textChangeListeners.iterator(); iter.hasNext();) { - TextChangeListener element = (TextChangeListener) iter.next(); - element.textChanged(changeEvent); - } + for (TextChangeListener listener : textChangeListeners) { + listener.textChanged(changeEvent); + } } /** @@ -385,10 +399,9 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen consoleWidth = width; repairLines(0); TextChangedEvent changeEvent = new TextChangedEvent(this); - for (Iterator iter = textChangeListeners.iterator(); iter.hasNext();) { - TextChangeListener element = (TextChangeListener) iter.next(); - element.textSet(changeEvent); - } + 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 d578e0e9e..2aa907a4b 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 @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -36,10 +36,11 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList private IConsoleView fView; private Menu fMenu; - + /* (non-Javadoc) * @see org.eclipse.ui.texteditor.IUpdate#update() */ + @Override public void update() { IConsole[] consoles = ConsolePlugin.getDefault().getConsoleManager().getConsoles(); setEnabled(consoles.length > 1); @@ -47,8 +48,8 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList public ConsoleDropDownAction(IConsoleView view) { fView= view; - setText(ConsoleMessages.ConsoleDropDownAction_0); - setToolTipText(ConsoleMessages.ConsoleDropDownAction_1); + setText(ConsoleMessages.ConsoleDropDownAction_0); + setToolTipText(ConsoleMessages.ConsoleDropDownAction_1); setImageDescriptor(ConsolePluginImages.getImageDescriptor(IConsoleConstants.IMG_VIEW_CONSOLE)); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_DISPLAY_CONSOLE_ACTION); setMenuCreator(this); @@ -59,11 +60,12 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuCreator#dispose() */ + @Override public void dispose() { if (fMenu != null) { fMenu.dispose(); } - + fView= null; ConsolePlugin.getDefault().getConsoleManager().removeConsoleListener(this); } @@ -71,6 +73,7 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu) */ + @Override public Menu getMenu(Menu parent) { return null; } @@ -78,11 +81,12 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList /* (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); IConsole[] consoles= ConsolePlugin.getDefault().getConsoleManager().getConsoles(); IConsole current = fView.getConsole(); @@ -94,7 +98,7 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList } return fMenu; } - + private void addActionToMenu(Menu parent, Action action, int accelerator) { if (accelerator < 10) { StringBuffer label= new StringBuffer(); @@ -112,6 +116,7 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList /* (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ + @Override public void run() { ConsoleView consoleView = (ConsoleView) fView; boolean pinned = consoleView.isPinned(); @@ -140,12 +145,14 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList } } } - + /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleListener#consolesAdded(org.eclipse.ui.console.IConsole[]) */ + @Override public void consolesAdded(IConsole[] consoles) { UIJob job = new UIJob("") { //$NON-NLS-1$ + @Override public IStatus runInUIThread(IProgressMonitor monitor) { update(); return Status.OK_STATUS; @@ -157,14 +164,16 @@ class ConsoleDropDownAction extends Action implements IMenuCreator, IConsoleList } /* (non-Javadoc) - * + * * Dispose the menu when a launch is removed, such that the actions in this * menu do not hang on to associated resources. - * + * * @see org.eclipse.ui.console.IConsoleListener#consolesRemoved(org.eclipse.ui.console.IConsole[]) */ + @Override public void consolesRemoved(IConsole[] consoles) { UIJob job = new UIJob("") { //$NON-NLS-1$ + @Override public IStatus runInUIThread(IProgressMonitor monitor) { if (fMenu != null) { fMenu.dispose(); 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 377d3d56d..379076fea 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -46,14 +46,16 @@ public class ConsoleFactoryExtension implements IPluginContribution { /* (non-Javadoc) * @see org.eclipse.ui.IPluginContribution#getLocalId() */ - public String getLocalId() { + @Override + public String getLocalId() { return fConfig.getAttribute("id"); //$NON-NLS-1$ } /* (non-Javadoc) * @see org.eclipse.ui.IPluginContribution#getPluginId() */ - public String getPluginId() { + @Override + public String getPluginId() { return fConfig.getContributor().getName(); } @@ -62,7 +64,7 @@ public class ConsoleFactoryExtension implements IPluginContribution { Expression enablementExpression = getEnablementExpression(); if (enablementExpression == null) { return true; - } + } EvaluationContext context = new EvaluationContext(null, this); EvaluationResult evaluationResult = enablementExpression.evaluate(context); return evaluationResult != EvaluationResult.FALSE; @@ -71,11 +73,11 @@ public class ConsoleFactoryExtension implements IPluginContribution { return false; } } - + public Expression getEnablementExpression() throws CoreException { if (fEnablementExpression == null) { IConfigurationElement[] elements = fConfig.getChildren(ExpressionTagNames.ENABLEMENT); - IConfigurationElement enablement = elements.length > 0 ? elements[0] : null; + IConfigurationElement enablement = elements.length > 0 ? elements[0] : null; if (enablement != null) { fEnablementExpression = ExpressionConverter.getDefault().perform(enablement); diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleHyperlinkPosition.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleHyperlinkPosition.java index b98df7300..841e2d3be 100644 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleHyperlinkPosition.java +++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleHyperlinkPosition.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -15,21 +15,21 @@ import org.eclipse.ui.console.ConsolePlugin; import org.eclipse.ui.console.IHyperlink; /** - * Describes the postition of a hyperlink within the Console's document. + * Describes the position of a hyperlink within the Console's document. * * @since 3.1 */ public class ConsoleHyperlinkPosition extends Position { - + public static final String HYPER_LINK_CATEGORY = ConsolePlugin.getUniqueIdentifier() + ".CONSOLE_HYPERLINK_POSITION"; //$NON-NLS-1$ - + private IHyperlink fLink = null; public ConsoleHyperlinkPosition(IHyperlink link, int offset, int length) { super(offset, length); fLink = link; } - + public IHyperlink getHyperLink() { return fLink; } @@ -37,6 +37,7 @@ public class ConsoleHyperlinkPosition extends Position { /** * @see java.lang.Object#equals(java.lang.Object) */ + @Override public boolean equals(Object arg) { return arg instanceof ConsoleHyperlinkPosition && super.equals(arg) && getHyperLink().equals(((ConsoleHyperlinkPosition)arg).getHyperLink()); } @@ -44,6 +45,7 @@ public class ConsoleHyperlinkPosition extends Position { /** * @see java.lang.Object#hashCode() */ + @Override public int hashCode() { return super.hashCode() + getHyperLink().hashCode(); } 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 aea898a2f..fbc8a7a50 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -48,58 +48,59 @@ import org.eclipse.ui.progress.WorkbenchJob; /** * The singleton console manager. - * + * * @since 3.0 */ public class ConsoleManager implements IConsoleManager { - + /** * Console listeners */ private ListenerList fListeners = null; - + /** * List of registered consoles */ - private List fConsoles = new ArrayList(10); + private List<IConsole> fConsoles = new ArrayList<IConsole>(10); + - // change notification constants private final static int ADDED = 1; private final static int REMOVED = 2; - private List fPatternMatchListeners; + private List<PatternMatchListenerExtension> fPatternMatchListeners; + + private List<ConsolePageParticipantExtension> fPageParticipants; - private List fPageParticipants; + private List<ConsoleFactoryExtension> fConsoleFactoryExtensions; + + private List<IConsoleView> fConsoleViews = new ArrayList<IConsoleView>(); - private List fConsoleFactoryExtensions; - - private List fConsoleViews = new ArrayList(); - private boolean fWarnQueued = false; - + private RepaintJob fRepaintJob = new RepaintJob(); - + private class RepaintJob extends WorkbenchJob { - private Set list = new HashSet(); + private Set<IConsole> list = new HashSet<IConsole>(); public RepaintJob() { super("schedule redraw() of viewers"); //$NON-NLS-1$ setSystem(true); } - + void addConsole(IConsole console) { synchronized (list) { list.add(console); } } - - public IStatus runInUIThread(IProgressMonitor monitor) { + + @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]; @@ -125,27 +126,29 @@ public class ConsoleManager implements IConsoleManager { return Status.OK_STATUS; } } - + /** * Notifies a console listener of additions or removals */ class ConsoleNotifier implements ISafeRunnable { - + private IConsoleListener fListener; private int fType; private IConsole[] fChanged; - + /* (non-Javadoc) * @see org.eclipse.core.runtime.ISafeRunnable#handleException(java.lang.Throwable) */ + @Override public void handleException(Throwable exception) { - IStatus status = new Status(IStatus.ERROR, ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.INTERNAL_ERROR, ConsoleMessages.ConsoleManager_0, exception); + IStatus status = new Status(IStatus.ERROR, ConsolePlugin.getUniqueIdentifier(), IConsoleConstants.INTERNAL_ERROR, ConsoleMessages.ConsoleManager_0, exception); ConsolePlugin.log(status); } /* (non-Javadoc) * @see org.eclipse.core.runtime.ISafeRunnable#run() */ + @Override public void run() throws Exception { switch (fType) { case ADDED: @@ -154,12 +157,14 @@ public class ConsoleManager implements IConsoleManager { case REMOVED: fListener.consolesRemoved(fChanged); break; + default: + break; } } /** * Notifies the given listener of the adds/removes - * + * * @param consoles the consoles that changed * @param update the type of change */ @@ -173,12 +178,12 @@ public class ConsoleManager implements IConsoleManager { for (int i= 0; i < copiedListeners.length; i++) { fListener = (IConsoleListener)copiedListeners[i]; SafeRunner.run(this); - } + } fChanged = null; - fListener = null; + fListener = null; } - } - + } + public void registerConsoleView(ConsoleView view) { synchronized (fConsoleViews) { fConsoleViews.add(view); @@ -189,10 +194,11 @@ public class ConsoleManager implements IConsoleManager { fConsoleViews.remove(view); } } - + /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleManager#addConsoleListener(org.eclipse.ui.console.IConsoleListener) */ + @Override public void addConsoleListener(IConsoleListener listener) { if (fListeners == null) { fListeners = new ListenerList(); @@ -203,6 +209,7 @@ public class ConsoleManager implements IConsoleManager { /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleManager#removeConsoleListener(org.eclipse.ui.console.IConsoleListener) */ + @Override public void removeConsoleListener(IConsoleListener listener) { if (fListeners != null) { fListeners.remove(listener); @@ -212,8 +219,9 @@ public class ConsoleManager implements IConsoleManager { /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleManager#addConsoles(org.eclipse.ui.console.IConsole[]) */ + @Override public void addConsoles(IConsole[] consoles) { - List added = new ArrayList(consoles.length); + List<IConsole> added = new ArrayList<IConsole>(consoles.length); synchronized (fConsoles) { for (int i = 0; i < consoles.length; i++) { IConsole console = consoles[i]; @@ -225,18 +233,19 @@ public class ConsoleManager implements IConsoleManager { fConsoles.add(console); added.add(console); } - } + } } if (!added.isEmpty()) { - fireUpdate((IConsole[])added.toArray(new IConsole[added.size()]), ADDED); + fireUpdate(added.toArray(new IConsole[added.size()]), ADDED); } } /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleManager#removeConsoles(org.eclipse.ui.console.IConsole[]) */ + @Override public void removeConsoles(IConsole[] consoles) { - List removed = new ArrayList(consoles.length); + List<IConsole> removed = new ArrayList<IConsole>(consoles.length); synchronized (fConsoles) { for (int i = 0; i < consoles.length; i++) { IConsole console = consoles[i]; @@ -246,43 +255,45 @@ public class ConsoleManager implements IConsoleManager { } } if (!removed.isEmpty()) { - fireUpdate((IConsole[])removed.toArray(new IConsole[removed.size()]), REMOVED); + fireUpdate(removed.toArray(new IConsole[removed.size()]), REMOVED); } } /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleManager#getConsoles() */ + @Override public IConsole[] getConsoles() { synchronized (fConsoles) { - return (IConsole[])fConsoles.toArray(new IConsole[fConsoles.size()]); + return fConsoles.toArray(new IConsole[fConsoles.size()]); } } /** * Fires notification. - * + * * @param consoles consoles added/removed * @param type ADD or REMOVE */ private void fireUpdate(IConsole[] consoles, int type) { new ConsoleNotifier().notify(consoles, type); } - - + + private class ShowConsoleViewJob extends WorkbenchJob { - private IConsole console; - + private IConsole console; + ShowConsoleViewJob() { super("Show Console View"); //$NON-NLS-1$ setSystem(true); setPriority(Job.SHORT); } - + void setConsole(IConsole console) { this.console = console; } - + + @Override public IStatus runInUIThread(IProgressMonitor monitor) { boolean consoleFound = false; IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); @@ -290,9 +301,8 @@ public class ConsoleManager implements IConsoleManager { IWorkbenchPage page= window.getActivePage(); if (page != null) { synchronized (fConsoleViews) { - for (Iterator iter = fConsoleViews.iterator(); iter.hasNext();) { - ConsoleView consoleView = (ConsoleView) iter.next(); - if (consoleView.getSite().getPage().equals(page)) { + for (IConsoleView consoleView : fConsoleViews) { + if (consoleView.getSite().getPage().equals(page)) { boolean consoleVisible = page.isPartVisible(consoleView); if (consoleVisible) { consoleFound = true; @@ -303,9 +313,9 @@ public class ConsoleManager implements IConsoleManager { consoleView.display(console); } } - } + } } - + if (!consoleFound) { try { IConsoleView consoleView = (IConsoleView) page.showView(IConsoleConstants.ID_CONSOLE_VIEW, null, IWorkbenchPage.VIEW_CREATE); @@ -313,7 +323,7 @@ public class ConsoleManager implements IConsoleManager { if (bringToTop) { page.bringToTop(consoleView); } - consoleView.display(console); + consoleView.display(console); } catch (PartInitException pie) { ConsolePlugin.log(pie); } @@ -322,18 +332,19 @@ public class ConsoleManager implements IConsoleManager { } console = null; return Status.OK_STATUS; - } + } } - + private ShowConsoleViewJob showJob = new ShowConsoleViewJob(); /** * @see IConsoleManager#showConsoleView(IConsole) */ + @Override public void showConsoleView(final IConsole console) { showJob.setConsole(console); showJob.schedule(100); - } - + } + /** * Returns whether the given console view should be brought to the top. * The view should not be brought to the top if the view is pinned on @@ -350,14 +361,16 @@ public class ConsoleManager implements IConsoleManager { } return bringToTop; } - + /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleManager#warnOfContentChange(org.eclipse.ui.console.IConsole) */ + @Override public void warnOfContentChange(final IConsole console) { if (!fWarnQueued) { fWarnQueued = true; Job job = new UIJob(ConsolePlugin.getStandardDisplay(), ConsoleMessages.ConsoleManager_consoleContentChangeJob) { + @Override public IStatus runInUIThread(IProgressMonitor monitor) { IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { @@ -367,8 +380,8 @@ public class ConsoleManager implements IConsoleManager { if (consoleView != null) { consoleView.warnOfContentChange(console); } - } - } + } + } fWarnQueued = false; return Status.OK_STATUS; } @@ -381,26 +394,27 @@ public class ConsoleManager implements IConsoleManager { /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleManager#getPatternMatchListenerDelegates(org.eclipse.ui.console.IConsole) */ - public IPatternMatchListener[] createPatternMatchListeners(IConsole console) { + @Override + public IPatternMatchListener[] createPatternMatchListeners(IConsole console) { if (fPatternMatchListeners == null) { - fPatternMatchListeners = new ArrayList(); + 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); + fPatternMatchListeners.add(extension); } } - ArrayList list = new ArrayList(); - for(Iterator i = fPatternMatchListeners.iterator(); i.hasNext(); ) { - PatternMatchListenerExtension extension = (PatternMatchListenerExtension) i.next(); + 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); @@ -416,7 +430,7 @@ public class ConsoleManager implements IConsoleManager { ConsolePlugin.log(e); } } - return (PatternMatchListener[])list.toArray(new PatternMatchListener[0]); + return list.toArray(new PatternMatchListener[0]); } /* (non-Javadoc) @@ -424,7 +438,7 @@ public class ConsoleManager implements IConsoleManager { */ public IConsolePageParticipant[] getPageParticipants(IConsole console) { if(fPageParticipants == null) { - fPageParticipants = new ArrayList(); + 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++) { @@ -433,9 +447,9 @@ public class ConsoleManager implements IConsoleManager { fPageParticipants.add(extension); } } - ArrayList list = new ArrayList(); - for(Iterator i = fPageParticipants.iterator(); i.hasNext(); ) { - ConsolePageParticipantExtension extension = (ConsolePageParticipantExtension) i.next(); + 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()); @@ -444,7 +458,7 @@ public class ConsoleManager implements IConsoleManager { ConsolePlugin.log(e); } } - return (IConsolePageParticipant[]) list.toArray(new IConsolePageParticipant[0]); + return list.toArray(new IConsolePageParticipant[0]); } /* (non-Javadoc) @@ -452,20 +466,21 @@ public class ConsoleManager implements IConsoleManager { */ public ConsoleFactoryExtension[] getConsoleFactoryExtensions() { if (fConsoleFactoryExtensions == null) { - fConsoleFactoryExtensions = new ArrayList(); + 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 (ConsoleFactoryExtension[]) fConsoleFactoryExtensions.toArray(new ConsoleFactoryExtension[0]); + return fConsoleFactoryExtensions.toArray(new ConsoleFactoryExtension[0]); } - - - public void refresh(final IConsole console) { + + + @Override + public void refresh(final IConsole console) { fRepaintJob.addConsole(console); - fRepaintJob.schedule(50); + fRepaintJob.schedule(50); } } 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 37a522f51..9bf749569 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -33,31 +33,33 @@ public class ConsolePageParticipantExtension implements IPluginContribution { /* (non-Javadoc) * @see org.eclipse.ui.IPluginContribution#getLocalId() */ - public String getLocalId() { + @Override + public String getLocalId() { return fConfig.getAttribute("id"); //$NON-NLS-1$ } /* (non-Javadoc) * @see org.eclipse.ui.IPluginContribution#getPluginId() */ - public String getPluginId() { + @Override + public String getPluginId() { 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 evaluationResult == EvaluationResult.TRUE; } return true; } - + public Expression getEnablementExpression() throws CoreException { if (fEnablementExpression == null) { IConfigurationElement[] elements = fConfig.getChildren(ExpressionTagNames.ENABLEMENT); - IConfigurationElement enablement = elements.length > 0 ? elements[0] : null; + IConfigurationElement enablement = elements.length > 0 ? elements[0] : null; if (enablement != null) { fEnablementExpression = ExpressionConverter.getDefault().perform(enablement); 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 e765d7a61..d445277c0 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 @@ -36,7 +36,7 @@ public class ConsolePatternMatcher implements IDocumentListener { /** * Collection of compiled pattern match listeners */ - private ArrayList fPatterns = new ArrayList(); + private ArrayList<CompiledPatternMatchListener> fPatterns = new ArrayList<CompiledPatternMatchListener>(); private TextConsole fConsole; @@ -56,10 +56,11 @@ public class ConsolePatternMatcher implements IDocumentListener { /* * (non-Javadoc) - * + * * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) */ - protected IStatus run(IProgressMonitor monitor) { + @Override + protected IStatus run(IProgressMonitor monitor) { IDocument doc = fConsole.getDocument(); String text = null; int prevBaseOffset = -1; @@ -170,11 +171,12 @@ public class ConsolePatternMatcher implements IDocumentListener { return Status.OK_STATUS; } - public boolean belongsTo(Object family) { + @Override + public boolean belongsTo(Object family) { return family == fConsole; } - - + + } private class CompiledPatternMatchListener { @@ -203,21 +205,18 @@ public class ConsolePatternMatcher implements IDocumentListener { /** * 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) { - - // check for dups - for (Iterator iter = fPatterns.iterator(); iter.hasNext();) { - CompiledPatternMatchListener element = (CompiledPatternMatchListener) iter.next(); - if (element.listener == matchListener) { - return; - } - } - + 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$ } @@ -238,14 +237,14 @@ public class ConsolePatternMatcher implements IDocumentListener { /** * 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 iter = fPatterns.iterator(); iter.hasNext();) { - CompiledPatternMatchListener element = (CompiledPatternMatchListener) iter.next(); + for (Iterator<CompiledPatternMatchListener> iter = fPatterns.iterator(); iter.hasNext();) { + CompiledPatternMatchListener element = iter.next(); if (element.listener == matchListener) { iter.remove(); matchListener.disconnect(); @@ -257,46 +256,42 @@ public class ConsolePatternMatcher implements IDocumentListener { public void disconnect() { fMatchJob.cancel(); synchronized (fPatterns) { - Iterator iterator = fPatterns.iterator(); - while (iterator.hasNext()) { - CompiledPatternMatchListener notifier = (CompiledPatternMatchListener) iterator.next(); - notifier.dispose(); - } + for (CompiledPatternMatchListener listener : fPatterns) { + listener.dispose(); + } fPatterns.clear(); } } /* * (non-Javadoc) - * + * * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) */ - public void documentAboutToBeChanged(DocumentEvent event) { + @Override + public void documentAboutToBeChanged(DocumentEvent event) { } /* * (non-Javadoc) - * + * * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) */ - public void documentChanged(DocumentEvent event) { + @Override + public void documentChanged(DocumentEvent event) { if (event.fLength > 0) { synchronized (fPatterns) { if (event.fDocument.getLength() == 0) { // document has been cleared, reset match listeners - Iterator iter = fPatterns.iterator(); - while (iter.hasNext()) { - CompiledPatternMatchListener notifier = (CompiledPatternMatchListener) iter.next(); - notifier.end = 0; - } + for (CompiledPatternMatchListener notifier : fPatterns) { + notifier.end = 0; + } } else { - if (event.fOffset == 0) { + if (event.fOffset == 0) { //document was trimmed - Iterator iter = fPatterns.iterator(); - while (iter.hasNext()) { - CompiledPatternMatchListener notifier = (CompiledPatternMatchListener) iter.next(); - notifier.end = notifier.end > event.fLength ? notifier.end-event.fLength : 0; - } + for (CompiledPatternMatchListener notifier : fPatterns) { + notifier.end = notifier.end > event.fLength ? notifier.end - event.fLength : 0; + } } } } @@ -304,7 +299,7 @@ public class ConsolePatternMatcher implements IDocumentListener { fMatchJob.schedule(); } - + public void forceFinalMatching() { fScheduleFinal = true; fMatchJob.schedule(); 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 46dc213fe..2909471c5 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 @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -15,7 +15,7 @@ import org.eclipse.ui.console.IConsole; /** * Tests if an IOConsole's type matches the expected value - * + * * @since 3.1 */ public class ConsoleTypePropertyTester extends PropertyTester { @@ -23,7 +23,8 @@ 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) */ - public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { + @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; 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 45d9bc823..eb5ef07df 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -18,15 +18,6 @@ import java.util.Map; import org.eclipse.core.runtime.ISafeRunnable; import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.SafeRunner; - -import org.eclipse.swt.events.MouseAdapter; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.ToolBar; -import org.eclipse.swt.widgets.ToolItem; - import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IToolBarManager; @@ -36,7 +27,13 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.IBasicPropertyConstants; - +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; import org.eclipse.ui.IPartListener2; import org.eclipse.ui.IViewReference; import org.eclipse.ui.IViewSite; @@ -63,55 +60,55 @@ import org.eclipse.ui.progress.IWorkbenchSiteProgressService; /** * Page book console view. - * + * * @since 3.0 */ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleListener, IPropertyChangeListener, IPartListener2 { - + /** * Whether this console is pinned. */ private boolean fPinned = false; - + /** * Stack of consoles in MRU order */ - private List fStack = new ArrayList(); - + private List<IConsole> fStack = new ArrayList<IConsole>(); + /** * The console being displayed, or <code>null</code> if none */ private IConsole fActiveConsole = null; - + /** * Map of consoles to dummy console parts (used to close pages) */ - private Map fConsoleToPart; - + private Map<IConsole, ConsoleWorkbenchPart> fConsoleToPart; + /** * Map of consoles to array of page participants */ - private Map fConsoleToPageParticipants; - + private Map<IConsole, ListenerList> fConsoleToPageParticipants; + /** * Map of parts to consoles */ - private Map fPartToConsole; - + private Map<ConsoleWorkbenchPart, IConsole> fPartToConsole; + /** * Whether this view is active */ private boolean fActive = false; - + /** * 'In Console View' context */ private IContextActivation fActivatedContext; - + // actions - private PinConsoleAction fPinAction = null; + private PinConsoleAction fPinAction = null; private ConsoleDropDownAction fDisplayConsoleAction = null; - + private OpenConsoleAction fOpenConsoleAction = null; private boolean fScrollLock; @@ -123,6 +120,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ + @Override public void propertyChange(PropertyChangeEvent event) { Object source = event.getSource(); if (source instanceof IConsole && event.getProperty().equals(IBasicPropertyConstants.P_TEXT)) { @@ -136,6 +134,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart) */ + @Override public void partClosed(IWorkbenchPart part) { super.partClosed(part); fPinAction.update(); @@ -144,6 +143,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.console.IConsoleView#getConsole() */ + @Override public IConsole getConsole() { return fActiveConsole; } @@ -151,27 +151,28 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.part.PageBookView#showPageRec(org.eclipse.ui.part.PageBookView.PageRec) */ + @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 = (IConsole)fPartToConsole.get(pageRec.part); + IConsole console = fPartToConsole.get(pageRec.part); if (!fStack.contains(console)) { fStack.add(console); } return; } - - IConsole recConsole = (IConsole)fPartToConsole.get(pageRec.part); + + 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 = (IConsole) fStack.get(0); + tos = fStack.get(0); } if (tos != null && !tos.equals(fActiveConsole) && fActive) { deactivateParticipants(tos); @@ -181,7 +182,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL fStack.add(0,fActiveConsole); activateParticipants(fActiveConsole); } - updateTitle(); + updateTitle(); updateHelp(); // update console actions if (fPinAction != null) { @@ -192,10 +193,10 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL ((IOConsolePage)page).setAutoScroll(!fScrollLock); } } - + /** * Activates the participants for the given console, if any. - * + * * @param console */ private void activateParticipants(IConsole console) { @@ -207,9 +208,11 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL for (int i = 0; i < participants.length; i++) { final IConsolePageParticipant participant = (IConsolePageParticipant) participants[i]; SafeRunner.run(new ISafeRunnable() { + @Override public void run() throws Exception { participant.activated(); } + @Override public void handleException(Throwable exception) { ConsolePlugin.log(exception); listeners.remove(participant); @@ -222,10 +225,10 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /** * Returns a stack of consoles in the view in MRU order. - * + * * @return a stack of consoles in the view in MRU order */ - protected List getConsoleStack() { + protected List<IConsole> getConsoleStack() { return fStack; } @@ -235,16 +238,16 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL protected void updateTitle() { IConsole console = getConsole(); if (console == null) { - setContentDescription(ConsoleMessages.ConsoleView_0); + setContentDescription(ConsoleMessages.ConsoleView_0); } else { String newName = console.getName(); String oldName = getContentDescription(); if (newName!=null && !(newName.equals(oldName))) { - setContentDescription(console.getName()); + setContentDescription(console.getName()); } } } - + protected void updateHelp() { IConsole console = getConsole(); String helpContextId = null; @@ -261,19 +264,22 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.part.PageBookView#doDestroyPage(org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.part.PageBookView.PageRec) */ + @Override protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) { - IConsole console = (IConsole)fPartToConsole.get(part); - + IConsole console = fPartToConsole.get(part); + // dispose page participants - ListenerList listeners = (ListenerList) fConsoleToPageParticipants.remove(console); + ListenerList listeners = fConsoleToPageParticipants.remove(console); if (listeners != null) { Object[] participants = listeners.getListeners(); for (int i = 0; i < participants.length; i++) { final IConsolePageParticipant participant = (IConsolePageParticipant) participants[i]; SafeRunner.run(new ISafeRunnable() { + @Override public void run() throws Exception { participant.dispose(); } + @Override public void handleException(Throwable exception) { ConsolePlugin.log(exception); } @@ -285,31 +291,32 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL page.dispose(); pageRecord.dispose(); console.removePropertyChangeListener(this); - + // empty cross-reference cache fPartToConsole.remove(part); fConsoleToPart.remove(console); if (fPartToConsole.isEmpty()) { fActiveConsole = null; } - + // update console actions - fPinAction.update(); + fPinAction.update(); } - + /** * Returns the page participants registered for the given console, or <code>null</code> - * + * * @param console * @return registered page participants or <code>null</code> */ private ListenerList getParticipants(IConsole console) { - return (ListenerList) fConsoleToPageParticipants.get(console); + return fConsoleToPageParticipants.get(console); } /* (non-Javadoc) * @see org.eclipse.ui.part.PageBookView#doCreatePage(org.eclipse.ui.IWorkbenchPart) */ + @Override protected PageRec doCreatePage(IWorkbenchPart dummyPart) { ConsoleWorkbenchPart part = (ConsoleWorkbenchPart)dummyPart; final IConsole console = part.getConsole(); @@ -317,7 +324,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL initPage(page); page.createControl(getPageBook()); console.addPropertyChangeListener(this); - + // initialize page participants IConsolePageParticipant[] consoleParticipants = ((ConsoleManager)getConsoleManager()).getPageParticipants(console); final ListenerList participants = new ListenerList(); @@ -329,16 +336,18 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL for (int i = 0; i < listeners.length; i++) { final IConsolePageParticipant participant = (IConsolePageParticipant) listeners[i]; SafeRunner.run(new ISafeRunnable() { + @Override public void run() throws Exception { participant.init(page, console); } + @Override public void handleException(Throwable exception) { ConsolePlugin.log(exception); participants.remove(participant); } }); } - + PageRec rec = new PageRec(dummyPart, page); return rec; } @@ -346,6 +355,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.part.PageBookView#isImportant(org.eclipse.ui.IWorkbenchPart) */ + @Override protected boolean isImportant(IWorkbenchPart part) { return part instanceof ConsoleWorkbenchPart; } @@ -353,6 +363,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPart#dispose() */ + @Override public void dispose() { IViewSite site = getViewSite(); if(site != null) { @@ -360,13 +371,13 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL } super.dispose(); ConsoleManager consoleManager = (ConsoleManager) ConsolePlugin.getDefault().getConsoleManager(); - consoleManager.removeConsoleListener(this); + consoleManager.removeConsoleListener(this); consoleManager.unregisterConsoleView(this); } /** * Returns the console manager. - * + * * @return the console manager */ private IConsoleManager getConsoleManager() { @@ -376,6 +387,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.part.PageBookView#createDefaultPage(org.eclipse.ui.part.PageBook) */ + @Override protected IPage createDefaultPage(PageBook book) { MessagePage page = new MessagePage(); page.createControl(getPageBook()); @@ -386,9 +398,11 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleListener#consolesAdded(org.eclipse.ui.console.IConsole[]) */ + @Override public void consolesAdded(final IConsole[] consoles) { if (isAvailable()) { Runnable r = new Runnable() { + @Override public void run() { for (int i = 0; i < consoles.length; i++) { if (isAvailable()) { @@ -417,15 +431,17 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleListener#consolesRemoved(org.eclipse.ui.console.IConsole[]) */ + @Override public void consolesRemoved(final IConsole[] consoles) { if (isAvailable()) { Runnable r = new Runnable() { + @Override public void run() { for (int i = 0; i < consoles.length; i++) { if (isAvailable()) { IConsole console = consoles[i]; fStack.remove(console); - ConsoleWorkbenchPart part = (ConsoleWorkbenchPart)fConsoleToPart.get(console); + ConsoleWorkbenchPart part = fConsoleToPart.get(console); if (part != null) { partClosed(part); } @@ -448,14 +464,14 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL */ public ConsoleView() { super(); - fConsoleToPart = new HashMap(); - fPartToConsole = new HashMap(); - fConsoleToPageParticipants = new HashMap(); - + fConsoleToPart = new HashMap<IConsole, ConsoleWorkbenchPart>(); + fPartToConsole = new HashMap<ConsoleWorkbenchPart, IConsole>(); + fConsoleToPageParticipants = new HashMap<IConsole, ListenerList>(); + ConsoleManager consoleManager = (ConsoleManager) ConsolePlugin.getDefault().getConsoleManager(); consoleManager.registerConsoleView(this); } - + protected void createActions() { fPinAction = new PinConsoleAction(this); fDisplayConsoleAction = new ConsoleDropDownAction(this); @@ -477,6 +493,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL ToolBarManager tbm= (ToolBarManager) mgr; final ToolBar tb= tbm.getControl(); tb.addMouseListener(new MouseAdapter() { + @Override public void mouseDown(MouseEvent e) { ToolItem ti= tb.getItem(new Point(e.x, e.y)); if (ti != null) { @@ -501,6 +518,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleView#display(org.eclipse.ui.console.IConsole) */ + @Override public void display(IConsole console) { if (fPinned && fActiveConsole != null) { return; @@ -508,7 +526,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL if (console.equals(fActiveConsole)) { return; } - ConsoleWorkbenchPart part = (ConsoleWorkbenchPart)fConsoleToPart.get(console); + ConsoleWorkbenchPart part = fConsoleToPart.get(console); if (part != null) { partActivated(part); } @@ -517,6 +535,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /*/* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleView#pin(org.eclipse.ui.console.IConsole) */ + @Override public void setPinned(boolean pin) { fPinned = pin; if (fPinAction != null) { @@ -527,6 +546,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleView#isPinned() */ + @Override public boolean isPinned() { return fPinned; } @@ -534,14 +554,15 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.part.PageBookView#getBootstrapPart() */ + @Override protected IWorkbenchPart getBootstrapPart() { return null; } - + /** * Registers the given runnable with the display * associated with this view's control, if any. - * + * * @see org.eclipse.swt.widgets.Display#asyncExec(java.lang.Runnable) */ public void asyncExec(Runnable r) { @@ -549,7 +570,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL getPageBook().getDisplay().asyncExec(r); } } - + /** * Creates this view's underlying viewer and actions. * Hooks a pop-up menu to the underlying viewer's control, @@ -566,6 +587,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL * </ul> * @see IWorkbenchPart#createPartControl(Composite) */ + @Override public void createPartControl(Composite parent) { super.createPartControl(parent); createActions(); @@ -577,34 +599,40 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL getViewSite().getPage().addPartListener((IPartListener2)this); initPageSwitcher(); } - + /** * Initialize the PageSwitcher. */ private void initPageSwitcher() { new PageSwitcher(this) { + @Override public void activatePage(Object page) { ShowConsoleAction.showConsole((IConsole) page, ConsoleView.this); } + @Override public ImageDescriptor getImageDescriptor(Object page) { return ((IConsole) page).getImageDescriptor(); } + @Override public String getName(Object page) { return ((IConsole) page).getName(); } + @Override public Object[] getPages() { return getConsoleManager().getConsoles(); } - + + @Override public int getCurrentPageIndex() { IConsole currentConsole= getConsole(); IConsole[] consoles= getConsoleManager().getConsoles(); for (int i= 0; i < consoles.length; i++) { - if (consoles[i].equals(currentConsole)) + if (consoles[i].equals(currentConsole)) { return i; + } } return super.getCurrentPageIndex(); } @@ -620,14 +648,15 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL IConsole[] consoles = manager.getConsoles(); consolesAdded(consoles); // add as a listener - manager.addConsoleListener(this); - } - + manager.addConsoleListener(this); + } + /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleView#warnOfContentChange(org.eclipse.ui.console.IConsole) */ + @Override public void warnOfContentChange(IConsole console) { - IWorkbenchPart part = (IWorkbenchPart)fConsoleToPart.get(console); + IWorkbenchPart part = fConsoleToPart.get(console); if (part != null) { IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) part.getSite().getAdapter(IWorkbenchSiteProgressService.class); if (service != null) { @@ -635,8 +664,9 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL } } } - - public Object getAdapter(Class key) { + + @Override + public Object getAdapter(Class key) { Object adpater = super.getAdapter(key); if (adpater == null) { IConsole console = getConsole(); @@ -661,6 +691,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference) */ + @Override public void partActivated(IWorkbenchPartReference partRef) { if (isThisPart(partRef)) { fActive = true; @@ -675,18 +706,21 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference) */ + @Override public void partBroughtToTop(IWorkbenchPartReference partRef) { } /* (non-Javadoc) * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference) */ + @Override public void partClosed(IWorkbenchPartReference partRef) { } /* (non-Javadoc) * @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference) */ + @Override public void partDeactivated(IWorkbenchPartReference partRef) { if (isThisPart(partRef)) { fActive = false; @@ -697,10 +731,10 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL } } } - + /** - * Returns if the specified part reference is to this view part (if the part - * reference is the console view or not) + * Returns if the specified part reference is to this view part (if the part + * reference is the console view or not) * @param partRef * @return true if the specified part reference is the console view */ @@ -724,7 +758,7 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /** * Deactivates participants for the given console, if any. - * + * * @param console console to deactivate */ private void deactivateParticipants(IConsole console) { @@ -736,9 +770,11 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL for (int i = 0; i < participants.length; i++) { final IConsolePageParticipant participant = (IConsolePageParticipant) participants[i]; SafeRunner.run(new ISafeRunnable() { + @Override public void run() throws Exception { participant.deactivated(); } + @Override public void handleException(Throwable exception) { ConsolePlugin.log(exception); listeners.remove(participant); @@ -752,31 +788,36 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference) */ + @Override public void partOpened(IWorkbenchPartReference partRef) { } /* (non-Javadoc) * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference) */ + @Override public void partHidden(IWorkbenchPartReference partRef) { } /* (non-Javadoc) * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference) */ + @Override public void partVisible(IWorkbenchPartReference partRef) { } /* (non-Javadoc) * @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference) */ - public void partInputChanged(IWorkbenchPartReference partRef) { + @Override + public void partInputChanged(IWorkbenchPartReference partRef) { } /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleView#setScrollLock(boolean) */ - public void setScrollLock(boolean scrollLock) { + @Override + public void setScrollLock(boolean scrollLock) { fScrollLock = scrollLock; IPage page = getCurrentPage(); @@ -788,14 +829,16 @@ public class ConsoleView extends PageBookView implements IConsoleView, IConsoleL /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleView#getScrollLock() */ - public boolean getScrollLock() { + @Override + public boolean getScrollLock() { return fScrollLock; } - + /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleView#pin(org.eclipse.ui.console.IConsole) */ - public void pin(IConsole console) { + @Override + public void pin(IConsole console) { if (console == null) { setPinned(false); } else { 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 8a32fc8c1..5fe80b8df 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 @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -24,10 +24,11 @@ public class ConsoleViewConsoleFactory implements IConsoleFactory { /* * (non-Javadoc) - * + * * @see org.eclipse.ui.console.IConsoleFactory#openConsole() */ - public void openConsole() { + @Override + public void openConsole() { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page = window.getActivePage(); 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 e3377a4dc..5a9acda45 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 @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -24,10 +24,11 @@ public class ConsoleWorkbenchPart implements IWorkbenchPart { private IConsole fConsole = null; private IWorkbenchPartSite fSite = null; - + /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ + @Override public boolean equals(Object obj) { return (obj instanceof ConsoleWorkbenchPart) && fConsole.equals(((ConsoleWorkbenchPart)obj).fConsole); @@ -36,6 +37,7 @@ public class ConsoleWorkbenchPart implements IWorkbenchPart { /* (non-Javadoc) * @see java.lang.Object#hashCode() */ + @Override public int hashCode() { return fConsole.hashCode(); } @@ -52,24 +54,28 @@ public class ConsoleWorkbenchPart implements IWorkbenchPart { /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPart#addPropertyListener(org.eclipse.ui.IPropertyListener) */ + @Override public void addPropertyListener(IPropertyListener listener) { } /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) */ + @Override public void createPartControl(Composite parent) { } /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPart#dispose() */ + @Override public void dispose() { } /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPart#getSite() */ + @Override public IWorkbenchPartSite getSite() { return fSite; } @@ -77,6 +83,7 @@ public class ConsoleWorkbenchPart implements IWorkbenchPart { /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPart#getTitle() */ + @Override public String getTitle() { return ""; //$NON-NLS-1$ } @@ -84,6 +91,7 @@ public class ConsoleWorkbenchPart implements IWorkbenchPart { /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPart#getTitleImage() */ + @Override public Image getTitleImage() { return null; } @@ -91,6 +99,7 @@ public class ConsoleWorkbenchPart implements IWorkbenchPart { /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPart#getTitleToolTip() */ + @Override public String getTitleToolTip() { return ""; //$NON-NLS-1$ } @@ -98,25 +107,28 @@ public class ConsoleWorkbenchPart implements IWorkbenchPart { /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPart#removePropertyListener(org.eclipse.ui.IPropertyListener) */ + @Override public void removePropertyListener(IPropertyListener listener) { } /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPart#setFocus() */ + @Override public void setFocus() { } /* (non-Javadoc) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) */ + @Override public Object getAdapter(Class adapter) { return null; } /** * Returns the console associated with this part. - * + * * @return console associated with this part */ protected IConsole getConsole() { 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 492dfd552..5a735ccf9 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,7 +17,7 @@ import org.eclipse.ui.console.TextConsoleViewer; /** * Follows a hyperlink in the console - * + * * @since 3.1 */ public class FollowHyperlinkAction extends Action { @@ -28,8 +28,8 @@ public class FollowHyperlinkAction extends Action { * Constructs a follow link action */ public FollowHyperlinkAction(TextConsoleViewer consoleViewer) { - super(ConsoleMessages.FollowHyperlinkAction_0); - setToolTipText(ConsoleMessages.FollowHyperlinkAction_1); + super(ConsoleMessages.FollowHyperlinkAction_0); + setToolTipText(ConsoleMessages.FollowHyperlinkAction_1); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_OPEN_LINK_ACTION); this.viewer = consoleViewer; } @@ -37,14 +37,16 @@ public class FollowHyperlinkAction extends Action { /* (non-Javadoc) * @see org.eclipse.jface.action.IAction#isEnabled() */ - public boolean isEnabled() { + @Override + public boolean isEnabled() { return viewer.getHyperlink() != null; } - + /* * (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ + @Override public void run() { IHyperlink link = viewer.getHyperlink(); if (link != null) { 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 3ed6aa714..0c78ed550 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,11 +12,10 @@ package org.eclipse.ui.internal.console; import org.eclipse.jface.text.BadPositionCategoryException; import org.eclipse.jface.text.DefaultPositionUpdater; -import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition; /** * When any region of a hyperlink is replaced, the hyperlink needs to be deleted. - * + * * @since 3.3 */ public class HyperlinkUpdater extends DefaultPositionUpdater { @@ -32,6 +31,7 @@ public class HyperlinkUpdater extends DefaultPositionUpdater { * * @return <code>true</code> if position has NOT been deleted */ + @Override protected boolean notDeleted() { int positionEnd = fPosition.offset + fPosition.length - 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 3f8d72fe9..3d8a1de56 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 @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -24,9 +24,9 @@ import org.eclipse.ui.console.TextConsoleViewer; /** * A page for an IOConsole - * + * * @since 3.1 - * + * */ public class IOConsolePage extends TextConsolePage { @@ -40,7 +40,8 @@ public class IOConsolePage extends TextConsolePage { super(console, view); fPropertyChangeListener = new IPropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { + @Override + public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); if (property.equals(IConsoleConstants.P_CONSOLE_OUTPUT_COMPLETE)) { setReadOnly(); @@ -52,10 +53,11 @@ public class IOConsolePage extends TextConsolePage { /* * (non-Javadoc) - * + * * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) */ - public void createControl(Composite parent) { + @Override + public void createControl(Composite parent) { super.createControl(parent); if (fReadOnly) { IOConsoleViewer viewer = (IOConsoleViewer) getViewer(); @@ -65,11 +67,12 @@ public class IOConsolePage extends TextConsolePage { /* * (non-Javadoc) - * + * * @see org.eclipse.ui.console.TextConsolePage#createViewer(org.eclipse.swt.widgets.Composite, * org.eclipse.ui.console.TextConsole) */ - protected TextConsoleViewer createViewer(Composite parent) { + @Override + protected TextConsoleViewer createViewer(Composite parent) { return new IOConsoleViewer(parent, (TextConsole)getConsole()); } @@ -95,7 +98,8 @@ public class IOConsolePage extends TextConsolePage { /* (non-Javadoc) * @see org.eclipse.ui.console.TextConsolePage#createActions() */ - protected void createActions() { + @Override + protected void createActions() { super.createActions(); fScrollLockAction = new ScrollLockAction(getConsoleView()); setAutoScroll(!fScrollLockAction.isChecked()); @@ -104,7 +108,8 @@ public class IOConsolePage extends TextConsolePage { /* (non-Javadoc) * @see org.eclipse.ui.console.TextConsolePage#contextMenuAboutToShow(org.eclipse.jface.action.IMenuManager) */ - protected void contextMenuAboutToShow(IMenuManager menuManager) { + @Override + protected void contextMenuAboutToShow(IMenuManager menuManager) { super.contextMenuAboutToShow(menuManager); menuManager.add(fScrollLockAction); IOConsoleViewer viewer = (IOConsoleViewer) getViewer(); @@ -116,20 +121,22 @@ public class IOConsolePage extends TextConsolePage { /* * (non-Javadoc) - * + * * @see org.eclipse.ui.console.TextConsolePage#configureToolBar(org.eclipse.jface.action.IToolBarManager) */ - protected void configureToolBar(IToolBarManager mgr) { + @Override + protected void configureToolBar(IToolBarManager mgr) { super.configureToolBar(mgr); mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fScrollLockAction); } /* * (non-Javadoc) - * + * * @see org.eclipse.ui.part.IPage#dispose() */ - public void dispose() { + @Override + public void dispose() { if (fScrollLockAction != null) { fScrollLockAction.dispose(); fScrollLockAction = null; 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 519cbc76b..bd20169be 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 @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2004, 2008 IBM Corporation and others. + * Copyright (c) 2004, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -19,7 +19,7 @@ import org.eclipse.ui.console.IOConsoleOutputStream; /** * A region in an IOConsole's document. - * + * * @since 3.1 */ public class IOConsolePartition implements ITypedRegion { @@ -37,14 +37,14 @@ public class IOConsolePartition implements ITypedRegion { * 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. */ @@ -54,7 +54,7 @@ public class IOConsolePartition implements ITypedRegion { this.type = OUTPUT_PARTITION_TYPE; this.readOnly = true; } - + /** * Creates a new partition to contain input from a console */ @@ -65,7 +65,7 @@ public class IOConsolePartition implements ITypedRegion { this.type = INPUT_PARTITION_TYPE; this.readOnly = false; } - + /** * Inserts a string into this partition. * @param s The string to insert @@ -75,7 +75,7 @@ public class IOConsolePartition implements ITypedRegion { buffer.insert(insertOffset, s); length += s.length(); } - + /** * Deletes data from this partition. * @param delOffset @@ -85,12 +85,13 @@ public class IOConsolePartition implements ITypedRegion { buffer.delete(delOffset, delOffset+delLength); length -= delLength; } - + /* * (non-Javadoc) * @see org.eclipse.jface.text.ITypedRegion#getType() */ - public String getType() { + @Override + public String getType() { return type; } @@ -98,7 +99,8 @@ public class IOConsolePartition implements ITypedRegion { * (non-Javadoc) * @see org.eclipse.jface.text.IRegion#getLength() */ - public int getLength() { + @Override + public int getLength() { return length; } @@ -106,28 +108,29 @@ public class IOConsolePartition implements ITypedRegion { * (non-Javadoc) * @see org.eclipse.jface.text.IRegion#getOffset() */ - public int 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. @@ -135,7 +138,7 @@ public class IOConsolePartition implements ITypedRegion { public String getString() { return buffer.toString(); } - + /** * Returns a StyleRange object which may be used for setting the style * of this partition in a viewer. @@ -145,46 +148,46 @@ public class IOConsolePartition implements ITypedRegion { } /** - * Returns the font of the input stream if the type of the partition - * is <code>INPUT_PARTITION_TYPE</code>, otherwise it returns the output + * 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 + * 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() { @@ -197,10 +200,10 @@ public class IOConsolePartition implements ITypedRegion { public void clearBuffer() { buffer.setLength(0); } - + /** * Returns the underlying output stream - * + * * @return the underlying output stream */ IOConsoleOutputStream getStream() { 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 5a74807b2..6f32defb7 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -46,15 +46,15 @@ import org.eclipse.ui.progress.WorkbenchJob; public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocumentPartitionerExtension { private PendingPartition consoleClosedPartition; private IDocument document; - private ArrayList partitions; + private ArrayList<IOConsolePartition> partitions; /** * Blocks of data that have not yet been appended to the document. */ - private ArrayList pendingPartitions; + private ArrayList<PendingPartition> pendingPartitions; /** * A list of PendingPartitions to be appended by the updateJob */ - private ArrayList updatePartitions; + private ArrayList<PendingPartition> updatePartitions; /** * The last partition appended to the document */ @@ -62,7 +62,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum /** * Job that appends pending partitions to the document. */ - private QueueProcessingJob queueJob; + private QueueProcessingJob queueJob; /** * The input stream attached to this document. */ @@ -75,7 +75,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum * A list of partitions containing input from the console, that have * not been appended to the input stream yet. */ - private ArrayList inputPartitions; + private ArrayList<IOConsolePartition> inputPartitions; /** * offset used by updateJob */ @@ -89,64 +89,66 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum private boolean connected = false; private IOConsole console; - + private TrimJob trimJob = new TrimJob(); /** * Lock for appending to and removing from the document - used * to synchronize addition of new text/partitions in the update - * job and handling buffer overflow/clearing of the console. + * job and handling buffer overflow/clearing of the console. */ private Object overflowLock = new Object(); - - - private int fBuffer; - + + + private int fBuffer; + public IOConsolePartitioner(IOConsoleInputStream inputStream, IOConsole console) { this.inputStream = inputStream; this.console = console; trimJob.setRule(console.getSchedulingRule()); } - + public IDocument getDocument() { return document; } - + /* * (non-Javadoc) * @see org.eclipse.jface.text.IDocumentPartitioner#connect(org.eclipse.jface.text.IDocument) */ + @Override public void connect(IDocument doc) { document = doc; document.setDocumentPartitioner(this); lld = document.getLegalLineDelimiters(); - partitions = new ArrayList(); - pendingPartitions = new ArrayList(); - inputPartitions = new ArrayList(); + partitions = new ArrayList<IOConsolePartition>(); + pendingPartitions = new ArrayList<PendingPartition>(); + inputPartitions = new ArrayList<IOConsolePartition>(); queueJob = new QueueProcessingJob(); queueJob.setSystem(true); queueJob.setPriority(Job.INTERACTIVE); queueJob.setRule(console.getSchedulingRule()); connected = true; } - + public int getHighWaterMark() { return highWaterMark; } - + public int getLowWaterMark() { return lowWaterMark; } - + public void setWaterMarks(int low, int high) { lowWaterMark = low; highWaterMark = high; ConsolePlugin.getStandardDisplay().asyncExec(new Runnable() { + @Override public void run() { checkBufferSize(); } }); } - + /** * Notification from the console that all of its streams have been closed. */ @@ -157,13 +159,14 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum } queueJob.schedule(); //ensure that all pending partitions are processed. } - + /* * (non-Javadoc) * @see org.eclipse.jface.text.IDocumentPartitioner#disconnect() */ + @Override public void disconnect() { - synchronized (overflowLock) { + synchronized (overflowLock) { document = null; partitions.clear(); connected = false; @@ -173,112 +176,120 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum } } } - + /* * (non-Javadoc) * @see org.eclipse.jface.text.IDocumentPartitioner#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) */ + @Override public void documentAboutToBeChanged(DocumentEvent event) { } - + /* * (non-Javadoc) * @see org.eclipse.jface.text.IDocumentPartitioner#documentChanged(org.eclipse.jface.text.DocumentEvent) */ + @Override public boolean documentChanged(DocumentEvent event) { return documentChanged2(event) != null; } - + /* * (non-Javadoc) * @see org.eclipse.jface.text.IDocumentPartitioner#getLegalContentTypes() */ + @Override public String[] getLegalContentTypes() { return new String[] { IOConsolePartition.OUTPUT_PARTITION_TYPE, IOConsolePartition.INPUT_PARTITION_TYPE }; } - + /* * (non-Javadoc) * @see org.eclipse.jface.text.IDocumentPartitioner#getContentType(int) */ + @Override public String getContentType(int offset) { return getPartition(offset).getType(); } - + /* * (non-Javadoc) * @see org.eclipse.jface.text.IDocumentPartitioner#computePartitioning(int, int) */ - public ITypedRegion[] computePartitioning(int offset, int length) { + @Override + public ITypedRegion[] computePartitioning(int offset, int length) { int rangeEnd = offset + length; int left= 0; int right= partitions.size() - 1; int mid= 0; IOConsolePartition position= null; - + if (left == right) { - return new IOConsolePartition[]{(IOConsolePartition) partitions.get(0)}; + return new IOConsolePartition[]{partitions.get(0)}; } while (left < right) { - + mid= (left + right) / 2; - - position= (IOConsolePartition) partitions.get(mid); + + position= partitions.get(mid); if (rangeEnd < position.getOffset()) { - if (left == mid) + if (left == mid) { right= left; - else + } else { right= mid -1; + } } else if (offset > (position.getOffset() + position.getLength() - 1)) { - if (right == mid) + if (right == mid) { left= right; - else + } else { left= mid +1; + } } else { left= right= mid; } } - - - List list = new ArrayList(); + + + List<IOConsolePartition> list = new ArrayList<IOConsolePartition>(); int index = left - 1; if (index >= 0) { - position= (IOConsolePartition) partitions.get(index); + position= partitions.get(index); while (index >= 0 && (position.getOffset() + position.getLength()) > offset) { index--; if (index >= 0) { - position= (IOConsolePartition) partitions.get(index); + position= partitions.get(index); } - } + } } index++; - position= (IOConsolePartition) partitions.get(index); + position= partitions.get(index); while (index < partitions.size() && (position.getOffset() < rangeEnd)) { list.add(position); index++; if (index < partitions.size()) { - position= (IOConsolePartition) partitions.get(index); + position= partitions.get(index); } } - - return (ITypedRegion[]) list.toArray(new IOConsolePartition[list.size()]); - } - + return list.toArray(new IOConsolePartition[list.size()]); + } + + /* * (non-Javadoc) * @see org.eclipse.jface.text.IDocumentPartitioner#getPartition(int) */ + @Override public ITypedRegion getPartition(int offset) { for (int i = 0; i < partitions.size(); i++) { - ITypedRegion partition = (ITypedRegion) partitions.get(i); + ITypedRegion partition = partitions.get(i); int start = partition.getOffset(); int end = start + partition.getLength(); if (offset >= start && offset < end) { return partition; - } + } } - + if (lastPartition == null) { synchronized(partitions) { lastPartition = new IOConsolePartition(inputStream, ""); //$NON-NLS-1$ @@ -289,11 +300,11 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum } return lastPartition; } - + /** * Enforces the buffer size. - * When the number of lines in the document exceeds the high water mark, the - * beginning of the document is trimmed until the number of lines equals the + * When the number of lines in the document exceeds the high water mark, the + * beginning of the document is trimmed until the number of lines equals the * low water mark. */ private void checkBufferSize() { @@ -307,7 +318,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum } } } - + /** * Clears the console */ @@ -317,12 +328,13 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum trimJob.schedule(); } } - + /* * (non-Javadoc) - * + * * @see org.eclipse.jface.text.IDocumentPartitionerExtension#documentChanged2(org.eclipse.jface.text.DocumentEvent) */ + @Override public IRegion documentChanged2(DocumentEvent event) { if (document == null) { return null; //another thread disconnected the partitioner @@ -337,52 +349,51 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum lastPartition = null; return new Region(0, 0); } - - + + if (updateInProgress) { synchronized(partitions) { if (updatePartitions != null) { - for (Iterator i = updatePartitions.iterator(); i.hasNext(); ) { - PendingPartition pp = (PendingPartition) i.next(); - if (pp == consoleClosedPartition) { + 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); + partition.setOffset(firstOffset); lastPartition = partition; partitions.add(partition); } firstOffset += ppLen; - } + } } } } else {// user input. int amountDeleted = event.getLength() ; - + if (amountDeleted > 0) { - int offset = event.fOffset; + int offset = event.fOffset; IOConsolePartition partition = (IOConsolePartition) getPartition(offset); if(partition == lastPartition) { partition.delete(event.fOffset-partition.getOffset(), amountDeleted); - } + } } - + synchronized(partitions) { if (lastPartition == null || lastPartition.isReadOnly()) { - lastPartition = new IOConsolePartition(inputStream, event.fText); + lastPartition = new IOConsolePartition(inputStream, event.fText); lastPartition.setOffset(event.fOffset); partitions.add(lastPartition); inputPartitions.add(lastPartition); } else { lastPartition.insert(event.fText, (event.fOffset-lastPartition.getOffset())); } - + int lastLineDelimiter = -1; String partitionText = lastPartition.getString(); for (int i = 0; i < lld.length; i++) { @@ -397,9 +408,9 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum } if (lastLineDelimiter != -1) { StringBuffer input = new StringBuffer(); - Iterator it = inputPartitions.iterator(); + Iterator<IOConsolePartition> it = inputPartitions.iterator(); while (it.hasNext()) { - IOConsolePartition partition = (IOConsolePartition) it.next(); + IOConsolePartition partition = it.next(); if (partition.getOffset() + partition.getLength() <= event.fOffset + lastLineDelimiter) { if (partition == lastPartition) { lastPartition = null; @@ -431,19 +442,19 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum } } - } - + } + return new Region(event.fOffset, event.fText.length()); } - + private void setUpdateInProgress(boolean b) { updateInProgress = b; } - + /** * A stream has been appended, add to pendingPartions list and schedule updateJob. * updateJob is scheduled with a slight delay, this allows the console to run the job - * less frequently and update the document with a greater amount of data each time + * less frequently and update the document with a greater amount of data each time * the job is run * @param stream The stream that was written to. * @param s The string that should be appended to the document. @@ -453,7 +464,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum throw new IOException("Document is closed"); //$NON-NLS-1$ } synchronized(pendingPartitions) { - PendingPartition last = (PendingPartition) (pendingPartitions.size() > 0 ? pendingPartitions.get(pendingPartitions.size()-1) : null); + PendingPartition last = pendingPartitions.size() > 0 ? pendingPartitions.get(pendingPartitions.size()-1) : null; if (last != null && last.stream == stream) { last.append(s); } else { @@ -464,7 +475,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum queueJob.schedule(50); } } - + if (fBuffer > 160000) { if(Display.getCurrent() == null){ try { @@ -481,29 +492,29 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum } } } - + /** * Holds data until updateJob can be run and the document can be updated. */ private class PendingPartition { StringBuffer text = new StringBuffer(8192); IOConsoleOutputStream stream; - + PendingPartition(IOConsoleOutputStream stream, String text) { this.stream = stream; if (text != null) { append(text); } } - + void append(String moreText) { text.append(moreText); fBuffer += moreText.length(); } } - + /** - * Updates the document. Will append everything that is available before + * Updates the document. Will append everything that is available before * finishing. */ private class QueueProcessingJob extends UIJob { @@ -511,32 +522,34 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum QueueProcessingJob() { super("IOConsole Updater"); //$NON-NLS-1$ } - + /* * (non-Javadoc) * @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor) */ - public IStatus runInUIThread(IProgressMonitor monitor) { + @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. */ - public boolean shouldRun() { + @Override + public boolean shouldRun() { boolean shouldRun = connected && pendingPartitions != null && pendingPartitions.size() > 0; return shouldRun; } } - + void processQueue() { synchronized (overflowLock) { - ArrayList pendingCopy = new ArrayList(); + ArrayList<PendingPartition> pendingCopy = new ArrayList<PendingPartition>(); StringBuffer buffer = null; boolean consoleClosed = false; synchronized(pendingPartitions) { @@ -547,22 +560,19 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum } // determine buffer size int size = 0; - for (Iterator i = pendingCopy.iterator(); i.hasNext(); ) { - PendingPartition pp = (PendingPartition) i.next(); - if (pp != consoleClosedPartition) { + for (PendingPartition pp : pendingCopy) { + if (pp != consoleClosedPartition) { size+= pp.text.length(); - } + } } buffer = new StringBuffer(size); - for (Iterator i = pendingCopy.iterator(); i.hasNext(); ) { - PendingPartition pp = (PendingPartition) i.next(); - if (pp != consoleClosedPartition) { + for (PendingPartition pp : pendingCopy) { + if (pp != consoleClosedPartition) { buffer.append(pp.text); } else { consoleClosed = true; } } - if (connected) { setUpdateInProgress(true); updatePartitions = pendingCopy; @@ -583,18 +593,18 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum } } - + /** * 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. */ @@ -602,10 +612,10 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum 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) { @@ -615,7 +625,8 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum /* (non-Javadoc) * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) */ - public IStatus runInUIThread(IProgressMonitor monitor) { + @Override + public IStatus runInUIThread(IProgressMonitor monitor) { IJobManager jobManager = Job.getJobManager(); try { jobManager.join(console, monitor); @@ -627,7 +638,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum if (document == null) { return Status.OK_STATUS; } - + int length = document.getLength(); if (truncateOffset < length) { synchronized (overflowLock) { @@ -637,7 +648,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum setUpdateInProgress(true); document.set(""); //$NON-NLS-1$ setUpdateInProgress(false); - partitions.clear(); + partitions.clear(); } else { // overflow int cutoffLine = document.getLineOfOffset(truncateOffset); @@ -647,20 +658,19 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum // 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 (Iterator i = partitions.iterator(); i.hasNext(); ) { - IOConsolePartition p = (IOConsolePartition) i.next(); + for (IOConsolePartition p : partitions) { p.setOffset(offset); offset += p.getLength(); } @@ -676,20 +686,22 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#isReadOnly(int) */ - public boolean isReadOnly(int offset) { + @Override + public boolean isReadOnly(int offset) { return ((IOConsolePartition)getPartition(offset)).isReadOnly(); } /* (non-Javadoc) * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#computeStyleRange(int, int) */ - public StyleRange[] getStyleRanges(int offset, int length) { + @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++) { + 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); 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 e686955f0..6ea0498e1 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 @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -24,7 +24,7 @@ import org.eclipse.ui.console.TextConsoleViewer; /** * Viewer used to display an IOConsole - * + * * @since 3.1 */ public class IOConsoleViewer extends TextConsoleViewer { @@ -34,7 +34,7 @@ public class IOConsoleViewer extends TextConsoleViewer { private boolean fAutoScroll = true; private IDocumentListener fDocumentListener; - + public IOConsoleViewer(Composite parent, TextConsole console) { super(parent, console); } @@ -49,10 +49,11 @@ public class IOConsoleViewer extends TextConsoleViewer { /* * (non-Javadoc) - * + * * @see org.eclipse.jface.text.TextViewer#handleVerifyEvent(org.eclipse.swt.events.VerifyEvent) */ - protected void handleVerifyEvent(VerifyEvent e) { + @Override + protected void handleVerifyEvent(VerifyEvent e) { IDocument doc = getDocument(); String[] legalLineDelimiters = doc.getLegalLineDelimiters(); String eventString = e.text; @@ -94,7 +95,8 @@ public class IOConsoleViewer extends TextConsoleViewer { */ public void setReadOnly() { ConsolePlugin.getStandardDisplay().asyncExec(new Runnable() { - public void run() { + @Override + public void run() { StyledText text = getTextWidget(); if (text != null && !text.isDisposed()) { text.setEditable(false); @@ -109,15 +111,16 @@ public class IOConsoleViewer extends TextConsoleViewer { public boolean isReadOnly() { return !getTextWidget().getEditable(); } - + /* (non-Javadoc) * @see org.eclipse.jface.text.ITextViewer#setDocument(org.eclipse.jface.text.IDocument) */ - public void setDocument(IDocument document) { + @Override + public void setDocument(IDocument document) { IDocument oldDocument= getDocument(); - + super.setDocument(document); - + if (oldDocument != null) { oldDocument.removeDocumentListener(getDocumentListener()); } @@ -125,14 +128,16 @@ public class IOConsoleViewer extends TextConsoleViewer { document.addDocumentListener(getDocumentListener()); } } - + private IDocumentListener getDocumentListener() { if (fDocumentListener == null) { fDocumentListener= new IDocumentListener() { - public void documentAboutToBeChanged(DocumentEvent event) { + @Override + public void documentAboutToBeChanged(DocumentEvent event) { } - public void documentChanged(DocumentEvent event) { + @Override + public void documentChanged(DocumentEvent event) { if (fAutoScroll) { revealEndOfDocument(); } 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 ab8d900a7..e43768493 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 @@ -1,29 +1,26 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.ui.internal.console; import org.eclipse.core.runtime.CoreException; - +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IMenuCreator; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.ToolItem; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.ActionContributionItem; -import org.eclipse.jface.action.IMenuCreator; -import org.eclipse.jface.resource.ImageDescriptor; - import org.eclipse.ui.PlatformUI; import org.eclipse.ui.activities.WorkbenchActivityHelper; import org.eclipse.ui.console.ConsolePlugin; @@ -39,45 +36,48 @@ public class OpenConsoleAction extends Action implements IMenuCreator { public OpenConsoleAction() { fFactoryExtensions = ((ConsoleManager)ConsolePlugin.getDefault().getConsoleManager()).getConsoleFactoryExtensions(); - setText(ConsoleMessages.OpenConsoleAction_0); - setToolTipText(ConsoleMessages.OpenConsoleAction_1); + setText(ConsoleMessages.OpenConsoleAction_0); + setToolTipText(ConsoleMessages.OpenConsoleAction_1); setImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_NEW_CON)); setMenuCreator(this); PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_OPEN_CONSOLE_ACTION); } - + /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuCreator#dispose() */ - public void dispose() { + @Override + public void dispose() { fFactoryExtensions = null; } - + /* * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event) * @since 3.5 */ - public void runWithEvent(Event event) { + @Override + public void runWithEvent(Event event) { 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) */ - public Menu getMenu(Control parent) { + @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++) { @@ -91,7 +91,7 @@ public class OpenConsoleAction extends Action implements IMenuCreator { } return fMenu; } - + private void addActionToMenu(Menu parent, Action action, int accelerator) { if (accelerator < 10) { StringBuffer label= new StringBuffer(); @@ -102,7 +102,7 @@ public class OpenConsoleAction extends Action implements IMenuCreator { label.append(action.getText()); action.setText(label.toString()); } - + ActionContributionItem item= new ActionContributionItem(action); item.fill(parent, -1); } @@ -110,12 +110,13 @@ public class OpenConsoleAction extends Action implements IMenuCreator { /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu) */ - public Menu getMenu(Menu parent) { + @Override + public Menu getMenu(Menu parent) { return null; } - + private class ConsoleFactoryAction extends Action { - + private ConsoleFactoryExtension fConfig; private IConsoleFactory fFactory; @@ -126,27 +127,29 @@ public class OpenConsoleAction extends Action implements IMenuCreator { } fConfig = extension; } - - + + /* (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ - public void 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) */ - public void runWithEvent(Event event) { + @Override + public void runWithEvent(Event event) { 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 eab75136a..aaf415555 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 @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -20,50 +20,56 @@ public class PatternMatchListener implements IPatternMatchListener { private PatternMatchListenerExtension fExtension; private IPatternMatchListenerDelegate fDelegate; - + public PatternMatchListener(PatternMatchListenerExtension extension) throws CoreException { fExtension = extension; fDelegate = fExtension.createDelegate(); - } + } /* (non-Javadoc) * @see org.eclipse.ui.console.IPatternMatchListener#getPattern() */ - public String getPattern() { + @Override + public String getPattern() { return fExtension.getPattern(); } /* (non-Javadoc) * @see org.eclipse.ui.console.IPatternMatchListener#getCompilerFlags() */ - public int getCompilerFlags() { + @Override + public int getCompilerFlags() { return fExtension.getCompilerFlags(); } - + /* (non-Javadoc) * @see org.eclipse.ui.console.IPatternMatchListener#matchFound(org.eclipse.ui.console.PatternMatchEvent) */ - public void matchFound(PatternMatchEvent event) { + @Override + public void matchFound(PatternMatchEvent event) { fDelegate.matchFound(event); } - + /* (non-Javadoc) * @see org.eclipse.ui.console.IPatternMatchListenerDelegate#connect(org.eclipse.ui.console.TextConsole) */ - public void connect(TextConsole console) { + @Override + public void connect(TextConsole console) { fDelegate.connect(console); } /* (non-Javadoc) * @see org.eclipse.ui.console.IPatternMatchListener#disconnect() */ - public void disconnect() { + @Override + public void disconnect() { fDelegate.disconnect(); } /* (non-Javadoc) * @see org.eclipse.ui.console.IPatternMatchListener#getQuickPattern() */ + @Override public String getLineQualifier() { return fExtension.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 b4081dfe6..869129180 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 @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -36,10 +36,10 @@ public class PatternMatchListenerExtension implements IPluginContribution { 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. @@ -51,12 +51,12 @@ public class PatternMatchListenerExtension implements IPluginContribution { if (flagsElement == null) { return val; } - + try { - flagsElement = flagsElement.replaceAll("Pattern.", ""); //$NON-NLS-1$ //$NON-NLS-2$ - String[] tokens = flagsElement.split("\\s\\|\\s"); //$NON-NLS-1$ - Class clazz = Class.forName("java.util.regex.Pattern"); //$NON-NLS-1$ - + 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); @@ -70,25 +70,25 @@ public class PatternMatchListenerExtension implements IPluginContribution { } 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) { - String message = MessageFormat.format("{0} " +getLocalId() + " {1} " + getPluginId() + " {2}", new String[] {ConsoleMessages.PatternMatchListenerExtension_3,ConsoleMessages.PatternMatchListenerExtension_4,ConsoleMessages.PatternMatchListenerExtension_5}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + 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)); } - IConfigurationElement enablement = elements.length > 0 ? elements[0] : null; + IConfigurationElement enablement = elements.length > 0 ? elements[0] : null; if (enablement != null) { fEnablementExpression = ExpressionConverter.getDefault().perform(enablement); @@ -96,7 +96,7 @@ public class PatternMatchListenerExtension implements IPluginContribution { } return fEnablementExpression; } - + /* * returns the regular expression to be matched. */ @@ -122,18 +122,20 @@ public class PatternMatchListenerExtension implements IPluginContribution { } return fFlags; } - + /* (non-Javadoc) * @see org.eclipse.ui.IPluginContribution#getLocalId() */ - public String getLocalId() { + @Override + public String getLocalId() { return fConfig.getAttribute("id"); //$NON-NLS-1$ } /* (non-Javadoc) * @see org.eclipse.ui.IPluginContribution#getPluginId() */ - public String getPluginId() { + @Override + public String getPluginId() { return fConfig.getContributor().getName(); } 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 61d307407..94e5d51e0 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 @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ @@ -20,15 +20,15 @@ import org.eclipse.ui.texteditor.IUpdate; * Pins the currently visible console in a console view. */ public class PinConsoleAction extends Action implements IUpdate { - + private IConsoleView fView = null; /** * Constructs a 'pin console' action */ public PinConsoleAction(IConsoleView view) { - super(ConsoleMessages.PinConsoleAction_0, IAction.AS_CHECK_BOX); - setToolTipText(ConsoleMessages.PinConsoleAction_1); + super(ConsoleMessages.PinConsoleAction_0, IAction.AS_CHECK_BOX); + setToolTipText(ConsoleMessages.PinConsoleAction_1); setImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_PIN)); setDisabledImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_DLCL_PIN)); setHoverImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_LCL_PIN)); @@ -36,17 +36,19 @@ public class PinConsoleAction extends Action implements IUpdate { fView = view; update(); } - + /* (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ + @Override public void run() { fView.setPinned(isChecked()); } - + /* (non-Javadoc) * @see org.eclipse.ui.texteditor.IUpdate#update() */ + @Override public void update() { setEnabled(fView.getConsole() != null); setChecked(fView.isPinned()); 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 e0b2ad268..07d13c7b8 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 IBM Corporation and others. + * Copyright (c) 2004, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,33 +16,34 @@ import org.eclipse.ui.console.IConsoleView; /** * Toggles console auto-scroll - * + * * @since 3.1 */ public class ScrollLockAction extends Action { private IConsoleView fConsoleView; - + public ScrollLockAction(IConsoleView consoleView) { - super(ConsoleMessages.ScrollLockAction_0); + super(ConsoleMessages.ScrollLockAction_0); fConsoleView = consoleView; - - setToolTipText(ConsoleMessages.ScrollLockAction_1); - setHoverImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_LCL_LOCK)); + + 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); - boolean checked = fConsoleView.getScrollLock(); + boolean checked = fConsoleView.getScrollLock(); setChecked(checked); } /** * @see org.eclipse.jface.action.IAction#run() */ + @Override public void run() { fConsoleView.setScrollLock(isChecked()); } - + public void dispose() { 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 ed846b0cf..ea09fb14e 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,7 +11,6 @@ package org.eclipse.ui.internal.console; import org.eclipse.jface.action.Action; - import org.eclipse.ui.console.IConsole; import org.eclipse.ui.console.IConsoleView; @@ -19,20 +18,21 @@ import org.eclipse.ui.console.IConsoleView; * Shows a specific console in the console view */ public class ShowConsoleAction extends Action { - + private IConsole fConsole; private IConsoleView fView; /* (non-Javadoc) * @see org.eclipse.jface.action.IAction#run() */ + @Override public void run() { showConsole(fConsole, fView); } /** * Shows the given console in the given console view. - * + * * @param console the console to show * @param consoleView the console view */ @@ -44,14 +44,14 @@ public class ShowConsoleAction extends Action { } consoleView.display(console); if (pinned) { - consoleView.setPinned(true); + consoleView.setPinned(true); } } } /** * Constructs an action to display the given console. - * + * * @param view the console view in which the given console is contained * @param console the console */ |