Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2011-12-15 15:35:43 +0000
committerUwe Stieber2011-12-15 15:35:43 +0000
commit7e62d9e9a5691775ecd264dc8cb864ffcd5d43d4 (patch)
tree94ae09f236bb9a2a1a73652c9c82e7129310c5be /target_explorer/plugins
parent94ae86e98b3d3e4e4d2baf73dd7c6ad35dcfd555 (diff)
downloadorg.eclipse.tcf-7e62d9e9a5691775ecd264dc8cb864ffcd5d43d4.tar.gz
org.eclipse.tcf-7e62d9e9a5691775ecd264dc8cb864ffcd5d43d4.tar.xz
org.eclipse.tcf-7e62d9e9a5691775ecd264dc8cb864ffcd5d43d4.zip
Target Explorer: Added global action handler to Script Pad
Diffstat (limited to 'target_explorer/plugins')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.properties15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.xml45
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java70
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/CopyAction.java51
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/CutAction.java51
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/DeleteAction.java57
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PasteAction.java68
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PlayAction.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/SelectAllAction.java51
9 files changed, 406 insertions, 6 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.properties
index 38d9a47e7..7e91df362 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.properties
@@ -17,6 +17,21 @@ ScriptPad.name=Script Pad
# ***** Command Contributions *****
+command.cut.label=Cu&t
+command.cut.tooltip=Cut
+
+command.copy.label=&Copy
+command.copy.tooltip=Copy
+
+command.paste.label=&Paste
+command.paste.tooltip=Paste
+
+command.delete.label=&Delete
+command.delete.tooltip=Delete
+
+command.selectall.label=Select &All
+command.selectall.tooltip=Select All
+
PeersSubMenuAction.label=Peers
PeersSubMenuAction.tooltip=Select the peer to play the script on.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.xml
index 1292750b4..bc1543416 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/plugin.xml
@@ -80,6 +80,51 @@
</viewContribution>
</extension>
+ <extension point="org.eclipse.ui.menus">
+ <menuContribution locationURI="popup:org.eclipse.tcf.te.tcf.ui.views.scriptpad">
+ <separator name="group.edit" visible="true"/>
+ <command
+ commandId="org.eclipse.ui.edit.cut"
+ disabledIcon="platform:/plugin/org.eclipse.ui/icons/full/dtool16/cut_edit.gif"
+ icon="platform:/plugin/org.eclipse.ui/icons/full/etool16/cut_edit.gif"
+ label="%command.cut.label"
+ style="push"
+ tooltip="%command.cut.tooltip">
+ </command>
+ <command
+ commandId="org.eclipse.ui.edit.copy"
+ disabledIcon="platform:/plugin/org.eclipse.ui/icons/full/dtool16/copy_edit.gif"
+ icon="platform:/plugin/org.eclipse.ui/icons/full/etool16/copy_edit.gif"
+ label="%command.copy.label"
+ style="push"
+ tooltip="%command.copy.tooltip">
+ </command>
+ <command
+ commandId="org.eclipse.ui.edit.paste"
+ disabledIcon="platform:/plugin/org.eclipse.ui/icons/full/dtool16/paste_edit.gif"
+ icon="platform:/plugin/org.eclipse.ui/icons/full/etool16/paste_edit.gif"
+ label="%command.paste.label"
+ style="push"
+ tooltip="%command.paste.tooltip">
+ </command>
+ <separator name="group.select" visible="true"/>
+ <command
+ commandId="org.eclipse.ui.edit.delete"
+ disabledIcon="platform:/plugin/org.eclipse.ui/icons/full/dtool16/delete.gif"
+ icon="platform:/plugin/org.eclipse.ui/icons/full/etool16/delete.gif"
+ label="%command.delete.label"
+ style="push"
+ tooltip="%command.delete.tooltip">
+ </command>
+ <command
+ commandId="org.eclipse.ui.edit.selectAll"
+ label="%command.selectall.label"
+ style="push"
+ tooltip="%command.selectall.tooltip">
+ </command>
+ </menuContribution>
+ </extension>
+
<!-- Script Pad event listener contributions -->
<extension point="org.eclipse.tcf.te.runtime.eventListeners">
<eventListener
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java
index b52d517e8..3ce3ca205 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java
@@ -27,6 +27,8 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CaretEvent;
+import org.eclipse.swt.custom.CaretListener;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@@ -34,9 +36,16 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions.CopyAction;
+import org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions.CutAction;
+import org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions.DeleteAction;
+import org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions.PasteAction;
+import org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions.SelectAllAction;
import org.eclipse.tcf.te.ui.swt.DisplayUtil;
+import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPartConstants;
+import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.part.ViewPart;
/**
@@ -52,6 +61,13 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection
// Reference to the selected peer model
private IPeerModel peerModel;
+ // References to the global action handlers
+ private CutAction cutHandler;
+ private CopyAction copyHandler;
+ private PasteAction pasteHandler;
+ /* default */ DeleteAction deleteHandler;
+ private SelectAllAction selectAllHandler;
+
/**
* Constructor.
*/
@@ -82,6 +98,12 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection
text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
text.setFont(JFaceResources.getTextFont());
text.addSelectionListener(this);
+ text.addCaretListener(new CaretListener() {
+ @Override
+ public void caretMoved(CaretEvent event) {
+ if (deleteHandler != null) deleteHandler.updateEnabledState();
+ }
+ });
// Register ourselves as selection provider
getViewSite().setSelectionProvider(this);
@@ -91,6 +113,9 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection
// Create the toolbar
createToolbar();
+ // Hook the global actions
+ hookGlobalActions();
+
// Update the action bars
getViewSite().getActionBars().updateActionBars();
}
@@ -127,6 +152,30 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection
}
/**
+ * Hook the global actions.
+ */
+ protected void hookGlobalActions() {
+ IActionBars actionBars = getViewSite().getActionBars();
+
+ cutHandler = new CutAction(this);
+ actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), cutHandler);
+
+ copyHandler = new CopyAction(this);
+ actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), copyHandler);
+
+ pasteHandler = new PasteAction(this);
+ actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), pasteHandler);
+
+ deleteHandler = new DeleteAction(this);
+ actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteHandler);
+
+ selectAllHandler = new SelectAllAction(this);
+ actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), selectAllHandler);
+
+ updateActionEnablements();
+ }
+
+ /**
* Creates the views toolbar.
*/
private void createToolbar() {
@@ -190,6 +239,7 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection
// Fire the selection changed event
fireSelectionChanged();
+ updateActionEnablements();
}
/**
@@ -206,6 +256,17 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection
}
}
+ /**
+ * Update the action enablements
+ */
+ public void updateActionEnablements() {
+ if (cutHandler != null) cutHandler.updateEnabledState();
+ if (copyHandler != null) copyHandler.updateEnabledState();
+ if (pasteHandler != null) pasteHandler.updateEnabledState();
+ if (deleteHandler != null) deleteHandler.updateEnabledState();
+ if (selectAllHandler != null) selectAllHandler.updateEnabledState();
+ }
+
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
*/
@@ -219,6 +280,7 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection
@Override
public void widgetSelected(SelectionEvent e) {
fireSelectionChanged();
+ updateActionEnablements();
}
/**
@@ -250,11 +312,11 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection
}
/**
- * Returns the script.
+ * Returns the styled text widget.
*
- * @return The script.
+ * @return The styled text widget or <code>null</code>.
*/
- public String getScript() {
- return text.getText();
+ public StyledText getStyledText() {
+ return text;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/CopyAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/CopyAction.java
new file mode 100644
index 000000000..c61d86220
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/CopyAction.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.Action;
+import org.eclipse.tcf.te.tcf.ui.views.scriptpad.ScriptPad;
+
+/**
+ * Script Pad copy action handler implementation.
+ */
+public class CopyAction extends Action {
+ // Reference to the parent view
+ private final ScriptPad view;
+
+ /**
+ * Constructor.
+ *
+ * @param view The parent Script Pad view. Must not be <code>null</code>.
+ */
+ public CopyAction(ScriptPad view) {
+ super();
+
+ Assert.isNotNull(view);
+ this.view = view;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ if (view.getStyledText() == null || view.getStyledText().isDisposed()) return;
+ view.getStyledText().copy();
+ view.updateActionEnablements();
+ }
+
+ /**
+ * Updates the actions enabled state.
+ */
+ public void updateEnabledState() {
+ setEnabled(view.getStyledText() != null && view.getStyledText().getSelectionCount() > 0);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/CutAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/CutAction.java
new file mode 100644
index 000000000..1e22128fd
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/CutAction.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.Action;
+import org.eclipse.tcf.te.tcf.ui.views.scriptpad.ScriptPad;
+
+/**
+ * Script Pad cut action handler implementation.
+ */
+public class CutAction extends Action {
+ // Reference to the parent view
+ private final ScriptPad view;
+
+ /**
+ * Constructor.
+ *
+ * @param view The parent Script Pad view. Must not be <code>null</code>.
+ */
+ public CutAction(ScriptPad view) {
+ super();
+
+ Assert.isNotNull(view);
+ this.view = view;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ if (view.getStyledText() == null || view.getStyledText().isDisposed()) return;
+ view.getStyledText().cut();
+ view.updateActionEnablements();
+ }
+
+ /**
+ * Updates the actions enabled state.
+ */
+ public void updateEnabledState() {
+ setEnabled(view.getStyledText() != null && view.getStyledText().getEditable() && view.getStyledText().getSelectionCount() > 0);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/DeleteAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/DeleteAction.java
new file mode 100644
index 000000000..8cfb7c66c
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/DeleteAction.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.tcf.te.tcf.ui.views.scriptpad.ScriptPad;
+
+/**
+ * Script Pad delete action handler implementation.
+ */
+public class DeleteAction extends Action {
+ // Reference to the parent view
+ private final ScriptPad view;
+
+ /**
+ * Constructor.
+ *
+ * @param view The parent Script Pad view. Must not be <code>null</code>.
+ */
+ public DeleteAction(ScriptPad view) {
+ super();
+
+ Assert.isNotNull(view);
+ this.view = view;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ if (view.getStyledText() == null || view.getStyledText().isDisposed()) return;
+ Point selection = view.getStyledText().getSelection();
+ if (selection.y == selection.x && selection.x < view.getStyledText().getCharCount()) {
+ view.getStyledText().setSelection(selection.x, selection.x + 1);
+ }
+ view.getStyledText().insert(""); //$NON-NLS-1$
+ view.updateActionEnablements();
+ }
+
+ /**
+ * Updates the actions enabled state.
+ */
+ public void updateEnabledState() {
+ setEnabled(view.getStyledText() != null && view.getStyledText().getEditable()
+ && (view.getStyledText().getSelectionCount() > 0 || view.getStyledText().getCaretOffset() < view.getStyledText().getCharCount()));
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PasteAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PasteAction.java
new file mode 100644
index 000000000..7025ff3b2
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PasteAction.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.tcf.te.tcf.ui.views.scriptpad.ScriptPad;
+
+/**
+ * Script Pad paste action handler implementation.
+ */
+public class PasteAction extends Action {
+ // Reference to the parent view
+ private final ScriptPad view;
+
+ /**
+ * Constructor.
+ *
+ * @param view The parent Script Pad view. Must not be <code>null</code>.
+ */
+ public PasteAction(ScriptPad view) {
+ super();
+
+ Assert.isNotNull(view);
+ this.view = view;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ if (view.getStyledText() == null || view.getStyledText().isDisposed()) return;
+ view.getStyledText().paste();
+ view.updateActionEnablements();
+ }
+
+ /**
+ * Updates the actions enabled state.
+ */
+ public void updateEnabledState() {
+ boolean canPaste = false;
+ if (view.getStyledText() != null && view.getStyledText().getEditable()) {
+ Clipboard clipboard = new Clipboard(view.getStyledText().getDisplay());
+ TransferData[] td = clipboard.getAvailableTypes();
+ for (int i = 0; i < td.length; ++i) {
+ if (TextTransfer.getInstance().isSupportedType(td[i])) {
+ canPaste = true;
+ break;
+ }
+ }
+
+ clipboard.dispose();
+ }
+
+ setEnabled(canPaste);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PlayAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PlayAction.java
index 05da44317..5b7a61850 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PlayAction.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/PlayAction.java
@@ -97,8 +97,8 @@ public class PlayAction extends Action implements IViewActionDelegate, IActionDe
String script = null;
IPeerModel peerModel = null;
- if (view instanceof ScriptPad) {
- script = ((ScriptPad)view).getScript();
+ if (view instanceof ScriptPad && ((ScriptPad)view).getStyledText() != null) {
+ script = ((ScriptPad)view).getStyledText().getText();
peerModel = ((ScriptPad)view).getPeerModel();
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/SelectAllAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/SelectAllAction.java
new file mode 100644
index 000000000..2f4545070
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/SelectAllAction.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Wind River Systems, Inc. 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.action.Action;
+import org.eclipse.tcf.te.tcf.ui.views.scriptpad.ScriptPad;
+
+/**
+ * Script Pad select all action handler implementation.
+ */
+public class SelectAllAction extends Action {
+ // Reference to the parent view
+ private final ScriptPad view;
+
+ /**
+ * Constructor.
+ *
+ * @param view The parent Script Pad view. Must not be <code>null</code>.
+ */
+ public SelectAllAction(ScriptPad view) {
+ super();
+
+ Assert.isNotNull(view);
+ this.view = view;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ if (view.getStyledText() == null || view.getStyledText().isDisposed()) return;
+ view.getStyledText().selectAll();
+ view.updateActionEnablements();
+ }
+
+ /**
+ * Updates the actions enabled state.
+ */
+ public void updateEnabledState() {
+ setEnabled(view.getStyledText() != null && view.getStyledText().getCharCount() > 0);
+ }
+}

Back to the top