From 44abbde7c141b702357ced55c72a1d6ecd2bdf69 Mon Sep 17 00:00:00 2001
From: cvs2svn
Date: Thu, 12 Nov 2009 20:03:37 +0000
Subject: This commit was manufactured by cvs2svn to create branch
'FlexBreakpoint'.
Sprout from master 2009-11-12 20:03:34 UTC Darin Wright June 2, 2006 The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
-at http://www.eclipse.org/legal/epl-v10.html.
-For purposes of the EPL, "Program" will mean the Content. If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party ("Redistributor") and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at http://www.eclipse.org.
- * Clients implementing consoles should subclass this class.
- *
- * Since 3.1, this method is only called automatically if this console was
- * created with an automatic lifecycle.
- *
- * Since 3.1, this methods is only called automatically if this console was
- * created with an automatic lifecycle.
- *
- * The console implementations provided by this plug-in are textual
- * (
- * Subclass
- * The changes supported by the console view are as follows:
- * About This Content
-
-License
-
-init()
- * and dispose()
.
- */
- class Lifecycle implements IConsoleListener {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsoleListener#consolesAdded(org.eclipse.ui.console.IConsole[])
- */
- public void consolesAdded(IConsole[] consoles) {
- for (int i = 0; i < consoles.length; i++) {
- IConsole console = consoles[i];
- if (console == AbstractConsole.this) {
- initialize();
- }
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsoleListener#consolesRemoved(org.eclipse.ui.console.IConsole[])
- */
- public void consolesRemoved(IConsole[] consoles) {
- for (int i = 0; i < consoles.length; i++) {
- IConsole console = consoles[i];
- if (console == AbstractConsole.this) {
- ConsolePlugin.getDefault().getConsoleManager().removeConsoleListener(this);
- destroy();
- }
- }
- }
- }
-
- /**
- * 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)
- */
- public void handleException(Throwable 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()
- */
- 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) {
- if (fListeners == null) {
- return;
- }
- fEvent = event;
- Object[] copiedListeners= fListeners.getListeners();
- for (int i= 0; i < copiedListeners.length; i++) {
- fListener = (IPropertyChangeListener)copiedListeners[i];
- SafeRunner.run(this);
- }
- fListener = null;
- }
- }
-
- /**
- * Constructs a new console with the given name and image.
- *
- * @param name console name, cannot be null
- * @param imageDescriptor image descriptor, or null
if none
- * @param autoLifecycle whether this console's lifecycle methods should be called
- * automatically when it is added (initialize()
) and removed
- * (destroy()
) from the console manager. When false
,
- * clients are responsible for calling the lifecycle methods.
- * @since 3.1
- */
- 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 null
- * @param type console type identifier or null
- * @param imageDescriptor image descriptor, or null
if none
- * @param autoLifecycle whether this console's lifecycle methods should be called
- * automatically when it is added (initialize()
) and removed
- * (destroy()
) from the console manager. When false
,
- * clients are responsible for calling the lifecycle methods.
- * @since 3.1
- */
- public AbstractConsole(String name, String type, ImageDescriptor imageDescriptor, boolean autoLifecycle) {
- setName(name);
- setType(type);
- setImageDescriptor(imageDescriptor);
- if (autoLifecycle) {
- ConsolePlugin.getDefault().getConsoleManager().addConsoleListener(new Lifecycle());
- }
- }
-
- /**
- * Constructs a new console with the given name and image. The console's lifecycle
- * methods init()
and dispose()
will be called when the
- * console is added and removed from the console manager.
- *
- * @param name console name, cannot be null
- * @param imageDescriptor image descriptor, or null
if none
- */
- public AbstractConsole(String name, ImageDescriptor imageDescriptor) {
- this(name, imageDescriptor, true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsole#getName()
- */
- public String getName() {
- return fName;
- }
-
- /**
- * 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) {
- if (!name.equals(fName)) {
- String old = fName;
- fName = name;
- firePropertyChange(this, IBasicPropertyConstants.P_TEXT, old, name);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsole#getImageDescriptor()
- */
- 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)
- */
- public void addPropertyChangeListener(IPropertyChangeListener listener) {
- if (fListeners == null) {
- fListeners = new ListenerList();
- }
- fListeners.add(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsole#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
- */
- public void removePropertyChangeListener(IPropertyChangeListener listener) {
- if (fListeners != null) {
- fListeners.remove(listener);
- }
- }
-
- /**
- * Notify all listeners that the given 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 null
- * @param newValue the new value of the property, or null
- */
- public void firePropertyChange(Object source, String property, Object oldValue, Object newValue) {
- if (fListeners == null) {
- return;
- }
- 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.
- * null
- * if none. When a non-null
value is returned the associated help
- * will be installed for this console.
- *
- * @return help context id or null
- * @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
deleted file mode 100644
index df35a076f..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/ConsolePlugin.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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.console;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.console.ConsoleManager;
-import org.eclipse.ui.internal.console.ConsolePluginImages;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-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
- */
- private IConsoleManager fConsoleManager = null;
-
- /**
- * The singleton console plug-in instance
- */
- private static ConsolePlugin fgPlugin= null;
-
- /**
- * Unique identifier constant (value "org.eclipse.ui.console"
)
- * 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.
- */
- public static ConsolePlugin getDefault() {
- return fgPlugin;
- }
-
- public ConsolePlugin() {
- super();
- fgPlugin = this;
- }
-
- /**
- * Convenience method which returns the unique identifier of this plug-in.
- */
- public static String getUniqueIdentifier() {
- return PI_UI_CONSOLE;
- }
-
- /**
- * Logs the specified status with this plug-in's log.
- *
- * @param status status to log
- */
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
- /**
- * Logs the specified throwable with this plug-in's log.
- *
- * @param t throwable to log
- */
- public static void log(Throwable t) {
- if (t instanceof CoreException) {
- log(((CoreException)t).getStatus());
- } else {
- 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
- * @param exception the exception to be included in the status or null
if none
- * @return a new error status
- */
- 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
- * the first access.
- *
- * @return IConsoleManager
- */
- public IConsoleManager getConsoleManager() {
- if (fConsoleManager == null) {
- fConsoleManager = new ConsoleManager();
- }
- return fConsoleManager;
- }
-
- /**
- * Returns the workbench display.
- */
- public static Display getStandardDisplay() {
- return PlatformUI.getWorkbench().getDisplay();
- }
-
- /**
- * Utility method with conventions
- */
- public static void errorDialog(Shell shell, String title, String message, Throwable t) {
- IStatus status;
- if (t instanceof CoreException) {
- status= ((CoreException)t).getStatus();
- // 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;
- }
- } else {
- status= new Status(IStatus.ERROR, getUniqueIdentifier(), IConsoleConstants.INTERNAL_ERROR, "Error within Debug UI: ", t); //$NON-NLS-1$
- log(status);
- }
- ErrorDialog.openError(shell, title, message, status);
- }
-
- /**
- * Returns the Image
identified by the given key,
- * or null
if it does not exist.
- *
- * @return the Image
identified by the given key,
- * or null
if it does not exist
- * @since 3.1
- */
- public static Image getImage(String key) {
- return ConsolePluginImages.getImage(key);
- }
-
- /**
- * Returns the ImageDescriptor
identified by the given key,
- * or null
if it does not exist.
- *
- * @return the ImageDescriptor
identified by the given key,
- * or null
if it does not exist
- * @since 3.1
- */
- public static ImageDescriptor getImageDescriptor(String key) {
- return ConsolePluginImages.getImageDescriptor(key);
- }
-
- /* (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- if (fConsoleManager != null) {
- IConsole[] consoles = fConsoleManager.getConsoles();
- if (consoles != null) {
- fConsoleManager.removeConsoles(consoles);
- }
- }
- super.stop(context);
- }
-
-
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsole.java
deleted file mode 100644
index 7b935820d..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsole.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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.console;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.ui.part.IPageBookViewPage;
-
-/**
- * A console. A console is commonly used to display messages such as the output
- * streams of a system process. A console can be displayed in one or more console
- * views.
- * TextConsole
, MessageConsole
and IOConsole
).
- * However a client can provide alternate presentations since a console implementation
- * is responsible for providing is page for the page book views in which consoles are
- * displayed.
- * AbstractConsole
when implementing this interface.
- * null
- * if none.
- *
- * @return an image descriptor for this console, or null
- * if none
- */
- public ImageDescriptor getImageDescriptor();
-
- /**
- * Creates and returns a new page for this console. The page is displayed
- * for this console in the console given view.
- *
- * @param view the view in which the page is to be created
- * @return a page book view page representation of this console
- */
- public IPageBookViewPage createPage(IConsoleView view);
-
- /**
- * Adds a listener for changes to properties of this console.
- * Has no effect if an identical listener is already registered.
- *
- *
- * IBasicPropertyConstants.P_TEXT
- indicates the name
- * of a console has changedIBasicPropertyConstants.P_IMAGE
- indicates the image
- * of a console has changed
- * Consoles may define additional properties as required. - *
- * - * @param listener a property change listener - */ - public void addPropertyChangeListener(IPropertyChangeListener listener); - - /** - * Removes the given property listener from this console page. - * Has no effect if an identical listener is not already registered. - * - * @param listener a property listener - */ - public void removePropertyChangeListener(IPropertyChangeListener listener); - - /** - * Returns a unique identifier for this console's type, ornull
- * if unspecified.
- *
- * @return a unique identifier for this console's type, or null
- * @since 3.1
- */
- public String getType();
-
-}
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
deleted file mode 100644
index 06d04d14b..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleConstants.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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.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 "org.eclipse.ui.console"
).
- */
- public static final String PLUGIN_ID = ConsolePlugin.getUniqueIdentifier();
-
- /**
- * Console view identifier (value "org.eclipse.ui.console.ConsoleView"
).
- */
- public static final String ID_CONSOLE_VIEW= "org.eclipse.ui.console.ConsoleView"; //$NON-NLS-1$
-
- /**
- * Type identifier for MessageConsole
- * @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 "org.eclipse.ui.console.ConsoleFont"
).
- *
- * @deprecated When a console is created, its font is set to the default text font as specified
- * by JFaceResources.TEXT_FONT
. Clients must provide their own infrastructure to
- * manage console specific fonts.
- */
- 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 "launchGroup"
).
- */
- public static final String LAUNCH_GROUP = "launchGroup"; //$NON-NLS-1$
-
- /**
- * Menu group identifier for the console view context menu and toolbar, for actions pertaining to
- * console output. (value"outputGroup"
).
- */
- 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.
- */
- public static final String IMG_LCL_CLEAR= "IMG_LCL_CLEAR"; //$NON-NLS-1$
-
- /**
- * Status code indicating an unexpected internal error.
- */
- public static final int INTERNAL_ERROR = 120;
-
- /**
- * Console pattern match listeners extension point identifier
- * (value "consolePatternMatchListeners"
).
- *
- * @since 3.1
- */
- public static final String EXTENSION_POINT_CONSOLE_PATTERN_MATCH_LISTENERS = "consolePatternMatchListeners"; //$NON-NLS-1$
-
- /**
- * Console page participants extension point identifier
- * (value "consolePageParticipants"
).
- *
- * @since 3.1
- */
- public static final String EXTENSION_POINT_CONSOLE_PAGE_PARTICIPANTS = "consolePageParticipants"; //$NON-NLS-1$
-
- /**
- * Console factories extension point identifier
- * (value "consoleFactories"
).
- *
- * @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$
-
- /**
- * The default tab size for text consoles.
- *
- * @since 3.1
- */
- public static final int DEFAULT_TAB_SIZE = 8;
-
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleDocumentPartitioner.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleDocumentPartitioner.java
deleted file mode 100644
index 0da81fe60..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleDocumentPartitioner.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 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.console;
-
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.swt.custom.StyleRange;
-
-/**
- * A document partitioner for a text console.
- * - * In addition to regular partitioner duties, a console document partitioner - * dictates which regions in its document are read-only and provides style ranges. - *
- *- * Clients may implement this interface. - *
- * @see org.eclipse.ui.console.TextConsole - * @since 3.1 - */ -public interface IConsoleDocumentPartitioner extends IDocumentPartitioner { - - /** - * Returns whether this partitioner's document is read-only at the specified - * offset. The user is not allowed to type in read-only locations. - * - * @param offset document offset - * @return whether this partitioner's document is read-only at the specified - * offset - */ - public boolean isReadOnly(int offset); - - /** - * Returns style ranges for the specified region of this partitioner's document - * to use when rendering, ornull
if none.
- *
- * @param offset beginning offset for which style ranges are requested
- * @param length the length of text for which style ranges are requested
- * @return style ranges for the specified region of this partitioner's document
- * to use when rendering, or null
if none
- */
- public StyleRange[] getStyleRanges(int offset, int length);
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleFactory.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleFactory.java
deleted file mode 100644
index 4e27fede6..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleFactory.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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.console;
-
-/**
- * A console factory extension is responsible for opening a console in the console view.
- * Extensions appear on a menu in the console view, and their openConsole
- * method is called when the action is invoked. Implementations may choose to open a new
- * console or activate an existing console. The extension point used to contribute a
- * console factory is org.eclipse.ui.console.consoleFactories
.
- * - * Following is an example console factory extension. - *
- * <extension point="org.eclipse.ui.console.consoleFactories"> - * <consoleFactory - * label="Command Console" - * icon="icons\cmd_console.gif" - * class="com.example.CommandConsoleFactory"> - * </consoleFactory> - * </extension> - *- * An action appears in the console view's 'Open Console' drop-down menu with the - * corresponding
label
and optional icon
. When the action
- * is invoked, the specified class
is instantiated and called to
- * open a console, via the method openConsole()
.
- *
- * - * Clients providing console factory extensions are intended to implement - * this interface. - *
- * @since 3.1 - */ -public interface IConsoleFactory { - /** - * Opens a console in the console view. Implementations may create a new - * console or activate an existing console. - */ - public void openConsole(); - -} diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleListener.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleListener.java deleted file mode 100644 index 41aedb236..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 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.console; - -/** - * A console listener is notified when consoles are added or removed from - * the console manager. - *- * Clients may implement this interface. - *
- * @since 3.0 - */ -public interface IConsoleListener { - - /** - * Notification the given consoles have been added to the console - * manager. - * - * @param consoles added consoles - */ - public void consolesAdded(IConsole[] consoles); - - /** - * Notification the given consoles have been removed from the - * console manager. - * - * @param consoles removed consoles - */ - public void consolesRemoved(IConsole[] consoles); - -} diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleManager.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleManager.java deleted file mode 100644 index 14ac3b8ec..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleManager.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 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.console; - -/** - * The console manager manages registered consoles. - * @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 IConsoleManager { - - /** - * Registers the given listener for console notifications. Has - * no effect if an identical listener is already registered. - * - * @param listener listener to register - */ - public void addConsoleListener(IConsoleListener listener); - - /** - * Unregisters the given listener for console notifications. Has - * no effect if an identical listener is not already registered. - * - * @param listener listener to unregister - */ - public void removeConsoleListener(IConsoleListener listener); - - /** - * Adds the given consoles to the console manager. Has no effect for - * equivalent consoles already registered. The consoles will be added - * to any existing console views. - * - * @param consoles consoles to add - */ - public void addConsoles(IConsole[] consoles); - - /** - * Removes the given consoles from the console manager. If the consoles are - * being displayed in any console views, the associated pages will be removed - * and disposed. - * - * @param consoles consoles to remove - */ - public void removeConsoles(IConsole[] consoles); - - /** - * Returns a collection of consoles registered with the console manager. - * - * @return a collection of consoles registered with the console manager - */ - public IConsole[] getConsoles(); - - /** - * Opens the console view and displays given the console. - * If the view is already open, it is brought to the front unless - * the view is pinned on a console other than the given console. - * Has no effect if the given console is not currently registered. - * - * @param console console to display - */ - public void showConsoleView(IConsole console); - - /** - * Warns that the content of the given console has changed in - * all console views. Has no effect if the given console is not - * currently registered. - * - * @param console the console that has changed - */ - public void warnOfContentChange(IConsole console); - - /** - * Creates and returns a collection of new pattern match listeners enabled for - * the given console. The pattern match listeners are new instances, intended - * to be used in a new console. No methods on the participants have been - * called. Clients are responsible for connecting to and disconnecting from - * the pattern match listeners. - *
- * Console pattern match listeners are contributed via the
- * org.eclipse.ui.console.consolePatternMatchListeners
extension point.
- *
org.eclispe.ui.console.consolePageParticipants
extension point.
- * - * Participant behavior is implementation dependent. For example, a page participant - * could add actions to a console's toolbar by accessing a its page's action bars. - *
- *- * Following is an example extension definition. - *
- * <extension point="org.eclipse.ui.console.consolePageParticipants"> - * <consolePageParticipant - * id="com.example.ExamplePageParticipant" - * class="com.example.ExamplePageParticipant"> - * </consolePageParticipant> - * </extension> - *- * - * The example page participant is contributed to all console pages. An optional - *
enablement
attribute may be specified to control which consoles
- * a page participant is applicable to.
- * - * Clients contributing console page participant extensions are intended to - * implement this interface. - *
- * @since 3.1 - */ -public interface IConsolePageParticipant extends IAdaptable { - /** - * Called during page initialization. Marks the start of this - * page participant's lifecycle. - * - * @param page the page corresponding to the given console - * @param console the console for which a page has been created - */ - public void init(IPageBookViewPage page, IConsole console); - - /** - * Disposes this page participant. Marks the end of this - * page participant's lifecycle. - */ - public void dispose(); - - /** - * Notification this participant's page has been activated. - */ - public void activated(); - - /** - * Notification this participant's page has been deactivated. - */ - public void deactivated(); - -} diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleView.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleView.java deleted file mode 100644 index e1bc354d6..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IConsoleView.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 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.console; - -import org.eclipse.ui.IViewPart; - -/** - * A view that displays consoles registered with the console manager. - * @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 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. - * - * @param console console to display, cannot benull
- */
- 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 true
to pin the current console to the
- * top of the stack, false
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 null
un-pins this console
- *
- * @param console console to pin, or null
to un-pin
- * @deprecated rather than pinning a specific console, a console view is
- * pinned - use setPinned(boolean)
- */
- 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 null
- * if none
- *
- * @return the console currently being displayed, or null
- * 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);
-
- /**
- * Sets the scroll lock state of the currently active console.
- *
- * @param scrollLock true
to turn scroll lock on, otherwise false
- * @since 3.1
- */
- public void setScrollLock(boolean scrollLock);
-
- /**
- * Returns the scroll lock state of the currently active console.
- *
- * @return true
if scroll lock is on, false
otherwise
- * @since 3.1
- */
- public boolean getScrollLock();
-
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IHyperlink.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IHyperlink.java
deleted file mode 100644
index 38aa4994c..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IHyperlink.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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.console;
-
-/**
- * A hyperlink in a console. Link behavior is implementation dependent.
- * - * Clients may implement this interface. - *
- * @since 3.1 - */ -public interface IHyperlink { - - /** - * Notification that the mouse has entered this link's region. - */ - public void linkEntered(); - - /** - * Notification that the mouse has exited this link's region - */ - public void linkExited(); - - /** - * Notification that this link has been activated. Performs - * context specific linking. - */ - public void linkActivated(); -} diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IHyperlink2.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IHyperlink2.java deleted file mode 100644 index 3895f1583..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IHyperlink2.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 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.console; - -import org.eclipse.swt.widgets.Event; - -/** - * Optional extension to {@link IHyperlink}. - *
- * Clients implementing {@link IHyperlink} may also implement this interface.
- * When implemented, the method linkActivated(Event)
is called instead of
- * linkActivated()
.
- *
- * Clients may instantiate and subclass this class. - *
- * @since 3.1 - */ -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; - - /** - * 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 ornull
- * @param imageDescriptor image to display for this console or null
- * @param autoLifecycle whether lifecycle methods should be called automatically
- * when this console is added/removed from the console manager
- */
- public IOConsole(String name, String consoleType, ImageDescriptor imageDescriptor, boolean autoLifecycle) {
- this(name, consoleType, imageDescriptor, null, autoLifecycle);
- }
-
- /**
- * Constructs a console with the given name, type, image, encoding and lifecycle.
- *
- * @param name name to display for this console
- * @param consoleType console type identifier or null
- * @param imageDescriptor image to display for this console or null
- * @param encoding the encoding that should be used to render the text, or null
- * if the system default encoding should be used
- * @param autoLifecycle whether lifecycle methods should be called automatically
- * when this console is added/removed from the console manager
- */
- public IOConsole(String name, String consoleType, ImageDescriptor imageDescriptor, String encoding, boolean autoLifecycle) {
- super(name, consoleType, imageDescriptor, autoLifecycle);
- if (encoding != null) {
- fEncoding = encoding;
- }
- openStreams = new ArrayList();
- inputStream = new IOConsoleInputStream(this);
- synchronized (openStreams) {
- 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 null
- * @param imageDescriptor image to display for this console or null
- */
- 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 (null
) type.
- *
- * @param name name to display for this console
- * @param imageDescriptor image to display for this console or null
- */
- 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) {
- return new IOConsolePage(this, view);
- }
-
- /**
- * Creates and returns a new output stream which may be used to write to this console.
- * A console may be connected to more than one output stream at once. Clients are
- * responsible for closing any output streams created on this console.
- * - * Clients should avoid writing large amounts of output to this stream in the UI - * thread. The console needs to process the output in the UI thread and if the client - * hogs the UI thread writing output to the console, the console will not be able - * to process the output. - *
- * @return a new output stream connected to this console - */ - public IOConsoleOutputStream newOutputStream() { - IOConsoleOutputStream outputStream = new IOConsoleOutputStream(this); - outputStream.setEncoding(fEncoding); - synchronized(openStreams) { - openStreams.add(outputStream); - } - return outputStream; - } - - /** - * Returns the input stream connected to the keyboard. - * - * @return the input stream connected to the keyboard. - */ - public IOConsoleInputStream getInputStream() { - return inputStream; - } - - /** - * Returns this console's document partitioner. - * - * @return this console's document partitioner - */ - protected IConsoleDocumentPartitioner getPartitioner() { - return partitioner; - } - - /** - * 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 - * its text buffer (if -1 the console does not limit output) - * @exception IllegalArgumentException if low >= high & low != -1 - */ - public void setWaterMarks(int low, int high) { - if (low >= 0) { - if (low >= high) { - throw new IllegalArgumentException("High water mark must be greater than low water mark"); //$NON-NLS-1$ - } - } - partitioner.setWaterMarks(low, high); - } - - /** - * Check if all streams connected to this console are closed. If so, - * notify the partitioner that this console is finished. - */ - private void checkFinished() { - if (openStreams.isEmpty()) { - partitioner.streamsClosed(); - } - } - - /** - * Notification that an output stream connected to this console has been closed. - * - * @param stream stream that closed - */ - void streamClosed(IOConsoleOutputStream stream) { - synchronized (openStreams) { - openStreams.remove(stream); - checkFinished(); - } - } - - /** - * Notification that the input stream connected to this console has been closed. - * - * @param stream stream that closed - */ - void streamClosed(IOConsoleInputStream stream) { - synchronized (openStreams) { - openStreams.remove(stream); - checkFinished(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.console.TextConsole#clearConsole() - */ - public void clearConsole() { - if (partitioner != null) { - partitioner.clearBuffer(); - } - } - - /** - * Disposes this console. - */ - protected void dispose() { - super.dispose(); - partitioner.disconnect(); - //make a copy of the open streams and close them all - //a copy is needed as close the streams results in a callback that - //removes the streams from the openStreams collection (bug 152794) - 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) { - } - } - } - inputStream = null; - } - - /** - * Returns the encoding for this console, ornull
to indicate
- * default encoding.
- *
- * @return the encoding set for this console, or null
to indicate
- * default encoding
- * @since 3.3
- */
- public String getEncoding() {
- return fEncoding;
- }
-}
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
deleted file mode 100644
index f6933856b..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleInputStream.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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.console;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-
-/**
- * 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
- * @noinstantiate This class is not intended to be instantiated by clients.
- * @noextend This class is not intended to be subclassed by clients.
- *
- */
-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.
- */
- 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.
- */
- private int fontStyle = SWT.NORMAL;
-
-
- /**
- * Constructs a new input stream on the given console.
- *
- * @param console I/O console
- */
- IOConsoleInputStream(IOConsole console) {
- this.console = console;
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.InputStream#read(byte[], int, int)
- */
- 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);
- outPointer += toCopy;
- size -= toCopy;
- } else {
- int bytesToEnd = input.length-outPointer;
- System.arraycopy(input, outPointer, b, off, bytesToEnd);
- System.arraycopy(input, 0, b, off+bytesToEnd, toCopy-bytesToEnd);
- outPointer = toCopy-bytesToEnd;
- size -=toCopy;
- }
- return toCopy;
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.InputStream#read(byte[])
- */
- public int read(byte[] b) throws IOException {
- return read(b, 0, b.length);
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.InputStream#read()
- */
- public synchronized int read() throws IOException {
- waitForData();
- if (available() == -1) {
- return -1;
- }
-
- byte b = input[outPointer];
- outPointer++;
- if (outPointer == input.length) {
- outPointer = 0;
- }
- size -= 1;
- return b;
- }
-
- /**
- * Blocks until data is available to be read.
- * Ensure that the monitor for this object is obtained before
- * calling this method.
- */
- private void waitForData() {
- while (size == 0 && !closed) {
- try {
- wait();
- } catch (InterruptedException e) {
- }
- }
- }
-
- /**
- * Appends text to this input stream's buffer.
- *
- * @param text the text to append to the buffer.
- */
- public synchronized void appendData(String text) {
- String encoding = console.getEncoding();
- byte[] newData;
- if (encoding!=null)
- try {
- newData = text.getBytes(encoding);
- } catch (UnsupportedEncodingException e) {
- 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;
- size = newData.length;
- outPointer = 0;
- } else if (inPointer < outPointer || input.length - inPointer > newData.length) {
- System.arraycopy(newData, 0, input, inPointer, newData.length);
- inPointer += newData.length;
- size += newData.length;
- } else {
- System.arraycopy(newData, 0, input, inPointer, input.length-inPointer);
- System.arraycopy(newData, input.length-inPointer, input, 0, newData.length-(input.length-inPointer));
- inPointer = newData.length-(input.length-inPointer);
- size += newData.length;
- }
-
- if (inPointer == input.length) {
- inPointer = 0;
- }
- notifyAll();
- }
-
- /**
- * Enlarges the buffer.
- */
- private void growArray() {
- byte[] newInput = new byte[input.length+1024];
- if (outPointer < inPointer) {
- System.arraycopy(input, outPointer, newInput, 0, size);
- } else {
- System.arraycopy(input, outPointer, newInput, 0, input.length-outPointer);
- System.arraycopy(input, 0, newInput, input.length-outPointer, inPointer);
- }
- outPointer = 0;
- inPointer = size;
- input = newInput;
- newInput = null;
- }
-
- /**
- * Returns this stream's font style.
- *
- * @return the font style used to decorate input in the associated console
- */
- public int getFontStyle() {
- return fontStyle;
- }
-
- /**
- * Sets this stream's font style.
- *
- * @param newFontStyle the font style to be used to decorate input in the associated console
- */
- public void setFontStyle(int newFontStyle) {
- if (newFontStyle != fontStyle) {
- int old = fontStyle;
- fontStyle = newFontStyle;
- console.firePropertyChange(this, IConsoleConstants.P_FONT_STYLE, 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) {
- Color old = color;
- if (old == null || !old.equals(newColor)) {
- color = newColor;
- console.firePropertyChange(this, IConsoleConstants.P_STREAM_COLOR, old, newColor);
- }
- }
-
- /**
- * Returns the color used to decorate input in the associated console
- *
- * @return the color used to decorate input in the associated console
- */
- public Color getColor() {
- return color;
- }
-
- /* (non-Javadoc)
- * @see java.io.InputStream#available()
- */
- 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 {
- if(closed) {
- throw new IOException("Input Stream Closed"); //$NON-NLS-1$
- }
- closed = true;
- notifyAll();
- console.streamClosed(this);
- }
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleOutputStream.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleOutputStream.java
deleted file mode 100644
index c035e1a6f..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsoleOutputStream.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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.console;
-
-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;
-
-/**
- * OutputStream used to write to an IOConsole.
- *
- * Clients are not intended to instantiate this class directly, instead
- * use IOConsole.newOutputStream()
.
- *
- * Clients should avoid writing large amounts of output to this stream in the UI - * thread. The console needs to process the output in the UI thread and if the client - * hogs the UI thread writing output to the console, the console will not be able - * to process the output. - *
- * @since 3.1 - * @noinstantiate This class is not intended to be instantiated by clients. - * @noextend This class is not intended to be subclassed by clients. - */ -public class IOConsoleOutputStream extends OutputStream { - /** - * Flag indicating whether this stream has been closed. - */ - private boolean closed = false; - - /** - * 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. - */ - private int fontStyle; - - private String fEncoding; - private String fDefaultEncoding = WorkbenchEncoding.getWorkbenchDefaultEncoding(); - - private boolean fNeedsEncoding = false; - - private boolean prependCR; - - /** - * Constructs a new output stream on the given console. - * - * @param console I/O console - */ - IOConsoleOutputStream(IOConsole console) { - this.console = console; - this.partitioner = (IOConsolePartitioner) console.getPartitioner(); - } - - /** - * Returns the font style used to decorate data written to this stream. - * - * @return the font style used to decorate data written to this stream - */ - public int getFontStyle() { - return fontStyle; - } - - /** - * Sets the font style to be used to decorate data written to this stream. - * - * @param newFontStyle the font style to be used to decorate data written to this stream - */ - public void setFontStyle(int newFontStyle) { - if (newFontStyle != fontStyle) { - int old = fontStyle; - fontStyle = newFontStyle; - console.firePropertyChange(this, IConsoleConstants.P_FONT_STYLE, 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. - */ - public boolean isActivateOnWrite() { - return activateOnWrite; - } - - /** - * Sets whether to activate the console this stream is writing to when this stream - * is written to. - * - * @param activateOnWrite whether the console this stream is writing to will be activated when this stream - * is written to. - */ - public void setActivateOnWrite(boolean activateOnWrite) { - this.activateOnWrite = activateOnWrite; - } - - /** - * Sets the color of this stream. Usenull
to indicate
- * the default color.
- *
- * @param newColor color of this stream, or null
- */
- public void setColor(Color newColor) {
- Color old = color;
- if (old == null || !old.equals(newColor)) {
- color = newColor;
- console.firePropertyChange(this, IConsoleConstants.P_STREAM_COLOR, old, newColor);
- }
- }
-
- /**
- * Returns the color of this stream, or null
- * if default.
- *
- * @return the color of this stream, or null
- */
- public Color getColor() {
- return color;
- }
-
- /**
- * Returns true if the stream has been closed
- * @return true is the stream has been closed, false otherwise.
- */
- public synchronized boolean isClosed() {
- return closed;
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.OutputStream#close()
- */
- public synchronized void close() throws IOException {
- if(closed) {
- throw new IOException("Output Stream is closed"); //$NON-NLS-1$
- }
- if (prependCR) { // force writing of last /r
- prependCR = false;
- notifyParitioner("\r"); //$NON-NLS-1$
- }
- console.streamClosed(this);
- closed = true;
- partitioner = null;
- }
-
- /*
- * (non-Javadoc)
- * @see java.io.OutputStream#flush()
- */
- 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 {
- if (fNeedsEncoding) {
- encodedWrite(new String(b, off, len, fEncoding));
- } else {
- encodedWrite(new String(b, off, len));
- }
- }
- /*
- * (non-Javadoc)
- * @see java.io.OutputStream#write(byte[])
- */
- 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 {
- 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 synchronized void write(String str) throws IOException {
- if (fNeedsEncoding) {
- byte[] defaultBytes = str.getBytes();
- str = new String(defaultBytes, fEncoding);
- }
- encodedWrite(str);
- }
-
- private void encodedWrite(String encodedString) throws IOException {
- if(closed) {
- throw new IOException("Output Stream is closed"); //$NON-NLS-1$
- }
- if (prependCR){
- encodedString="\r"+encodedString; //$NON-NLS-1$
- prependCR=false;
- }
- if (encodedString.endsWith("\r")) { //$NON-NLS-1$
- prependCR = true;
- encodedString = new String(encodedString.substring(0, encodedString.length()-1));
- }
- notifyParitioner(encodedString);
- }
-
- private void notifyParitioner(String encodedString) throws IOException {
- try {
- partitioner.streamAppended(this, encodedString);
-
- if (activateOnWrite) {
- console.activate();
- } else {
- ConsolePlugin.getDefault().getConsoleManager().warnOfContentChange(console);
- }
- } catch (IOException e) {
- if (!closed) {
- close();
- }
- throw e;
- }
- }
-
- /**
- * Sets the character encoding used to interpret characters written to this steam.
- *
- * @param encoding encoding identifier
- */
- public void setEncoding(String encoding) {
- fEncoding = encoding;
- fNeedsEncoding = (fEncoding!=null) && (!fEncoding.equals(fDefaultEncoding));
- }
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListener.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListener.java
deleted file mode 100644
index d3042ead2..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListener.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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.console;
-
-/**
- * A pattern match listener is registered with a TextConsole
,
- * and is notified when its pattern has been matched to contents in
- * that console. A pattern match listener can be registered with a console
- * programmatically or via the consolePatternMatchListeners
extension
- * point.
- * - * Following is an example console pattern match listener extension definition. - * - * <extension point="org.eclipse.ui.console.consolePatternMatchListeners"> - * <consolePatternMatchListener - * id="com.example.ConsolePatternMatcher" - * regex=".*foo.*" - * class="com.example.ConsolePatternMatcher"> - * </consolePatternMatchListener> - * </extension> - * - * Attributes are specified as follows: - *
id
- a unique identifier for the pattern match listenerregex
- regular expression to matchclass
- fully qualified name of the Java class implementing
- * org.eclipse.ui.console.IPatternMatchListenerDelegate
- * Optionally a qualifier
attribute may be specified to improve performance
- * of regular expression matching. A qualifier specifies a simple regular expression used to
- * qualify lines for the search. Lines that do not contain the qualifier are not considered.
- *
- * Optionally an enablement
expression may be provided to specify
- * which console(s) a pattern matcher should be contributed to.
- *
- * Clients may implement this interface directly if registering a pattern match listener with
- * a text console programmatically. Clients contributing a pattern match listener via an
- * extension implement IPatternMatchListenerDelegate
instead.
- *
Pattern.compile(String regex, int flags)
- *
- * @return the flags to use when compiling this pattern match listener's
- * regular expression
- * @see java.util.regex.Pattern#compile(java.lang.String, int)
- */
- public int getCompilerFlags();
-
- /**
- * Returns a simple regular expression used to identify lines that may
- * match this pattern matcher's complete pattern, or null
.
- * Use of this attribute can improve performance by disqualifying lines
- * from the search. When a line is found containing a match for this expression,
- * the line is searched from the beginning for this pattern matcher's
- * complete pattern. Lines not containing this pattern are discarded.
- *
- * @return a simple regular expression used to identify lines that may
- * match this pattern matcher's complete pattern, or null
- */
- public String getLineQualifier();
-
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListenerDelegate.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListenerDelegate.java
deleted file mode 100644
index a3e60dd87..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IPatternMatchListenerDelegate.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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.console;
-
-/**
- * A pattern match listener delegate is notified of regular expression matches
- * in a text console. A delegate is contributed via the
- * consolePatternMatcherListeners
extension point.
- * - * Clients contributing a console pattern match listener extension are intended - * to implement this interface. - *
- * @see org.eclipse.ui.console.IPatternMatchListener - * @see org.eclipse.ui.console.TextConsole - * @since 3.1 - */ -public interface IPatternMatchListenerDelegate { - /** - * Notification that pattern matching will begin in the specified console. - * A pattern matcher is connected to only one console at a time. - * - * @param console the console in which pattern matching will be performed - */ - public void connect(TextConsole console); - - /** - * Notification that pattern matching has been completed in the console - * this delegate was last connected to. - */ - public void disconnect(); - - /** - * Notification that a match has been found. - * - * @param event event describing where the match was found - */ - public void matchFound(PatternMatchEvent event); -} 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 deleted file mode 100644 index b9f3071bf..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsole.java +++ /dev/null @@ -1,153 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 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.console; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.internal.console.IOConsolePage; -import org.eclipse.ui.part.IPageBookViewPage; - -/** - * A console that displays messages. A message console may have one or - * more streams connected to it (MessageConsoleStream
).
- * Text written to streams is buffered and processed in a Job by the
- * console's document partitioner.
- * - * Clients may instantiate this class. - *
- * @since 3.0 - * @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} - */ - 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} - */ - 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} - */ - 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; - - /** - * Constructs a message console with the given name and image. - * - * @param name console name - * @param imageDescriptor console image descriptor ornull
- */
- public MessageConsole(String name, ImageDescriptor imageDescriptor) {
- this(name, imageDescriptor, true);
- }
-
- /**
- * Constructs a message console.
- *
- * @param name console name
- * @param imageDescriptor console image descriptor or null
- * @param autoLifecycle whether lifecycle methods should be called automatically
- * when added and removed from the console manager
- * @since 3.1
- */
- 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 null
- * @param imageDescriptor console image descriptor or null
- * @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 null
- * @param imageDescriptor console image descriptor or null
- * @param encoding the encoding that should be used to render the text, or null
- * if the system default encoding should be used
- * @param autoLifecycle whether lifecycle methods should be called automatically
- * when added and removed from the console manager
- * @since 3.5
- */
- public MessageConsole(String name, String consoleType, ImageDescriptor imageDescriptor, String encoding, boolean autoLifecycle) {
- super(name, consoleType, imageDescriptor, encoding, autoLifecycle);
- }
-
- /**
- * Returns a new message stream connected to this console.
- * - * Clients should avoid writing large amounts of output to this stream in the UI - * thread. The console needs to process the output in the UI thread and if the client - * hogs the UI thread writing output to the console, the console will not be able - * to process the output. - *
- * @return a new message stream connected to this console - */ - public MessageConsoleStream newMessageStream() { - return new MessageConsoleStream(this); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.console.IConsole#createPage(org.eclipse.ui.console.IConsoleView) - */ - 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() { - 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 - */ - protected void appendToDocument(String text, MessageConsoleStream stream) { - } -} diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsoleStream.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsoleStream.java deleted file mode 100644 index 274e8a8f2..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/MessageConsoleStream.java +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 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.console; - -import java.io.IOException; - -/** - * Used to write messages to a message console. A message console may have more - * than one stream connected to it. Each stream may be displayed in a different - * color. - *- * Instances are created via a {@link org.eclipse.ui.console.MessageConsole}. - *
- *- * Clients should avoid writing large amounts of output to this stream in the UI - * thread. The console needs to process the output in the UI thread and if the client - * hogs the UI thread writing output to the console, the console will not be able - * to process the output. - *
- *- * Since 3.1, this class extends {@link org.eclipse.ui.console.IOConsoleOutputStream}. - *
- * @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 MessageConsoleStream extends IOConsoleOutputStream { - - private MessageConsole fMessageConsole; - - /** - * Constructs a new stream connected to the given console. - * - * @param console the console to write messages to - */ - public MessageConsoleStream(MessageConsole console) { - super(console); - fMessageConsole = console; - } - - /** - * Appends the specified message to this stream. - * - * @param message message to append - */ - public void print(String message) { - try { - write(message); - } catch (IOException e) { - ConsolePlugin.log(e); - } - } - - - /** - * Appends a line separator string to this stream. - */ - public void println() { - try { - write("\n"); //$NON-NLS-1$ - } catch (IOException e) { - ConsolePlugin.log(e); - } - } - - /** - * Appends the specified message to this stream, followed by a line - * separator string. - * - * @param message message to print - */ - public void println(String message) { - print(message + "\n"); //$NON-NLS-1$ - } - - /** - * Returns the console this stream is connected to. - * - * @return the console this stream is connected to - */ - public MessageConsole getConsole() { - return fMessageConsole; - } -} diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/PatternMatchEvent.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/PatternMatchEvent.java deleted file mode 100644 index c4c00ff6f..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/PatternMatchEvent.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 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.console; - -import java.util.EventObject; - -/** - * An event describing a pattern match in a text console. The source of the event - * is aTextConsole
.
- * - * Clients may instantiate this class. - *
- * @see org.eclipse.ui.console.IPatternMatchListener - * @see org.eclipse.ui.console.TextConsole - * @since 3.1 - * @noextend This class is not intended to be subclassed by clients. - */ -public class PatternMatchEvent extends EventObject { - /* - * required by EventObject for ObjectSerialization. - */ - private static final long serialVersionUID = 876890383326854537L; - - /** - * The offset of the match within the console's document. - */ - private int offset; - - /** - * The length of the matched string - */ - private int length; - - /** - * Constructs a new pattern match event. - * - * @param console the console in which the match was found - * @param matchOffset the offset at which the match was found - * @param matchLength the length of the text that matched - */ - public PatternMatchEvent(TextConsole console, int matchOffset, int matchLength) { - super(console); - offset = matchOffset; - length = matchLength; - } - - /** - * Returns the length of the matched string. - * - * @return the length of the matched string - */ - public int getLength() { - return length; - } - - /** - * Returns the offset of the match within the document. - * - * @return the offset of the match within the document - */ - public int getOffset() { - return offset; - } - -} 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 deleted file mode 100644 index 81561f9ff..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsole.java +++ /dev/null @@ -1,554 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 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.console; - -import java.util.HashMap; - -import org.eclipse.core.runtime.jobs.ISchedulingRule; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.BadPositionCategoryException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.Region; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.ui.internal.console.ConsoleDocument; -import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition; -import org.eclipse.ui.internal.console.ConsolePatternMatcher; -import org.eclipse.ui.part.IPageBookViewPage; - -/** - * An abstract text console that supports regular expression matching and - * hyperlinks. - *
- * Pattern match listeners can be registered with a console programmatically
- * or via the org.eclipse.ui.console.consolePatternMatchListeners
- * extension point.
- *
- * Clients may subclass this class. Subclasses must provide a document partitioner. - *
- * @since 3.1 - */ -public abstract class TextConsole extends AbstractConsole { - - /** - * The current width of the console. Used for fixed width consoles. - * A value of <=0 means does not have a fixed width. - */ - private int fConsoleWidth; - /** - * The current tab width - */ - private int fTabWidth; - /** - * The font used by this console - */ - private Font fFont; - - /** - * The background color used by this console ornull
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 IConsoleManager fConsoleManager = ConsolePlugin.getDefault().getConsoleManager();
-
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.AbstractConsole#dispose()
- */
- protected void dispose() {
- super.dispose();
- fFont = null;
- synchronized(fAttributes) {
- fAttributes.clear();
- }
- }
- /**
- * Constructs a console with the given name, image descriptor, and lifecycle
- *
- * @param name name to display for this console
- * @param consoleType console type identifier or null
- * @param imageDescriptor image to display for this console or null
- * @param autoLifecycle whether lifecycle methods should be called automatically
- * when this console is added/removed from the console manager
- */
- public TextConsole(String name, String consoleType, ImageDescriptor imageDescriptor, boolean autoLifecycle) {
- super(name, consoleType, imageDescriptor, autoLifecycle);
- fDocument = new ConsoleDocument();
- fDocument.addPositionCategory(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY);
- fPatternMatcher = new ConsolePatternMatcher(this);
- fDocument.addDocumentListener(fPatternMatcher);
- fTabWidth = IConsoleConstants.DEFAULT_TAB_SIZE;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsole#createPage(org.eclipse.ui.console.IConsoleView)
- */
- public IPageBookViewPage createPage(IConsoleView view) {
- return new TextConsolePage(this, view);
- }
-
- /**
- * Returns this console's document.
- * - * Note that a console may or may not support direct manipulation of its document. - * For example, an I/O console document and its partitions are produced from the - * streams connected to it, and clients are not intended to modify the document's - * contents. - *
- * - * @return this console's document - */ - public IDocument getDocument() { - return fDocument; - } - - /** - * Returns the current width of this console. A value of zero of less - * indicates this console has no fixed width. - * - * @return the current width of this console - */ - public int getConsoleWidth() { - return fConsoleWidth; - } - - /** - * Sets the width of this console in characters. Any value greater than zero - * will cause this console to have a fixed width. - * - * @param width the width to make this console. Values of 0 or less imply - * the console does not have any fixed width. - */ - public void setConsoleWidth(int width) { - if (fConsoleWidth != width) { - int old = fConsoleWidth; - fConsoleWidth = width; - - firePropertyChange(this, IConsoleConstants.P_CONSOLE_WIDTH, new Integer(old), new Integer(fConsoleWidth)); - } - } - - /** - * Sets the tab width used in this console. - * - * @param newTabWidth the tab width - */ - public void setTabWidth(final int newTabWidth) { - if (fTabWidth != newTabWidth) { - final int oldTabWidth = fTabWidth; - fTabWidth = newTabWidth; - ConsolePlugin.getStandardDisplay().asyncExec(new Runnable() { - 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() { - if (fFont == null) { - fFont = getDefaultFont(); - } - return fFont; - } - - /** - * Returns the default text font. - * - * @return the default text font - */ - private Font getDefaultFont() { - return JFaceResources.getFont(JFaceResources.TEXT_FONT); - } - - /** - * Sets the font used by this console. Specifynull
to use
- * the default text font.
- *
- * @param newFont font, or null
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();
- }
- // fire property change if required
- if (!fFont.equals(newFont)) {
- Font old = fFont;
- fFont = newFont;
- firePropertyChange(this, IConsoleConstants.P_FONT, old, fFont);
- }
- }
-
- /**
- * Sets the background color used by this console. Specify null
to use
- * the default background color.
- *
- * @param background background color or null
for default
- * @since 3.3
- * @deprecated use setBackground(Color) instead
- */
- public void setBackgrond(Color background) {
- setBackground(background);
- }
-
- /**
- * Sets the background color used by this console. Specify null
to use
- * the default background color.
- *
- * @param background background color or null
for default
- * @since 3.3
- */
- public void setBackground(Color background) {
- if (fBackground == null) {
- if (background == null) {
- return;
- }
- } else if (fBackground.equals(background)){
- return;
- }
- Color old = fBackground;
- fBackground = background;
- firePropertyChange(this, IConsoleConstants.P_BACKGROUND_COLOR, old, fBackground);
- }
-
- /**
- * Returns the background color to use for this console or null
for the
- * default background color.
- *
- * @return background color or null
for default
- * @since 3.3
- */
- public Color getBackground() {
- return fBackground;
- }
-
- /**
- * Clears the console.
- * - * Since a console may or may not support direct manipulation - * of its document's contents, this method should be called to clear a text console's - * document. The default implementation sets this console's document content - * to the empty string directly. Subclasses should override as required. - *
- */ - public void clearConsole() { - IDocument document = getDocument(); - if (document != null) { - document.set(""); //$NON-NLS-1$ - } - } - - /** - * Returns the console's document partitioner. - * @return The console's document partitioner - */ - protected abstract IConsoleDocumentPartitioner getPartitioner(); - - /** - * Returns all hyperlinks in this console. - * - * @return all hyperlinks in this console - */ - public IHyperlink[] getHyperlinks() { - try { - Position[] positions = getDocument().getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); - IHyperlink[] hyperlinks = new IHyperlink[positions.length]; - for (int i = 0; i < positions.length; i++) { - ConsoleHyperlinkPosition position = (ConsoleHyperlinkPosition) positions[i]; - hyperlinks[i] = position.getHyperLink(); - } - return hyperlinks; - } catch (BadPositionCategoryException e) { - return new IHyperlink[0]; - } - } - - /** - * Returns the hyperlink at the given offset ofnull
if none.
- *
- * @param offset offset for which a hyperlink is requested
- * @return the hyperlink at the given offset of null
if none
- */
- public IHyperlink getHyperlink(int offset) {
- try {
- IDocument document = getDocument();
- if (document != null) {
- Position[] positions = document.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY);
- Position position = findPosition(offset, positions);
- if (position instanceof ConsoleHyperlinkPosition) {
- return ((ConsoleHyperlinkPosition) position).getHyperLink();
- }
- }
- } catch (BadPositionCategoryException e) {
- }
- return null;
- }
-
- /**
- * Binary search for the position at a given offset.
- *
- * @param offset the offset whose position should be found
- * @return the position containing the offset, or null
- */
- private Position findPosition(int offset, Position[] positions) {
-
- 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)
- right= left;
- else
- right= mid -1;
- } else if (offset > (position.getOffset() + position.getLength() - 1)) {
- if (right == mid)
- left= right;
- else
- left= mid +1;
- } else {
- left= right= mid;
- }
- }
-
- position= positions[left];
- if (offset >= position.getOffset() && (offset < (position.getOffset() + position.getLength()))) {
- return position;
- }
- return null;
- }
-
- /**
- * Adds the given pattern match listener to this console. The listener will
- * be connected and receive match notifications. Has no effect if an identical
- * listener has already been added.
- *
- * @param listener the listener to add
- */
- public void addPatternMatchListener(IPatternMatchListener listener) {
- fPatternMatcher.addPatternMatchListener(listener);
- }
-
- /**
- * Removes the given pattern match listener from this console. The listener will be
- * disconnected and will no longer receive match notifications. Has no effect
- * if the listener was not previously added.
- *
- * @param listener the pattern match listener to remove
- */
- public void removePatternMatchListener(IPatternMatchListener listener) {
- fPatternMatcher.removePatternMatchListener(listener);
- }
-
-
- /**
- * Job scheduling rule that prevent the job from running if the console's PatternMatcher
- * is active.
- */
- private class MatcherSchedulingRule implements ISchedulingRule {
- public boolean contains(ISchedulingRule rule) {
- return rule == this;
- }
-
- public boolean isConflicting(ISchedulingRule rule) {
- if (contains(rule)) {
- return true;
- }
- if (rule != this && rule instanceof MatcherSchedulingRule) {
- return (((MatcherSchedulingRule)rule).getConsole() == TextConsole.this);
- }
- return false;
- }
-
- public TextConsole getConsole() {
- return TextConsole.this;
- }
- }
-
- /**
- * Returns a scheduling rule which can be used to prevent jobs from running
- * while this console's pattern matcher is active.
- * - * Although this scheduling rule prevents jobs from running at the same time as - * pattern matching jobs for this console, it does not enforce any ordering of jobs. - * Since 3.2, pattern matching jobs belong to the job family identified by the console - * object that matching is occurring on. To ensure a job runs after all scheduled pattern - * matching is complete, clients must join on this console's job family. - *
- * @return a scheduling rule which can be used to prevent jobs from running - * while this console's pattern matcher is active - */ - public ISchedulingRule getSchedulingRule() { - return new MatcherSchedulingRule(); - } - - /** - * This console's partitioner should call this method when it is not expecting any new data - * to be appended to the document. - */ - public void partitionerFinished() { - fPatternMatcher.forceFinalMatching(); - fPartitionerFinished = true; - checkFinished(); - } - - /** - * Called by this console's pattern matcher when matching is complete. - *- * Clients should not call this method. - *
- */ - public void matcherFinished() { - fMatcherFinished = true; - fDocument.removeDocumentListener(fPatternMatcher); - checkFinished(); - } - - /** - * Fires the console output complete property change event. - */ - private synchronized void checkFinished() { - if (!fCompleteFired && fPartitionerFinished && fMatcherFinished ) { - fCompleteFired = true; - firePropertyChange(this, IConsoleConstants.P_CONSOLE_OUTPUT_COMPLETE, null, null); - } - } - - /** - * Adds a hyperlink to this console. - * - * @param hyperlink the hyperlink to add - * @param offset the offset in the console document at which the hyperlink should be added - * @param length the length of the text which should be hyperlinked - * @throws BadLocationException if the specified location is not valid. - */ - public void addHyperlink(IHyperlink hyperlink, int offset, int length) throws BadLocationException { - IDocument document = getDocument(); - ConsoleHyperlinkPosition hyperlinkPosition = new ConsoleHyperlinkPosition(hyperlink, offset, length); - try { - document.addPosition(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY, hyperlinkPosition); - fConsoleManager.refresh(this); - } catch (BadPositionCategoryException e) { - ConsolePlugin.log(e); - } - } - - /** - * Returns the region associated with the given hyperlink. - * - * @param link hyperlink - * @return the region associated with the hyperlink or null if the hyperlink is not found. - */ - public IRegion getRegion(IHyperlink link) { - try { - IDocument doc = getDocument(); - if (doc != null) { - Position[] positions = doc.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); - for (int i = 0; i < positions.length; i++) { - ConsoleHyperlinkPosition position = (ConsoleHyperlinkPosition)positions[i]; - if (position.getHyperLink().equals(link)) { - return new Region(position.getOffset(), position.getLength()); - } - } - } - } catch (BadPositionCategoryException e) { - } - return null; - } - - /** - * Returns the attribute associated with the specified key. - * - * @param key attribute key - * @return the attribute associated with the specified key - */ - public Object getAttribute(String key) { - synchronized (fAttributes) { - return fAttributes.get(key); - } - } - - /** - * Sets an attribute value. Intended for client data. - * - * @param key attribute key - * @param value attribute value - */ - public void setAttribute(String key, Object value) { - synchronized(fAttributes) { - fAttributes.put(key, value); - } - } -} 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 deleted file mode 100644 index ae76fec0a..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java +++ /dev/null @@ -1,413 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 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 - * Livar Cunha (livarcocc@gmail.com) - Bug 236049 - *******************************************************************************/ - -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; -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.ui.IActionBars; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.IWorkbenchActionConstants; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.console.actions.ClearOutputAction; -import org.eclipse.ui.console.actions.TextViewerAction; -import org.eclipse.ui.internal.console.ConsoleMessages; -import org.eclipse.ui.internal.console.ConsoleResourceBundleMessages; -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; - -/** - * A page for a text console. - *
- * Clients may contribute actions to the context menu of a text console page
- * using the org.eclipse.ui.popupMenus
extension point. The context
- * menu identifier for a text console page is the associated console's type
- * suffixed with .#ContextMenu
. When a console does not specify
- * a type, the context menu id is #ContextMenu
.
- *
- * Clients may subclass this class. - *
- * @since 3.1 - */ -public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListener, IAdaptable { - private IPageSite fSite; - private TextConsole fConsole; - private IConsoleView fConsoleView; - private TextConsoleViewer fViewer; - private MenuManager fMenuManager; - protected Map fGlobalActions = new HashMap(); - protected ArrayList fSelectionActions = new ArrayList(); - protected ClearOutputAction fClearOutputAction; - - // text selection listener, used to update selection dependent actions on selection changes - private ISelectionChangedListener selectionChangedListener = new ISelectionChangedListener() { - 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) { - IUpdate findReplace = (IUpdate)fGlobalActions.get(ActionFactory.FIND.getId()); - if (findReplace != null) { - findReplace.update(); - } - - if (fClearOutputAction != null) { - IDocument doc = fViewer.getDocument(); - if(doc != null) { - fClearOutputAction.setEnabled(doc.getLength() > 0); - } - } - } - }; - - /** - * Constructs a text console page for the given console in the given view. - * - * @param console text console - * @param view console view the page is contained in - */ - public TextConsolePage(TextConsole console, IConsoleView view) { - fConsole = console; - fConsoleView = view; - } - - /** - * 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() { - return fSite; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.part.IPageBookViewPage#init(org.eclipse.ui.part.IPageSite) - */ - public void init(IPageSite pageSite) throws PartInitException { - fSite = pageSite; - } - - /** - * Updates selection dependent actions. - */ - protected void updateSelectionDependentActions() { - Iterator iterator= fSelectionActions.iterator(); - while (iterator.hasNext()) { - updateAction((String)iterator.next()); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite) - */ - 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$ - } - fMenuManager= new MenuManager("#ContextMenu", id); //$NON-NLS-1$ - fMenuManager.setRemoveAllWhenShown(true); - fMenuManager.addMenuListener(new IMenuListener() { - 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); - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.part.IPage#dispose() - */ - public void dispose() { - fConsole.removePropertyChangeListener(this); - JFaceResources.getFontRegistry().removeListener(this); - - if (fMenuManager != null) { - fMenuManager.dispose(); - } - fClearOutputAction = null; - fSelectionActions.clear(); - fGlobalActions.clear(); - - fViewer.getSelectionProvider().removeSelectionChangedListener(selectionChangedListener); - fViewer.removeTextListener(textListener); - fViewer = null; - } - - - /* - * (non-Javadoc) - * @see org.eclipse.ui.part.IPage#getControl() - */ - 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) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.part.IPage#setFocus() - */ - public void setFocus() { - if (fViewer != null) { - fViewer.getTextWidget().setFocus(); - } - } - - /* - * (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - 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)) { - fViewer.getTextWidget().redraw(); - } else if (property.equals(IConsoleConstants.P_STREAM_COLOR)) { - fViewer.getTextWidget().redraw(); - } else if (source.equals(fConsole) && property.equals(IConsoleConstants.P_TAB_SIZE)) { - Integer tabSize = (Integer)event.getNewValue(); - fViewer.setTabWidth(tabSize.intValue()); - } else if (source.equals(fConsole) && property.equals(IConsoleConstants.P_CONSOLE_WIDTH)) { - fViewer.setConsoleWidth(fConsole.getConsoleWidth()); - } else if (IConsoleConstants.P_BACKGROUND_COLOR.equals(property)) { - fViewer.getTextWidget().setBackground(fConsole.getBackground()); - } - } - } - - /** - * Creates actions. - */ - protected void createActions() { - IActionBars actionBars= getSite().getActionBars(); - TextViewerAction action= new TextViewerAction(fViewer, ITextOperationTarget.SELECT_ALL); - action.configureAction(ConsoleMessages.TextConsolePage_SelectAllText, ConsoleMessages.TextConsolePage_SelectAllDescrip, ConsoleMessages.TextConsolePage_SelectAllDescrip); - action.setActionDefinitionId(ActionFactory.SELECT_ALL.getCommandId()); - PlatformUI.getWorkbench().getHelpSystem().setHelp(action, IConsoleHelpContextIds.CONSOLE_SELECT_ALL_ACTION); - 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); - setGlobalAction(actionBars, ActionFactory.FIND.getId(), fraction); - - fSelectionActions.add(ActionFactory.CUT.getId()); - 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 - */ - protected void setGlobalAction(IActionBars actionBars, String actionID, IAction action) { - fGlobalActions.put(actionID, action); - actionBars.setGlobalActionHandler(actionID, action); - } - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - public Object getAdapter(Class required) { - if (IFindReplaceTarget.class.equals(required)) { - return fViewer.getFindReplaceTarget(); - } - if (Widget.class.equals(required)) { - return fViewer.getTextWidget(); - } - 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); - if (action instanceof IUpdate) { - ((IUpdate) action).update(); - } - } - - - /** - * Fill the context menu - * - * @param menuManager menu - */ - protected void contextMenuAboutToShow(IMenuManager menuManager) { - IDocument doc= fViewer.getDocument(); - if (doc == null) { - 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(new Separator("FIND")); //$NON-NLS-1$ - menuManager.add((IAction)fGlobalActions.get(ActionFactory.FIND.getId())); - menuManager.add(new FollowHyperlinkAction(fViewer)); - menuManager.add(fClearOutputAction); - - menuManager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); - } - - protected void configureToolBar(IToolBarManager mgr) { - mgr.appendToGroup(IConsoleConstants.OUTPUT_GROUP, fClearOutputAction); - } - - - /** - * Returns the viewer contained in this page. - * - * @return the viewer contained in this page - */ - public TextConsoleViewer getViewer() { - return fViewer; - } - - /** - * Sets the viewer contained in this page. - * - * @param viewer text viewer - */ - public void setViewer(TextConsoleViewer viewer) { - this.fViewer = viewer; - } -} diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java deleted file mode 100644 index 50c1a8e2d..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsoleViewer.java +++ /dev/null @@ -1,699 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 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.console; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.preference.JFacePreferences; -import org.eclipse.jface.resource.ColorRegistry; -import org.eclipse.jface.resource.JFaceColors; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.text.BadPositionCategoryException; -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.jface.text.IPositionUpdater; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.LineBackgroundEvent; -import org.eclipse.swt.custom.LineBackgroundListener; -import org.eclipse.swt.custom.LineStyleEvent; -import org.eclipse.swt.custom.LineStyleListener; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.MouseMoveListener; -import org.eclipse.swt.events.MouseTrackListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.ui.internal.console.ConsoleDocumentAdapter; -import org.eclipse.ui.internal.console.ConsoleHyperlinkPosition; -import org.eclipse.ui.progress.WorkbenchJob; - -/** - * Default viewer used to display aTextConsole
.
- * - * Clients may subclass this class. - *
- * - * @since 3.1 - */ -public class TextConsoleViewer extends SourceViewer implements LineStyleListener, LineBackgroundListener, MouseTrackListener, MouseMoveListener, MouseListener { - /** - * Adapts document to the text widget. - */ - private ConsoleDocumentAdapter documentAdapter; - - private IHyperlink hyperlink; - - private Cursor handCursor; - - private Cursor textCursor; - - private int consoleWidth = -1; - - private TextConsole console; - - private IPropertyChangeListener propertyChangeListener; - - private IDocumentListener documentListener = new IDocumentListener() { - public void documentAboutToBeChanged(DocumentEvent event) { - } - - public void documentChanged(DocumentEvent event) { - updateLinks(event.fOffset); - } - }; - // event listener used to send event to hyperlink for IHyperlink2 - private Listener mouseUpListener = new Listener() { - public void handleEvent(Event event) { - if (hyperlink != null) { - String selection = getTextWidget().getSelectionText(); - if (selection.length() <= 0) { - if (event.button == 1) { - if (hyperlink instanceof IHyperlink2) { - ((IHyperlink2) hyperlink).linkActivated(event); - } else { - hyperlink.linkActivated(); - } - } - } - } - } - }; - - WorkbenchJob revealJob = new WorkbenchJob("Reveal End of Document") {//$NON-NLS-1$ - public IStatus runInUIThread(IProgressMonitor monitor) { - StyledText textWidget = getTextWidget(); - if (textWidget != null && !textWidget.isDisposed()) { - int lineCount = textWidget.getLineCount(); - textWidget.setTopIndex(lineCount - 1); - } - return Status.OK_STATUS; - } - }; - - private IPositionUpdater positionUpdater = new IPositionUpdater() { - public void update(DocumentEvent event) { - try { - IDocument document = getDocument(); - if (document != null) { - Position[] positions = document.getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); - for (int i = 0; i < positions.length; i++) { - Position position = positions[i]; - if (position.offset == event.fOffset && position.length<=event.fLength) { - position.delete(); - } - if (position.isDeleted) { - document.removePosition(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY, position); - } - } - } - } catch (BadPositionCategoryException e) { - } - } - }; - - /** - * Constructs a new viewer in the given parent for the specified console. - * - * @param parent - * containing widget - * @param console - * text console - */ - public TextConsoleViewer(Composite parent, TextConsole console) { - super(parent, null, SWT.V_SCROLL | SWT.H_SCROLL); - this.console = console; - - IDocument document = console.getDocument(); - setDocument(document); - - StyledText styledText = getTextWidget(); - styledText.setDoubleClickEnabled(true); - styledText.addLineStyleListener(this); - styledText.addLineBackgroundListener(this); - styledText.setEditable(true); - setFont(console.getFont()); - styledText.addMouseTrackListener(this); - styledText.addListener(SWT.MouseUp, mouseUpListener); - - ColorRegistry colorRegistry = JFaceResources.getColorRegistry(); - propertyChangeListener = new HyperlinkColorChangeListener(); - colorRegistry.addListener(propertyChangeListener); - - revealJob.setSystem(true); - document.addDocumentListener(documentListener); - document.addPositionUpdater(positionUpdater); - } - - /** - * Sets the tab width used by this viewer. - * - * @param tabWidth - * the tab width used by this viewer - */ - public void setTabWidth(int tabWidth) { - StyledText styledText = getTextWidget(); - int oldWidth = styledText.getTabs(); - if (tabWidth != oldWidth) { - styledText.setTabs(tabWidth); - } - } - - /** - * Sets the font used by this viewer. - * - * @param font - * the font used by this viewer - */ - public void setFont(Font font) { - StyledText styledText = getTextWidget(); - Font oldFont = styledText.getFont(); - if (oldFont == font) { - return; - } - if (font == null || !(font.equals(oldFont))) { - styledText.setFont(font); - } - } - - /** - * Positions the cursor at the end of the document. - */ - protected void revealEndOfDocument() { - revealJob.schedule(50); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.custom.LineStyleListener#lineGetStyle(org.eclipse.swt.custom.LineStyleEvent) - */ - public void lineGetStyle(LineStyleEvent event) { - IDocument document = getDocument(); - if (document != null && document.getLength() > 0) { - ArrayList ranges = new ArrayList(); - int offset = event.lineOffset; - int length = event.lineText.length(); - - StyleRange[] partitionerStyles = ((IConsoleDocumentPartitioner) document.getDocumentPartitioner()).getStyleRanges(event.lineOffset, event.lineText.length()); - if (partitionerStyles != null) { - for (int i = 0; i < partitionerStyles.length; i++) { - ranges.add(partitionerStyles[i]); - } - } else { - ranges.add(new StyleRange(offset, length, null, null)); - } - - try { - Position[] positions = getDocument().getPositions(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY); - Position[] overlap = findPosition(offset, length, positions); - Color color = JFaceColors.getHyperlinkText(Display.getCurrent()); - if (overlap != null) { - for (int i = 0; i < overlap.length; i++) { - Position position = overlap[i]; - StyleRange linkRange = new StyleRange(position.offset, position.length, color, null); - linkRange.underline = true; - override(ranges, linkRange); - } - } - } catch (BadPositionCategoryException e) { - } - - if (ranges.size() > 0) { - event.styles = (StyleRange[]) ranges.toArray(new StyleRange[ranges.size()]); - } - } - } - - private void override(List ranges, StyleRange newRange) { - if (ranges.isEmpty()) { - ranges.add(newRange); - return; - } - - int start = newRange.start; - int end = start + newRange.length; - for (int i = 0; i < ranges.size(); i++) { - StyleRange existingRange = (StyleRange) ranges.get(i); - int rEnd = existingRange.start + existingRange.length; - if (end <= existingRange.start || start >= rEnd) { - continue; - } - - if (start < existingRange.start && end > existingRange.start) { - start = existingRange.start; - } - - if (start >= existingRange.start && end <= rEnd) { - existingRange.length = start - existingRange.start; - ranges.add(++i, newRange); - if (end != rEnd) { - ranges.add(++i, new StyleRange(end, rEnd - end - 1, existingRange.foreground, existingRange.background)); - } - return; - } else if (start >= existingRange.start && start < rEnd) { - existingRange.length = start - existingRange.start; - ranges.add(++i, newRange); - } else if (end >= rEnd) { - ranges.remove(i); - } else { - ranges.add(++i, new StyleRange(end + 1, rEnd - end + 1, existingRange.foreground, existingRange.background)); - } - } - } - - /** - * Binary search for the positions overlapping the given range - * - * @param offset - * the offset of the range - * @param length - * the length of the range - * @param positions - * the positions to search - * @return the positions overlapping the given range, ornull
- */
- private Position[] findPosition(int offset, int length, Position[] positions) {
-
- if (positions.length == 0)
- return null;
-
- int rangeEnd = offset + length;
- int left = 0;
- int right = positions.length - 1;
- int mid = 0;
- Position position = null;
-
- while (left < right) {
-
- mid = (left + right) / 2;
-
- position = positions[mid];
- if (rangeEnd < position.getOffset()) {
- if (left == mid)
- right = left;
- else
- right = mid - 1;
- } else if (offset > (position.getOffset() + position.getLength() - 1)) {
- if (right == mid)
- left = right;
- else
- left = mid + 1;
- } else {
- left = right = mid;
- }
- }
-
- List list = new ArrayList();
- int index = left - 1;
- if (index >= 0) {
- position = positions[index];
- while (index >= 0 && (position.getOffset() + position.getLength()) > offset) {
- index--;
- if (index > 0) {
- position = positions[index];
- }
- }
- }
- index++;
- position = positions[index];
- while (index < positions.length && (position.getOffset() < rangeEnd)) {
- list.add(position);
- index++;
- if (index < positions.length) {
- position = positions[index];
- }
- }
-
- if (list.isEmpty()) {
- return null;
- }
- return (Position[]) 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) {
- event.lineBackground = null;
- }
-
- /**
- * Returns the hand cursor.
- *
- * @return the hand cursor
- */
- protected Cursor getHandCursor() {
- if (handCursor == null) {
- handCursor = new Cursor(ConsolePlugin.getStandardDisplay(), SWT.CURSOR_HAND);
- }
- return handCursor;
- }
-
- /**
- * Returns the text cursor.
- *
- * @return the text cursor
- */
- protected Cursor getTextCursor() {
- if (textCursor == null) {
- textCursor = new Cursor(ConsolePlugin.getStandardDisplay(), SWT.CURSOR_IBEAM);
- }
- return textCursor;
- }
-
- /**
- * Notification a hyperlink has been entered.
- *
- * @param link
- * the link that was entered
- */
- protected void linkEntered(IHyperlink link) {
- Control control = getTextWidget();
- if (hyperlink != null) {
- linkExited(hyperlink);
- }
- hyperlink = link;
- hyperlink.linkEntered();
- control.setCursor(getHandCursor());
- control.redraw();
- control.addMouseListener(this);
- }
-
- /**
- * Notification a link was exited.
- *
- * @param link
- * the link that was exited
- */
- protected void linkExited(IHyperlink link) {
- link.linkExited();
- hyperlink = null;
- Control control = getTextWidget();
- control.setCursor(getTextCursor());
- control.redraw();
- control.removeMouseListener(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent)
- */
- 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) {
- getTextWidget().removeMouseMoveListener(this);
- if (hyperlink != null) {
- linkExited(hyperlink);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseHover(MouseEvent e) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseMove(MouseEvent e) {
- int offset = -1;
- try {
- Point p = new Point(e.x, e.y);
- offset = getTextWidget().getOffsetAtLocation(p);
- } catch (IllegalArgumentException ex) {
- // out of the document range
- }
- updateLinks(offset);
- }
-
- /**
- * The cursor has just be moved to the given offset, the mouse has hovered
- * over the given offset. Update link rendering.
- *
- * @param offset
- */
- protected void updateLinks(int offset) {
- if (offset >= 0) {
- IHyperlink link = getHyperlink(offset);
- if (link != null) {
- if (link.equals(hyperlink)) {
- return;
- }
- linkEntered(link);
- return;
- }
- }
- if (hyperlink != null) {
- linkExited(hyperlink);
- }
- }
-
- /**
- * Returns the currently active hyperlink or null
if none.
- *
- * @return the currently active hyperlink or null
if none
- */
- public IHyperlink getHyperlink() {
- return hyperlink;
- }
-
- /**
- * Returns the hyperlink at the specified offset, or null
if
- * none.
- *
- * @param offset
- * offset at which a hyperlink has been requested
- * @return hyperlink at the specified offset, or null
if none
- */
- public IHyperlink getHyperlink(int offset) {
- if (offset >= 0 && console != null) {
- return console.getHyperlink(offset);
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent e) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.TextViewer#createDocumentAdapter()
- */
- protected IDocumentAdapter createDocumentAdapter() {
- if (documentAdapter == null) {
- documentAdapter = new ConsoleDocumentAdapter(consoleWidth = -1);
- }
- return documentAdapter;
- }
-
- /**
- * Sets the console to have a fixed character width. Use -1 to indicate that
- * a fixed width should not be used.
- *
- * @param width
- * fixed character width of the console, or -1
- */
- public void setConsoleWidth(int width) {
- if (consoleWidth != width) {
- consoleWidth = width;
- ConsolePlugin.getStandardDisplay().asyncExec(new Runnable() {
- public void run() {
- if (documentAdapter != null) {
- documentAdapter.setWidth(consoleWidth);
- }
- }
- });
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.TextViewer#handleDispose()
- */
- protected void handleDispose() {
- IDocument document = getDocument();
- if (document != null) {
- document.removeDocumentListener(documentListener);
- document.removePositionUpdater(positionUpdater);
- }
-
- StyledText styledText = getTextWidget();
- styledText.removeLineStyleListener(this);
- styledText.removeLineBackgroundListener(this);
- styledText.removeMouseTrackListener(this);
-
- if(handCursor != null) {
- handCursor.dispose();
- }
- handCursor = null;
- if(textCursor != null) {
- textCursor.dispose();
- }
- textCursor = null;
- hyperlink = null;
- console = null;
-
- ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
- colorRegistry.removeListener(propertyChangeListener);
-
- super.handleDispose();
- }
-
- class HyperlinkColorChangeListener implements IPropertyChangeListener {
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(JFacePreferences.ACTIVE_HYPERLINK_COLOR) || event.getProperty().equals(JFacePreferences.HYPERLINK_COLOR)) {
- getTextWidget().redraw();
- }
- }
-
- }
-
- /*
- * work around to memory leak in TextViewer$WidgetCommand
- */
- protected void updateTextListeners(WidgetCommand cmd) {
- super.updateTextListeners(cmd);
- cmd.preservedText = null;
- cmd.event = null;
- cmd.text = null;
- }
-
- protected void internalRevealRange(int start, int end) {
- StyledText textWidget = getTextWidget();
- int startLine = documentAdapter.getLineAtOffset(start);
- int endLine = documentAdapter.getLineAtOffset(end);
-
- int top = textWidget.getTopIndex();
- if (top > -1) {
- // scroll vertically
- int lines = getVisibleLinesInViewport();
- int bottom = top + lines;
-
- // two lines at the top and the bottom should always be left
- // if window is smaller than 5 lines, always center position is
- // chosen
- int bufferZone = 2;
- if (startLine >= top + bufferZone && startLine <= bottom - bufferZone && endLine >= top + bufferZone && endLine <= bottom - bufferZone) {
-
- // do not scroll at all as it is already visible
- } else {
- int delta = Math.max(0, lines - (endLine - startLine));
- textWidget.setTopIndex(startLine - delta / 3);
- updateViewportListeners(INTERNAL);
- }
-
- // scroll horizontally
- if (endLine < startLine) {
- endLine += startLine;
- startLine = endLine - startLine;
- endLine -= startLine;
- }
-
- int startPixel = -1;
- int endPixel = -1;
-
- if (endLine > startLine) {
- // reveal the beginning of the range in the start line
- IRegion extent = getExtent(start, start);
- startPixel = extent.getOffset() + textWidget.getHorizontalPixel();
- endPixel = startPixel;
- } else {
- IRegion extent = getExtent(start, end);
- startPixel = extent.getOffset() + textWidget.getHorizontalPixel();
- endPixel = startPixel + extent.getLength();
- }
-
- int visibleStart = textWidget.getHorizontalPixel();
- int visibleEnd = visibleStart + textWidget.getClientArea().width;
-
- // scroll only if not yet visible
- if (startPixel < visibleStart || visibleEnd < endPixel) {
- // set buffer zone to 10 pixels
- bufferZone = 10;
- int newOffset = visibleStart;
- int visibleWidth = visibleEnd - visibleStart;
- int selectionPixelWidth = endPixel - startPixel;
-
- if (startPixel < visibleStart)
- newOffset = startPixel;
- else if (selectionPixelWidth + bufferZone < visibleWidth)
- newOffset = endPixel + bufferZone - visibleWidth;
- else
- newOffset = startPixel;
-
- float index = ((float) newOffset) / ((float) getAverageCharWidth());
-
- textWidget.setHorizontalIndex(Math.round(index));
- }
-
- }
- }
-
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/ClearOutputAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/ClearOutputAction.java
deleted file mode 100644
index a1de229b5..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/ClearOutputAction.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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.console.actions;
-
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.console.TextConsole;
-import org.eclipse.ui.internal.console.ConsoleMessages;
-import org.eclipse.ui.internal.console.ConsolePluginImages;
-import org.eclipse.ui.internal.console.IConsoleHelpContextIds;
-import org.eclipse.ui.internal.console.IInternalConsoleConstants;
-
-/**
- * Clears the output in a text console.
- * - * Clients may instantiate this class. - *
- * @since 3.0 - * @noextend This class is not intended to be subclassed by clients. - */ -public class ClearOutputAction extends Action { - - private ITextViewer fViewer; - private TextConsole fIOConsole; - - /** - * 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)); - setDisabledImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_DLCL_CLEAR)); - setImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_CLEAR)); - 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 theIOConsole
, rather than clearing
- * its document directly.
- *
- * @param ioConsole I/O console the action is associated with
- * @since 3.1
- */
- public ClearOutputAction(TextConsole ioConsole) {
- 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
- */
- public ClearOutputAction(ITextViewer viewer) {
- this();
- fViewer = viewer;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- BusyIndicator.showWhile(ConsolePlugin.getStandardDisplay(), new Runnable() {
- public void run() {
- if (fIOConsole == null) {
- IDocument document = fViewer.getDocument();
- if (document != null) {
- document.set(""); //$NON-NLS-1$
- }
- fViewer.setSelectedRange(0, 0);
- } else {
- fIOConsole.clearConsole();
- }
- }
- });
- }
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/CloseConsoleAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/CloseConsoleAction.java
deleted file mode 100644
index 8691ac226..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/CloseConsoleAction.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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.console.actions;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.internal.console.ConsoleMessages;
-import org.eclipse.ui.internal.console.ConsolePluginImages;
-import org.eclipse.ui.internal.console.IInternalConsoleConstants;
-
-/**
- * Removes a console from the console manager.
- * - * Clients may instantiate this class. - *
- * @since 3.1 - * @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); - fConsole = console; - } - - 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 deleted file mode 100644 index b3809ea13..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerAction.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 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.console.actions; - - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.text.ITextOperationTarget; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.ui.texteditor.IUpdate; - -/** - * Common function for actions that operate on a text viewer. - *- * Clients may subclass this class. - *
- * @since 3.0 - */ -public class TextViewerAction extends Action implements IUpdate { - - private int fOperationCode= -1; - private ITextOperationTarget fOperationTarget; - - /** - * Constructs a new action in the given text viewer with - * the specified operation code. - * - * @param viewer - * @param operationCode - */ - public TextViewerAction(ITextViewer viewer, int operationCode) { - fOperationCode= operationCode; - fOperationTarget= viewer.getTextOperationTarget(); - update(); - } - - /* (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) - */ - public void update() { - - boolean wasEnabled= isEnabled(); - boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode)); - setEnabled(isEnabled); - - if (wasEnabled != isEnabled) { - firePropertyChange(ENABLED, wasEnabled ? Boolean.TRUE : Boolean.FALSE, isEnabled ? Boolean.TRUE : Boolean.FALSE); - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.IAction#run() - */ - 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 - */ - public void configureAction(String text, String toolTipText, String description) { - setText(text); - setToolTipText(toolTipText); - setDescription(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 deleted file mode 100644 index b029804f5..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/TextViewerGotoLineAction.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 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.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; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.console.ConsolePlugin; -import org.eclipse.ui.internal.console.ConsoleMessages; - -/** - * Action to position a text viewer to a specific line. - *- * Clients may instantiate this class. - *
- * @since 3.0 - * @noextend This class is not intended to be subclassed by clients. - */ -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 - * jumped. - */ - class NumberValidator implements IInputValidator { - - 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; - - } catch (NumberFormatException x) { - return ConsoleMessages.TextViewerGotoLineAction_Not_a_number_2; - } - - return null; - } - } - - 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); - } - - /** - * @see TextViewerAction#update() - */ - public void update() { - } - - /** - * Jumps to the line. - */ - protected void gotoLine(int line) { - - IDocument document= fTextViewer.getDocument(); - try { - int start= document.getLineOffset(line); - int length= document.getLineLength(line); - 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); // - } - } - - /* (non-Javadoc) - * @see org.eclipse.jface.action.IAction#run() - */ - 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 value= Integer.toString(startLine); - Shell activeShell= fTextViewer.getTextWidget().getShell(); - InputDialog d= new InputDialog(activeShell, title, message, value, new NumberValidator()); - if (d.open() == Window.OK) { - try { - 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); // - } - } - } 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); // - return; - } - } -} diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/package.html b/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/package.html deleted file mode 100644 index cfb538c69..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/actions/package.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - -Application programming interfaces for Eclipse console specific - actions.
- -This package provides a set of actions related to the Eclipse console.
-Clients are allowed to instantiate classes from this package. The classes are - not intended to be subclassed.
- - diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/package.html b/org.eclipse.ui.console/src/org/eclipse/ui/console/package.html deleted file mode 100644 index f6debb148..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/console/package.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - -Application programming interfaces for interaction -with the Eclipse console.
- -The Eclipse platform UI console plug-in provides a set of classes and interfaces to -facilitate the creation and display of consoles in the ConsoleView. This package -contains a generic abstract console (AbstractConsole) that provides some basic -functionality as well as two complete implementations of consoles that may be subclassed. -
The class TextConsole supports regular expression matching and hyperlinks. - Clients must provide their own document partitioner. -
-IOConsole extends TextConsole and provides support for creating consoles based upon -input and output streams via the use of IOConsoleOutputStream and -IOConsoleInputStream. IOConsole is not an abstract class, it may be used as is or -subclassed. -
-A console manager (IConsoleManager) manages all active consoles, and - provides notification of consoles which are added and removed. Consoles are - displayed in a page book view. Each console implementation is reponsible for - creating its page (IPageBookView), which provides freedom of presentation - to the console implementation. A single console may be displayed simultaneously - in multiple console views, in different workbench windows. -
- - 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 deleted file mode 100644 index ddf2491c6..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocument.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 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.jface.text.BadLocationException; -import org.eclipse.jface.text.BadPositionCategoryException; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.Position; - -/** - * A console document. Requires synchronization for multi-threaded access. - */ -public class ConsoleDocument extends Document { - - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocument#get(int, int) - */ - public synchronized String get(int pos, int length) throws BadLocationException { - return super.get(pos, length); - } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocument#getLength() - */ - public synchronized int getLength() { - return super.getLength(); - } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocument#getLineDelimiter(int) - */ - public synchronized String getLineDelimiter(int line) throws BadLocationException { - return super.getLineDelimiter(line); - } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocument#getLineInformation(int) - */ - public synchronized IRegion getLineInformation(int line) throws BadLocationException { - return super.getLineInformation(line); - } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocument#getLineInformationOfOffset(int) - */ - public synchronized IRegion getLineInformationOfOffset(int offset) throws BadLocationException { - return super.getLineInformationOfOffset(offset); - } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocument#getLineLength(int) - */ - public synchronized int getLineLength(int line) throws BadLocationException { - return super.getLineLength(line); - } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocument#getLineOffset(int) - */ - public synchronized int getLineOffset(int line) throws BadLocationException { - return super.getLineOffset(line); - } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocument#getLineOfOffset(int) - */ - public int getLineOfOffset(int pos) throws BadLocationException { - return super.getLineOfOffset(pos); - } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocument#getNumberOfLines() - */ - public synchronized int getNumberOfLines() { - return super.getNumberOfLines(); - } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocument#replace(int, int, java.lang.String) - */ - 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) { - super.set(text); - } - /* (non-Javadoc) - * @see org.eclipse.jface.text.AbstractDocument#completeInitialization() - */ - 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 { - 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 { - super.removePosition(category, position); - } - /* (non-Javadoc) - * @see org.eclipse.jface.text.IDocument#getPositions(java.lang.String) - */ - 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 deleted file mode 100644 index 2b00475d4..000000000 --- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java +++ /dev/null @@ -1,394 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 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 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; - -/** - * 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 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(); - consoleWidth = width; - } - - /* - * repairs lines list from the beginning of the line containing the offset of any - * DocumentEvent, to the end of the Document. - */ - private void repairLines(int eventOffset) { - if (document == null) { - return; - } - try { - int docLine = document.getLineOfOffset(eventOffset); - int docLineOffset = document.getLineOffset(docLine); - int widgetLine = getLineAtOffset(docLineOffset); - - for (int i=regionCount-1; i>=widgetLine; i--) { - regionCount--; - } - - int numLinesInDoc = document.getNumberOfLines(); - - int nextOffset = document.getLineOffset(docLine); - for (int i = docLine; iImage
s and the ImageDescriptor
s.
- */
- private static ImageRegistry imageRegistry;
-
- /* Declare Common paths */
- private static URL ICON_BASE_URL= null;
-
- static {
- String pathSuffix = "icons/full/"; //$NON-NLS-1$
- ICON_BASE_URL= ConsolePlugin.getDefault().getBundle().getEntry(pathSuffix);
- }
-
- // Use IPath and toOSString to build the names to ensure they have the slashes correct
- private final static String LOCALTOOL= "clcl16/"; //basic colors - size 16x16 //$NON-NLS-1$
- private final static String DLCL= "dlcl16/"; //disabled - size 16x16 //$NON-NLS-1$
- private final static String ELCL= "elcl16/"; //enabled - size 16x16 //$NON-NLS-1$
- private final static String VIEW= "cview16/"; // views //$NON-NLS-1$
-
- /**
- * Declare all images
- */
- private static void declareImages() {
- // Actions
-
- //local toolbars
- declareRegistryImage(IConsoleConstants.IMG_LCL_CLEAR, LOCALTOOL + "clear_co.gif"); //$NON-NLS-1$
- declareRegistryImage(IInternalConsoleConstants.IMG_LCL_PIN, LOCALTOOL + "pin.gif"); //$NON-NLS-1$
- declareRegistryImage(IInternalConsoleConstants.IMG_LCL_LOCK, LOCALTOOL + "lock_co.gif"); //$NON-NLS-1$
-
- // disabled local toolbars
- declareRegistryImage(IInternalConsoleConstants.IMG_DLCL_CLEAR, DLCL + "clear_co.gif"); //$NON-NLS-1$
- declareRegistryImage(IInternalConsoleConstants.IMG_DLCL_PIN, DLCL + "pin.gif"); //$NON-NLS-1$
- declareRegistryImage(IInternalConsoleConstants.IMG_DLCL_LOCK, DLCL + "lock_co.gif"); //$NON-NLS-1$
- declareRegistryImage(IInternalConsoleConstants.IMG_DLCL_CLOSE, DLCL + "rem_co.gif"); //$NON-NLS-1$
-
- // enabled local toolbars
- declareRegistryImage(IInternalConsoleConstants.IMG_ELCL_CLEAR, ELCL + "clear_co.gif"); //$NON-NLS-1$
- declareRegistryImage(IInternalConsoleConstants.IMG_ELCL_PIN, ELCL + "pin.gif"); //$NON-NLS-1$
- declareRegistryImage(IInternalConsoleConstants.IMG_ELCL_LOCK, ELCL + "lock_co.gif"); //$NON-NLS-1$
- declareRegistryImage(IInternalConsoleConstants.IMG_ELCL_CLOSE, ELCL + "rem_co.gif"); //$NON-NLS-1$
- declareRegistryImage(IInternalConsoleConstants.IMG_ELCL_NEW_CON, ELCL + "new_con.gif"); //$NON-NLS-1$
-
- // Views
- declareRegistryImage(IConsoleConstants.IMG_VIEW_CONSOLE, VIEW + "console_view.gif"); //$NON-NLS-1$
- }
-
- /**
- * Declare an Image in the registry table.
- * @param key The key to use when registering the image
- * @param path The path where the image can be found. This path is relative to where
- * this plugin class is found (i.e. typically the packages directory)
- */
- private final static void declareRegistryImage(String key, String path) {
- ImageDescriptor desc= ImageDescriptor.getMissingImageDescriptor();
- try {
- desc= ImageDescriptor.createFromURL(makeIconFileURL(path));
- } catch (MalformedURLException me) {
- ConsolePlugin.log(me);
- }
- imageRegistry.put(key, desc);
- }
-
- /**
- * Returns the ImageRegistry.
- */
- public static ImageRegistry getImageRegistry() {
- if (imageRegistry == null) {
- initializeImageRegistry();
- }
- return imageRegistry;
- }
-
- /**
- * Initialize the image registry by declaring all of the required
- * graphics. This involves creating JFace image descriptors describing
- * how to create/find the image should it be needed.
- * The image is not actually allocated until requested.
- *
- * Prefix conventions
- * Wizard Banners WIZBAN_
- * Preference Banners PREF_BAN_
- * Property Page Banners PROPBAN_
- * Color toolbar CTOOL_
- * Enable toolbar ETOOL_
- * Disable toolbar DTOOL_
- * Local enabled toolbar ELCL_
- * Local Disable toolbar DLCL_
- * Object large OBJL_
- * Object small OBJS_
- * View VIEW_
- * Product images PROD_
- * Misc images MISC_
- *
- * Where are the images?
- * The images (typically gifs) are found in the same location as this plugin class.
- * This may mean the same package directory as the package holding this class.
- * The images are declared using this.getClass() to ensure they are looked up via
- * this plugin class.
- * @see org.eclipse.jface.resource.ImageRegistry
- */
- public static ImageRegistry initializeImageRegistry() {
- imageRegistry= new ImageRegistry(ConsolePlugin.getStandardDisplay());
- declareImages();
- return imageRegistry;
- }
-
- /**
- * Returns the Image identified by the given key,
- * or null
if it does not exist.
- */
- public static Image getImage(String key) {
- return getImageRegistry().get(key);
- }
-
- /**
- * Returns the ImageDescriptor identified by the given key,
- * or null
if it does not exist.
- */
- public static ImageDescriptor getImageDescriptor(String key) {
- return getImageRegistry().getDescriptor(key);
- }
-
- private static URL makeIconFileURL(String iconPath) throws MalformedURLException {
- if (ICON_BASE_URL == null) {
- throw new MalformedURLException();
- }
-
- return new URL(ICON_BASE_URL, iconPath);
- }
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleResourceBundleMessages.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleResourceBundleMessages.java
deleted file mode 100644
index 33b7d8568..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleResourceBundleMessages.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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 java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class ConsoleResourceBundleMessages {
- private static final String BUNDLE_NAME = "org.eclipse.ui.internal.console.ConsoleResourceBundleMessages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
-
- private ConsoleResourceBundleMessages() {
- }
-
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- public static ResourceBundle getBundle() {
- return RESOURCE_BUNDLE;
- }
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleResourceBundleMessages.properties b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleResourceBundleMessages.properties
deleted file mode 100644
index 9aeb0ef43..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleResourceBundleMessages.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2005 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
-###############################################################################
-
-
-# These strings are used by the Find Replace Action and loaded as a Resource Bundle.
-# See TextConsolePage.createActions()
-
-find_replace_action_label=&Find/Replace...
-find_replace_action_tooltip=Find/Replace
-find_replace_action_image=
-find_replace_action_description=Find/Replace
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
deleted file mode 100644
index 46dc213fe..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleTypePropertyTester.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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.expressions.PropertyTester;
-import org.eclipse.ui.console.IConsole;
-
-/**
- * Tests if an IOConsole's type matches the expected value
- *
- * @since 3.1
- */
-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) {
- 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
deleted file mode 100644
index 3289a1b61..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
+++ /dev/null
@@ -1,807 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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 java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-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;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.action.ToolBarManager;
-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.ui.IPartListener2;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.console.AbstractConsole;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.console.IConsoleListener;
-import org.eclipse.ui.console.IConsoleManager;
-import org.eclipse.ui.console.IConsolePageParticipant;
-import org.eclipse.ui.console.IConsoleView;
-import org.eclipse.ui.contexts.IContextActivation;
-import org.eclipse.ui.contexts.IContextService;
-import org.eclipse.ui.part.IPage;
-import org.eclipse.ui.part.IPageBookViewPage;
-import org.eclipse.ui.part.MessagePage;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.ui.part.PageBookView;
-import org.eclipse.ui.part.PageSwitcher;
-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();
-
- /**
- * The console being displayed, or null
if none
- */
- private IConsole fActiveConsole = null;
-
- /**
- * Map of consoles to dummy console parts (used to close pages)
- */
- private Map fConsoleToPart;
-
- /**
- * Map of consoles to array of page participants
- */
- private Map fConsoleToPageParticipants;
-
- /**
- * Map of parts to consoles
- */
- private Map fPartToConsole;
-
- /**
- * Whether this view is active
- */
- private boolean fActive = false;
-
- /**
- * 'In Console View' context
- */
- private IContextActivation fActivatedContext;
-
- // actions
- private PinConsoleAction fPinAction = null;
- private ConsoleDropDownAction fDisplayConsoleAction = null;
-
- private OpenConsoleAction fOpenConsoleAction = null;
-
- private boolean fScrollLock;
-
- private boolean isAvailable() {
- return getPageBook() != null && !getPageBook().isDisposed();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- Object source = event.getSource();
- if (source instanceof IConsole && event.getProperty().equals(IBasicPropertyConstants.P_TEXT)) {
- if (source.equals(getConsole())) {
- updateTitle();
- }
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
- */
- public void partClosed(IWorkbenchPart part) {
- super.partClosed(part);
- fPinAction.update();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.ui.console.IConsoleView#getConsole()
- */
- public IConsole getConsole() {
- return fActiveConsole;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.PageBookView#showPageRec(org.eclipse.ui.part.PageBookView.PageRec)
- */
- 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);
- if (!fStack.contains(console)) {
- fStack.add(console);
- }
- return;
- }
-
- IConsole recConsole = (IConsole)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);
- }
- if (tos != null && !tos.equals(fActiveConsole)) {
- deactivateParticipants(tos);
- }
- if (fActiveConsole != null && !fActiveConsole.equals(tos)) {
- fStack.remove(fActiveConsole);
- fStack.add(0,fActiveConsole);
- activateParticipants(fActiveConsole);
- }
- updateTitle();
- updateHelp();
- // update console actions
- if (fPinAction != null) {
- fPinAction.update();
- }
- IPage page = getCurrentPage();
- if (page instanceof IOConsolePage) {
- ((IOConsolePage)page).setAutoScroll(!fScrollLock);
- }
- }
-
- /**
- * Activates the participants for the given console, if any.
- *
- * @param console
- */
- private void activateParticipants(IConsole console) {
- // activate
- if (console != null && fActive) {
- final ListenerList listeners = getParticipants(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() {
- public void run() throws Exception {
- participant.activated();
- }
- public void handleException(Throwable exception) {
- ConsolePlugin.log(exception);
- listeners.remove(participant);
- }
- });
- }
- }
- }
- }
-
- /**
- * 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() {
- return fStack;
- }
-
- /**
- * Updates the view title based on the active console
- */
- protected void updateTitle() {
- IConsole console = getConsole();
- if (console == null) {
- setContentDescription(ConsoleMessages.ConsoleView_0);
- } else {
- String newName = console.getName();
- String oldName = getContentDescription();
- if (newName!=null && !(newName.equals(oldName))) {
- setContentDescription(console.getName());
- }
- }
- }
-
- protected void updateHelp() {
- IConsole console = getConsole();
- String helpContextId = null;
- if (console instanceof AbstractConsole) {
- AbstractConsole abs = (AbstractConsole) console;
- helpContextId = abs.getHelpContextId();
- }
- if (helpContextId == null) {
- helpContextId = IConsoleHelpContextIds.CONSOLE_VIEW;
- }
- PlatformUI.getWorkbench().getHelpSystem().setHelp(getPageBook().getParent(), helpContextId);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.PageBookView#doDestroyPage(org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.part.PageBookView.PageRec)
- */
- protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) {
- IConsole console = (IConsole)fPartToConsole.get(part);
-
- // dispose page participants
- ListenerList listeners = (ListenerList) 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() {
- public void run() throws Exception {
- participant.dispose();
- }
- public void handleException(Throwable exception) {
- ConsolePlugin.log(exception);
- }
- });
- }
- }
-
- IPage page = pageRecord.page;
- 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();
- }
-
- /**
- * Returns the page participants registered for the given console, or null
- *
- * @param console
- * @return registered page participants or null
- */
- private ListenerList getParticipants(IConsole console) {
- return (ListenerList) fConsoleToPageParticipants.get(console);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.PageBookView#doCreatePage(org.eclipse.ui.IWorkbenchPart)
- */
- protected PageRec doCreatePage(IWorkbenchPart dummyPart) {
- ConsoleWorkbenchPart part = (ConsoleWorkbenchPart)dummyPart;
- final IConsole console = part.getConsole();
- final IPageBookViewPage page = console.createPage(this);
- initPage(page);
- page.createControl(getPageBook());
- console.addPropertyChangeListener(this);
-
- // initialize page participants
- IConsolePageParticipant[] consoleParticipants = ((ConsoleManager)getConsoleManager()).getPageParticipants(console);
- final ListenerList participants = new ListenerList();
- for (int i = 0; i < consoleParticipants.length; i++) {
- participants.add(consoleParticipants[i]);
- }
- fConsoleToPageParticipants.put(console, participants);
- Object[] listeners = participants.getListeners();
- for (int i = 0; i < listeners.length; i++) {
- final IConsolePageParticipant participant = (IConsolePageParticipant) listeners[i];
- SafeRunner.run(new ISafeRunnable() {
- public void run() throws Exception {
- participant.init(page, console);
- }
- public void handleException(Throwable exception) {
- ConsolePlugin.log(exception);
- participants.remove(participant);
- }
- });
- }
-
- PageRec rec = new PageRec(dummyPart, page);
- return rec;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.PageBookView#isImportant(org.eclipse.ui.IWorkbenchPart)
- */
- protected boolean isImportant(IWorkbenchPart part) {
- return part instanceof ConsoleWorkbenchPart;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#dispose()
- */
- public void dispose() {
- IViewSite site = getViewSite();
- if(site != null) {
- site.getPage().removePartListener((IPartListener2)this);
- }
- super.dispose();
- ConsoleManager consoleManager = (ConsoleManager) ConsolePlugin.getDefault().getConsoleManager();
- consoleManager.removeConsoleListener(this);
- consoleManager.unregisterConsoleView(this);
- }
-
- /**
- * Returns the console manager.
- *
- * @return the console manager
- */
- private IConsoleManager getConsoleManager() {
- return ConsolePlugin.getDefault().getConsoleManager();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.PageBookView#createDefaultPage(org.eclipse.ui.part.PageBook)
- */
- protected IPage createDefaultPage(PageBook book) {
- MessagePage page = new MessagePage();
- page.createControl(getPageBook());
- initPage(page);
- return page;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsoleListener#consolesAdded(org.eclipse.ui.console.IConsole[])
- */
- public void consolesAdded(final IConsole[] consoles) {
- if (isAvailable()) {
- Runnable r = new Runnable() {
- public void run() {
- for (int i = 0; i < consoles.length; i++) {
- if (isAvailable()) {
- IConsole console = consoles[i];
- // ensure it's still registered since this is done asynchronously
- IConsole[] allConsoles = getConsoleManager().getConsoles();
- for (int j = 0; j < allConsoles.length; j++) {
- IConsole registered = allConsoles[j];
- if (registered.equals(console)) {
- ConsoleWorkbenchPart part = new ConsoleWorkbenchPart(console, getSite());
- fConsoleToPart.put(console, part);
- fPartToConsole.put(part, console);
- partActivated(part);
- break;
- }
- }
-
- }
- }
- }
- };
- asyncExec(r);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsoleListener#consolesRemoved(org.eclipse.ui.console.IConsole[])
- */
- public void consolesRemoved(final IConsole[] consoles) {
- if (isAvailable()) {
- Runnable r = new Runnable() {
- 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);
- if (part != null) {
- partClosed(part);
- }
- if (getConsole() == null) {
- IConsole[] available = getConsoleManager().getConsoles();
- if (available.length > 0) {
- display(available[available.length - 1]);
- }
- }
- }
- }
- }
- };
- asyncExec(r);
- }
- }
-
- /**
- * Constructs a console view
- */
- public ConsoleView() {
- super();
- fConsoleToPart = new HashMap();
- fPartToConsole = new HashMap();
- fConsoleToPageParticipants = new HashMap();
-
- ConsoleManager consoleManager = (ConsoleManager) ConsolePlugin.getDefault().getConsoleManager();
- consoleManager.registerConsoleView(this);
- }
-
- protected void createActions() {
- fPinAction = new PinConsoleAction(this);
- fDisplayConsoleAction = new ConsoleDropDownAction(this);
- ConsoleFactoryExtension[] extensions = ((ConsoleManager)ConsolePlugin.getDefault().getConsoleManager()).getConsoleFactoryExtensions();
- if (extensions.length > 0) {
- fOpenConsoleAction = new OpenConsoleAction();
- }
- }
-
- protected void configureToolBar(IToolBarManager mgr) {
- mgr.add(new Separator(IConsoleConstants.LAUNCH_GROUP));
- mgr.add(new Separator(IConsoleConstants.OUTPUT_GROUP));
- mgr.add(new Separator("fixedGroup")); //$NON-NLS-1$
- mgr.add(fPinAction);
- mgr.add(fDisplayConsoleAction);
- if (fOpenConsoleAction != null) {
- mgr.add(fOpenConsoleAction);
- if (mgr instanceof ToolBarManager) {
- ToolBarManager tbm= (ToolBarManager) mgr;
- final ToolBar tb= tbm.getControl();
- tb.addMouseListener(new MouseAdapter() {
- public void mouseDown(MouseEvent e) {
- ToolItem ti= tb.getItem(new Point(e.x, e.y));
- if (ti.getData() instanceof ActionContributionItem) {
- ActionContributionItem actionContributionItem= (ActionContributionItem) ti.getData();
- IAction action= actionContributionItem.getAction();
- if (action == fOpenConsoleAction) {
- Event event= new Event();
- event.widget= ti;
- event.x= e.x;
- event.y= e.y;
- action.runWithEvent(event);
- }
- }
- }
- });
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsoleView#display(org.eclipse.ui.console.IConsole)
- */
- public void display(IConsole console) {
- if (fPinned && fActiveConsole != null) {
- return;
- }
- if (console.equals(fActiveConsole)) {
- return;
- }
- ConsoleWorkbenchPart part = (ConsoleWorkbenchPart)fConsoleToPart.get(console);
- if (part != null) {
- partActivated(part);
- }
- }
-
- /*/* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsoleView#pin(org.eclipse.ui.console.IConsole)
- */
- public void setPinned(boolean pin) {
- fPinned = pin;
- if (fPinAction != null) {
- fPinAction.update();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsoleView#isPinned()
- */
- public boolean isPinned() {
- return fPinned;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.PageBookView#getBootstrapPart()
- */
- 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) {
- if (isAvailable()) {
- getPageBook().getDisplay().asyncExec(r);
- }
- }
-
- /**
- * Creates this view's underlying viewer and actions.
- * Hooks a pop-up menu to the underlying viewer's control,
- * as well as a key listener. When the delete key is pressed,
- * the REMOVE_ACTION
is invoked. Hooks help to
- * this view. Subclasses must implement the following methods
- * which are called in the following order when a view is
- * created:
- * createViewer(Composite)
- the context
- * menu is hooked to the viewer's control.
- * createActions()
- * configureToolBar(IToolBarManager)
- * getHelpContextId()
- *
- * @see IWorkbenchPart#createPartControl(Composite)
- */
- public void createPartControl(Composite parent) {
- super.createPartControl(parent);
- createActions();
- IToolBarManager tbm= getViewSite().getActionBars().getToolBarManager();
- configureToolBar(tbm);
- updateForExistingConsoles();
- getViewSite().getActionBars().updateActionBars();
- PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IConsoleHelpContextIds.CONSOLE_VIEW);
- getViewSite().getPage().addPartListener((IPartListener2)this);
- initPageSwitcher();
- }
-
- /**
- * Initialize the PageSwitcher.
- */
- private void initPageSwitcher() {
- new PageSwitcher(this) {
- public void activatePage(Object page) {
- ShowConsoleAction.showConsole((IConsole) page, ConsoleView.this);
- }
-
- public ImageDescriptor getImageDescriptor(Object page) {
- return ((IConsole) page).getImageDescriptor();
- }
-
- public String getName(Object page) {
- return ((IConsole) page).getName();
- }
-
- public Object[] getPages() {
- return getConsoleManager().getConsoles();
- }
-
- public int getCurrentPageIndex() {
- IConsole currentConsole= getConsole();
- IConsole[] consoles= getConsoleManager().getConsoles();
- for (int i= 0; i < consoles.length; i++) {
- if (consoles[i].equals(currentConsole))
- return i;
- }
- return super.getCurrentPageIndex();
- }
- };
- }
-
- /**
- * Initialize for existing consoles
- */
- private void updateForExistingConsoles() {
- IConsoleManager manager = getConsoleManager();
- // create pages for consoles
- IConsole[] consoles = manager.getConsoles();
- consolesAdded(consoles);
- // add as a listener
- manager.addConsoleListener(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsoleView#warnOfContentChange(org.eclipse.ui.console.IConsole)
- */
- public void warnOfContentChange(IConsole console) {
- IWorkbenchPart part = (IWorkbenchPart)fConsoleToPart.get(console);
- if (part != null) {
- IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) part.getSite().getAdapter(IWorkbenchSiteProgressService.class);
- if (service != null) {
- service.warnOfContentChange();
- }
- }
- }
-
- public Object getAdapter(Class key) {
- Object adpater = super.getAdapter(key);
- if (adpater == null) {
- IConsole console = getConsole();
- if (console != null) {
- ListenerList listeners = getParticipants(console);
- // an adapter can be asked for before the console participants are created
- if (listeners != null) {
- Object[] participants = listeners.getListeners();
- for (int i = 0; i < participants.length; i++) {
- IConsolePageParticipant participant = (IConsolePageParticipant) participants[i];
- adpater = participant.getAdapter(key);
- if (adpater != null) {
- return adpater;
- }
- }
- }
- }
- }
- return adpater;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partActivated(IWorkbenchPartReference partRef) {
- if (isThisPart(partRef)) {
- fActive = true;
- IContextService contextService = (IContextService)getSite().getService(IContextService.class);
- if(contextService != null) {
- fActivatedContext = contextService.activateContext(IConsoleConstants.ID_CONSOLE_VIEW);
- activateParticipants(fActiveConsole);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partBroughtToTop(IWorkbenchPartReference partRef) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partClosed(IWorkbenchPartReference partRef) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partDeactivated(IWorkbenchPartReference partRef) {
- if (isThisPart(partRef)) {
- fActive = false;
- IContextService contextService = (IContextService)getSite().getService(IContextService.class);
- if(contextService != null) {
- contextService.deactivateContext(fActivatedContext);
- deactivateParticipants(fActiveConsole);
- }
- }
- }
-
- /**
- * Returns if the specified part reference is to this view part (if the part
- * reference is the console view or not)
- * @param partRef
- * @return true if the specified part reference is the console view
- */
- protected boolean isThisPart(IWorkbenchPartReference partRef) {
- if (partRef instanceof IViewReference) {
- IViewReference viewRef = (IViewReference) partRef;
- if (getViewSite() != null && viewRef.getId().equals(getViewSite().getId())) {
- String secId = viewRef.getSecondaryId();
- String mySec = null;
- if (getSite() instanceof IViewSite) {
- mySec = ((IViewSite)getSite()).getSecondaryId();
- }
- if (mySec == null) {
- return secId == null;
- }
- return mySec.equals(secId);
- }
- }
- return false;
- }
-
- /**
- * Deactivates participants for the given console, if any.
- *
- * @param console console to deactivate
- */
- private void deactivateParticipants(IConsole console) {
- // deactivate
- if (console != null) {
- final ListenerList listeners = getParticipants(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() {
- public void run() throws Exception {
- participant.deactivated();
- }
- public void handleException(Throwable exception) {
- ConsolePlugin.log(exception);
- listeners.remove(participant);
- }
- });
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partOpened(IWorkbenchPartReference partRef) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partHidden(IWorkbenchPartReference partRef) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partVisible(IWorkbenchPartReference partRef) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference)
- */
- public void partInputChanged(IWorkbenchPartReference partRef) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsoleView#setScrollLock(boolean)
- */
- public void setScrollLock(boolean scrollLock) {
- fScrollLock = scrollLock;
-
- IPage page = getCurrentPage();
- if (page instanceof IOConsolePage) {
- ((IOConsolePage)page).setAutoScroll(!scrollLock);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsoleView#getScrollLock()
- */
- public boolean getScrollLock() {
- return fScrollLock;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsoleView#pin(org.eclipse.ui.console.IConsole)
- */
- public void pin(IConsole console) {
- if (console == null) {
- setPinned(false);
- } else {
- if (isPinned()) {
- setPinned(false);
- }
- display(console);
- setPinned(true);
- }
- }
-}
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
deleted file mode 100644
index 8a32fc8c1..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleViewConsoleFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.console.IConsoleFactory;
-
-public class ConsoleViewConsoleFactory implements IConsoleFactory {
-
- int counter = 1;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.console.IConsoleFactory#openConsole()
- */
- public void openConsole() {
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- try {
- String secondaryId = "Console View #" + counter; //$NON-NLS-1$
- page.showView(IConsoleConstants.ID_CONSOLE_VIEW, secondaryId, 1);
- counter++;
- } catch (PartInitException e) {
- ConsolePlugin.log(e);
- }
- }
- }
- }
-
-}
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
deleted file mode 100644
index e3377a4dc..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleWorkbenchPart.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.console.IConsole;
-
-/**
- * Fake part to use as keys in page book for console pages
- */
-public class ConsoleWorkbenchPart implements IWorkbenchPart {
-
- private IConsole fConsole = null;
- private IWorkbenchPartSite fSite = null;
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- return (obj instanceof ConsoleWorkbenchPart) &&
- fConsole.equals(((ConsoleWorkbenchPart)obj).fConsole);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return fConsole.hashCode();
- }
-
- /**
- * Constructs a part for the given console that binds to the given
- * site
- */
- public ConsoleWorkbenchPart(IConsole console, IWorkbenchPartSite site) {
- fConsole = console;
- fSite = site;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#addPropertyListener(org.eclipse.ui.IPropertyListener)
- */
- public void addPropertyListener(IPropertyListener listener) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
- */
- public void createPartControl(Composite parent) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#dispose()
- */
- public void dispose() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#getSite()
- */
- public IWorkbenchPartSite getSite() {
- return fSite;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#getTitle()
- */
- public String getTitle() {
- return ""; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#getTitleImage()
- */
- public Image getTitleImage() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#getTitleToolTip()
- */
- public String getTitleToolTip() {
- return ""; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#removePropertyListener(org.eclipse.ui.IPropertyListener)
- */
- public void removePropertyListener(IPropertyListener listener) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWorkbenchPart#setFocus()
- */
- public void setFocus() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- return null;
- }
-
- /**
- * Returns the console associated with this part.
- *
- * @return console associated with this part
- */
- protected IConsole getConsole() {
- return fConsole;
- }
-}
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
deleted file mode 100644
index 492dfd552..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/FollowHyperlinkAction.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.jface.action.Action;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.console.IHyperlink;
-import org.eclipse.ui.console.TextConsoleViewer;
-
-/**
- * Follows a hyperlink in the console
- *
- * @since 3.1
- */
-public class FollowHyperlinkAction extends Action {
-
- private TextConsoleViewer viewer;
-
- /**
- * Constructs a follow link action
- */
- public FollowHyperlinkAction(TextConsoleViewer consoleViewer) {
- super(ConsoleMessages.FollowHyperlinkAction_0);
- setToolTipText(ConsoleMessages.FollowHyperlinkAction_1);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_OPEN_LINK_ACTION);
- this.viewer = consoleViewer;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#isEnabled()
- */
- public boolean isEnabled() {
- return viewer.getHyperlink() != null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- IHyperlink link = viewer.getHyperlink();
- if (link != null) {
- link.linkActivated();
- }
- }
-
-}
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
deleted file mode 100644
index 3ed6aa714..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/HyperlinkUpdater.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 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.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 {
-
- /**
- * @param category
- */
- public HyperlinkUpdater() {
- super(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY);
- }
- /**
- * When any region of a hyperlink is replaced, the hyperlink needs to be deleted.
- *
- * @return true
if position has NOT been deleted
- */
- protected boolean notDeleted() {
-
- int positionEnd = fPosition.offset + fPosition.length - 1;
- int editEnd = fOffset + fLength - 1;
- if ((fOffset <= fPosition.offset && (editEnd > fPosition.offset)) ||
- (fOffset < positionEnd && (editEnd > positionEnd)) ||
- (fOffset >= fPosition.offset && fOffset <= positionEnd) ||
- (editEnd >= fPosition.offset && editEnd <= positionEnd)) {
-
- fPosition.delete();
-
- try {
- fDocument.removePosition(ConsoleHyperlinkPosition.HYPER_LINK_CATEGORY, fPosition);
- } catch (BadPositionCategoryException x) {
- }
-
- return false;
- }
-
- return true;
- }
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IConsoleHelpContextIds.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IConsoleHelpContextIds.java
deleted file mode 100644
index 85a4e69b2..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IConsoleHelpContextIds.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.ui.console.IConsoleConstants;
-
-/**
- * Help context ids for the console plugin.
- *
- * This interface contains constants only; it is not intended to be implemented
- * or extended.
- *
- *
- */
-public interface IConsoleHelpContextIds {
-
- public static final String PREFIX = IConsoleConstants.PLUGIN_ID + "."; //$NON-NLS-1$
-
- // Actions
- public static final String CLEAR_CONSOLE_ACTION = PREFIX + "clear_console_action_context"; //$NON-NLS-1$
- public static final String CONSOLE_SCROLL_LOCK_ACTION = PREFIX + "console_scroll_lock_action_context"; //$NON-NLS-1$
- public static final String CONSOLE_SELECT_ALL_ACTION = PREFIX + "console_select_all_action_context"; //$NON-NLS-1$
- public static final String CONSOLE_COPY_ACTION = PREFIX + "copy_to_clipboard_action_context"; //$NON-NLS-1$
- public static final String CONSOLE_CUT_ACTION = PREFIX + "console_cut_action_context"; //$NON-NLS-1$
- public static final String CONSOLE_PASTE_ACTION = PREFIX + "console_paste_action_context"; //$NON-NLS-1$
- public static final String CONSOLE_FIND_REPLACE_ACTION = PREFIX + "console_find_replace_action_context"; //$NON-NLS-1$
- public static final String CONSOLE_OPEN_LINK_ACTION = PREFIX + "console_open_link_action_context"; //$NON-NLS-1$
- public static final String CONSOLE_OPEN_CONSOLE_ACTION = PREFIX + "console_open_console_action_context"; //$NON-NLS-1$
- public static final String CONSOLE_DISPLAY_CONSOLE_ACTION = PREFIX + "console_display_console_action"; //$NON-NLS-1$
- public static final String CONSOLE_PIN_CONSOLE_ACITON = PREFIX + "console_pin_console_action"; //$NON-NLS-1$
-
- // Views
- public static final String CONSOLE_VIEW = PREFIX + "console_view_context"; //$NON-NLS-1$
-
- // Preference pages
- public static final String CONSOLE_PREFERENCE_PAGE = PREFIX + "console_preference_page_context"; //$NON-NLS-1$
-}
-
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IInternalConsoleConstants.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IInternalConsoleConstants.java
deleted file mode 100644
index 00f5cbc3b..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IInternalConsoleConstants.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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;
-
-public interface IInternalConsoleConstants {
-
- // tool images
- public static final String IMG_LCL_PIN = "IMG_LCL_PIN"; //$NON-NLS-1$
- public static final String IMG_LCL_LOCK = "IMG_LCL_LOCK"; //$NON-NLS-1$
-
- // disabled local tool images
- public static final String IMG_DLCL_PIN = "IMG_DLCL_PIN"; //$NON-NLS-1$
- public static final String IMG_DLCL_CLEAR= "IMG_DLCL_CLEAR"; //$NON-NLS-1$
- public static final String IMG_DLCL_LOCK = "IMG_DLCL_LOCK"; //$NON-NLS-1$
- public static final String IMG_DLCL_CLOSE = "IMG_DLCL_CLOSE"; //$NON-NLS-1$
-
- // enabled local tool images
- public static final String IMG_ELCL_PIN = "IMG_ELCL_PIN"; //$NON-NLS-1$
- public static final String IMG_ELCL_CLEAR= "IMG_ELCL_CLEAR"; //$NON-NLS-1$
- public static final String IMG_ELCL_LOCK = "IMG_ELCL_LOCK"; //$NON-NLS-1$
- public static final String IMG_ELCL_CLOSE = "IMG_ELCL_CLOSE"; //$NON-NLS-1$
- public static final String IMG_ELCL_NEW_CON = "IMG_ELCL_NEW_CON"; //$NON-NLS-1$
-}
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
deleted file mode 100644
index 3f8d72fe9..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePage.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.console.IConsoleConstants;
-import org.eclipse.ui.console.IConsoleView;
-import org.eclipse.ui.console.TextConsole;
-import org.eclipse.ui.console.TextConsolePage;
-import org.eclipse.ui.console.TextConsoleViewer;
-
-/**
- * A page for an IOConsole
- *
- * @since 3.1
- *
- */
-public class IOConsolePage extends TextConsolePage {
-
- private ScrollLockAction fScrollLockAction;
-
- private boolean fReadOnly;
-
- private IPropertyChangeListener fPropertyChangeListener;
-
- public IOConsolePage(TextConsole console, IConsoleView view) {
- super(console, view);
-
- fPropertyChangeListener = new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- String property = event.getProperty();
- if (property.equals(IConsoleConstants.P_CONSOLE_OUTPUT_COMPLETE)) {
- setReadOnly();
- }
- }
- };
- console.addPropertyChangeListener(fPropertyChangeListener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- if (fReadOnly) {
- IOConsoleViewer viewer = (IOConsoleViewer) getViewer();
- viewer.setReadOnly();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.console.TextConsolePage#createViewer(org.eclipse.swt.widgets.Composite,
- * org.eclipse.ui.console.TextConsole)
- */
- protected TextConsoleViewer createViewer(Composite parent) {
- return new IOConsoleViewer(parent, (TextConsole)getConsole());
- }
-
- public void setAutoScroll(boolean scroll) {
- IOConsoleViewer viewer = (IOConsoleViewer) getViewer();
- if (viewer != null) {
- viewer.setAutoScroll(scroll);
- fScrollLockAction.setChecked(!scroll);
- }
- }
-
- /**
- * Informs the viewer that it's text widget should not be editable.
- */
- public void setReadOnly() {
- fReadOnly = true;
- IOConsoleViewer viewer = (IOConsoleViewer) getViewer();
- if (viewer != null) {
- viewer.setReadOnly();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.TextConsolePage#createActions()
- */
- protected void createActions() {
- super.createActions();
- fScrollLockAction = new ScrollLockAction(getConsoleView());
- setAutoScroll(!fScrollLockAction.isChecked());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.TextConsolePage#contextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
- */
- protected void contextMenuAboutToShow(IMenuManager menuManager) {
- super.contextMenuAboutToShow(menuManager);
- menuManager.add(fScrollLockAction);
- IOConsoleViewer viewer = (IOConsoleViewer) getViewer();
- if (!viewer.isReadOnly()) {
- menuManager.remove(ActionFactory.CUT.getId());
- menuManager.remove(ActionFactory.PASTE.getId());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.console.TextConsolePage#configureToolBar(org.eclipse.jface.action.IToolBarManager)
- */
- 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() {
- if (fScrollLockAction != null) {
- fScrollLockAction.dispose();
- fScrollLockAction = null;
- }
- getConsole().removePropertyChangeListener(fPropertyChangeListener);
- super.dispose();
- }
-
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java
deleted file mode 100644
index 519cbc76b..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartition.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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.jface.text.ITypedRegion;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IOConsoleInputStream;
-import org.eclipse.ui.console.IOConsoleOutputStream;
-
-/**
- * A region in an IOConsole's document.
- *
- * @since 3.1
- */
-public class IOConsolePartition implements ITypedRegion {
- public static final String OUTPUT_PARTITION_TYPE = ConsolePlugin.getUniqueIdentifier() + ".io_console_output_partition_type"; //$NON-NLS-1$
- public static final String INPUT_PARTITION_TYPE = ConsolePlugin.getUniqueIdentifier() + ".io_console_input_partition_type"; //$NON-NLS-1$
-
- /**
- * The data contained by this partition.
- */
- private StringBuffer buffer;
- private String type;
- private int offset;
- /**
- * Output partitions are all read only.
- * Input partitions are read only once they have been appended to the console's input stream.
- */
- private boolean readOnly;
-
- /**
- * Only one of inputStream or outputStream will be null depending on the partitions type.
- */
- private IOConsoleOutputStream outputStream;
- private IOConsoleInputStream inputStream;
- private int length;
-
- /**
- * Creates a new partition to contain output to console.
- */
- public IOConsolePartition(IOConsoleOutputStream outputStream, int length) {
- this.outputStream = outputStream;
- this.length = length;
- this.type = OUTPUT_PARTITION_TYPE;
- this.readOnly = true;
- }
-
- /**
- * Creates a new partition to contain input from a console
- */
- public IOConsolePartition(IOConsoleInputStream inputStream, String text) {
- this.inputStream = inputStream;
- buffer = new StringBuffer(text);
- length = text.length();
- this.type = INPUT_PARTITION_TYPE;
- this.readOnly = false;
- }
-
- /**
- * Inserts a string into this partition.
- * @param s The string to insert
- * @param offset the offset in the partition
- */
- public void insert(String s, int insertOffset) {
- buffer.insert(insertOffset, s);
- length += s.length();
- }
-
- /**
- * Deletes data from this partition.
- * @param delOffset
- * @param delLength
- */
- public void delete(int delOffset, int delLength) {
- buffer.delete(delOffset, delOffset+delLength);
- length -= delLength;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.text.ITypedRegion#getType()
- */
- public String getType() {
- return type;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.text.IRegion#getLength()
- */
- public int getLength() {
- return length;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.text.IRegion#getOffset()
- */
- public int getOffset() {
- return offset;
- }
-
- /**
- * Sets this partitions offset in the document.
- *
- * @param offset This partitions offset in the document.
- */
- public void setOffset(int offset) {
- this.offset = offset;
- }
-
- /**
- * Sets this partition's length.
- *
- * @param length
- */
- public void setLength(int length) {
- this.length = length;
- }
-
- /**
- * Returns the data contained in this partition.
- * @return The data contained in this partition.
- */
- public String getString() {
- return buffer.toString();
- }
-
- /**
- * Returns a StyleRange object which may be used for setting the style
- * of this partition in a viewer.
- */
- public StyleRange getStyleRange(int rangeOffset, int rangeLength) {
- return new StyleRange(rangeOffset, rangeLength, getColor(), null, getFontStyle());
- }
-
- /**
- * Returns the font of the input stream if the type of the partition
- * is INPUT_PARTITION_TYPE
, 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 INPUT_PARTITION_TYPE
, 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 true
.
- *
- * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#isReadOnly(int)
- */
- public void setReadOnly() {
- readOnly = true;
- }
-
- /**
- * Clears the contents of the buffer
- */
- public void clearBuffer() {
- buffer.setLength(0);
- }
-
- /**
- * Returns the underlying output stream
- *
- * @return the underlying output stream
- */
- IOConsoleOutputStream getStream() {
- return outputStream;
- }
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
deleted file mode 100644
index 5a74807b2..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
+++ /dev/null
@@ -1,699 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 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 java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitionerExtension;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsoleDocumentPartitioner;
-import org.eclipse.ui.console.IOConsole;
-import org.eclipse.ui.console.IOConsoleInputStream;
-import org.eclipse.ui.console.IOConsoleOutputStream;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.ui.progress.WorkbenchJob;
-
-/**
- * Partitions an IOConsole's document
- * @since 3.1
- *
- */
-public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocumentPartitionerExtension {
- private PendingPartition consoleClosedPartition;
- private IDocument document;
- private ArrayList partitions;
- /**
- * Blocks of data that have not yet been appended to the document.
- */
- private ArrayList pendingPartitions;
- /**
- * A list of PendingPartitions to be appended by the updateJob
- */
- private ArrayList updatePartitions;
- /**
- * The last partition appended to the document
- */
- private IOConsolePartition lastPartition;
- /**
- * Job that appends pending partitions to the document.
- */
- private QueueProcessingJob queueJob;
- /**
- * The input stream attached to this document.
- */
- private IOConsoleInputStream inputStream;
- /**
- * Flag to indicate that the updateJob is updating the document.
- */
- private boolean updateInProgress;
- /**
- * A list of partitions containing input from the console, that have
- * not been appended to the input stream yet.
- */
- private ArrayList inputPartitions;
- /**
- * offset used by updateJob
- */
- private int firstOffset;
- /**
- * An array of legal line delimiters
- */
- private String[] lld;
- private int highWaterMark = -1;
- private int lowWaterMark = -1;
- 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.
- */
- private Object overflowLock = new Object();
-
-
- 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)
- */
- public void connect(IDocument doc) {
- document = doc;
- document.setDocumentPartitioner(this);
- lld = document.getLegalLineDelimiters();
- partitions = new ArrayList();
- pendingPartitions = new ArrayList();
- inputPartitions = new ArrayList();
- 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() {
- public void run() {
- checkBufferSize();
- }
- });
- }
-
- /**
- * Notification from the console that all of its streams have been closed.
- */
- public void streamsClosed() {
- consoleClosedPartition = new PendingPartition(null, null);
- synchronized (pendingPartitions) {
- pendingPartitions.add(consoleClosedPartition);
- }
- queueJob.schedule(); //ensure that all pending partitions are processed.
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.text.IDocumentPartitioner#disconnect()
- */
- public void disconnect() {
- synchronized (overflowLock) {
- document = null;
- partitions.clear();
- connected = false;
- try {
- inputStream.close();
- } catch (IOException e) {
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.text.IDocumentPartitioner#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.text.IDocumentPartitioner#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public boolean documentChanged(DocumentEvent event) {
- return documentChanged2(event) != null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.text.IDocumentPartitioner#getLegalContentTypes()
- */
- public String[] getLegalContentTypes() {
- return new String[] { IOConsolePartition.OUTPUT_PARTITION_TYPE, IOConsolePartition.INPUT_PARTITION_TYPE };
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.text.IDocumentPartitioner#getContentType(int)
- */
- 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) {
- 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)};
- }
- while (left < right) {
-
- mid= (left + right) / 2;
-
- position= (IOConsolePartition) partitions.get(mid);
- if (rangeEnd < position.getOffset()) {
- if (left == mid)
- right= left;
- else
- right= mid -1;
- } else if (offset > (position.getOffset() + position.getLength() - 1)) {
- if (right == mid)
- left= right;
- else
- left= mid +1;
- } else {
- left= right= mid;
- }
- }
-
-
- List list = new ArrayList();
- int index = left - 1;
- if (index >= 0) {
- position= (IOConsolePartition) partitions.get(index);
- while (index >= 0 && (position.getOffset() + position.getLength()) > offset) {
- index--;
- if (index >= 0) {
- position= (IOConsolePartition) partitions.get(index);
- }
- }
- }
- index++;
- position= (IOConsolePartition) partitions.get(index);
- while (index < partitions.size() && (position.getOffset() < rangeEnd)) {
- list.add(position);
- index++;
- if (index < partitions.size()) {
- position= (IOConsolePartition) partitions.get(index);
- }
- }
-
- return (ITypedRegion[]) list.toArray(new IOConsolePartition[list.size()]);
- }
-
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.text.IDocumentPartitioner#getPartition(int)
- */
- public ITypedRegion getPartition(int offset) {
- for (int i = 0; i < partitions.size(); i++) {
- ITypedRegion partition = (ITypedRegion) 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$
- lastPartition.setOffset(offset);
- partitions.add(lastPartition);
- inputPartitions.add(lastPartition);
- }
- }
- 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
- * low water mark.
- */
- private void checkBufferSize() {
- if (document != null && highWaterMark > 0) {
- int length = document.getLength();
- if (length > highWaterMark) {
- if (trimJob.getState() == Job.NONE) { //if the job isn't already running
- trimJob.setOffset(length - lowWaterMark);
- trimJob.schedule();
- }
- }
- }
- }
-
- /**
- * Clears the console
- */
- public void clearBuffer() {
- synchronized (overflowLock) {
- trimJob.setOffset(-1);
- trimJob.schedule();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentPartitionerExtension#documentChanged2(org.eclipse.jface.text.DocumentEvent)
- */
- public IRegion documentChanged2(DocumentEvent event) {
- if (document == null) {
- return null; //another thread disconnected the partitioner
- }
- if (document.getLength() == 0) { //document cleared
- if (lastPartition != null && lastPartition.getType().equals(IOConsolePartition.INPUT_PARTITION_TYPE)) {
- synchronized (partitions) {
- partitions.remove(lastPartition);
- inputPartitions.remove(lastPartition);
- }
- }
- 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) {
- continue;
- }
-
- int ppLen = pp.text.length();
- if (lastPartition != null && lastPartition.getStream() == pp.stream) {
- int len = lastPartition.getLength();
- lastPartition.setLength(len + ppLen);
- } else {
- IOConsolePartition partition = new IOConsolePartition(pp.stream, ppLen);
- partition.setOffset(firstOffset);
- lastPartition = partition;
- partitions.add(partition);
- }
- firstOffset += ppLen;
- }
- }
- }
- } else {// user input.
- int amountDeleted = event.getLength() ;
-
- if (amountDeleted > 0) {
- 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.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++) {
- String ld = lld[i];
- int index = partitionText.lastIndexOf(ld);
- if (index != -1) {
- index += ld.length();
- }
- if (index > lastLineDelimiter) {
- lastLineDelimiter = index;
- }
- }
- if (lastLineDelimiter != -1) {
- StringBuffer input = new StringBuffer();
- Iterator it = inputPartitions.iterator();
- while (it.hasNext()) {
- IOConsolePartition partition = (IOConsolePartition) it.next();
- if (partition.getOffset() + partition.getLength() <= event.fOffset + lastLineDelimiter) {
- if (partition == lastPartition) {
- lastPartition = null;
- }
- input.append(partition.getString());
- partition.clearBuffer();
- partition.setReadOnly();
- it.remove();
- } else {
- //create a new partition containing everything up to the line delimiter
- //and append that to the string buffer.
- String contentBefore = partitionText.substring(0, lastLineDelimiter);
- IOConsolePartition newPartition = new IOConsolePartition(inputStream, contentBefore);
- newPartition.setOffset(partition.getOffset());
- newPartition.setReadOnly();
- newPartition.clearBuffer();
- int index = partitions.indexOf(partition);
- partitions.add(index, newPartition);
- input.append(contentBefore);
- //delete everything that has been appended to the buffer.
- partition.delete(0, lastLineDelimiter);
- partition.setOffset(lastLineDelimiter + partition.getOffset());
- lastLineDelimiter = 0;
- }
- }
- if (input.length() > 0) {
- inputStream.appendData(input.toString());
- }
-
- }
- }
- }
-
- 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
- * the job is run
- * @param stream The stream that was written to.
- * @param s The string that should be appended to the document.
- */
- public void streamAppended(IOConsoleOutputStream stream, String s) throws IOException {
- if (document == null) {
- throw new IOException("Document is closed"); //$NON-NLS-1$
- }
- synchronized(pendingPartitions) {
- PendingPartition last = (PendingPartition) (pendingPartitions.size() > 0 ? pendingPartitions.get(pendingPartitions.size()-1) : null);
- if (last != null && last.stream == stream) {
- last.append(s);
- } else {
- pendingPartitions.add(new PendingPartition(stream, s));
- if (fBuffer > 1000) {
- queueJob.schedule();
- } else {
- queueJob.schedule(50);
- }
- }
-
- if (fBuffer > 160000) {
- if(Display.getCurrent() == null){
- try {
- pendingPartitions.wait();
- } catch (InterruptedException e) {
- }
- } else {
- /*
- * if we are in UI thread we cannot lock it, so process
- * queued output.
- */
- processQueue();
- }
- }
- }
- }
-
- /**
- * 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
- * finishing.
- */
- private class QueueProcessingJob extends UIJob {
-
- 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) {
- 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() {
- boolean shouldRun = connected && pendingPartitions != null && pendingPartitions.size() > 0;
- return shouldRun;
- }
- }
-
- void processQueue() {
- synchronized (overflowLock) {
- ArrayList pendingCopy = new ArrayList();
- StringBuffer buffer = null;
- boolean consoleClosed = false;
- synchronized(pendingPartitions) {
- pendingCopy.addAll(pendingPartitions);
- pendingPartitions.clear();
- fBuffer = 0;
- pendingPartitions.notifyAll();
- }
- // determine buffer size
- int size = 0;
- for (Iterator i = pendingCopy.iterator(); i.hasNext(); ) {
- PendingPartition pp = (PendingPartition) i.next();
- 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) {
- buffer.append(pp.text);
- } else {
- consoleClosed = true;
- }
- }
-
- if (connected) {
- setUpdateInProgress(true);
- updatePartitions = pendingCopy;
- firstOffset = document.getLength();
- try {
- if (buffer != null) {
- document.replace(firstOffset, 0, buffer.toString());
- }
- } catch (BadLocationException e) {
- }
- updatePartitions = null;
- setUpdateInProgress(false);
- }
- if (consoleClosed) {
- console.partitionerFinished();
- }
- checkBufferSize();
- }
-
- }
-
- /**
- * Job to trim the console document, runs in the UI thread.
- */
- private class TrimJob extends WorkbenchJob {
-
- /**
- * trims output up to the line containing the given offset,
- * or all output if -1.
- */
- private int truncateOffset;
-
- /**
- * Creates a new job to trim the buffer.
- */
- TrimJob() {
- super("Trim Job"); //$NON-NLS-1$
- setSystem(true);
- }
-
- /**
- * Sets the trim offset.
- *
- * @param offset trims output up to the line containing the given offset
- */
- public void setOffset(int offset) {
- truncateOffset = offset;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus runInUIThread(IProgressMonitor monitor) {
- IJobManager jobManager = Job.getJobManager();
- try {
- jobManager.join(console, monitor);
- } catch (OperationCanceledException e1) {
- return Status.CANCEL_STATUS;
- } catch (InterruptedException e1) {
- return Status.CANCEL_STATUS;
- }
- if (document == null) {
- return Status.OK_STATUS;
- }
-
- int length = document.getLength();
- if (truncateOffset < length) {
- synchronized (overflowLock) {
- try {
- if (truncateOffset < 0) {
- // clear
- setUpdateInProgress(true);
- document.set(""); //$NON-NLS-1$
- setUpdateInProgress(false);
- partitions.clear();
- } else {
- // overflow
- int cutoffLine = document.getLineOfOffset(truncateOffset);
- int cutOffset = document.getLineOffset(cutoffLine);
-
-
- // set the new length of the first partition
- IOConsolePartition partition = (IOConsolePartition) getPartition(cutOffset);
- partition.setLength(partition.getOffset() + partition.getLength() - cutOffset);
-
- setUpdateInProgress(true);
- document.replace(0, cutOffset, ""); //$NON-NLS-1$
- setUpdateInProgress(false);
-
- //remove partitions and reset Partition offsets
- int index = partitions.indexOf(partition);
- for (int i = 0; i < index; i++) {
- partitions.remove(0);
- }
-
- int offset = 0;
- for (Iterator i = partitions.iterator(); i.hasNext(); ) {
- IOConsolePartition p = (IOConsolePartition) i.next();
- p.setOffset(offset);
- offset += p.getLength();
- }
- }
- } catch (BadLocationException e) {
- }
- }
- }
- return Status.OK_STATUS;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IConsoleDocumentPartitioner#isReadOnly(int)
- */
- 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) {
- if (!connected) {
- return new StyleRange[0];
- }
- IOConsolePartition[] computedPartitions = (IOConsolePartition[])computePartitioning(offset, length);
- StyleRange[] styles = new StyleRange[computedPartitions.length];
- for (int i = 0; i < computedPartitions.length; i++) {
- int rangeStart = Math.max(computedPartitions[i].getOffset(), offset);
- int rangeLength = computedPartitions[i].getLength();
- styles[i] = computedPartitions[i].getStyleRange(rangeStart, rangeLength);
- }
- return styles;
- }
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsoleViewer.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsoleViewer.java
deleted file mode 100644
index e686955f0..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsoleViewer.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsoleDocumentPartitioner;
-import org.eclipse.ui.console.TextConsole;
-import org.eclipse.ui.console.TextConsoleViewer;
-
-/**
- * Viewer used to display an IOConsole
- *
- * @since 3.1
- */
-public class IOConsoleViewer extends TextConsoleViewer {
- /**
- * will always scroll with output if value is true.
- */
- private boolean fAutoScroll = true;
-
- private IDocumentListener fDocumentListener;
-
- public IOConsoleViewer(Composite parent, TextConsole console) {
- super(parent, console);
- }
-
- public boolean isAutoScroll() {
- return fAutoScroll;
- }
-
- public void setAutoScroll(boolean scroll) {
- fAutoScroll = scroll;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.TextViewer#handleVerifyEvent(org.eclipse.swt.events.VerifyEvent)
- */
- protected void handleVerifyEvent(VerifyEvent e) {
- IDocument doc = getDocument();
- String[] legalLineDelimiters = doc.getLegalLineDelimiters();
- String eventString = e.text;
- try {
- IConsoleDocumentPartitioner partitioner = (IConsoleDocumentPartitioner) doc.getDocumentPartitioner();
- if (!partitioner.isReadOnly(e.start)) {
- boolean isCarriageReturn = false;
- for (int i = 0; i < legalLineDelimiters.length; i++) {
- if (e.text.equals(legalLineDelimiters[i])) {
- isCarriageReturn = true;
- break;
- }
- }
-
- if (!isCarriageReturn) {
- super.handleVerifyEvent(e);
- return;
- }
- }
-
- int length = doc.getLength();
- if (e.start == length) {
- super.handleVerifyEvent(e);
- } else {
- try {
- doc.replace(length, 0, eventString);
- } catch (BadLocationException e1) {
- }
- e.doit = false;
- }
- } finally {
- StyledText text = (StyledText) e.widget;
- text.setCaretOffset(text.getCharCount());
- }
- }
-
- /**
- * makes the associated text widget uneditable.
- */
- public void setReadOnly() {
- ConsolePlugin.getStandardDisplay().asyncExec(new Runnable() {
- public void run() {
- StyledText text = getTextWidget();
- if (text != null && !text.isDisposed()) {
- text.setEditable(false);
- }
- }
- });
- }
-
- /**
- * @return false
if text is editable
- */
- 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) {
- IDocument oldDocument= getDocument();
-
- super.setDocument(document);
-
- if (oldDocument != null) {
- oldDocument.removeDocumentListener(getDocumentListener());
- }
- if (document != null) {
- document.addDocumentListener(getDocumentListener());
- }
- }
-
- private IDocumentListener getDocumentListener() {
- if (fDocumentListener == null) {
- fDocumentListener= new IDocumentListener() {
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
-
- public void documentChanged(DocumentEvent event) {
- if (fAutoScroll) {
- revealEndOfDocument();
- }
- }
- };
- }
- return fDocumentListener;
- }
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java
deleted file mode 100644
index ab8d900a7..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/OpenConsoleAction.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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.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;
-import org.eclipse.ui.console.IConsoleFactory;
-
-/**
- * @since 3.1
- */
-public class OpenConsoleAction extends Action implements IMenuCreator {
-
- private ConsoleFactoryExtension[] fFactoryExtensions;
- private Menu fMenu;
-
- public OpenConsoleAction() {
- fFactoryExtensions = ((ConsoleManager)ConsolePlugin.getDefault().getConsoleManager()).getConsoleFactoryExtensions();
- 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() {
- fFactoryExtensions = null;
- }
-
- /*
- * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
- * @since 3.5
- */
- 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) {
- if (fMenu != null) {
- fMenu.dispose();
- }
-
- fMenu= new Menu(parent);
- int accel = 1;
- for (int i = 0; i < fFactoryExtensions.length; i++) {
- ConsoleFactoryExtension extension = fFactoryExtensions[i];
- if (!WorkbenchActivityHelper.filterItem(extension) && extension.isEnabled()) {
- String label = extension.getLabel();
- ImageDescriptor image = extension.getImageDescriptor();
- addActionToMenu(fMenu, new ConsoleFactoryAction(label, image, extension), accel);
- accel++;
- }
- }
- return fMenu;
- }
-
- private void addActionToMenu(Menu parent, Action action, int accelerator) {
- if (accelerator < 10) {
- StringBuffer label= new StringBuffer();
- //add the numerical accelerator
- label.append('&');
- label.append(accelerator);
- label.append(' ');
- label.append(action.getText());
- action.setText(label.toString());
- }
-
- ActionContributionItem item= new ActionContributionItem(action);
- item.fill(parent, -1);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu)
- */
- public Menu getMenu(Menu parent) {
- return null;
- }
-
- private class ConsoleFactoryAction extends Action {
-
- private ConsoleFactoryExtension fConfig;
- private IConsoleFactory fFactory;
-
- public ConsoleFactoryAction(String label, ImageDescriptor image, ConsoleFactoryExtension extension) {
- setText(label);
- if (image != null) {
- setImageDescriptor(image);
- }
- fConfig = extension;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#run()
- */
- 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) {
- 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
deleted file mode 100644
index eab75136a..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListener.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 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.ui.console.IPatternMatchListener;
-import org.eclipse.ui.console.IPatternMatchListenerDelegate;
-import org.eclipse.ui.console.PatternMatchEvent;
-import org.eclipse.ui.console.TextConsole;
-
-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() {
- return fExtension.getPattern();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IPatternMatchListener#getCompilerFlags()
- */
- 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) {
- fDelegate.matchFound(event);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IPatternMatchListenerDelegate#connect(org.eclipse.ui.console.TextConsole)
- */
- public void connect(TextConsole console) {
- fDelegate.connect(console);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IPatternMatchListener#disconnect()
- */
- public void disconnect() {
- fDelegate.disconnect();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.console.IPatternMatchListener#getQuickPattern()
- */
- 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
deleted file mode 100644
index b4081dfe6..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PatternMatchListenerExtension.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 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 java.lang.reflect.Field;
-
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.ExpressionConverter;
-import org.eclipse.core.expressions.ExpressionTagNames;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.variables.VariablesPlugin;
-import org.eclipse.ui.IPluginContribution;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.console.IPatternMatchListenerDelegate;
-
-import com.ibm.icu.text.MessageFormat;
-
-public class PatternMatchListenerExtension implements IPluginContribution {
-
- private IConfigurationElement fConfig;
- private Expression fEnablementExpression;
- private String fPattern;
- private String fQualifier;
- private int fFlags = -1;
-
- public PatternMatchListenerExtension(IConfigurationElement extension) {
- fConfig = extension;
- }
-
- /*
- * returns the integer value of the flags defined in java.util.regex.Pattern.
- * Both Pattern.MULTILINE
and MULTILINE
will return
- * the same value.
- */
- public int parseFlags(String flagsElement) {
- int val = 0;
- 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$
-
- for (int i = 0; i < tokens.length; i++) {
- Field field = clazz.getDeclaredField(tokens[i]);
- val |= field.getInt(null);
- }
- } catch (ClassNotFoundException e) {
- ConsolePlugin.log(e);
- } catch (NoSuchFieldException e) {
- ConsolePlugin.log(e);
- } catch (IllegalAccessException e) {
- ConsolePlugin.log(e);
- }
- return val;
- }
-
- public boolean isEnabledFor(IConsole console) throws CoreException {
- EvaluationContext context = new EvaluationContext(null, console);
- EvaluationResult evaluationResult = getEnablementExpression().evaluate(context);
- return evaluationResult == EvaluationResult.TRUE;
- }
-
- public IPatternMatchListenerDelegate createDelegate() throws CoreException {
- return (IPatternMatchListenerDelegate) fConfig.createExecutableExtension("class"); //$NON-NLS-1$
- }
-
- public Expression getEnablementExpression() throws CoreException {
- if (fEnablementExpression == null) {
- IConfigurationElement[] elements = fConfig.getChildren(ExpressionTagNames.ENABLEMENT);
- if (elements.length == 0) {
- 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$
- ConsolePlugin.log(new Status(IStatus.WARNING, ConsolePlugin.getUniqueIdentifier(), IStatus.OK, message, null));
- }
- IConfigurationElement enablement = elements.length > 0 ? elements[0] : null;
-
- if (enablement != null) {
- fEnablementExpression = ExpressionConverter.getDefault().perform(enablement);
- }
- }
- return fEnablementExpression;
- }
-
- /*
- * returns the regular expression to be matched.
- */
- public String getPattern() {
- if (fPattern == null) {
- fPattern = fConfig.getAttribute("regex"); //$NON-NLS-1$
- try {
- fPattern = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(fPattern, false);
- } catch (CoreException e) {
- ConsolePlugin.log(e);
- }
- }
- return fPattern;
- }
-
- /*
- * returns the flags to be used by Pattern.compile(pattern, flags)
- */
- public int getCompilerFlags() {
- if(fFlags < 0) {
- String flagsAttribute = fConfig.getAttribute("flags"); //$NON-NLS-1$
- fFlags = parseFlags(flagsAttribute);
- }
- return fFlags;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPluginContribution#getLocalId()
- */
- public String getLocalId() {
- return fConfig.getAttribute("id"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPluginContribution#getPluginId()
- */
- public String getPluginId() {
- return fConfig.getContributor().getName();
- }
-
- public String getQuickPattern() {
- if (fQualifier == null) {
- fQualifier = fConfig.getAttribute("qualifier"); //$NON-NLS-1$
- try {
- if (fQualifier != null) {
- fQualifier = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(fQualifier, false);
- }
- } catch (CoreException e) {
- ConsolePlugin.log(e);
- }
- }
- return fQualifier;
- }
-}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PinConsoleAction.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PinConsoleAction.java
deleted file mode 100644
index 61d307407..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/PinConsoleAction.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2007 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.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.console.IConsoleView;
-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);
- setImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_PIN));
- setDisabledImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_DLCL_PIN));
- setHoverImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_LCL_PIN));
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_PIN_CONSOLE_ACITON);
- fView = view;
- update();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- fView.setPinned(isChecked());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- 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
deleted file mode 100644
index e0b2ad268..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ScrollLockAction.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 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.jface.action.Action;
-import org.eclipse.ui.PlatformUI;
-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);
- fConsoleView = consoleView;
-
- setToolTipText(ConsoleMessages.ScrollLockAction_1);
- setHoverImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_LCL_LOCK));
- setDisabledImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_DLCL_LOCK));
- setImageDescriptor(ConsolePluginImages.getImageDescriptor(IInternalConsoleConstants.IMG_ELCL_LOCK));
- PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IConsoleHelpContextIds.CONSOLE_SCROLL_LOCK_ACTION);
- boolean checked = fConsoleView.getScrollLock();
- setChecked(checked);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#run()
- */
- 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
deleted file mode 100644
index ed846b0cf..000000000
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ShowConsoleAction.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 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.jface.action.Action;
-
-import org.eclipse.ui.console.IConsole;
-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()
- */
- 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
- */
- public static void showConsole(IConsole console, IConsoleView consoleView) {
- if (!console.equals(consoleView.getConsole())) {
- boolean pinned = consoleView.isPinned();
- if (pinned) {
- consoleView.setPinned(false);
- }
- consoleView.display(console);
- if (pinned) {
- consoleView.setPinned(true);
- }
- }
- }
-
- /**
- * Constructs an action to display the given console.
- *
- * @param view the console view in which the given console is contained
- * @param console the console
- */
- public ShowConsoleAction(IConsoleView view, IConsole console) {
- super(console.getName(), AS_RADIO_BUTTON);
- fConsole = console;
- fView = view;
- setImageDescriptor(console.getImageDescriptor());
- }
-}
--
cgit v1.2.3