diff --git a/rse/plugins/org.eclipse.rse.terminals.ui/META-INF/MANIFEST.MF b/rse/plugins/org.eclipse.rse.terminals.ui/META-INF/MANIFEST.MF index 101d3ffa0e9..c64c82ef383 100644 --- a/rse/plugins/org.eclipse.rse.terminals.ui/META-INF/MANIFEST.MF +++ b/rse/plugins/org.eclipse.rse.terminals.ui/META-INF/MANIFEST.MF @@ -12,8 +12,7 @@ Require-Bundle: org.eclipse.ui, org.eclipse.rse.core;bundle-version="[3.0.0,4.0.0)", org.eclipse.rse.ui;bundle-version="[3.0.0,4.0.0)", org.eclipse.rse.subsystems.terminals.core;bundle-version="[0.1.0,0.2.0)", - org.eclipse.tm.terminal;bundle-version="[2.0.0,2.1.0)", - org.eclipse.tm.terminal.view;bundle-version="[2.0.0,2.1.0)" + org.eclipse.tm.terminal;bundle-version="[2.0.0,2.1.0)" Bundle-ActivationPolicy: lazy Eclipse-LazyStart: true Bundle-Vendor: %providerName diff --git a/rse/plugins/org.eclipse.rse.terminals.ui/src/org/eclipse/rse/internal/terminals/ui/views/RSETerminalConnectorImpl.java b/rse/plugins/org.eclipse.rse.terminals.ui/src/org/eclipse/rse/internal/terminals/ui/views/RSETerminalConnectorImpl.java index a9060a6f13d..d5d63555133 100644 --- a/rse/plugins/org.eclipse.rse.terminals.ui/src/org/eclipse/rse/internal/terminals/ui/views/RSETerminalConnectorImpl.java +++ b/rse/plugins/org.eclipse.rse.terminals.ui/src/org/eclipse/rse/internal/terminals/ui/views/RSETerminalConnectorImpl.java @@ -68,7 +68,10 @@ public class RSETerminalConnectorImpl extends TerminalConnectorImpl { } public void setTerminalSize(int newWidth, int newHeight) { - shell.setTerminalSize(newWidth, newHeight); + if(shell != null) + { + shell.setTerminalSize(newWidth, newHeight); + } } public InputStream getInputStream() { diff --git a/rse/plugins/org.eclipse.rse.terminals.ui/src/org/eclipse/rse/internal/terminals/ui/views/TerminalViewTab.java b/rse/plugins/org.eclipse.rse.terminals.ui/src/org/eclipse/rse/internal/terminals/ui/views/TerminalViewTab.java index 544c2c5a61b..28a267d3b6b 100644 --- a/rse/plugins/org.eclipse.rse.terminals.ui/src/org/eclipse/rse/internal/terminals/ui/views/TerminalViewTab.java +++ b/rse/plugins/org.eclipse.rse.terminals.ui/src/org/eclipse/rse/internal/terminals/ui/views/TerminalViewTab.java @@ -31,13 +31,11 @@ import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.model.ISystemRegistry; import org.eclipse.rse.internal.terminals.ui.TerminalServiceHelper; import org.eclipse.rse.subsystems.terminals.core.ITerminalServiceSubSystem; -import org.eclipse.rse.subsystems.terminals.core.TerminalServiceSubSystem; import org.eclipse.rse.subsystems.terminals.core.elements.TerminalElement; import org.eclipse.rse.ui.view.ISystemViewElementAdapter; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.CTabFolder; import org.eclipse.swt.custom.CTabItem; -import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.events.DisposeEvent; import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.MenuEvent; @@ -48,45 +46,42 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Menu; -import org.eclipse.tm.internal.terminal.actions.TerminalAction; -import org.eclipse.tm.internal.terminal.actions.TerminalActionClearAll; -import org.eclipse.tm.internal.terminal.actions.TerminalActionCopy; -import org.eclipse.tm.internal.terminal.actions.TerminalActionCut; -import org.eclipse.tm.internal.terminal.actions.TerminalActionPaste; -import org.eclipse.tm.internal.terminal.actions.TerminalActionSelectAll; import org.eclipse.tm.internal.terminal.control.ITerminalListener; import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; import org.eclipse.tm.internal.terminal.control.TerminalViewControlFactory; +import org.eclipse.tm.internal.terminal.control.actions.AbstractTerminalAction; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionClearAll; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionCopy; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionCut; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionPaste; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionSelectAll; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; import org.eclipse.tm.internal.terminal.provisional.api.TerminalState; -import org.eclipse.tm.internal.terminal.view.ITerminalView; /** * This is the desktop view wrapper of the System View viewer. */ -public class TerminalViewTab extends Composite implements ITerminalListener, - ITerminalView { +public class TerminalViewTab extends Composite implements ITerminalListener{ public static String DATA_KEY_CONTROL = "$_control_$"; //$NON-NLS-1$ private CTabFolder tabFolder; private Menu menu; - private TerminalViewer viewer; private boolean fMenuAboutToShow; - private TerminalAction fActionEditCopy; + private TerminalActionCopy fActionEditCopy; - private TerminalAction fActionEditCut; + private TerminalActionCut fActionEditCut; - private TerminalAction fActionEditPaste; + private TerminalActionPaste fActionEditPaste; - private TerminalAction fActionEditClearAll; + private TerminalActionClearAll fActionEditClearAll; - private TerminalAction fActionEditSelectAll; + private TerminalActionSelectAll fActionEditSelectAll; protected class TerminalContextMenuHandler implements MenuListener, IMenuListener { public void menuHidden(MenuEvent event) { fMenuAboutToShow = false; - updateEditCopy(); + fActionEditCopy.updateAction(fMenuAboutToShow); } public void menuShown(MenuEvent e) { @@ -95,11 +90,11 @@ public class TerminalViewTab extends Composite implements ITerminalListener, 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); } } @@ -109,7 +104,6 @@ public class TerminalViewTab extends Composite implements ITerminalListener, tabFolder.setLayout(new FillLayout()); tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH)); setLayout(new FillLayout()); - this.viewer = viewer; tabFolder.setBackground(parent.getBackground()); tabFolder.setSimple(false); tabFolder.setUnselectedImageVisible(false); @@ -242,11 +236,31 @@ public class TerminalViewTab extends Composite implements ITerminalListener, } protected void setupActions() { - fActionEditCopy = new TerminalActionCopy(this); - fActionEditCut = new TerminalActionCut(this); - fActionEditPaste = new TerminalActionPaste(this); - fActionEditClearAll = new TerminalActionClearAll(this); - fActionEditSelectAll = new TerminalActionSelectAll(this); + fActionEditCopy = new TerminalActionCopy(){ + protected ITerminalViewControl getTarget() { + return getCurrentTerminalViewControl(); + } + }; + fActionEditCut = new TerminalActionCut(){ + protected ITerminalViewControl getTarget() { + return getCurrentTerminalViewControl(); + } + }; + fActionEditPaste = new TerminalActionPaste(){ + protected ITerminalViewControl getTarget() { + return getCurrentTerminalViewControl(); + } + }; + fActionEditClearAll = new TerminalActionClearAll(){ + protected ITerminalViewControl getTarget() { + return getCurrentTerminalViewControl(); + } + }; + fActionEditSelectAll = new TerminalActionSelectAll(){ + protected ITerminalViewControl getTarget() { + return getCurrentTerminalViewControl(); + } + }; } protected void setupContextMenus() { @@ -278,92 +292,6 @@ public class TerminalViewTab extends Composite implements ITerminalListener, menuMgr.add(new Separator("Additions")); //$NON-NLS-1$ } - public void onEditCopy() { - ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl(); - if (terminalViewControl == null) - return; - String selection = terminalViewControl.getSelection(); - - if (!selection.equals("")) {//$NON-NLS-1$ - terminalViewControl.copy(); - } else { - terminalViewControl.sendKey('\u0003'); - } - } - - public void updateEditCopy() { - boolean bEnabled = true; - ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl(); - if (terminalViewControl == null) - return; - if (fMenuAboutToShow) { - bEnabled = terminalViewControl.getSelection().length() > 0; - } - - fActionEditCopy.setEnabled(bEnabled); - } - - public void onEditCut() { - ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl(); - if (terminalViewControl == null) - return; - terminalViewControl.sendKey('\u0018'); - } - - public void updateEditCut() { - boolean bEnabled; - - bEnabled = !fMenuAboutToShow; - fActionEditCut.setEnabled(bEnabled); - } - - public void onEditPaste() { - ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl(); - if (terminalViewControl == null) - return; - terminalViewControl.paste(); - } - - public void updateEditPaste() { - ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl(); - if (terminalViewControl == null) - return; - String strText = (String) terminalViewControl.getClipboard() - .getContents(TextTransfer.getInstance()); - - boolean bEnabled = ((strText != null) && (!strText.equals("")));//$NON-NLS-1$ - - fActionEditPaste.setEnabled(bEnabled); - } - - public void onEditClearAll() { - ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl(); - if (terminalViewControl == null) - return; - terminalViewControl.clearTerminal(); - } - - public void updateEditClearAll() { - ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl(); - if (terminalViewControl == null) - return; - fActionEditClearAll.setEnabled(!terminalViewControl.isEmpty()); - } - - public void onEditSelectAll() { - ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl(); - if (terminalViewControl == null) - return; - terminalViewControl.selectAll(); - } - - public void updateEditSelectAll() { - ITerminalViewControl terminalViewControl = getCurrentTerminalViewControl(); - if (terminalViewControl == null) - return; - fActionEditSelectAll.setEnabled(!terminalViewControl.isEmpty()); - } - private void setTabTitle(IAdaptable root, CTabItem titem) { ISystemViewElementAdapter va = (ISystemViewElementAdapter) root .getAdapter(ISystemViewElementAdapter.class); @@ -420,51 +348,6 @@ public class TerminalViewTab extends Composite implements ITerminalListener, } - public boolean hasCommandInputField() { - // TODO Auto-generated method stub - return false; - } - - public boolean isScrollLock() { - // TODO Auto-generated method stub - return false; - } - - public void onTerminalConnect() { - // TODO Auto-generated method stub - - } - - public void onTerminalDisconnect() { - // TODO Auto-generated method stub - - } - - public void onTerminalFontChanged() { - // TODO Auto-generated method stub - - } - - public void onTerminalNewTerminal() { - // TODO Auto-generated method stub - - } - - public void onTerminalSettings() { - // TODO Auto-generated method stub - - } - - public void setCommandInputField(boolean on) { - // TODO Auto-generated method stub - - } - - public void setScrollLock(boolean b) { - // TODO Auto-generated method stub - - } - private void updateWithUniqueTitle(String title, CTabItem currentItem) { CTabItem[] items = tabFolder.getItems(); int increment = 1; diff --git a/terminal/org.eclipse.tm.terminal.view/icons/clcl16/clear_co.gif b/terminal/org.eclipse.tm.terminal.view/icons/clcl16/clear_co.gif deleted file mode 100644 index af30a42f83d..00000000000 Binary files a/terminal/org.eclipse.tm.terminal.view/icons/clcl16/clear_co.gif and /dev/null differ diff --git a/terminal/org.eclipse.tm.terminal.view/icons/dlcl16/clear_co.gif b/terminal/org.eclipse.tm.terminal.view/icons/dlcl16/clear_co.gif deleted file mode 100644 index 6775edfabb9..00000000000 Binary files a/terminal/org.eclipse.tm.terminal.view/icons/dlcl16/clear_co.gif and /dev/null differ diff --git a/terminal/org.eclipse.tm.terminal.view/icons/elcl16/clear_co.gif b/terminal/org.eclipse.tm.terminal.view/icons/elcl16/clear_co.gif deleted file mode 100644 index af30a42f83d..00000000000 Binary files a/terminal/org.eclipse.tm.terminal.view/icons/elcl16/clear_co.gif and /dev/null differ diff --git a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/ActionMessages.java b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/ActionMessages.java index 95192d71f22..b94ee09799e 100644 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/ActionMessages.java +++ b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/ActionMessages.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.actions; @@ -30,11 +31,6 @@ public class ActionMessages extends NLS { public static String SCROLL_LOCK_0; public static String SCROLL_LOCK_1; - public static String COPY; - public static String CUT; - public static String PASTE; - public static String SELECTALL; - public static String CLEARALL; public static String SETTINGS; } diff --git a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/ActionMessages.properties b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/ActionMessages.properties index 75217014f2a..cfb5133f4d7 100644 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/ActionMessages.properties +++ b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/ActionMessages.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) - [227537] moved actions from terminal.view to terminal plugin ############################################################################### NEW_TERMINAL = New Terminal CONNECT = Connect @@ -20,10 +21,5 @@ DISCONNECT = Disconnect SETTINGS_ELLIPSE = Settings... SCROLL_LOCK_0 = Scroll &Lock SCROLL_LOCK_1 = Scroll Lock -COPY = Copy -CUT = Cut -PASTE = Paste -SELECTALL = Select All -CLEARALL = Clear Terminal SETTINGS = Settings TOGGLE_COMMAND_INPUT_FIELD= Toggle Command Input Field diff --git a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionClearAll.java b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionClearAll.java deleted file mode 100644 index cedc350c53c..00000000000 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionClearAll.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.actions; - -import org.eclipse.tm.internal.terminal.view.ITerminalView; -import org.eclipse.tm.internal.terminal.view.ImageConsts; - -public class TerminalActionClearAll extends TerminalAction -{ - public TerminalActionClearAll(ITerminalView 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() { - fTarget.onEditClearAll(); - } -} - - diff --git a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionCopy.java b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionCopy.java deleted file mode 100644 index 85780105b7f..00000000000 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionCopy.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.actions; - -import org.eclipse.tm.internal.terminal.view.ITerminalView; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -public class TerminalActionCopy extends TerminalAction -{ - public TerminalActionCopy(ITerminalView 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() { - fTarget.onEditCopy(); - } -} diff --git a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionCut.java b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionCut.java deleted file mode 100644 index 49283896b51..00000000000 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionCut.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.actions; - -import org.eclipse.tm.internal.terminal.view.ITerminalView; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -public class TerminalActionCut extends TerminalAction -{ - public TerminalActionCut(ITerminalView 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() { - fTarget.onEditCut(); - } -} diff --git a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionPaste.java b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionPaste.java deleted file mode 100644 index 2f4e8d4351e..00000000000 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionPaste.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004, 2007 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.actions; - -import org.eclipse.tm.internal.terminal.view.ITerminalView; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - -public class TerminalActionPaste extends TerminalAction -{ - public TerminalActionPaste(ITerminalView 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() { - fTarget.onEditPaste(); - } -} diff --git a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ITerminalView.java b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ITerminalView.java index a1074f80cca..42bb6269637 100644 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ITerminalView.java +++ b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ITerminalView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 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 @@ -7,6 +7,7 @@ * * Contributors: * Michael Scharf (Wind River) - initial API and implementation + * Martin Oberhuber (Wind River) - [227537] moved actions from terminal.view to terminal plugin *******************************************************************************/ package org.eclipse.tm.internal.terminal.view; @@ -21,11 +22,6 @@ public interface ITerminalView { public void onTerminalDisconnect(); public void onTerminalSettings(); public void onTerminalFontChanged(); - public void onEditCopy(); - public void onEditCut(); - public void onEditPaste(); - public void onEditClearAll(); - public void onEditSelectAll(); public boolean hasCommandInputField(); public void setCommandInputField(boolean on); public boolean isScrollLock(); diff --git a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ImageConsts.java b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ImageConsts.java index c02c33a59fc..c5cf4f476b5 100644 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ImageConsts.java +++ b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/ImageConsts.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) - 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.view; @@ -33,19 +34,16 @@ public interface ImageConsts public static final String IMAGE_CLCL_CONNECT = "ImageClclConnect"; //$NON-NLS-1$ public static final String IMAGE_CLCL_DISCONNECT = "ImageClclDisconnect"; //$NON-NLS-1$ public static final String IMAGE_CLCL_SETTINGS = "ImageClclSettings"; //$NON-NLS-1$ - public static final String IMAGE_CLCL_CLEAR_ALL = "ImageClclClearAll"; //$NON-NLS-1$ public static final String IMAGE_CLCL_SCROLL_LOCK = "ImageClclScrollLock"; //$NON-NLS-1$ public static final String IMAGE_DLCL_CONNECT = "ImageDlclConnect"; //$NON-NLS-1$ public static final String IMAGE_DLCL_DISCONNECT = "ImageDlclDisconnect"; //$NON-NLS-1$ public static final String IMAGE_DLCL_SETTINGS = "ImageDlclSettings"; //$NON-NLS-1$ - public static final String IMAGE_DLCL_CLEAR_ALL = "ImageDlclClearAll"; //$NON-NLS-1$ public static final String IMAGE_DLCL_SCROLL_LOCK = "ImageDlclScrollLock"; //$NON-NLS-1$ public static final String IMAGE_ELCL_CONNECT = "ImageElclConnect"; //$NON-NLS-1$ public static final String IMAGE_ELCL_DISCONNECT = "ImageElclDisconnect"; //$NON-NLS-1$ public static final String IMAGE_ELCL_SETTINGS = "ImageElclSettings"; //$NON-NLS-1$ - public static final String IMAGE_ELCL_CLEAR_ALL = "ImageElclClearAll"; //$NON-NLS-1$ public static final String IMAGE_ELCL_SCROLL_LOCK = "ImageElclScrollLock"; //$NON-NLS-1$ public static final String IMAGE_CLCL_COMMAND_INPUT_FIELD = "ImageClclCommandInputField";//$NON-NLS-1$ public static final String IMAGE_ELCL_COMMAND_INPUT_FIELD = "ImageDlclCommandInputField";//$NON-NLS-1$ diff --git a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalView.java b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalView.java index 89fb64b67a9..cb52cf9bdbf 100644 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalView.java +++ b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalView.java @@ -15,8 +15,9 @@ * Martin Oberhuber (Wind River) - fixed copyright headers and beautified * Martin Oberhuber (Wind River) - [206892] State handling: Only allow connect when CLOSED * Michael Scharf (Wind River) - [209656] ClassCastException in TerminalView under Eclipse-3.4M3 - * Michael Scharf (Wind River) - [189774] Ctrl+V does not work in the command input field. + * Michael Scharf (Wind River) - [189774] Ctrl+V does not work in the command input field. * Michael Scharf (Wind River) - [217999] Duplicate context menu entries in Terminal + * Anna Dushistova (MontaVista) - [227537] moved actions from terminal.view to terminal plugin *******************************************************************************/ package org.eclipse.tm.internal.terminal.view; @@ -33,7 +34,6 @@ import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.window.Window; -import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.events.MenuEvent; import org.eclipse.swt.events.MenuListener; import org.eclipse.swt.widgets.Composite; @@ -41,20 +41,20 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Menu; import org.eclipse.tm.internal.terminal.actions.TerminalAction; -import org.eclipse.tm.internal.terminal.actions.TerminalActionClearAll; import org.eclipse.tm.internal.terminal.actions.TerminalActionConnect; -import org.eclipse.tm.internal.terminal.actions.TerminalActionCopy; -import org.eclipse.tm.internal.terminal.actions.TerminalActionCut; import org.eclipse.tm.internal.terminal.actions.TerminalActionDisconnect; import org.eclipse.tm.internal.terminal.actions.TerminalActionNewTerminal; -import org.eclipse.tm.internal.terminal.actions.TerminalActionPaste; -import org.eclipse.tm.internal.terminal.actions.TerminalActionSelectAll; import org.eclipse.tm.internal.terminal.actions.TerminalActionSettings; import org.eclipse.tm.internal.terminal.actions.TerminalActionToggleCommandInputField; import org.eclipse.tm.internal.terminal.control.CommandInputFieldWithHistory; import org.eclipse.tm.internal.terminal.control.ITerminalListener; import org.eclipse.tm.internal.terminal.control.ITerminalViewControl; import org.eclipse.tm.internal.terminal.control.TerminalViewControlFactory; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionClearAll; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionCopy; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionCut; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionPaste; +import org.eclipse.tm.internal.terminal.control.actions.TerminalActionSelectAll; import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore; import org.eclipse.tm.internal.terminal.provisional.api.ITerminalConnector; import org.eclipse.tm.internal.terminal.provisional.api.Logger; @@ -92,15 +92,15 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi protected TerminalAction fActionTerminalSettings; - protected TerminalAction fActionEditCopy; + protected TerminalActionCopy fActionEditCopy; - protected TerminalAction fActionEditCut; + protected TerminalActionCut fActionEditCut; - protected TerminalAction fActionEditPaste; + protected TerminalActionPaste fActionEditPaste; - protected TerminalAction fActionEditClearAll; + protected TerminalActionClearAll fActionEditClearAll; - protected TerminalAction fActionEditSelectAll; + protected TerminalActionSelectAll fActionEditSelectAll; protected TerminalAction fActionToggleCommandInputField; @@ -233,9 +233,7 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi return fCtlTerminal.getState()==TerminalState.CONNECTING || fCtlTerminal.getState()==TerminalState.OPENED; } - private boolean isConnected() { - return fCtlTerminal.getState()==TerminalState.CONNECTED; - } + public void onTerminalDisconnect() { fCtlTerminal.disconnectTerminal(); } @@ -356,65 +354,6 @@ public class TerminalView extends ViewPart implements ITerminalView, ITerminalLi fCtlTerminal.setFont(JFaceResources.getFont(FONT_DEFINITION)); } - public void onEditCopy() { - String selection=fCtlTerminal.getSelection(); - - if (!selection.equals("")) {//$NON-NLS-1$ - fCtlTerminal.copy(); - } else { - fCtlTerminal.sendKey('\u0003'); - } - } - - public void updateEditCopy() { - boolean bEnabled=true; - - if (fMenuAboutToShow) { - bEnabled = fCtlTerminal.getSelection().length()>0; - } - - 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/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewPlugin.java b/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewPlugin.java index 5de2c98f97c..41017326ca9 100644 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/view/TerminalViewPlugin.java +++ b/terminal/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/terminal/org.eclipse.tm.terminal/META-INF/MANIFEST.MF b/terminal/org.eclipse.tm.terminal/META-INF/MANIFEST.MF index d62bf57e9d5..f1d4ddecb35 100644 --- a/terminal/org.eclipse.tm.terminal/META-INF/MANIFEST.MF +++ b/terminal/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/terminal/org.eclipse.tm.terminal/build.properties b/terminal/org.eclipse.tm.terminal/build.properties index 730e1bdb868..19b1c113ae6 100644 --- a/terminal/org.eclipse.tm.terminal/build.properties +++ b/terminal/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/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/AbstractTerminalAction.java new file mode 100644 index 00000000000..42ca60e7d54 --- /dev/null +++ b/terminal/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/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionSelectAll.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java similarity index 52% rename from terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionSelectAll.java rename to terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.java index aecffa2e24a..30a3091f0cd 100644 --- a/terminal/org.eclipse.tm.terminal.view/src/org/eclipse/tm/internal/terminal/actions/TerminalActionSelectAll.java +++ b/terminal/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/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ActionMessages.properties new file mode 100644 index 00000000000..a5e6b1fae65 --- /dev/null +++ b/terminal/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/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/ImageConsts.java new file mode 100644 index 00000000000..b69b669eadf --- /dev/null +++ b/terminal/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/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionClearAll.java new file mode 100644 index 00000000000..400c08bb8e8 --- /dev/null +++ b/terminal/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/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCopy.java new file mode 100644 index 00000000000..3bc2bdcaf11 --- /dev/null +++ b/terminal/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/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionCut.java new file mode 100644 index 00000000000..50232f168c6 --- /dev/null +++ b/terminal/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/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionPaste.java new file mode 100644 index 00000000000..36d30b0db1c --- /dev/null +++ b/terminal/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/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/actions/TerminalActionSelectAll.java new file mode 100644 index 00000000000..08c4aa29e00 --- /dev/null +++ b/terminal/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/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java b/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java index d8e38bb5e26..d76858230e4 100644 --- a/terminal/org.eclipse.tm.terminal/src/org/eclipse/tm/internal/terminal/control/impl/TerminalPlugin.java +++ b/terminal/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); + } }