diff options
11 files changed, 141 insertions, 11 deletions
diff --git a/org.eclipse.debug.ui/icons/full/clcl16/lock_co.gif b/org.eclipse.debug.ui/icons/full/clcl16/lock_co.gif Binary files differnew file mode 100644 index 000000000..d47ecfd8b --- /dev/null +++ b/org.eclipse.debug.ui/icons/full/clcl16/lock_co.gif diff --git a/org.eclipse.debug.ui/icons/full/dlcl16/lock_co.gif b/org.eclipse.debug.ui/icons/full/dlcl16/lock_co.gif Binary files differnew file mode 100644 index 000000000..c67c0d87e --- /dev/null +++ b/org.eclipse.debug.ui/icons/full/dlcl16/lock_co.gif diff --git a/org.eclipse.debug.ui/icons/full/elcl16/lock_co.gif b/org.eclipse.debug.ui/icons/full/elcl16/lock_co.gif Binary files differnew file mode 100644 index 000000000..be3943a46 --- /dev/null +++ b/org.eclipse.debug.ui/icons/full/elcl16/lock_co.gif diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java index 49f969475..3dbba9000 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugPluginImages.java @@ -78,17 +78,20 @@ public class DebugPluginImages { //Local toolbars declareRegistryImage(IDebugUIConstants.IMG_LCL_DETAIL_PANE, LOCALTOOL + "toggledetailpane_co.gif"); //$NON-NLS-1$ declareRegistryImage(IDebugUIConstants.IMG_LCL_CLEAR, LOCALTOOL + "clear_co.gif"); //$NON-NLS-1$ + declareRegistryImage(IDebugUIConstants.IMG_LCL_LOCK, LOCALTOOL + "lock_co.gif"); //$NON-NLS-1$ declareRegistryImage(IDebugUIConstants.IMG_LCL_TYPE_NAMES, LOCALTOOL + "tnames_co.gif"); //$NON-NLS-1$ declareRegistryImage(IDebugUIConstants.IMG_LCL_DISCONNECT, LOCALTOOL + "disconnect_co.gif"); //$NON-NLS-1$ // disabled local toolbars declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_DETAIL_PANE, ELCL + "toggledetailpane_co.gif"); //$NON-NLS-1$ declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_CLEAR, DLCL + "clear_co.gif"); //$NON-NLS-1$ + declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_LOCK, DLCL + "lock_co.gif"); //$NON-NLS-1$ declareRegistryImage(IInternalDebugUIConstants.IMG_DLCL_TYPE_NAMES, DLCL + "tnames_co.gif"); //$NON-NLS-1$ // enabled local toolbars declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_DETAIL_PANE, ELCL + "toggledetailpane_co.gif"); //$NON-NLS-1$ declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_CLEAR, ELCL + "clear_co.gif"); //$NON-NLS-1$ + declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_LOCK, ELCL + "lock_co.gif"); //$NON-NLS-1$ declareRegistryImage(IInternalDebugUIConstants.IMG_ELCL_TYPE_NAMES, ELCL + "tnames_co.gif"); //$NON-NLS-1$ //Object diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java index 4751c4f95..4df7ccd44 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IDebugHelpContextIds.java @@ -23,7 +23,8 @@ public interface IDebugHelpContextIds { // Actions public static final String CHANGE_VALUE_ACTION = PREFIX + "change_value_action_context"; //$NON-NLS-1$ - public static final String CLEAR_CONSOLE_ACTION = PREFIX + "clear_console_action_context"; //$NON-NLS-1$ + 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 OPEN_BREAKPOINT_ACTION = PREFIX + "open_breakpoint_action_context"; //$NON-NLS-1$ public static final String RELAUNCH_HISTORY_ACTION = PREFIX + "relaunch_history_action_context"; //$NON-NLS-1$ public static final String SHOW_DETAIL_PANE_ACTION = PREFIX + "show_detail_pane_action_context"; //$NON-NLS-1$ diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java index 1d5c4bfa8..e51d6cc6e 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java @@ -20,12 +20,14 @@ public interface IInternalDebugUIConstants { // disabled local tool images 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_DETAIL_PANE= "IMG_DLCL_DETAIL_PANE"; //$NON-NLS-1$ public static final String IMG_DLCL_CHANGE_VARIABLE_VALUE= "IMG_DLCL_CHANGE_VARIABLE_VALUE"; //$NON-NLS-1$ public static final String IMG_DLCL_TYPE_NAMES= "IMG_DLCL_TYPE_NAMES"; //$NON-NLS-1$ // enabled local tool images 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_DETAIL_PANE= "IMG_ELCL_DETAIL_PANE"; //$NON-NLS-1$ public static final String IMG_ELCL_CHANGE_VARIABLE_VALUE= "IMG_ELCL_CHANGE_VARIABLE_VALUE"; //$NON-NLS-1$ public static final String IMG_ELCL_TYPE_NAMES= "IMG_ELCL_TYPE_NAMES"; //$NON-NLS-1$ diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties index c9af7a307..eea63d74b 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties @@ -115,3 +115,5 @@ LaunchAsAction.Run_As_2=Run A&s ShowCurrentProcessAction.Show_Selected/Current_Process_1=Show Selected/Current Process ProcessDropDownAction.Select_Process_1=Select Process ProcessDropDownAction.Display_output_of_selected_process._2=Display output of selected process. +ScrollLockAction.Scroll_Lock_1=Scroll Lock +ScrollLockAction.Scroll_Lock_2=Scroll Lock diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleView.java index c851b66e5..b7b3354d1 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleView.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleView.java @@ -51,10 +51,13 @@ import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Widget; import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IMemento; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IViewSite; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PartInitException; import org.eclipse.ui.texteditor.FindReplaceAction; import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.IUpdate; @@ -64,6 +67,8 @@ public class ConsoleView extends AbstractDebugEventHandlerView implements IDocum protected ClearOutputAction fClearOutputAction= null; protected FollowHyperlinkAction fFollowLinkAction = null; protected ProcessDropDownAction fProcessDropDownAction = null; + protected ScrollLockAction fScrollLockAction = null; + private boolean fIsLocked = false; protected Map fGlobalActions= new HashMap(10); protected List fSelectionActions = new ArrayList(3); @@ -273,6 +278,9 @@ public class ConsoleView extends AbstractDebugEventHandlerView implements IDocum fFollowLinkAction = new FollowHyperlinkAction(getConsoleViewer()); fProcessDropDownAction = new ProcessDropDownAction(this); + fScrollLockAction = new ScrollLockAction(getConsoleViewer()); + fScrollLockAction.setChecked(fIsLocked); + getConsoleViewer().setAutoScroll(!fIsLocked); actionBars.updateActionBars(); @@ -306,8 +314,10 @@ public class ConsoleView extends AbstractDebugEventHandlerView implements IDocum */ protected void configureToolBar(IToolBarManager mgr) { mgr.add(new Separator(IDebugUIConstants.LAUNCH_GROUP)); + mgr.add(new Separator(IDebugUIConstants.OUTPUT_GROUP)); mgr.add(fClearOutputAction); mgr.add(fProcessDropDownAction); + mgr.add(fScrollLockAction); } /** @@ -503,4 +513,32 @@ public class ConsoleView extends AbstractDebugEventHandlerView implements IDocum } } } + + /** + * Save scroll lock. + * + * @see org.eclipse.ui.IViewPart#saveState(org.eclipse.ui.IMemento) + */ + public void saveState(IMemento memento) { + super.saveState(memento); + if (fScrollLockAction != null) { + memento.putString(getViewSite().getId() + ".scrollLock", new Boolean(fScrollLockAction.isChecked()).toString()); //$NON-NLS-1$ + } + } + + /** + * Restore scroll lock. + * + * @see org.eclipse.ui.IViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento) + */ + public void init(IViewSite site, IMemento memento) throws PartInitException { + super.init(site, memento); + if (memento != null) { + String lock = memento.getString(site.getId() + ".scrollLock"); //$NON-NLS-1$ + if (lock != null) { + fIsLocked = new Boolean(lock).booleanValue(); + } + } + } + }
\ No newline at end of file diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleViewer.java index 6c79b8e0f..c87a9be52 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleViewer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ConsoleViewer.java @@ -75,6 +75,12 @@ public class ConsoleViewer extends TextViewer implements IPropertyChangeListener private boolean fVisible = false; protected InternalDocumentListener fInternalDocumentListener= new InternalDocumentListener(); + + /** + * Whether the console scrolls as output is appended. + */ + private boolean fAutoScroll = true; + /** * Internal document listener. */ @@ -138,17 +144,19 @@ public class ConsoleViewer extends TextViewer implements IPropertyChangeListener * Reveals (makes visible) the end of the current document */ protected void revealEndOfDocument() { - IDocument doc= getDocument(); - int lines = doc.getNumberOfLines(); - try { - // lines are 0-based - int offset = doc.getLineOffset(lines - 1); - if (offset > 0) { - StyledText widget= getTextWidget(); - widget.setCaretOffset(offset); - widget.showSelection(); + if (isAutoScroll()) { + IDocument doc= getDocument(); + int lines = doc.getNumberOfLines(); + try { + // lines are 0-based + int offset = doc.getLineOffset(lines - 1); + if (offset > 0) { + StyledText widget= getTextWidget(); + widget.setCaretOffset(offset); + widget.showSelection(); + } + } catch (BadLocationException e) { } - } catch (BadLocationException e) { } } @@ -464,6 +472,24 @@ public class ConsoleViewer extends TextViewer implements IPropertyChangeListener } } } + + /** + * Sets whether this viewer should auto-scroll as output is appended to the + * document. + * + * @param scroll + */ + public void setAutoScroll(boolean scroll) { + fAutoScroll = scroll; + } + + /** + * Returns whether this viewer should auto-scroll as output is appended to + * the document. + */ + public boolean isAutoScroll() { + return fAutoScroll; + } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ScrollLockAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ScrollLockAction.java new file mode 100644 index 000000000..8d742cdd4 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/console/ScrollLockAction.java @@ -0,0 +1,45 @@ +package org.eclipse.debug.internal.ui.views.console; + +/********************************************************************** +Copyright (c) 2000, 2002 IBM Corp. All rights reserved. +This file is made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html +**********************************************************************/ + +import org.eclipse.debug.internal.ui.DebugPluginImages; +import org.eclipse.debug.internal.ui.IDebugHelpContextIds; +import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; +import org.eclipse.debug.internal.ui.actions.ActionMessages; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.jface.action.Action; +import org.eclipse.ui.help.WorkbenchHelp; + +/** + * Toggles console auto-scroll + */ +public class ScrollLockAction extends Action { + + private ConsoleViewer fConsoleViewer; + + public ScrollLockAction(ConsoleViewer viewer) { + super(ActionMessages.getString("ScrollLockAction.Scroll_Lock_1")); //$NON-NLS-1$ + fConsoleViewer= viewer; + setToolTipText(ActionMessages.getString("ScrollLockAction.Scroll_Lock_2")); //$NON-NLS-1$ + setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_LOCK)); + setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_LOCK)); + setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_LOCK)); + WorkbenchHelp.setHelp( + this, + IDebugHelpContextIds.CONSOLE_SCROLL_LOCK_ACTION); + setChecked(false); + } + + /** + * @see org.eclipse.jface.action.IAction#run() + */ + public void run() { + fConsoleViewer.setAutoScroll(!isChecked()); + } +} + diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java index 84843df87..c999ab77c 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/IDebugUIConstants.java @@ -303,6 +303,13 @@ public interface IDebugUIConstants { public static final String IMG_LCL_DISCONNECT= "IMG_LCL_DISCONNECT"; //$NON-NLS-1$ /** + * Scroll lock action image identifier + * + * @since 2.1 + */ + public static final String IMG_LCL_LOCK = "IMG_LCL_LOCK"; //$NON-NLS-1$ + + /** * Content assist action image identifier. */ public static final String IMG_LCL_CONTENT_ASSIST= "IMG_LCL_CONTENT_ASSIST"; //$NON-NLS-1$ @@ -505,6 +512,12 @@ public interface IDebugUIConstants { */ public static final String LAUNCH_GROUP = "launchGroup"; //$NON-NLS-1$ + /** + * Identifier for an output group in a menu (value + * <code>"outputGroup"</code>). + */ + public static final String OUTPUT_GROUP = "outputGroup"; //$NON-NLS-1$ + /** * Identifier for an empty group preceding a * variable group in a menu (value <code>"emptyVariableGroup"</code>). |