From 6cbd7e602de14f930f1ce38ad3f71c6da5101d5a Mon Sep 17 00:00:00 2001 From: Martin Oberhuber Date: Fri, 25 Apr 2008 20:14:53 +0000 Subject: [PATCH] [227537] moved actions from terminal.view to terminal plugin (apply Patch from Anna Dushistova) --- .../icons/clcl16/clear_co.gif | Bin 595 -> 0 bytes .../icons/dlcl16/clear_co.gif | Bin 364 -> 0 bytes .../icons/elcl16/clear_co.gif | Bin 595 -> 0 bytes .../terminal/actions/ActionMessages.java | 8 +- .../actions/ActionMessages.properties | 8 +- .../actions/TerminalActionClearAll.java | 42 ------- .../terminal/actions/TerminalActionCopy.java | 40 ------- .../terminal/actions/TerminalActionCut.java | 40 ------- .../terminal/actions/TerminalActionPaste.java | 40 ------- .../internal/terminal/view/ITerminalView.java | 8 +- .../internal/terminal/view/ImageConsts.java | 6 +- .../internal/terminal/view/TerminalView.java | 109 ++++-------------- .../terminal/view/TerminalViewPlugin.java | 6 +- org.eclipse.tm.terminal/META-INF/MANIFEST.MF | 14 ++- org.eclipse.tm.terminal/build.properties | 11 +- .../actions/AbstractTerminalAction.java | 101 ++++++++++++++++ .../control/actions/ActionMessages.java | 37 +++--- .../control/actions/ActionMessages.properties | 22 ++++ .../terminal/control/actions/ImageConsts.java | 31 +++++ .../actions/TerminalActionClearAll.java | 55 +++++++++ .../control/actions/TerminalActionCopy.java | 64 ++++++++++ .../control/actions/TerminalActionCut.java | 55 +++++++++ .../control/actions/TerminalActionPaste.java | 62 ++++++++++ .../actions/TerminalActionSelectAll.java | 52 +++++++++ .../terminal/control/impl/TerminalPlugin.java | 30 ++++- 25 files changed, 540 insertions(+), 301 deletions(-) delete mode 100644 org.eclipse.tm.terminal.view/icons/clcl16/clear_co.gif delete mode 100644 org.eclipse.tm.terminal.view/icons/dlcl16/clear_co.gif delete mode 100644 org.eclipse.tm.terminal.view/icons/elcl16/clear_co.gif delete mode 100644 org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionClearAll.java delete mode 100644 org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionCopy.java delete mode 100644 org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionCut.java delete mode 100644 org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionPaste.java create mode 100644 org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java rename org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionSelectAll.java => org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java (52%) create mode 100644 org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties create mode 100644 org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java create mode 100644 org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java create mode 100644 org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java create mode 100644 org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java create mode 100644 org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java create mode 100644 org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java diff --git a/org.eclipse.tm.terminal.view/icons/clcl16/clear_co.gif b/org.eclipse.tm.terminal.view/icons/clcl16/clear_co.gif deleted file mode 100644 index af30a42f83d2f91801206463e1f4601a747dd38e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 595 zcmZ?wbhEHb6krfwc*el+;Qr&!Uw{Aj`RCh@zn{MT*?;oxyHCG9ef|CO*PkChf49xr z*E9dn%Iz0#-hcJ>)9(*oeotO@Y}T67i#DHMvE%ZZJy-8O|Ni97&*$%czWwy;^S9r3 zo`1jp^2fthKi+)${p!QdZ$ExNd-wC(&%YnO{{Hms_tzi4zyJI_W5&cyo7UdHe|Of* z{<*XJmMv^wG_UL6rjotu%lB?5-?_GG%gWmI%NmdGpZDg~qvKl(k8UnLx~2Hg#?qZ@ zs#Y&v%S5&t*x!DuCAn{q`0`asHmv0urNPAKQAvYB_$;} zIXNyaE;cqcGBPqWG&DFkI4CG6FfcG6Ai&?>-_OtQ|Ns9C0}2#>vM@3*gfi%WTmgy` z2KEgNp{C6(&7tib?WP<(y|$*E9cHRboKu+W?9C^J>Z%9|aC6C9+u2x5)MuAemSmLN zAgMReQb|NuXu%?WgNcR`5^M(!OBhcylH0yhfQMJnWTKUV_?0Uxu3jz-u0F1z+G3{` zuzEW)`F=drwRH^dde6KTp?5HjDwPt!%ua0$DEtSh$2VJr-3M iJ8pc$DH7Bta2KY#wb zefxI%_U+rYZQHbI)0#DFRqv0~ApMGF@$oHuXY?Afzt&YU@8#*FFH zr%#(U?f?J(3={yxpDc_F4B8AjATvOIVqoh$Ae!bOv##%ivfAOCFau8&wgXGj^h7d5 zgbic_SR0;xy2Hivydi4sR4$3$c5$5yZN&+Ub^IH-l?#g4`GgtjB!mRJx|kGH)9(*oeotO@Y}T67i#DHMvE%ZZJy-8O|Ni97&*$%czWwy;^S9r3 zo`1jp^2fthKi+)${p!QdZ$ExNd-wC(&%YnO{{Hms_tzi4zyJI_W5&cyo7UdHe|Of* z{<*XJmMv^wG_UL6rjotu%lB?5-?_GG%gWmI%NmdGpZDg~qvKl(k8UnLx~2Hg#?qZ@ zs#Y&v%S5&t*x!DuCAn{q`0`asHmv0urNPAKQAvYB_$;} zIXNyaE;cqcGBPqWG&DFkI4CG6FfcG6Ai&?>-_OtQ|Ns9C0}2#>vM@3*gfi%WTmgy` z2KEgNp{C6(&7tib?WP<(y|$*E9cHRboKu+W?9C^J>Z%9|aC6C9+u2x5)MuAemSmLN zAgMReQb|NuXu%?WgNcR`5^M(!OBhcylH0yhfQMJnWTKUV_?0Uxu3jz-u0F1z+G3{` zuzEW)`F=drwRH^dde6KTp?5HjDwPt!%ua0$DEtSh$2VJr-3M iJ8pc$DH7Bta0; - } - - fActionEditCopy.setEnabled(bEnabled); - } - - public void onEditCut() { - fCtlTerminal.sendKey('\u0018'); - } - - public void updateEditCut() { - boolean bEnabled; - - bEnabled = !fMenuAboutToShow; - fActionEditCut.setEnabled(bEnabled); - } - - public void onEditPaste() { - fCtlTerminal.paste(); - } - - public void updateEditPaste() { - String strText = (String) fCtlTerminal.getClipboard().getContents(TextTransfer.getInstance()); - - boolean bEnabled = ((strText != null) && (!strText.equals("")) && (isConnected()));//$NON-NLS-1$ - - fActionEditPaste.setEnabled(bEnabled); - } - - public void onEditClearAll() { - fCtlTerminal.clearTerminal(); - } - - public void updateEditClearAll() { - fActionEditClearAll.setEnabled(!fCtlTerminal.isEmpty()); - } - - public void onEditSelectAll() { - fCtlTerminal.selectAll(); - } - - public void updateEditSelectAll() { - fActionEditSelectAll.setEnabled(!fCtlTerminal.isEmpty()); - } - // ViewPart interface public void createPartControl(Composite wndParent) { @@ -511,11 +450,11 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi fActionTerminalConnect = new TerminalActionConnect(this); fActionTerminalDisconnect = new TerminalActionDisconnect(this); fActionTerminalSettings = new TerminalActionSettings(this); - fActionEditCopy = new TerminalActionCopy(this); - fActionEditCut = new TerminalActionCut(this); - fActionEditPaste = new TerminalActionPaste(this); - fActionEditClearAll = new TerminalActionClearAll(this); - fActionEditSelectAll = new TerminalActionSelectAll(this); + fActionEditCopy = new TerminalActionCopy(fCtlTerminal); + fActionEditCut = new TerminalActionCut(fCtlTerminal); + fActionEditPaste = new TerminalActionPaste(fCtlTerminal); + fActionEditClearAll = new TerminalActionClearAll(fCtlTerminal); + fActionEditSelectAll = new TerminalActionSelectAll(fCtlTerminal); fActionToggleCommandInputField = new TerminalActionToggleCommandInputField(this); } protected void setupLocalToolBars() { @@ -569,7 +508,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi protected class TerminalContextMenuHandler implements MenuListener, IMenuListener { public void menuHidden(MenuEvent event) { fMenuAboutToShow = false; - updateEditCopy(); + fActionEditCopy.updateAction(fMenuAboutToShow); } public void menuShown(MenuEvent e) { @@ -577,11 +516,11 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi } public void menuAboutToShow(IMenuManager menuMgr) { fMenuAboutToShow = true; - updateEditCopy(); - updateEditCut(); - updateEditSelectAll(); - updateEditPaste(); - updateEditClearAll(); + fActionEditCopy.updateAction(fMenuAboutToShow); + fActionEditCut.updateAction(fMenuAboutToShow); + fActionEditSelectAll.updateAction(fMenuAboutToShow); + fActionEditPaste.updateAction(fMenuAboutToShow); + fActionEditClearAll.updateAction(fMenuAboutToShow); } } diff --git a/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewPlugin.java b/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewPlugin.java index 5de2c98f97c..41017326ca9 100644 --- a/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewPlugin.java +++ b/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewPlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2003, 2008 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 @@ -13,6 +13,7 @@ * Contributors: * Michael Scharf (Wind River) - split into core, view and connector plugins * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin *******************************************************************************/ package org.eclipse.tm.internal.terminal.view; @@ -49,7 +50,6 @@ public class TerminalViewPlugin extends AbstractUIPlugin { map.put(ImageConsts.IMAGE_CLCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_CLCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_CLCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$ - map.put(ImageConsts.IMAGE_CLCL_CLEAR_ALL, "clear_co.gif"); //$NON-NLS-1$ loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_LOCALTOOL, map); @@ -62,7 +62,6 @@ public class TerminalViewPlugin extends AbstractUIPlugin { map.put(ImageConsts.IMAGE_ELCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_ELCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_ELCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$ - map.put(ImageConsts.IMAGE_ELCL_CLEAR_ALL, "clear_co.gif"); //$NON-NLS-1$ loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_ELCL, map); @@ -75,7 +74,6 @@ public class TerminalViewPlugin extends AbstractUIPlugin { map.put(ImageConsts.IMAGE_DLCL_SETTINGS, "properties_tsk.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_DLCL_COMMAND_INPUT_FIELD, "command_input_field.gif"); //$NON-NLS-1$ map.put(ImageConsts.IMAGE_DLCL_SCROLL_LOCK, "lock_co.gif"); //$NON-NLS-1$ - map.put(ImageConsts.IMAGE_DLCL_CLEAR_ALL, "clear_co.gif"); //$NON-NLS-1$ loadImageRegistry(imageRegistry, ImageConsts.IMAGE_DIR_DLCL, map); diff --git a/org.eclipse.tm.terminal/META-INF/MANIFEST.MF b/org.eclipse.tm.terminal/META-INF/MANIFEST.MF index d62bf57e9d5..f1d4ddecb35 100644 --- a/org.eclipse.tm.terminal/META-INF/MANIFEST.MF +++ b/org.eclipse.tm.terminal/META-INF/MANIFEST.MF @@ -15,10 +15,20 @@ Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1, Bundle-ClassPath: . Export-Package: org.eclipse.tm.internal.terminal.connector;x-friends:="org.eclipse.tm.terminal.test", org.eclipse.tm.internal.terminal.control;x-friends:="org.eclipse.tm.terminal.view", + org.eclipse.tm.internal.terminal.control.actions;x-friends:="org.eclipse.tm.terminal.view", org.eclipse.tm.internal.terminal.control.impl;x-friends:="org.eclipse.tm.terminal.test", org.eclipse.tm.internal.terminal.emulator;x-friends:="org.eclipse.tm.terminal.test", org.eclipse.tm.internal.terminal.model;x-friends:="org.eclipse.tm.terminal.test", - org.eclipse.tm.internal.terminal.provisional.api;x-friends:="org.eclipse.tm.terminal.serial,org.eclipse.tm.terminal.ssh,org.eclipse.tm.terminal.telnet,org.eclipse.tm.terminal.view,org.eclipse.tm.terminal.test", - org.eclipse.tm.internal.terminal.provisional.api.provider;x-friends:="org.eclipse.tm.terminal.serial,org.eclipse.tm.terminal.ssh,org.eclipse.tm.terminal.telnet,org.eclipse.tm.terminal.test", + org.eclipse.tm.internal.terminal.provisional.api; + x-friends:="org.eclipse.tm.terminal.serial, + org.eclipse.tm.terminal.ssh, + org.eclipse.tm.terminal.telnet, + org.eclipse.tm.terminal.view, + org.eclipse.tm.terminal.test", + org.eclipse.tm.internal.terminal.provisional.api.provider; + x-friends:="org.eclipse.tm.terminal.serial, + org.eclipse.tm.terminal.ssh, + org.eclipse.tm.terminal.telnet, + org.eclipse.tm.terminal.test", org.eclipse.tm.internal.terminal.textcanvas;x-friends:="org.eclipse.tm.terminal.test", org.eclipse.tm.terminal.model diff --git a/org.eclipse.tm.terminal/build.properties b/org.eclipse.tm.terminal/build.properties index 730e1bdb868..19b1c113ae6 100644 --- a/org.eclipse.tm.terminal/build.properties +++ b/org.eclipse.tm.terminal/build.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2003, 2007 Wind River Systems, Inc. and others. +# Copyright (c) 2003, 2008 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 @@ -13,6 +13,7 @@ # Contributors: # Michael Scharf (Wind River) - split into core, view and connector plugins # Martin Oberhuber (Wind River) - fixed copyright headers and beautified +# Anna Dushistova (MontaVista) - added icons ############################################################################### bin.includes = .,\ META-INF/,\ @@ -20,8 +21,12 @@ bin.includes = .,\ plugin.properties,\ .options,\ README.txt,\ - about.html,about.ini,about.mappings,about.properties,\ - eclipse32.png + about.html,\ + about.ini,\ + about.mappings,\ + about.properties,\ + eclipse32.png,\ + icons/ source.. = src/ output.. = bin/ diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java new file mode 100644 index 00000000000..42ca60e7d54 --- /dev/null +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 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 + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - Adapted from TerminalAction + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tm.internal.terminal.control.impl.TerminalPlugin; + +public abstract class AbstractTerminalAction extends Action { + private final ITerminalViewControl fTarget; + + public AbstractTerminalAction(String strId) { + this(null, strId, 0); + } + + public AbstractTerminalAction(ITerminalViewControl target, + String strId) { + this(target, strId, 0); + } + + public AbstractTerminalAction(ITerminalViewControl target, + String strId, int style) { + super("", style); //$NON-NLS-1$ + + fTarget = target; + + setId(strId); + } + + abstract public void run(); + + protected void setupAction(String strText, String strToolTip, + String strImage, String strEnabledImage, String strDisabledImage, + boolean bEnabled) { + setupAction(strText, strToolTip, strImage, strEnabledImage, + strDisabledImage, bEnabled, TerminalPlugin.getDefault() + .getImageRegistry()); + } + + protected void setupAction(String strText, String strToolTip, + String strHoverImage, String strEnabledImage, + String strDisabledImage, boolean bEnabled, + ImageRegistry imageRegistry) { + setupAction(strText, strToolTip, imageRegistry + .getDescriptor(strHoverImage), imageRegistry + .getDescriptor(strEnabledImage), imageRegistry + .getDescriptor(strDisabledImage), bEnabled); + } + + protected void setupAction(String strText, String strToolTip, + ImageDescriptor hoverImage, ImageDescriptor enabledImage, + ImageDescriptor disabledImage, boolean bEnabled) { + setText(strText); + setToolTipText(strToolTip); + setEnabled(bEnabled); + if (enabledImage != null) { + setImageDescriptor(enabledImage); + } + if (disabledImage != null) { + setDisabledImageDescriptor(disabledImage); + } + if (hoverImage != null) { + setHoverImageDescriptor(hoverImage); + } + } + + /** + * Return the terminal instance on which the action should operate. + * + * @return the terminal instance on which the action should operate. + */ + protected ITerminalViewControl getTarget() { + return fTarget; + } + + /** + * Subclasses can update their action + * + * @param aboutToShow true before the menu is shown -- false when the menu + * gets hidden + */ + public void updateAction(boolean aboutToShow) { + } +} diff --git a/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionSelectAll.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java similarity index 52% rename from org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionSelectAll.java rename to org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java index aecffa2e24a..30a3091f0cd 100644 --- a/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionSelectAll.java +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2003, 2008 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 @@ -11,29 +11,24 @@ * Helmut Haigermoser and Ted Williams. * * Contributors: - * Michael Scharf (Wind River) - split into core, view and connector plugins + * Michael Scharf (Wind River) - split into core, view and connector plugins * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin *******************************************************************************/ -package org.eclipse.tm.internal.terminal.actions; +package org.eclipse.tm.internal.terminal.control.actions; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.tm.internal.terminal.view.ITerminalView; +import org.eclipse.osgi.util.NLS; -public class TerminalActionSelectAll extends TerminalAction -{ - public TerminalActionSelectAll(ITerminalView target) - { - super(target, - TerminalActionSelectAll.class.getName()); - - setupAction(ActionMessages.SELECTALL, - ActionMessages.SELECTALL, - (ImageDescriptor)null, - null, - null, - false); - } - public void run() { - fTarget.onEditSelectAll(); +public class ActionMessages extends NLS { + static { + NLS.initializeMessages(ActionMessages.class.getName(), + ActionMessages.class); } + + public static String COPY; + public static String CUT; + public static String PASTE; + public static String SELECTALL; + public static String CLEARALL; + } diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties new file mode 100644 index 00000000000..a5e6b1fae65 --- /dev/null +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties @@ -0,0 +1,22 @@ +############################################################################### +# Copyright (c) 2003, 2008 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 +# +# Initial Contributors: +# The following Wind River employees contributed to the Terminal component +# that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, +# Helmut Haigermoser and Ted Williams. +# +# Contributors: +# Michael Scharf (Wind River) - split into core, view and connector plugins +# Martin Oberhuber (Wind River) - fixed copyright headers and beautified +# Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin +############################################################################### +COPY = Copy +CUT = Cut +PASTE = Paste +SELECTALL = Select All +CLEARALL = Clear Terminal diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java new file mode 100644 index 00000000000..b69b669eadf --- /dev/null +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2003, 2008 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 + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - extracted from TerminalConsts + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +public interface ImageConsts { + public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$ + public final static String IMAGE_DIR_LOCALTOOL = IMAGE_DIR_ROOT + "clcl16/"; // basic colors - size 16x16 //$NON-NLS-1$ + public final static String IMAGE_DIR_DLCL = IMAGE_DIR_ROOT + "dlcl16/"; // disabled - size 16x16 //$NON-NLS-1$ + public final static String IMAGE_DIR_ELCL = IMAGE_DIR_ROOT+ "elcl16/"; // enabled - size 16x16 //$NON-NLS-1$ + + public static final String IMAGE_CLCL_CLEAR_ALL = "ImageClclClearAll"; //$NON-NLS-1$ + + public static final String IMAGE_DLCL_CLEAR_ALL = "ImageDlclClearAll"; //$NON-NLS-1$ + + public static final String IMAGE_ELCL_CLEAR_ALL = "ImageElclClearAll"; //$NON-NLS-1$ +} diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java new file mode 100644 index 00000000000..400c08bb8e8 --- /dev/null +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 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 + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin + ********************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; + +public class TerminalActionClearAll extends AbstractTerminalAction { + public TerminalActionClearAll() { + super(TerminalActionClearAll.class.getName()); + + setupAction(ActionMessages.CLEARALL, ActionMessages.CLEARALL, + ImageConsts.IMAGE_CLCL_CLEAR_ALL, + ImageConsts.IMAGE_ELCL_CLEAR_ALL, + ImageConsts.IMAGE_DLCL_CLEAR_ALL, false); + } + + public TerminalActionClearAll(ITerminalViewControl target) { + super(target, TerminalActionClearAll.class.getName()); + + setupAction(ActionMessages.CLEARALL, ActionMessages.CLEARALL, + ImageConsts.IMAGE_CLCL_CLEAR_ALL, + ImageConsts.IMAGE_ELCL_CLEAR_ALL, + ImageConsts.IMAGE_DLCL_CLEAR_ALL, false); + } + + public void run() { + ITerminalViewControl target = getTarget(); + if (target != null) { + target.clearTerminal(); + } + } + + public void updateAction(boolean aboutToShow) { + ITerminalViewControl target = getTarget(); + if (target != null) + setEnabled(!target.isEmpty()); + else + setEnabled(false); + } +} diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java new file mode 100644 index 00000000000..3bc2bdcaf11 --- /dev/null +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 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 + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +public class TerminalActionCopy extends AbstractTerminalAction { + public TerminalActionCopy() { + super(TerminalActionCopy.class.getName()); + ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); + setupAction(ActionMessages.COPY, ActionMessages.COPY, si + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED), true); + } + + public TerminalActionCopy(ITerminalViewControl target) { + super(target, TerminalActionCopy.class.getName()); + ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); + setupAction(ActionMessages.COPY, ActionMessages.COPY, si + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY), si + .getImageDescriptor(ISharedImages.IMG_TOOL_COPY_DISABLED), true); + } + + public void run() { + ITerminalViewControl target = getTarget(); + if (target != null) { + String selection = target.getSelection(); + + if (!selection.equals("")) {//$NON-NLS-1$ + target.copy(); + } else { + target.sendKey('\u0003'); + } + } + } + + public void updateAction(boolean aboutToShow) { + boolean bEnabled = true; + ITerminalViewControl target = getTarget(); + if (aboutToShow && target != null) { + bEnabled = target.getSelection().length() > 0; + } + setEnabled(bEnabled); + } +} diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java new file mode 100644 index 00000000000..50232f168c6 --- /dev/null +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 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 + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +public class TerminalActionCut extends AbstractTerminalAction { + public TerminalActionCut() { + super(TerminalActionCut.class.getName()); + ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); + setupAction(ActionMessages.CUT, ActionMessages.CUT, si + .getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si + .getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si + .getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true); + } + + public TerminalActionCut(ITerminalViewControl target) { + super(target, TerminalActionCut.class.getName()); + ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); + setupAction(ActionMessages.CUT, ActionMessages.CUT, si + .getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si + .getImageDescriptor(ISharedImages.IMG_TOOL_CUT), si + .getImageDescriptor(ISharedImages.IMG_TOOL_CUT_DISABLED), true); + } + + public void run() { + ITerminalViewControl target = getTarget(); + if (target != null) { + target.sendKey('\u0018'); + } + } + + public void updateAction(boolean aboutToShow) { + boolean bEnabled; + + bEnabled = !aboutToShow; + setEnabled(bEnabled); + } +} diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java new file mode 100644 index 00000000000..36d30b0db1c --- /dev/null +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 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 + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +import org.eclipse.swt.dnd.TextTransfer; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; +import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; + +public class TerminalActionPaste extends AbstractTerminalAction { + public TerminalActionPaste() { + super(TerminalActionPaste.class.getName()); + ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); + setupAction(ActionMessages.PASTE, ActionMessages.PASTE, si + .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), si + .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED), si + .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), false); + } + + public TerminalActionPaste(ITerminalViewControl target) { + super(target, TerminalActionPaste.class.getName()); + ISharedImages si = PlatformUI.getWorkbench().getSharedImages(); + setupAction(ActionMessages.PASTE, ActionMessages.PASTE, si + .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), si + .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE_DISABLED), si + .getImageDescriptor(ISharedImages.IMG_TOOL_PASTE), false); + } + + public void run() { + ITerminalViewControl target = getTarget(); + if (target != null) { + target.paste(); + } + } + + public void updateAction(boolean aboutToShow) { + boolean bEnabled = false; + ITerminalViewControl target = getTarget(); + if (target != null) { + String strText = (String) target.getClipboard().getContents( + TextTransfer.getInstance()); + bEnabled = ((strText != null) && (!strText.equals("")) && (target.getState() == TerminalState.CONNECTED));//$NON-NLS-1$ + } + setEnabled(bEnabled); + } +} diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java new file mode 100644 index 00000000000..08c4aa29e00 --- /dev/null +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2004, 2008 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 + * + * Initial Contributors: + * The following Wind River employees contributed to the Terminal component + * that contains this file: Chris Thew, Fran Litterio, Stephen Lamb, + * Helmut Haigermoser and Ted Williams. + * + * Contributors: + * Michael Scharf (Wind River) - split into core, view and connector plugins + * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin + *******************************************************************************/ +package org.eclipse.tm.internal.terminal.control.actions; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; + +public class TerminalActionSelectAll extends AbstractTerminalAction { + public TerminalActionSelectAll() { + super(TerminalActionSelectAll.class.getName()); + + setupAction(ActionMessages.SELECTALL, ActionMessages.SELECTALL, + (ImageDescriptor) null, null, null, false); + } + + public TerminalActionSelectAll(ITerminalViewControl target) { + super(target, TerminalActionSelectAll.class.getName()); + + setupAction(ActionMessages.SELECTALL, ActionMessages.SELECTALL, + (ImageDescriptor) null, null, null, false); + } + + public void run() { + ITerminalViewControl target = getTarget(); + if (target != null) { + target.selectAll(); + } + } + + public void updateAction(boolean aboutToShow) { + ITerminalViewControl target = getTarget(); + if (target != null) + setEnabled(!target.isEmpty()); + else + setEnabled(false); + } +} diff --git a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java index d8e38bb5e26..d76858230e4 100644 --- a/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java +++ b/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2003, 2008 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 @@ -11,12 +11,19 @@ * Helmut Haigermoser and Ted Williams. * * Contributors: - * Michael Scharf (Wind River) - split into core, view and connector plugins + * Michael Scharf (Wind River) - split into core, view and connector plugins * Martin Oberhuber (Wind River) - fixed copyright headers and beautified + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin *******************************************************************************/ package org.eclipse.tm.internal.terminal.control.impl; +import java.net.MalformedURLException; +import java.net.URL; + import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.tm.internal.terminal.control.actions.ImageConsts; import org.eclipse.tm.internal.terminal.provisional.api.Logger; import org.eclipse.ui.plugin.AbstractUIPlugin; @@ -55,4 +62,23 @@ public class TerminalPlugin extends AbstractUIPlugin { return new Boolean(strEnabled).booleanValue(); } + + protected void initializeImageRegistry(ImageRegistry imageRegistry) { + try { + // Local toolbars + putImageInRegistry(imageRegistry, ImageConsts.IMAGE_CLCL_CLEAR_ALL, ImageConsts.IMAGE_DIR_LOCALTOOL + "clear_co.gif"); //$NON-NLS-1$ + // Enabled local toolbars + putImageInRegistry(imageRegistry, ImageConsts.IMAGE_ELCL_CLEAR_ALL, ImageConsts.IMAGE_DIR_ELCL + "clear_co.gif"); //$NON-NLS-1$ + // Disabled local toolbars + putImageInRegistry(imageRegistry, ImageConsts.IMAGE_DLCL_CLEAR_ALL, ImageConsts.IMAGE_DIR_DLCL + "clear_co.gif"); //$NON-NLS-1$ + } catch (MalformedURLException malformedURLException) { + malformedURLException.printStackTrace(); + } + } + + protected void putImageInRegistry(ImageRegistry imageRegistry, String strKey, String relativePath) throws MalformedURLException { + URL url = TerminalPlugin.getDefault().getBundle().getEntry(relativePath); + ImageDescriptor imageDescriptor = ImageDescriptor.createFromURL(url); + imageRegistry.put(strKey, imageDescriptor); + } }