From 4bcfbb46f06a4e63fd47d6579c25bb31b188d1a7 Mon Sep 17 00:00:00 2001 From: "Judy N. Green" Date: Mon, 21 Oct 2002 20:22:26 +0000 Subject: [PATCH] Added a selection changed listener to the textViewer managed by the C Build View (BuildConsoleView.java). This updates the tool bar menu items to enable the copy action when there is a selection made in the C-Build console. --- .../cdt/internal/ui/BuildConsoleAction.java | 13 +++++-------- .../cdt/internal/ui/BuildConsoleView.java | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleAction.java index e326495b1f7..766df09a38c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleAction.java @@ -41,15 +41,12 @@ public class BuildConsoleAction extends TextEditorAction { * @see TextEditorAction */ public void update() { - - - //boolean wasEnabled= isEnabled(); + + 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); - }*/ + if (wasEnabled != isEnabled) { + setEnabled(isEnabled); + } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleView.java index fe2da44d42a..6e10d94260a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleView.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BuildConsoleView.java @@ -21,6 +21,8 @@ import org.eclipse.jface.text.TextEvent; import org.eclipse.jface.text.TextViewer; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.graphics.Font; @@ -74,13 +76,25 @@ public class BuildConsoleView extends ViewPart { actionBars.setGlobalActionHandler(ITextEditorActionConstants.COPY, fCopyAction); actionBars.setGlobalActionHandler(ITextEditorActionConstants.SELECT_ALL, fSelectAllAction); + + fTextViewer.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent e) { + // ensures that the copyAction updates is doability when the selections tate changes + fCopyAction.update(); + } + }); +// addTextListener(new ITextListener() { +// public void textChanged(TextEvent event) { +// fCopyAction.update(); +// fSelectAllAction.update(); +// } +// }); } /** * @see ViewPart#createPartControl */ public void createPartControl(Composite parent) { - //fTextViewer= new TextViewer(parent, SWT.V_SCROLL|SWT.H_SCROLL); fTextViewer= new TextViewer(parent, SWT.V_SCROLL|SWT.H_SCROLL|SWT.WRAP|SWT.MULTI); fTextViewer.setDocument(CPlugin.getDefault().getConsoleDocument()); fTextViewer.addTextListener(new ITextListener() {