1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

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.
This commit is contained in:
Judy N. Green 2002-10-21 20:22:26 +00:00
parent 83ea6524dc
commit 4bcfbb46f0
2 changed files with 20 additions and 9 deletions

View file

@ -41,15 +41,12 @@ public class BuildConsoleAction extends TextEditorAction {
* @see TextEditorAction * @see TextEditorAction
*/ */
public void update() { public void update() {
boolean wasEnabled= isEnabled();
//boolean wasEnabled= isEnabled();
boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode)); boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
setEnabled(isEnabled);
if (wasEnabled != isEnabled) {
/*if (wasEnabled != isEnabled) { setEnabled(isEnabled);
firePropertyChange(ENABLED, wasEnabled ? Boolean.TRUE : Boolean.FALSE, isEnabled ? Boolean.TRUE : Boolean.FALSE); }
}*/
} }
} }

View file

@ -21,6 +21,8 @@ import org.eclipse.jface.text.TextEvent;
import org.eclipse.jface.text.TextViewer; import org.eclipse.jface.text.TextViewer;
import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent; 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.SWT;
import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
@ -74,13 +76,25 @@ public class BuildConsoleView extends ViewPart {
actionBars.setGlobalActionHandler(ITextEditorActionConstants.COPY, fCopyAction); actionBars.setGlobalActionHandler(ITextEditorActionConstants.COPY, fCopyAction);
actionBars.setGlobalActionHandler(ITextEditorActionConstants.SELECT_ALL, fSelectAllAction); 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 * @see ViewPart#createPartControl
*/ */
public void createPartControl(Composite parent) { 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= new TextViewer(parent, SWT.V_SCROLL|SWT.H_SCROLL|SWT.WRAP|SWT.MULTI);
fTextViewer.setDocument(CPlugin.getDefault().getConsoleDocument()); fTextViewer.setDocument(CPlugin.getDefault().getConsoleDocument());
fTextViewer.addTextListener(new ITextListener() { fTextViewer.addTextListener(new ITextListener() {