From 87b6c82ef9bab201c8c5a25603bce5a81b908738 Mon Sep 17 00:00:00 2001 From: Martin Oberhuber < martin.oberhuber@windriver.com> Date: Tue, 27 May 2008 22:35:35 +0000 Subject: [PATCH] [226550] [api] Launch Shell and Launch Terminal actions should be contributed declaratively (patch applied from Anna Dushistova) --- .../ui/view/SystemViewRemoteFileAdapter.java | 30 +------ .../org.eclipse.rse.shells.ui/plugin.xml | 85 +++++++++++-------- .../actions/LaunchCommandActionDelegate.java | 53 ------------ .../LaunchShellCommandHandler.java} | 48 ++++------- 4 files changed, 69 insertions(+), 147 deletions(-) delete mode 100644 rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/actions/LaunchCommandActionDelegate.java rename rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/{actions/LaunchShellActionDelegate.java => handlers/LaunchShellCommandHandler.java} (51%) diff --git a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java index b7777a9ce91..79005c668da 100644 --- a/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java +++ b/rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java @@ -55,6 +55,7 @@ * David McKnight (IBM) - [229610] [api] File transfers should use workspace text file encoding * Rupen Mardirossian (IBM) - [227213] Copy and pasting to the parent folder will create a "Copy of" that resource * David Dykstal (IBM) [230821] fix IRemoteFileSubSystem API to be consistent with IFileService + * Anna Dushistova (MontaVista) - [226550] [api] Launch Shell and Launch Terminal actions should be contributed declaratively *******************************************************************************/ package org.eclipse.rse.internal.files.ui.view; @@ -157,7 +158,6 @@ import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileEmpty; import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileRoot; import org.eclipse.rse.subsystems.files.core.subsystems.RemoteSearchResultsContentsType; import org.eclipse.rse.subsystems.files.core.util.ValidatorFileUniqueName; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; import org.eclipse.rse.ui.ISystemContextMenuConstants; import org.eclipse.rse.ui.ISystemIconConstants; import org.eclipse.rse.ui.ISystemMessages; @@ -3452,8 +3452,6 @@ public class SystemViewRemoteFileAdapter * If the given value is false, then returns true if the target is not an archive file. *
  • name="isVirtual". If the given value is true, then returns true if the target is a virtual file. * If the given value is false, then returns true if the target is not a virtual file.
  • - *
  • name="isCommandSubSystemExists". If the given value is true, then returns true if the host contains a command subsystem. - * If the given value is false, then returns true if the host does not contain a command subsystem.
  • * *

    * @see org.eclipse.ui.IActionFilter#testAttribute(java.lang.Object, java.lang.String, java.lang.String) @@ -3635,32 +3633,6 @@ public class SystemViewRemoteFileAdapter } return false; } - else if (inName.equals("iscommandsubsystemexists")) { //$NON-NLS-1$ - - boolean test = value.equals("true"); //$NON-NLS-1$ - - ISubSystem subsystem = getSubSystem(tgt); - - if (subsystem != null) { - IHost host = subsystem.getHost(); - ISystemRegistry registry = RSECorePlugin.getTheSystemRegistry(); - - ISubSystem[] subsystems = registry.getSubSystems(host); - - for (int i = 0; i < subsystems.length; i++) { - ISubSystem temp = subsystems[i]; - - if (temp instanceof IRemoteCmdSubSystem) { - return test; - } - } - - return !test; - } - else { - return !test; - } - } } return super.testAttribute(target, name, value); diff --git a/rse/plugins/org.eclipse.rse.shells.ui/plugin.xml b/rse/plugins/org.eclipse.rse.shells.ui/plugin.xml index 91b4df014a5..5f7b3784aef 100644 --- a/rse/plugins/org.eclipse.rse.shells.ui/plugin.xml +++ b/rse/plugins/org.eclipse.rse.shells.ui/plugin.xml @@ -1,6 +1,6 @@ @@ -133,38 +134,52 @@ Martin Oberhuber (Wind River) - [186748] Move ISubSystemConfigurationAdapter fro - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/actions/LaunchCommandActionDelegate.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/actions/LaunchCommandActionDelegate.java deleted file mode 100644 index 19c47ed425c..00000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/actions/LaunchCommandActionDelegate.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation 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 IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin - ********************************************************************************/ - -package org.eclipse.rse.internal.shells.ui.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.ui.SystemBasePlugin; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.actions.ActionDelegate; - -public class LaunchCommandActionDelegate extends ActionDelegate implements IActionDelegate -{ - private SystemCommandAction _launchAction; - private ISelection _selection; - public LaunchCommandActionDelegate() - { - super(); - } - - public void run(IAction action) - { - if (_launchAction == null) - { - _launchAction = new SystemCommandAction(SystemBasePlugin.getActiveWorkbenchShell(), false); - } - _launchAction.updateSelection((IStructuredSelection)_selection); - _launchAction.run(); - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) - { - _selection = selection; - } -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/actions/LaunchShellActionDelegate.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/handlers/LaunchShellCommandHandler.java similarity index 51% rename from rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/actions/LaunchShellActionDelegate.java rename to rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/handlers/LaunchShellCommandHandler.java index 62be3d2a35f..6edf6391bf7 100644 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/actions/LaunchShellActionDelegate.java +++ b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/internal/shells/ui/handlers/LaunchShellCommandHandler.java @@ -1,5 +1,5 @@ /******************************************************************************** - * Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved. + * Copyright (c) 2006, 2008 IBM Corporation 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 @@ -12,42 +12,30 @@ * * Contributors: * Martin Oberhuber (Wind River) - [168870] refactor org.eclipse.rse.core package of the UI plugin + * Anna Dushistova (MontaVista) - Adopted from LaunchShellActionDelegate ********************************************************************************/ +package org.eclipse.rse.internal.shells.ui.handlers; -package org.eclipse.rse.internal.shells.ui.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.viewers.ISelection; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.rse.internal.shells.ui.actions.SystemCommandAction; import org.eclipse.rse.ui.SystemBasePlugin; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.actions.ActionDelegate; +import org.eclipse.ui.handlers.HandlerUtil; -public class LaunchShellActionDelegate extends ActionDelegate implements IActionDelegate -{ +public class LaunchShellCommandHandler extends AbstractHandler { private SystemCommandAction _launchAction; - private ISelection _selection; - public LaunchShellActionDelegate() - { - super(); - } - - public void run(IAction action) - { - if (_launchAction == null) - { - _launchAction = new SystemCommandAction(SystemBasePlugin.getActiveWorkbenchShell(), true); + + public Object execute(ExecutionEvent event) throws ExecutionException { + if (_launchAction == null) { + _launchAction = new SystemCommandAction(SystemBasePlugin + .getActiveWorkbenchShell(), true); } - _launchAction.updateSelection((IStructuredSelection)_selection); + _launchAction.updateSelection((IStructuredSelection) HandlerUtil + .getCurrentSelection(event)); _launchAction.run(); + return null; } - - /* (non-Javadoc) - * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) - */ - public void selectionChanged(IAction action, ISelection selection) - { - _selection = selection; - } -} \ No newline at end of file +}