diff options
Diffstat (limited to 'rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells')
37 files changed, 0 insertions, 8489 deletions
diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/Activator.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/Activator.java deleted file mode 100644 index ccff01a9a..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/Activator.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui; - -import org.eclipse.core.runtime.IAdapterManager; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.rse.shells.ui.view.ShellServiceSubSystemConfigurationAdapterFactory; -import org.eclipse.rse.shells.ui.view.SystemViewOutputAdapterFactory; -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - - -/** - * The main plugin class to be used in the desktop. - */ -public class Activator extends AbstractUIPlugin { - - //The shared instance. - private static Activator plugin; - SystemViewOutputAdapterFactory _svoaf; - - /** - * The constructor. - */ - public Activator() { - plugin = this; - } - - /** - * This method is called upon plug-in activation - */ - public void start(BundleContext context) throws Exception - { - super.start(context); - - IAdapterManager manager = Platform.getAdapterManager(); - - _svoaf = new SystemViewOutputAdapterFactory(); - _svoaf.registerWithManager(manager); - - ShellServiceSubSystemConfigurationAdapterFactory fac = new ShellServiceSubSystemConfigurationAdapterFactory(); - fac.registerWithManager(manager); - } - - /** - * For pathpath access to our adapters for viewable remote output objects. Exploits the knowledge we use singleton adapters. - */ - public SystemViewOutputAdapterFactory getSystemViewOutputAdapterFactory() - { - return _svoaf; - } - - /** - * This method is called when the plug-in is stopped - */ - public void stop(BundleContext context) throws Exception { - super.stop(context); - plugin = null; - } - - /** - * Returns the shared instance. - */ - public static Activator getDefault() { - return plugin; - } - - /** - * Returns an image descriptor for the image file at the given - * plug-in relative path. - * - * @param path the path - * @return the image descriptor - */ - public static ImageDescriptor getImageDescriptor(String path) { - return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.rse.shells.ui", path); - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/RemoteCommandHelpers.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/RemoteCommandHelpers.java deleted file mode 100644 index fe6b716c4..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/RemoteCommandHelpers.java +++ /dev/null @@ -1,186 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.rse.core.SystemBasePlugin; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.core.model.ISystemRegistry; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.internal.subsystems.shells.subsystems.RemoteCmdSubSystem; -import org.eclipse.rse.internal.subsystems.shells.subsystems.RemoteCommandShell; -import org.eclipse.rse.shells.ui.view.SystemCommandsUI; -import org.eclipse.rse.shells.ui.view.SystemCommandsViewPart; -import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystemConfiguration; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.messages.SystemMessageDialog; -import org.eclipse.swt.widgets.Shell; - - -/** - * Static helpers to simplify the act of running a universal command against - * a local or remote Unix, Windows or Linux command shell. - */ -public class RemoteCommandHelpers -{ - - /** - * Constructor for RemoteCommandHelpers. - */ - public RemoteCommandHelpers() - { - super(); - } - - /** - * Helper method to return the path to change-directory to, given a selected remote file object - */ - public static String getWorkingDirectory(IRemoteFile selectedFile) - { - String path = null; - if (selectedFile.isDirectory()) - path = selectedFile.getAbsolutePath(); - else - path = selectedFile.getParentPath(); - return path; - } - - - public static IRemoteCmdSubSystem getCmdSubSystem(IHost connection) - { - ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry(); - ISubSystem[] sses = sr.getSubSystems(connection); - for (int i = 0; i < sses.length; i++) - { - if (sses[i] instanceof IRemoteCmdSubSystem) - { - IRemoteCmdSubSystem cmdSubSystem = (RemoteCmdSubSystem)sses[i]; - return cmdSubSystem; - } - } - return null; - } - - public static IRemoteCmdSubSystem[] getCmdSubSystems(IHost connection) - { - List results = new ArrayList(); - ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry(); - ISubSystem[] sses = sr.getSubSystems(connection); - for (int i = 0; i < sses.length; i++) - { - if (sses[i] instanceof IRemoteCmdSubSystem) - { - IRemoteCmdSubSystem cmdSubSystem = (RemoteCmdSubSystem)sses[i]; - results.add(cmdSubSystem); - } - } - return (IRemoteCmdSubSystem[])results.toArray(new IRemoteCmdSubSystem[results.size()]); - } - - public static boolean runUniversalCommand(Shell shell, String cmdString, String path, - IRemoteCmdSubSystem cmdSubSystem) - { - return runUniversalCommand(shell, cmdString, path, cmdSubSystem, false); - } - - /** - * Encapsulation of code needed to run a universal subsystem command. A universal - * command is a command that runs in a Unix or Linux or Windows command shell, as - * opposed to something unique like an OS/400 or z/OS command. - * This: - * <ul> - * <li>Sets the current directory to the given path - * <li>Runs the given command remotely - * <li>Logs the command and its output in the command view - * </ul> - * - * @param shell - the shell to use if need to prompt for password or show msg dialog - * @param cmdString - the resolved command - * @param path - the path to run the command against - * @param cmdSubSystem - this connection's command subsystem, which will run the command - * @return true if we should continue, false if something went wrong - */ - public static boolean runUniversalCommand(Shell shell, String cmdString, String path, - IRemoteCmdSubSystem cmdSubSystem, boolean isCompile) - { - boolean ok = false; - if (cmdSubSystem != null) - { - ok = true; - try - { - - IRemoteCommandShell defaultShell= cmdSubSystem.getDefaultShell(); - - - showInView(defaultShell, isCompile, cmdString); - - IRemoteFileSubSystemConfiguration fileSSF = RemoteFileUtility.getFileSubSystemConfiguration(cmdSubSystem.getHost().getSystemType()); - IRemoteFile pwd = ((RemoteCommandShell)defaultShell).getWorkingDirectory(); - if (pwd == null || !pwd.getAbsolutePath().equals(path)) - { - if (path.indexOf(' ') > 0) - { - path = "\"" + path + "\""; //$NON-NLS-1$ //$NON-NLS-2$ - } - - String cdCmd = "cd " + path; //$NON-NLS-1$ - if (!fileSSF.isUnixStyle()) - { - if (path.endsWith(":")) //$NON-NLS-1$ - { - path += "\\"; //$NON-NLS-1$ - } - cdCmd = "cd /d " + path; //$NON-NLS-1$ - } - - cmdSubSystem.sendCommandToShell(cdCmd, defaultShell); - } - cmdSubSystem.sendCommandToShell(cmdString, defaultShell); - - - } - catch (Exception e) - { - SystemBasePlugin.logError("Run Remote Command failed", e); - SystemMessageDialog.displayExceptionMessage(shell, e); - ok = false; - } - } // end if - return ok; - } // end method - - - - - public static void showInView(IRemoteCommandShell cmd, boolean isCompile, String cmdString) { - SystemCommandsViewPart cmdsPart = SystemCommandsUI.getInstance().activateCommandsView(); - cmdsPart.updateOutput(cmd); - /* DKM - no longer show this for compile commands - if (isCompile) { - SystemBuildErrorViewPart errorPart = SystemCommandsUI.getInstance().activateBuildErrorView(); - errorPart.setInput((IAdaptable)cmd, cmdString); - } - */ - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/ShellResources.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/ShellResources.java deleted file mode 100644 index 7d1f07527..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/ShellResources.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui; - -import org.eclipse.osgi.util.NLS; - -public class ShellResources extends NLS -{ - private static String BUNDLE_NAME = "org.eclipse.rse.shells.ui.ShellResources"; - - public static String RESID_SHELL_PROPERTYPAGE_TITLE; - public static String RESID_SHELL_PROPERTYPAGE_DESCRIPTION; - public static String RESID_SHELL_PROPERTYPAGE_ENCODING; - public static String RESID_SHELL_PROPERTYPAGE_DEFAULT_ENCODING; - public static String RESID_SHELL_PROPERTYPAGE_HOST_ENCODING; - public static String RESID_SHELL_PROPERTYPAGE_OTHER_ENCODING; - public static String RESID_UNSUPPORTED_ENCODING; - - - public static String RESID_SHELLS_RUN_IN_NEW_SHELL_LABEL; - public static String RESID_SHELLS_RUN_IN_NEW_SHELL_TOOLTIP; - public static String RESID_SHELLS_RUN_COMMAND_LABEL; - public static String RESID_SHELLS_COMMAND_LABEL; - public static String RESID_SHELLS_COMMAND_TOOLTIP; - public static String RESID_SHELLS_COMMAND_SHELL_LABEL; - - // COMMANDS VIEW - public static String RESID_COMMANDSVIEW_RUN_LABEL; - public static String RESID_COMMANDSVIEW_RUN_TOOLTIP; - public static String RESID_COMMANDSVIEW_CMDCOMBO_TOOLTIP; - public static String RESID_COMMANDSVIEW_SUBSYSCOMBO_TOOLTIP; - public static String RESID_PREF_COMMANDSVIEW_BRINGTOFRONT_LABEL; - public static String RESID_PREF_COMMANDSVIEW_BRINGTOFRONT_TOOLTIP; - - // UNIVERSAL COMMMANDS VIEW - public static String RESID_COMMANDSVIEW_COMMAND_LABEL; - public static String RESID_COMMANDSVIEW_COMMAND_TOOLTIP; - public static String RESID_COMMANDSVIEW_PREVIOUS_TOOLTIP; - - // ACTIONS - public static String ACTION_RUN_COMMAND_LABEL; - public static String ACTION_RUN_COMMAND_TOOLTIP; - - public static String ACTION_RUN_SHELL_LABEL; - public static String ACTION_RUN_SHELL_TOOLTIP; - - public static String ACTION_LAUNCH_LABEL; - public static String ACTION_LAUNCH_TOOLTIP; - - public static String ACTION_SHOW_SHELL_LABEL; - public static String ACTION_SHOW_SHELL_TOOLTIP; - - public static String ACTION_CANCEL_SHELL_LABEL; - public static String ACTION_CANCEL_SHELL_TOOLTIP; - - public static String ACTION_CANCEL_REMOVE_SHELL_LABEL; - public static String ACTION_CANCEL_REMOVE_SHELL_TOOLTIP; - - public static String ACTION_EXPORT_SHELL_OUTPUT_LABEL; - public static String ACTION_EXPORT_SHELL_OUTPUT_TOOLTIP; - - public static String ACTION_EXPORT_SHELL_HISTORY_LABEL; - public static String ACTION_EXPORT_SHELL_HISTORY_TOOLTIP; - - public static String ACTION_OPEN_OUTPUT_LABEL; - public static String ACTION_OPEN_OUTPUT_TOOLTIP; - - static - { - // load message values from bundle file - NLS.initializeMessages(BUNDLE_NAME, ShellResources.class); - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/ShellResources.properties b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/ShellResources.properties deleted file mode 100644 index 74b885040..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/ShellResources.properties +++ /dev/null @@ -1,80 +0,0 @@ -################################################################################ -# Copyright (c) 2006 IBM Corporation. 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: -# {Name} (company) - description of contribution. -################################################################################ - -################################################################################### -############################ Universal Commands ############################ -################################################################################### -RESID_SHELL_PROPERTYPAGE_TITLE=Shell Settings -RESID_SHELL_PROPERTYPAGE_DESCRIPTION=Configure settings for shells -RESID_SHELL_PROPERTYPAGE_ENCODING=Shell Encoding -RESID_SHELL_PROPERTYPAGE_DEFAULT_ENCODING=Default -RESID_SHELL_PROPERTYPAGE_HOST_ENCODING=Host encoding -RESID_SHELL_PROPERTYPAGE_OTHER_ENCODING=Select or enter an encoding -RESID_UNSUPPORTED_ENCODING=This is not a supported encoding - -RESID_SHELLS_RUN_IN_NEW_SHELL_LABEL = Run in new shell -RESID_SHELLS_RUN_IN_NEW_SHELL_TOOLTIP = Indicate whether the command is to be launched in a new shell or the system default shell -RESID_SHELLS_RUN_COMMAND_LABEL = Run Command -RESID_SHELLS_COMMAND_LABEL = Command -RESID_SHELLS_COMMAND_TOOLTIP = Enter the command to invoke -RESID_SHELLS_COMMAND_SHELL_LABEL = Command Shell - -#============================================================= -# Commands View -#============================================================= -RESID_COMMANDSVIEW_RUN_LABEL=Run -RESID_COMMANDSVIEW_RUN_TOOLTIP=Run the specified command on the selected subsystem and connection -RESID_COMMANDSVIEW_CMDCOMBO_TOOLTIP=Specify the command to run -RESID_COMMANDSVIEW_SUBSYSCOMBO_TOOLTIP=Select the subsystem on which to run a command -RESID_PREF_COMMANDSVIEW_BRINGTOFRONT_LABEL=Show Commands view when command is run -RESID_PREF_COMMANDSVIEW_BRINGTOFRONT_TOOLTIP=Force the Commands view to the foreground when a remote system command is run - -#============================================================= -# Commands View -#============================================================= -RESID_COMMANDSVIEW_COMMAND_LABEL=Command -RESID_COMMANDSVIEW_COMMAND_TOOLTIP=Specify a command to run -RESID_COMMANDSVIEW_PREVIOUS_TOOLTIP=Specify a previously run command - -#============================================================= -# Actions -#============================================================= -ACTION_RUN_COMMAND_LABEL=Run Command... -ACTION_RUN_COMMAND_TOOLTIP=Issue a command from the selected resource - -ACTION_RUN_SHELL_LABEL=Launch Shell -ACTION_RUN_SHELL_TOOLTIP=Launch a new shell on the selected system - -ACTION_LAUNCH_LABEL=Launch -ACTION_LAUNCH_TOOLTIP=Launch a new shell on the selected system - -ACTION_SHOW_SHELL_LABEL=Show in Remote Shell View -ACTION_SHOW_SHELL_TOOLTIP=Show the selected shell in the Remote Shell view - -ACTION_CANCEL_SHELL_LABEL=Cancel Shell -ACTION_CANCEL_SHELL_TOOLTIP=Terminate the selected shell - -ACTION_CANCEL_REMOVE_SHELL_LABEL=Remove Shell -ACTION_CANCEL_REMOVE_SHELL_TOOLTIP=Terminate the selected shell and remove it from the Remote Shell view - -ACTION_EXPORT_SHELL_OUTPUT_LABEL=Export Shell Output... -ACTION_EXPORT_SHELL_OUTPUT_TOOLTIP=Export the output of the selected shell to a file - -ACTION_EXPORT_SHELL_HISTORY_LABEL=Export Shell History... -ACTION_EXPORT_SHELL_HISTORY_TOOLTIP=Export the command history for the selected shell to a file - -ACTION_OPEN_OUTPUT_LABEL= Goto -ACTION_OPEN_OUTPUT_TOOLTIP= Open the selected output object in an editor or view
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/SystemRemoteCommandEntryForm.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/SystemRemoteCommandEntryForm.java deleted file mode 100644 index 5beb9313b..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/SystemRemoteCommandEntryForm.java +++ /dev/null @@ -1,285 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui; -import org.eclipse.rse.core.SystemBasePlugin; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.core.model.ISubSystemConfigurationCategories; -import org.eclipse.rse.model.ISystemResourceChangeEvent; -import org.eclipse.rse.model.ISystemResourceChangeEvents; -import org.eclipse.rse.subsystems.files.core.model.ISystemRemoteCommand; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.widgets.SystemHostCombo; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; - - -/** - * A composite encapsulating the GUI widgets for a command console. Used in the CommandView view - * but can also be instantiated and used anywhere. - */ -public class SystemRemoteCommandEntryForm extends Composite - implements org.eclipse.rse.model.ISystemResourceChangeListener -{ - private SystemHostCombo sysConnCombo; - private IRemoteCmdSubSystem[] subSystems = null; - private int subSystemIndex = -1; - - private Combo cmdCombo; - private Combo subSysCombo; - private Button runButton; - - public SystemRemoteCommandEntryForm( Composite parent, int style ) - { - super(parent, style); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 4; - setLayout(gridLayout); - GridData gridData = new GridData(); - gridData.horizontalAlignment = GridData.FILL; - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = false; - setLayoutData(gridData); - - sysConnCombo = new SystemHostCombo(this, SWT.NULL, null, false, ISubSystemConfigurationCategories.SUBSYSTEM_CATEGORY_CMDS, false); - sysConnCombo.setWidthHint(100); - sysConnCombo.addSelectionListener( new SelectionAdapter() - { - public void widgetSelected(SelectionEvent event) - { - sysConnChanged(); - } - }); - sysConnCombo.listenToConnectionEvents(true); - - subSysCombo = SystemWidgetHelpers.createReadonlyCombo(this, new Listener() { - public void handleEvent(Event e) { - subSysChanged(); - } - }, ShellResources.RESID_COMMANDSVIEW_SUBSYSCOMBO_TOOLTIP); - ((GridData)subSysCombo.getLayoutData()).widthHint = 100; - - cmdCombo = SystemWidgetHelpers.createCombo(this, new Listener() { - public void handleEvent(Event e) { - commandChanged(); - } - }, ShellResources.RESID_COMMANDSVIEW_CMDCOMBO_TOOLTIP); - cmdCombo.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - checkRunButtonEnablement(); - } - } - ); - ((GridData)cmdCombo.getLayoutData()).widthHint = 250; - cmdCombo.addSelectionListener(new SelectionAdapter() { - public void widgetDefaultSelected( SelectionEvent e ) - { - handleCmdComboEnter(); - } - } ); - - runButton = SystemWidgetHelpers.createPushButton(this, new Listener() { - public void handleEvent(Event e) { - runCommand(); - } - }, ShellResources.RESID_COMMANDSVIEW_RUN_LABEL, ShellResources.RESID_COMMANDSVIEW_RUN_TOOLTIP); - //((GridData)runButton.getLayoutData()).widthHint = 30; - - pack(); - - populateSubSysCombo(); - populateCommandCombo(); - checkRunButtonEnablement(); - - cmdCombo.setFocus(); - - // ---------------------------------------- - // register with system registry for events - // ---------------------------------------- - RSEUIPlugin.getTheSystemRegistry().addSystemResourceChangeListener(this); - } - - private void runCommand() - { - String cmd = cmdCombo.getText(); - if ( cmd.length() > 0 ) - { - IHost sysConn = sysConnCombo.getHost(); - if ( sysConn != null ) - { - //SubSystem[] cmdSubSystems = RSEUIPlugin.getDefault().getSystemRegistry().getSubSystemsBySubSystemConfigurationCategory(ISubSystemConfigurationCategories.SUBSYSTEM_CATEGORY_CMDS, sysConn); - IRemoteCmdSubSystem[] cmdSubSystems = RemoteCommandHelpers.getCmdSubSystems(sysConn); - IRemoteCmdSubSystem currSubSystem = null; - String subSystemName = subSysCombo.getText(); - for (int i = 0; i < cmdSubSystems.length && currSubSystem == null; i++) - { - if ( subSystemName.equals(cmdSubSystems[i].getName() ) ) - currSubSystem = cmdSubSystems[i]; - } - - if ( currSubSystem != null ) - { - try - { - currSubSystem.runCommand(cmd, null); - } - catch ( Exception e ) - { - SystemBasePlugin.logInfo("Exception invoking command "+cmd+" on " + sysConn.getAliasName() ); - } - } - } - } - } - - /** - * Handle a change in the command combo - */ - private void commandChanged() - { - checkRunButtonEnablement(); - } - - - /** - * Handle a change in the subsystem combo - */ - private void subSysChanged() - { - subSystemIndex = subSysCombo.getSelectionIndex(); - populateCommandCombo(); - checkRunButtonEnablement(); - } - - /** - * Handle a change in the system connection combo - */ - private void sysConnChanged() - { - populateSubSysCombo(); - populateCommandCombo(); - checkRunButtonEnablement(); - } - - /** - * Determine if the Run button should be enabled - */ - private void checkRunButtonEnablement() - { - if ( sysConnCombo.getText().length() > 0 && subSysCombo.getText().length() > 0 && cmdCombo.getText().trim().length() > 0 ) - runButton.setEnabled(true); - else - runButton.setEnabled(false); - } - - /** - * Populate the list command subsystems for the selected connection - */ - private void populateSubSysCombo() - { - subSysCombo.removeAll(); - IHost sysConn = sysConnCombo.getHost(); - if ( sysConn != null ) - { - //subSystems = RSEUIPlugin.getDefault().getSystemRegistry().getSubSystemsBySubSystemConfigurationCategory(ISubSystemConfigurationCategories.SUBSYSTEM_CATEGORY_CMDS, sysConn); - subSystems = RemoteCommandHelpers.getCmdSubSystems(sysConn); - for (int i = 0; i < subSystems.length; i++) - { - if ( i == 0 ) - subSystemIndex = 0; - subSysCombo.add(subSystems[i].getName()); - } - subSysCombo.select(0); - } - } - - /** - * Populate the command combo with the history of executed commands on that subsystemlist command subsystems for the selected connection - */ - private void populateCommandCombo() - { - cmdCombo.removeAll(); - if ( subSystemIndex >= 0 ) - { - String[] cmds = subSystems[subSystemIndex].getExecutedCommands(); - if ( cmds != null ) - cmdCombo.setItems( cmds ); - } - } - - /** - * This is the method in your class that will be called when a - * system resource changes. Listen for run commands. - * @see ISystemResourceChangeEvent - */ - public void systemResourceChanged(ISystemResourceChangeEvent event) - { - int type = event.getType(); - Object src = event.getSource(); - Object parent = event.getParent(); - switch ( type ) - { - case ISystemResourceChangeEvents.EVENT_COMMAND_RUN: - if ( src instanceof ISystemRemoteCommand ) - { - if ( subSystemIndex >= 0 && subSystems[subSystemIndex] == ((ISystemRemoteCommand)src).getSubSystem() ) - { - // use asyncExec to avoid invalid Thread exceptions - Display.getDefault().asyncExec(new Runnable() { - public void run() - { - populateCommandCombo(); - } - } - ); - } - } - break; - case ISystemResourceChangeEvents.EVENT_COMMAND_MESSAGE: - break; - case ISystemResourceChangeEvents.EVENT_COMMAND_HISTORY_UPDATE: - // use asyncExec to avoid invalid Thread exceptions - Display.getDefault().asyncExec(new Runnable() { - public void run() - { - populateCommandCombo(); - } - } - ); - break; - } - } - - private void handleCmdComboEnter() - { - if ( runButton.isEnabled() ) - runCommand(); - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/LaunchCommandActionDelegate.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/LaunchCommandActionDelegate.java deleted file mode 100644 index d381c34bc..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/LaunchCommandActionDelegate.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.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.core.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/shells/ui/actions/LaunchShellActionDelegate.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/LaunchShellActionDelegate.java deleted file mode 100644 index e55875db3..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/LaunchShellActionDelegate.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.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.core.SystemBasePlugin; -import org.eclipse.ui.IActionDelegate; -import org.eclipse.ui.actions.ActionDelegate; - -public class LaunchShellActionDelegate extends ActionDelegate implements IActionDelegate -{ - private SystemCommandAction _launchAction; - private ISelection _selection; - public LaunchShellActionDelegate() - { - super(); - } - - public void run(IAction action) - { - if (_launchAction == null) - { - _launchAction = new SystemCommandAction(SystemBasePlugin.getActiveWorkbenchShell(), true); - } - _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/shells/ui/actions/SystemBaseShellAction.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemBaseShellAction.java deleted file mode 100644 index 99cc51420..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemBaseShellAction.java +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - - -package org.eclipse.rse.shells.ui.actions; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.ui.actions.SystemBaseAction; -import org.eclipse.swt.widgets.Shell; - - - -public abstract class SystemBaseShellAction extends SystemBaseAction -{ - protected List _selected; - - public SystemBaseShellAction(String name, String tooltip, ImageDescriptor image, Shell parent) - { - super(name, - tooltip, - image, - parent); - setAvailableOffline(true); - allowOnMultipleSelection(true); - _selected = new ArrayList(); - } - - /** - * Called when the selection changes. The selection is checked to - * make sure this action can be performed on the selected object. - */ - public boolean updateSelection(IStructuredSelection selection) - { - boolean enable = false; - Iterator e = selection.iterator(); - _selected.clear(); - while (e.hasNext()) - { - Object selected = e.next(); - if (selected instanceof IRemoteCommandShell) - { - if (isApplicable((IRemoteCommandShell)selected)) - { - _selected.add(selected); - enable = true; - } - else - { - return false; - } - } - else - { - return false; - } - } - - - return enable; - } - - protected boolean isApplicable(IRemoteCommandShell cmdShell) - { - return true; - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemCommandAction.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemCommandAction.java deleted file mode 100644 index 764eaefe4..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemCommandAction.java +++ /dev/null @@ -1,572 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.actions; - -import java.util.Iterator; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.rse.core.filters.ISystemFilterReference; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.shells.ui.RemoteCommandHelpers; -import org.eclipse.rse.shells.ui.ShellResources; -import org.eclipse.rse.shells.ui.view.SystemCommandsUI; -import org.eclipse.rse.shells.ui.view.SystemCommandsViewPart; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.ISystemMessages; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; -import org.eclipse.rse.ui.dialogs.SystemPromptDialog; -import org.eclipse.rse.ui.view.ISystemViewElementAdapter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - - -/** - * Launches a shell and/or runs a shell command, displaying the output - * in the Remote Systems Commands view. - */ -public class SystemCommandAction extends SystemBaseAction -{ - private IRemoteFile _selected; - private ISystemFilterReference _selectedFilterRef; - - - private boolean _isShell; - private IRemoteCmdSubSystem _cmdSubSystem; - - - /** - * The command dialog used when running a command. - */ - public class CommandDialog extends SystemPromptDialog - { - private Combo _cmdText; - private Button _launchNewShellButton; - private SystemMessage _errorMessage; - - private String _cmdStr; - private boolean _launchNewShell; - - /** - * Constructor for the CommandDialog - * @param shell the parent of the dialog - */ - public CommandDialog(Shell shell) - { - super(shell, ShellResources.RESID_SHELLS_RUN_COMMAND_LABEL); - //pack(); - } - - /** - * @return the user-specified command invocation - */ - public String getCmdStr() - { - return _cmdStr; - } - - /** - * @return whether the specified command is to be launched in a new shell or not - */ - public boolean launchNewShell() - { - return _launchNewShell; - } - - protected void buttonPressed(int buttonId) - { - setReturnCode(buttonId); - _cmdStr = _cmdText.getText(); - _launchNewShell = _launchNewShellButton.getSelection(); - close(); - } - - /** - * Constructs the dialog - * @param parent the parent of the dialog - */ - public Control createInner(Composite parent) - { - Composite c = new Composite(parent, SWT.NONE); - - GridLayout layout = new GridLayout(); - c.setLayout(layout); - c.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label aLabel = new Label(c, SWT.NONE); - aLabel.setText(ShellResources.RESID_SHELLS_COMMAND_LABEL); - - _cmdText = new Combo(c, SWT.SINGLE | SWT.BORDER); - GridData textData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); - _cmdText.setLayoutData(textData); - _cmdText.setText(""); //$NON-NLS-1$ - _cmdText.setToolTipText(ShellResources.RESID_SHELLS_COMMAND_TOOLTIP); - - // add keystroke listeners... - _cmdText.addModifyListener(new ModifyListener() - { - public void modifyText(ModifyEvent e) - { - validateInvocation(); - } - }); - - IRemoteCmdSubSystem cmdSubSystem = getCommandSubSystem(); - if (cmdSubSystem != null) - { - String[] cmds = cmdSubSystem.getExecutedCommands(); - if (cmds != null) - _cmdText.setItems(cmds); - } - - - _launchNewShellButton = new Button(c, SWT.CHECK); - _launchNewShellButton.setText(ShellResources.RESID_SHELLS_RUN_IN_NEW_SHELL_LABEL); - _launchNewShellButton.setToolTipText(ShellResources.RESID_SHELLS_RUN_IN_NEW_SHELL_TOOLTIP); - - setHelp(); - - enableOkButton(false); - return c; - } - - - /** - * returns the initial focus control - */ - protected Control getInitialFocusControl() - { - enableOkButton(false); - return _cmdText; - } - - private void setHelp() - { - setHelp(RSEUIPlugin.HELPPREFIX + "cmdi0000"); //$NON-NLS-1$ - } - - /** - * validate the invocation - * @return a SystemMessage if the invocation is invalid. - */ - protected SystemMessage validateInvocation() - { - _errorMessage = null; - String theNewName = _cmdText.getText(); - - if (theNewName.length() == 0) - { - _errorMessage = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_UCMD_INVOCATION_EMPTY); - } - - if (_errorMessage != null) - { - setErrorMessage(_errorMessage); - enableOkButton(false); - } - else - { - clearErrorMessage(); - enableOkButton(true); - } - - return _errorMessage; - } - } - - /** - * Constructor for SystemCommandAction - * @param parent - */ - public SystemCommandAction(Shell parent) - { - this(parent, false); - } - - /** - * Constructor for SystemCommandAction - * @param parent - * @param isShell indication of whether this action launches a shell or runs a command - */ - public SystemCommandAction(Shell parent, boolean isShell) - { - this(parent, isShell, null); - } - - /** - * Constructor for SystemCommandAction - * @param parent - * @param isShell indication of whether this action launches a shell or runs a command - * @param cmdSubSystem the command subsystem to use if launching a shell - */ - public SystemCommandAction(Shell parent, boolean isShell, IRemoteCmdSubSystem cmdSubSystem) - { - this( - isShell ? ShellResources.ACTION_RUN_SHELL_LABEL : ShellResources.ACTION_RUN_COMMAND_LABEL, - isShell ? ShellResources.ACTION_RUN_SHELL_TOOLTIP : ShellResources.ACTION_RUN_COMMAND_TOOLTIP, - parent, - isShell, - cmdSubSystem); - } - - /** - * Constructor for SystemCommandAction - * @param title the title of the action - * @param parent - * @param isShell indication of whether this action launches a shell or runs a command - * @param cmdSubSystem the command subsystem to use if launching a shell - */ - public SystemCommandAction(String title, Shell parent, boolean isShell, IRemoteCmdSubSystem cmdSubSystem) - { - this(title, null, parent, isShell, cmdSubSystem); - } - - - /** - * Constructor for SystemCommandAction - * @param title the title of the action - * @param tooltip the tooltip for the action - * @param parent - * @param isShell indication of whether this action launches a shell or runs a command - * @param cmdSubSystem the command subsystem to use if launching a shell - */ - public SystemCommandAction(String title, String tooltip, Shell parent, boolean isShell, IRemoteCmdSubSystem cmdSubSystem) - { - this( - title, - tooltip, - isShell ? RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_SHELL_ID) : RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_RUN_ID), - parent, - isShell, - cmdSubSystem); - } - - - /** - * Constructor for SystemCommandAction - * @param title the title of the action - * @param tooltip the tooltip for the action - * @param descriptor the image descriptor for the action - * @param parent - * @param isShell indication of whether this action launches a shell or runs a command - * @param cmdSubSystem the command subsystem to use if launching a shell - */ - public SystemCommandAction(String title, String tooltip, ImageDescriptor descriptor, Shell parent, boolean isShell, IRemoteCmdSubSystem cmdSubSystem) - { - super(title, tooltip, descriptor, parent); - _isShell = isShell; - _cmdSubSystem = cmdSubSystem; - if (_isShell) - setHelp(RSEUIPlugin.HELPPREFIX+"actn0113"); //$NON-NLS-1$ - else - setHelp(RSEUIPlugin.HELPPREFIX+"actn0114"); //$NON-NLS-1$ - } - - public void setSubSystem(IRemoteCmdSubSystem ss) - { - _cmdSubSystem = ss; - } - - /** - * Runs the command action. If the action is for launching a shell, the shell is launched - * and the commands view shows it's output. If the action is for running a command, a - * dialog pops up prompting for the invocation. - */ - public void run() - { - if (_isShell) - { - runShell(); - } - else - { - CommandDialog cmdDialog = new CommandDialog(getShell()); - if (cmdDialog.open() == Window.OK) - { - String cmdStr = cmdDialog.getCmdStr(); - if (cmdStr != null) - { - // run the command - runCommand(cmdStr, cmdDialog.launchNewShell()); - } - } - } - } - - private IRemoteCmdSubSystem getCommandSubSystem() - { - if (_selectedFilterRef != null) - { - ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)_selectedFilterRef).getAdapter(ISystemViewElementAdapter.class); - if (adapter != null) - { - ISubSystem ss = adapter.getSubSystem(_selectedFilterRef); - if (ss != null) - { - return RemoteCommandHelpers.getCmdSubSystem(ss.getHost()); - } - } - } - - IRemoteFile selectedFile = _selected; - if (_selected == null) - { - return _cmdSubSystem; - } - - IHost sysConn = selectedFile.getSystemConnection(); - if (sysConn != null) - { - ISubSystem currSubSystem = selectedFile.getParentRemoteFileSubSystem(); - if (currSubSystem != null) - { - try - { - Shell shell = getShell(); - IRemoteCmdSubSystem cmdSubSystem = RemoteCommandHelpers.getCmdSubSystem(currSubSystem.getHost()); - return cmdSubSystem; - } - catch (Exception e) - { - } - } - } - - return null; - } - - /** - * runs the command - */ - private void runCommand(String cmd, boolean launchNewShell) - { - if (cmd.length() > 0) - { - - try - { - Shell shell = getShell(); - - if (_selectedFilterRef != null) - { - ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)_selectedFilterRef).getAdapter(ISystemViewElementAdapter.class); - if (adapter != null) - { - ISubSystem ss = adapter.getSubSystem(_selectedFilterRef); - if (ss != null) - { - Object target = ss.getTargetForFilter(_selectedFilterRef); - if (target != null && target instanceof IRemoteFile) - { - _selected = (IRemoteFile)target; - } - } - } - } - - if (_selected != null) - { - IRemoteCmdSubSystem cmdSubSystem = getCommandSubSystem(); - String path = _selected.getAbsolutePath(); - - if (launchNewShell) - { - Object[] results = cmdSubSystem.runCommand(cmd, _selected); - Object cmdObject = results[0]; - if (cmdObject instanceof IRemoteCommandShell) - { - showInView((IRemoteCommandShell) cmdObject); - } - } - else - { - // run command in shell - IRemoteCommandShell defaultShell = cmdSubSystem.getDefaultShell(); - if (defaultShell != null) - { - showInView(defaultShell); - } - - String cdCmd = "cd " + path; //$NON-NLS-1$ - if ((cmdSubSystem.getHost().getSystemType().equals("Local") && System.getProperty("os.name").toLowerCase().startsWith("win")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - || cmdSubSystem.getHost().getSystemType().equals("Windows")) //$NON-NLS-1$ - { - cdCmd = "cd /d " + path; //$NON-NLS-1$ - } - cmdSubSystem.sendCommandToShell(cdCmd, defaultShell); - cmdSubSystem.sendCommandToShell(cmd, defaultShell); - } - } - else - { - IRemoteCmdSubSystem cmdSubSystem = getCommandSubSystem(); - if (cmdSubSystem != null) - { - Object[] results = cmdSubSystem.runCommand(cmd, _selected); - Object cmdObject = results[0]; - if (cmdObject instanceof IRemoteCommandShell) - { - showInView((IRemoteCommandShell) cmdObject); - } - } - } - - } - catch (Exception e) - { - e.printStackTrace(); - } - - } - } - - /** - * launches a new shell - */ - private void runShell() - { - try - { - Shell shell = getShell(); - if (_selectedFilterRef != null) - { - ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)((IAdaptable)_selectedFilterRef).getAdapter(ISystemViewElementAdapter.class); - if (adapter != null) - { - ISubSystem ss = adapter.getSubSystem(_selectedFilterRef); - if (ss != null) - { - Object target = ss.getTargetForFilter(_selectedFilterRef); - if (target != null && target instanceof IRemoteFile) - { - _selected = (IRemoteFile)target; - } - } - } - } - - IRemoteCmdSubSystem cmdSubSystem = getCommandSubSystem(); - if (cmdSubSystem != null) - { - if (cmdSubSystem.isConnected()) - { - SystemCommandsUI commandsUI = SystemCommandsUI.getInstance(); - SystemCommandsViewPart cmdsPart = commandsUI.activateCommandsView(); - IRemoteCommandShell cmd = cmdSubSystem.runShell(_selected); - cmdsPart.updateOutput(cmd); - } - else - { - cmdSubSystem.connect(); - if (cmdSubSystem.isConnected()) - { - SystemCommandsUI commandsUI = SystemCommandsUI.getInstance(); - SystemCommandsViewPart cmdsPart = commandsUI.activateCommandsView(); - IRemoteCommandShell cmd = cmdSubSystem.runShell( _selected); - cmdsPart.updateOutput(cmd); - } - //showInView(cmd); - } - } - - } - catch (Exception e) - { - e.printStackTrace(); - // RSEUIPlugin.getDefault().logInfo("Exception invoking command " + cmd + " on " + sysConn.getAliasName()); - } - - } - - /** - * shows the command in the commands view - */ - private void showInView(IRemoteCommandShell cmd) - { - SystemCommandsUI commandsUI = SystemCommandsUI.getInstance(); - SystemCommandsViewPart cmdsPart = commandsUI.activateCommandsView(); - cmdsPart.updateOutput(cmd); - } - - /** - * Called when the selection changes in the systems view. This determines - * the input object for the command and whether to enable or disable - * the action. - * - * @param selection the current seleciton - * @return whether to enable or disable the action - */ - public boolean updateSelection(IStructuredSelection selection) - { - boolean enable = false; - - Iterator e = selection.iterator(); - Object selected = e.next(); - - if (selected != null) - { - if (selected instanceof ISystemFilterReference) - { - _selectedFilterRef = (ISystemFilterReference)selected; - _selected = null; - enable = true; - } - if (selected instanceof IRemoteFile) - { - _selected = (IRemoteFile) selected; - _selectedFilterRef = null; - if (!_selected.isFile()) - { - enable = checkObjectType(_selected); - } - } - } - - if (enable) - { - IRemoteCmdSubSystem cmdSubSystem = getCommandSubSystem(); - if (_cmdSubSystem != cmdSubSystem) - { - _cmdSubSystem = cmdSubSystem; - enable = _cmdSubSystem.canRunCommand(); - } - } - else if (_cmdSubSystem != null) - { - enable = _cmdSubSystem.canRunShell(); - } - - return enable; - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemExportShellHistoryAction.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemExportShellHistoryAction.java deleted file mode 100644 index c3b9fd37c..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemExportShellHistoryAction.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2004, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.actions; - -import java.io.FileWriter; - -import org.eclipse.rse.shells.ui.ShellResources; -import org.eclipse.rse.shells.ui.view.SystemCommandsUI; -import org.eclipse.rse.shells.ui.view.SystemCommandsViewPart; -import org.eclipse.rse.subsystems.files.core.SystemFileResources; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Shell; - - - -/** - * @author dmcknigh - */ -public class SystemExportShellHistoryAction extends SystemBaseShellAction -{ - public SystemExportShellHistoryAction(Shell parent) - { - super(ShellResources.ACTION_EXPORT_SHELL_HISTORY_LABEL, - ShellResources.ACTION_EXPORT_SHELL_HISTORY_TOOLTIP, - RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_EXPORT_SHELL_HISTORY_ID), - parent); - allowOnMultipleSelection(false); - } - - - /** - * Called when this action is selected from the popup menu. - */ - public void run() - { - SystemCommandsViewPart viewPart = SystemCommandsUI.getInstance().activateCommandsView(); - for (int i = 0; i < _selected.size(); i++) - { - IRemoteCommandShell cmdShell = (IRemoteCommandShell)_selected.get(i); - - - FileDialog fdlg = new FileDialog(getShell(), SWT.SAVE); - fdlg.setText(SystemFileResources.RESID_ENTER_OR_SELECT_FILE_TITLE); - fdlg.setFileName(cmdShell.getId() + "-history.txt"); - fdlg.setFilterExtensions(new String[] {"*.txt"}); - String fileName = fdlg.open(); - try - { - //FileOutputStream stream = new FileOutputStream(fileName); - //OutputStreamWriter writer = new OutputStreamWriter(stream, "UTF-8"); - // DKM - file writer writes to local encoding - FileWriter writer= new FileWriter(fileName); - String[] cmds = cmdShell.getHistory(); - for (int o = 0; o < cmds.length; o++) - { - String cmd = cmds[o]; - writer.write(cmd); - writer.write("\r\n"); - - } - writer.close(); - } - catch (Exception e) - { - } - } - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemExportShellOutputAction.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemExportShellOutputAction.java deleted file mode 100644 index 75a5c6754..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemExportShellOutputAction.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2004, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.actions; - -import java.io.FileWriter; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.rse.shells.ui.ShellResources; -import org.eclipse.rse.shells.ui.view.SystemCommandsUI; -import org.eclipse.rse.shells.ui.view.SystemCommandsViewPart; -import org.eclipse.rse.subsystems.files.core.SystemFileResources; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.view.ISystemViewElementAdapter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Shell; - - - -/** - * @author dmcknigh - */ -public class SystemExportShellOutputAction extends SystemBaseShellAction -{ - public SystemExportShellOutputAction(Shell parent) - { - super(ShellResources.ACTION_EXPORT_SHELL_OUTPUT_LABEL, - ShellResources.ACTION_EXPORT_SHELL_OUTPUT_TOOLTIP, - RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_EXPORT_SHELL_OUTPUT_ID), - parent); - allowOnMultipleSelection(false); - } - - - /** - * Called when this action is selected from the popup menu. - */ - public void run() - { - SystemCommandsViewPart viewPart = SystemCommandsUI.getInstance().activateCommandsView(); - for (int i = 0; i < _selected.size(); i++) - { - IRemoteCommandShell cmdShell = (IRemoteCommandShell)_selected.get(i); - - FileDialog fdlg = new FileDialog(getShell(),SWT.SAVE); - fdlg.setText(SystemFileResources.RESID_ENTER_OR_SELECT_FILE_TITLE); - fdlg.setFileName(cmdShell.getId() + "-output.txt"); - fdlg.setFilterExtensions(new String[] {"*.txt"}); - String fileName = fdlg.open(); - try - { - - //FileOutputStream stream = new FileOutputStream(fileName); - //OutputStreamWriter writer = new OutputStreamWriter(stream, "UTF-8"); - // dkm - using local encoding - FileWriter writer = new FileWriter(fileName); - - Object[] outputs = cmdShell.listOutput(); - for (int o = 0; o < outputs.length; o++) - { - IAdaptable output = (IAdaptable)outputs[o]; - ISystemViewElementAdapter adapter = (ISystemViewElementAdapter)output.getAdapter(ISystemViewElementAdapter.class); - if (adapter != null) - { - writer.write(adapter.getText(output)); - writer.write("\r\n"); - } - } - writer.close(); - } - catch (Exception e) - { - } - } - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemShowInShellViewAction.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemShowInShellViewAction.java deleted file mode 100644 index 615c8e7dc..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemShowInShellViewAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2004, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.actions; - -import org.eclipse.rse.shells.ui.ShellResources; -import org.eclipse.rse.shells.ui.view.SystemCommandsUI; -import org.eclipse.rse.shells.ui.view.SystemCommandsViewPart; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.swt.widgets.Shell; - - - -public class SystemShowInShellViewAction extends SystemBaseShellAction -{ - /** - * Constructor. - * @param shell Shell of parent window, used as the parent for the dialog. - * Can be null, but be sure to call setParent before the action is used (ie, run). - */ - public SystemShowInShellViewAction(Shell parent) - { - super(ShellResources.ACTION_SHOW_SHELL_LABEL, - ShellResources.ACTION_SHOW_SHELL_TOOLTIP, - RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_SHOW_SHELL_ID), - parent); - allowOnMultipleSelection(false); - } - - /** - * Called when this action is selected from the popup menu. - */ - public void run() - { - SystemCommandsViewPart viewPart = SystemCommandsUI.getInstance().activateCommandsView(); - for (int i = 0; i < _selected.size(); i++) - { - IRemoteCommandShell cmdShell = (IRemoteCommandShell)_selected.get(i); - viewPart.updateOutput(cmdShell); - } - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemTerminateRemoveShellAction.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemTerminateRemoveShellAction.java deleted file mode 100644 index 91c7e2f95..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemTerminateRemoveShellAction.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - - -package org.eclipse.rse.shells.ui.actions; - -import org.eclipse.rse.shells.ui.ShellResources; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.swt.widgets.Shell; - - - -public class SystemTerminateRemoveShellAction extends SystemTerminateShellAction -{ - public SystemTerminateRemoveShellAction(Shell parent) - { - super(ShellResources.ACTION_CANCEL_REMOVE_SHELL_LABEL, - ShellResources.ACTION_CANCEL_REMOVE_SHELL_TOOLTIP, - RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_REMOVE_SHELL_ID), - parent); - } - - protected boolean isApplicable(IRemoteCommandShell cmdShell) - { - return true; - } - - - public void cancel(IRemoteCommandShell command) - { - try - { - IRemoteCmdSubSystem cmdSubSystem = command.getCommandSubSystem(); - if (cmdSubSystem != null) - { - cmdSubSystem.removeShell(command); - } - } - catch (Exception e) - { - // RSEUIPlugin.getDefault().logInfo("Exception invoking command " + cmd + " on " + sysConn.getAliasName()); - } - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemTerminateShellAction.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemTerminateShellAction.java deleted file mode 100644 index 694566e1c..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/actions/SystemTerminateShellAction.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2004, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.actions; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.rse.shells.ui.ShellResources; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.swt.widgets.Shell; - - - -public class SystemTerminateShellAction extends SystemBaseShellAction -{ - public SystemTerminateShellAction(Shell parent) - { - this(ShellResources.ACTION_CANCEL_SHELL_LABEL, - ShellResources.ACTION_CANCEL_SHELL_TOOLTIP, - RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CANCEL_ID), - parent); - } - - public SystemTerminateShellAction(String label, - String tooltip, - ImageDescriptor image, - Shell parent) - { - super(label, - tooltip, - image, - parent); - } - - public void run() - { - // DKM - need to deselect in tree - //SystemRegistry registry = RSEUIPlugin.getTheSystemRegistry(); - //registry.fireEvent(new SystemResourceChangeEvent()) - List selected = new ArrayList(); - selected.addAll(_selected); - for (int i = selected.size() -1; i >= 0; i--) - { - IRemoteCommandShell cmdShell = (IRemoteCommandShell)selected.get(i); - terminateShell(cmdShell); - } - } - - protected boolean isApplicable(IRemoteCommandShell cmdShell) - { - return cmdShell.isActive(); - } - - protected void terminateShell(IRemoteCommandShell command) - { - cancel(command); - } - - public void cancel(IRemoteCommandShell command) - { - try - { - IRemoteCmdSubSystem cmdSubSystem = command.getCommandSubSystem(); - if (cmdSubSystem != null) - { - cmdSubSystem.cancelShell(command); - } - } - catch (Exception e) - { - // RSEUIPlugin.getDefault().logInfo("Exception invoking command " + cmd + " on " + sysConn.getAliasName()); - } - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/propertypages/EnvironmentVariablesPropertyPage.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/propertypages/EnvironmentVariablesPropertyPage.java deleted file mode 100644 index 237ff8371..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/propertypages/EnvironmentVariablesPropertyPage.java +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.propertypages; - - - -import java.util.Collection; -import java.util.Iterator; -import java.util.Vector; - -import org.eclipse.rse.core.SystemBasePlugin; -import org.eclipse.rse.core.subsystems.IRemoteSystemEnvVar; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.shells.ui.RemoteCommandHelpers; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.ui.propertypages.SystemBasePropertyPage; -import org.eclipse.rse.ui.widgets.EnvironmentVariablesForm; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - - -/** - * Property page for editing persistant environment variables for an - * RSE connection. - */ -public class EnvironmentVariablesPropertyPage extends SystemBasePropertyPage -{ - private EnvironmentVariablesForm _form; - - /** - * Constructor for EnvironmentVariablesPropertyPage. - */ - public EnvironmentVariablesPropertyPage() - { - super(); - } - - /** - * @see org.eclipse.rse.ui.propertypages.SystemBasePropertyPage#createContentArea(Composite) - */ - protected Control createContentArea(Composite parent) - { - - IRemoteCmdSubSystem cmdSubSystem = getCmdSubSystem(); - if (cmdSubSystem != null) - { - - // Create property page UI - _form = - new EnvironmentVariablesForm( - getShell(), - getMessageLine(), - getElement(), - cmdSubSystem.getInvalidEnvironmentVariableNameCharacters()); - - // Load existing environment variables - IRemoteSystemEnvVar[] envVars = getCmdSubSystem().getEnvironmentVariableList(); - // Form only works with a simple inner class since it cannot easily instantiate - // RemoteSystemEnvVarImpl classes. We leave this complexity (via MOF) to the - // subsystem. - Vector envVarsVector = new Vector(); - for (int idx = 0; idx < envVars.length; idx++) - { - envVarsVector.add(_form.new EnvironmentVariable(envVars[idx].getName(), envVars[idx].getValue())); - } - _form.setEnvVars(envVarsVector); - - _form.createContents(parent); - - } - else - { - // Create property page UI - _form = - new EnvironmentVariablesForm( - getShell(), - getMessageLine(), - null, - null); - - _form.createContents(parent); - } - return parent; - } - - /** - * @see org.eclipse.rse.ui.propertypages.SystemBasePropertyPage#verifyPageContents() - */ - protected boolean verifyPageContents() - { - return true; - } - - /** - * Return the command subsystem implementation object. - */ - private IRemoteCmdSubSystem getCmdSubSystem() - { - Object subsystem = getElement(); - if (subsystem instanceof ISubSystem) - { - return RemoteCommandHelpers.getCmdSubSystem(((ISubSystem)subsystem).getHost()); - } - else - { - SystemBasePlugin.logError( - "EnvironmentVariablesPropertyPage.getCmdSubSystem: input element for property page is not an instanceof SubSystem: " - + subsystem); - return null; - } - } - - /** - * @see org.eclipse.jface.preference.IPreferencePage#performOk() - */ - public boolean performOk() - { - Collection envVars = _form.getEnvVars(); - String[] names = new String[envVars.size()]; - String[] values = new String[envVars.size()]; - - Iterator i = envVars.iterator(); - EnvironmentVariablesForm.EnvironmentVariable variable; - for (int idx = 0; i.hasNext(); idx++) - { - variable = (EnvironmentVariablesForm.EnvironmentVariable) i.next(); - names[idx] = variable.getName(); - values[idx] = variable.getValue(); - } - - getCmdSubSystem().setEnvironmentVariableList(names, values); - - return true; - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/propertypages/ShellServicesPropertyPage.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/propertypages/ShellServicesPropertyPage.java deleted file mode 100644 index 16bd5b0de..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/propertypages/ShellServicesPropertyPage.java +++ /dev/null @@ -1,109 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.propertypages; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.core.model.ISystemRegistry; -import org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.model.DummyHost; -import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystemConfiguration; -import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.ShellServiceSubSystem; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.propertypages.ServicesPropertyPage; -import org.eclipse.rse.ui.widgets.services.FactoryServiceElement; -import org.eclipse.rse.ui.widgets.services.ServiceElement; - - -public class ShellServicesPropertyPage extends ServicesPropertyPage -{ - - private IShellServiceSubSystemConfiguration _currentFactory; - - - protected ShellServiceSubSystem getShellServiceSubSystem() - { - return (ShellServiceSubSystem)getElement(); - } - - - protected ServiceElement[] getServiceElements() - { - ShellServiceSubSystem subSystem = getShellServiceSubSystem(); - IShellServiceSubSystemConfiguration[] factories = null; - IHost host = null; - if (subSystem == null || _currentFactory != null) - { - // create dummy host - factories = getShellServiceSubSystemFactories(getSystemType()); - host = new DummyHost(getHostname(), getSystemType()); - } - else - { - host = subSystem.getHost(); - _currentFactory = (IShellServiceSubSystemConfiguration)subSystem.getParentRemoteCmdSubSystemConfiguration(); - factories = getShellServiceSubSystemFactories(host.getSystemType()); - } - - // create elements for each - ServiceElement[] elements = new ServiceElement[factories.length]; - for (int i = 0; i < factories.length; i++) - { - IShellServiceSubSystemConfiguration factory = factories[i]; - - elements[i] = new FactoryServiceElement(host, factory); - if (factory == _currentFactory) - { - elements[i].setSelected(true); - } - } - return elements; - } - - - protected IShellServiceSubSystemConfiguration[] getShellServiceSubSystemFactories(String systemType) - { - List results = new ArrayList(); - ISystemRegistry sr = RSEUIPlugin.getTheSystemRegistry(); - ISubSystemConfiguration[] factories = sr.getSubSystemConfigurationsBySystemType(systemType); - - for (int i = 0; i < factories.length; i++) - { - ISubSystemConfiguration factory = factories[i]; - if (factory instanceof IShellServiceSubSystemConfiguration) - { - results.add(factory); - } - } - - return (IShellServiceSubSystemConfiguration[])results.toArray(new IShellServiceSubSystemConfiguration[results.size()]); - } - - - protected IServiceSubSystemConfiguration getCurrentServiceSubSystemConfiguration() - { - return _currentFactory; - } - - public void setSubSystemConfiguration(ISubSystemConfiguration factory) - { - _currentFactory = (IShellServiceSubSystemConfiguration)factory; - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/propertypages/SystemShellPropertyPage.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/propertypages/SystemShellPropertyPage.java deleted file mode 100644 index b5931e4af..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/propertypages/SystemShellPropertyPage.java +++ /dev/null @@ -1,142 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - - -package org.eclipse.rse.shells.ui.propertypages; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.rse.internal.subsystems.shells.subsystems.RemoteCmdSubSystem; -import org.eclipse.rse.shells.ui.ShellResources; -import org.eclipse.rse.shells.ui.view.EncodingForm; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.propertypages.SystemBasePropertyPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Group; - - - -public class SystemShellPropertyPage extends SystemBasePropertyPage -{ - private EncodingForm _form; - - public SystemShellPropertyPage() - { - super(); - setDescription(ShellResources.RESID_SHELL_PROPERTYPAGE_DESCRIPTION); - } - - public void setShellEncodingDefaults(List encodings) - { - StringBuffer history = new StringBuffer(); - for (int i = 0; i < encodings.size(); i++) - { - String encoding = (String)encodings.get(i); - history.append(encoding); - if (i < encodings.size()) - { - history.append(','); - } - } - - RSEUIPlugin.getDefault().getPreferenceStore().setValue("shell.encodingDefaults", history.toString()); - } - - public List getShellEncodingDefaults() - { - List result = new ArrayList(); - String attribute = RSEUIPlugin.getDefault().getPreferenceStore().getString("shell.encodingDefaults"); - if (attribute != null && attribute.length() > 0) - { - String[] list = attribute.split(","); - for (int i = 0; i < list.length; i++) - { - result.add(list[i]); - } - } - else - { - result.add("UTF-8"); - result.add("UTF-16"); - result.add("US-ASCII"); - result.add("ISO-8859-1"); - result.add("Cp1252"); - result.add("Cp1256"); - } - return result; - } - - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.propertypages.SystemBasePropertyPage#createContentArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createContentArea(Composite parent) - { - Font font = parent.getFont(); - Group group = new Group(parent, SWT.NONE); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - group.setLayoutData(data); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - group.setLayout(layout); - group.setText(ShellResources.RESID_SHELL_PROPERTYPAGE_ENCODING); - group.setFont(font); - - _form = new EncodingForm(getShell(), getMessageLine()); - _form.createContents(group); - - RemoteCmdSubSystem cmdSS = getCmdSubSystem(); - _form.initialize(getShellEncodingDefaults(), cmdSS.getShellEncoding()); - return _form.getDefaultControl(); - } - - public RemoteCmdSubSystem getCmdSubSystem() - { - return (RemoteCmdSubSystem)getElement(); - } - - /* (non-Javadoc) - * @see org.eclipse.rse.ui.propertypages.SystemBasePropertyPage#verifyPageContents() - */ - protected boolean verifyPageContents() - { - return true; - } - - /** - * @see org.eclipse.jface.preference.IPreferencePage#performOk() - */ - public boolean performOk() - { - String encoding = _form.getEncoding(); - getCmdSubSystem().setShellEncoding(encoding); - - List defaults = getShellEncodingDefaults(); - if (!defaults.contains(encoding)) - { - defaults.add(encoding); - setShellEncodingDefaults(defaults); - } - - return true; - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/CommandEntryContentAssistProcessor.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/CommandEntryContentAssistProcessor.java deleted file mode 100644 index 386009f7e..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/CommandEntryContentAssistProcessor.java +++ /dev/null @@ -1,640 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 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) - fix 158766: content assist works 1st time only - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.contentassist.CompletionProposal; -import org.eclipse.jface.text.contentassist.ContextInformation; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.jface.text.contentassist.IContextInformation; -import org.eclipse.jface.text.contentassist.IContextInformationValidator; -import org.eclipse.rse.core.subsystems.RemoteChildrenContentsType; -import org.eclipse.rse.internal.subsystems.shells.subsystems.RemoteCmdSubSystem; -import org.eclipse.rse.services.clientserver.messages.SystemMessageException; -import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; -import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFile; -import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileChildrenContentsType; -import org.eclipse.rse.subsystems.files.core.subsystems.RemoteFolderChildrenContentsType; -import org.eclipse.rse.subsystems.shells.core.model.ISystemOutputRemoteTypes; -import org.eclipse.rse.subsystems.shells.core.subsystems.ICandidateCommand; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.view.ISystemViewElementAdapter; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; - - -/** - * Class that implements the content assist processor interface for the command line. - */ -public class CommandEntryContentAssistProcessor implements IContentAssistProcessor -{ - - private class CompletionResults - { - private List _nameResults; - private List _proposalResults; - private List _proposalHelpResults; - private List _images; - - public CompletionResults() - { - _nameResults = new ArrayList(); - _proposalResults = new ArrayList(); - _proposalHelpResults = new ArrayList(); - _images = new ArrayList(); - } - - public int size() - { - return _nameResults.size(); - } - - public void addResult(String name, String text, String help, Image image) - { - _nameResults.add(name); - _proposalResults.add(text); - _proposalHelpResults.add(help); - _images.add(image); - } - - public String getNameAt(int i) - { - return (String) _nameResults.get(i); - } - - public String getTextAt(int i) - { - return (String) _proposalResults.get(i); - } - - public String getHelpAt(int i) - { - return (String) _proposalHelpResults.get(i); - } - - public Image getImageAt(int i) - { - return (Image) _images.get(i); - } - } - - private CommandEntryViewerConfiguration _configurator; - //private SystemTableViewProvider _provider; - private HashMap _imageMap; - private IRemoteCommandShell _remoteCommand; - private char _fileSeparator; - private char _foreignFileSeparator; - private IRemoteFile _lastFolderContext; - private boolean _isWindows; - private Image _envImage; - - private static int FILES_ONLY = 0; - private static int FOLDERS_ONLY = 1; - private static int FILES_AND_FOLDERS = 2; - - /** - * Constructor - */ - public CommandEntryContentAssistProcessor(CommandEntryViewerConfiguration configurator) - { - _configurator = configurator; - //_provider = new SystemTableViewProvider(); - _imageMap = new HashMap(); - } - - public void setRemoteCommand(IRemoteCommandShell cmd) - { - if (cmd != _remoteCommand) - { - - _remoteCommand = cmd; - if (_remoteCommand != null) - { - RemoteCmdSubSystem cmdSubsystem = (RemoteCmdSubSystem) _remoteCommand.getCommandSubSystem(); - //String type = cmdSubsystem.getHost().getSystemType(); - if (cmdSubsystem.isWindows()) - { - _isWindows = true; - _fileSeparator = '\\'; - _foreignFileSeparator = '/'; - } - else - { - _isWindows = false; - _fileSeparator = '/'; - _foreignFileSeparator = '\\'; - } - - _remoteCommand.getCandidateCommands(); - } - } - } - - public IRemoteCommandShell getRemoteCommand() - { - return _remoteCommand; - } - - private boolean isDeliminator(char c) - { - if (c == ' ' || c == ';' || c == ':' || c == '&' || c == '|' || c == '=') - return true; - return false; - } - - private String getCurrentText(ITextViewer viewer, int documentOffset) - { - StringBuffer currentText = new StringBuffer(); - String text = viewer.getDocument().get(); - if (documentOffset > -1) - { - boolean noWhiteSpace = true; - int firstChar = documentOffset - 1; - while (firstChar > -1 && noWhiteSpace) - { - char c = text.charAt(firstChar); - if (isDeliminator(c)) - { - noWhiteSpace = false; - } - else - { - currentText.insert(0, c); - } - firstChar--; - } - } - return currentText.toString(); - } - - private boolean isAtFirstToken(IDocument document) - { - String text = document.get(); - if (text.length() > 0) - { - int spaceIndex = text.indexOf(' '); - if (spaceIndex > 0) - { - return false; - } - } - - return true; - } - - private String getFirstToken(IDocument document) - { - StringBuffer buf = new StringBuffer(); - String text = document.get(); - int index = 0; - while (index < text.length()) - { - char c = text.charAt(index); - if (c == ' ') - { - return buf.toString(); - } - else - { - buf.append(c); - } - index++; - } - return buf.toString(); - } - - /** - * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int) - */ - public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) - { - //String text = viewer.getDocument().get(); - boolean atFirstToken = isAtFirstToken(viewer.getDocument()); - String firstToken = getFirstToken(viewer.getDocument()); - String currentText = getCurrentText(viewer, documentOffset); - - CompletionResults completions = getCompletions(firstToken, currentText, atFirstToken); - if (completions != null && completions.size() > 0) - { - ICompletionProposal[] proposalList = new ICompletionProposal[completions.size()]; - - int replacementOffset = documentOffset - currentText.length(); - int replacementLength = 0; - - replacementLength = documentOffset - replacementOffset; - - for (int idx = 0; idx < proposalList.length; idx++) - { - String name = completions.getNameAt(idx); - String proposal = completions.getTextAt(idx); - String help = completions.getHelpAt(idx); - Image image = completions.getImageAt(idx); - - // @param replacementString the actual string to be inserted into the document - // @param replacementOffset the offset of the text to be replaced - // @param replacementLength the length of the text to be replaced - // @param cursorPosition the position of the cursor following the insert relative to replacementOffset - // @param image the image to display for this proposal - // @param displayString the string to be displayed for the proposal - // @param contentInformation the context information associated with this proposal - // @param additionalProposalInfo the additional information associated with this proposal - ContextInformation info = new ContextInformation(proposal, help); - proposalList[idx] = new CompletionProposal(proposal, replacementOffset, replacementLength, documentOffset + proposal.length(), image, name, info, help); - - } - return proposalList; - } - return new ICompletionProposal[0]; - } - - private Image getImageFor(Object object) - { - ImageDescriptor descriptor = null; - Image image = null; - if (object instanceof ICandidateCommand) - { - ICandidateCommand cmd = (ICandidateCommand) object; - descriptor = cmd.getImageDescriptor(); - if (descriptor == null) - { - String type = cmd.getType(); - if (type.equals(ISystemOutputRemoteTypes.TYPE_FILE)) - { - descriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE); - } - else - { - descriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_RUN_ID); - } - } - } - else if (object instanceof IAdaptable) - { - ISystemViewElementAdapter adapter = (ISystemViewElementAdapter) ((IAdaptable) object).getAdapter(ISystemViewElementAdapter.class); - descriptor = adapter.getImageDescriptor(object); - } - - if (descriptor!=null) - { - image = (Image) _imageMap.get(descriptor); - if (image == null) - { - image = descriptor.createImage(); - _imageMap.put(descriptor, image); - } - } - return image; - } - - private Image getEnvironmentVariableImage() - { - if (_envImage == null) - { - _envImage = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_ENVVAR_ID).createImage(); - } - return _envImage; - } - - private CompletionResults getCompletions(String firstToken, String currentText, boolean atFirstToken) - { - CompletionResults results = new CompletionResults(); - if (_remoteCommand != null && _remoteCommand.isActive()) - { - Object context = _remoteCommand.getContext(); - if (context instanceof IRemoteFile) - { - IRemoteFile workingDirectory = (IRemoteFile)context; - - int separatorIndex = currentText.lastIndexOf(_fileSeparator); - int foreignseparatorIndex = currentText.lastIndexOf(_foreignFileSeparator); - if (foreignseparatorIndex > separatorIndex) - { - separatorIndex = foreignseparatorIndex; - } - - if (separatorIndex > 0) - { - String previousText = currentText.substring(0, separatorIndex + 1).replace(_foreignFileSeparator, _fileSeparator); - String nextText = ""; - if (separatorIndex < currentText.length()) - { - nextText = currentText.substring(separatorIndex + 1, currentText.length()); - } - - IRemoteFile contextDirectory = null; - String contextPath = null; - if (!_isWindows && currentText.charAt(0) == _fileSeparator) - { - contextPath = previousText; - } - else - { - contextPath = workingDirectory.getAbsolutePath() + _fileSeparator + previousText; - } - - if (_lastFolderContext != null && _lastFolderContext.getAbsolutePath().equals(contextPath)) - { - contextDirectory = _lastFolderContext; - } - else - { - try - { - contextDirectory = RemoteFileUtility.getFileSubSystem(_remoteCommand.getCommandSubSystem().getHost()).getRemoteFileObject(contextPath); - _lastFolderContext = contextDirectory; - } - catch (Exception e) - { - } - } - getFileCompletions(contextDirectory, previousText, nextText, results, FILES_AND_FOLDERS); - - } - else - { - if (atFirstToken) - { - if (!_isWindows && currentText.length() > 0 && currentText.charAt(0) == _fileSeparator) - { - getAbsoluteFileCompletions("", currentText, results, FILES_AND_FOLDERS); - } - else - { - getFileCompletions(workingDirectory, "", currentText, results, FILES_ONLY); - getCommandCompletions(currentText, results); - } - } - else - { - int flag = FILES_AND_FOLDERS; - - if (firstToken.equals("cd")) - { - flag = FOLDERS_ONLY; - } - else - { - if (_isWindows) - { - if (firstToken.equals("set") || currentText.startsWith("%")) - { - getEnvironmentCompletions(currentText, results); - return results; - } - } - else if (firstToken.equals("export") || currentText.startsWith("$")) - { - getEnvironmentCompletions(currentText, results); - return results; - } - } - - getFileCompletions(workingDirectory, "", currentText, results, flag); - } - } - } - else - { - getCommandCompletions(currentText, results); - } - } - - return results; - } - - private void getEnvironmentCompletions(String currentText, CompletionResults results) - { - IRemoteCmdSubSystem cmdSubsystem = _remoteCommand.getCommandSubSystem(); - if (cmdSubsystem != null) - { - List vars = cmdSubsystem.getHostEnvironmentVariables(); - if (vars != null) - { - for (int i = 0; i < vars.size(); i++) - { - String var = (String) vars.get(i); - int eqSepIndex = var.indexOf('='); - String name = var.substring(0, eqSepIndex); - String value = var.substring(eqSepIndex + 1, var.length()); - boolean hasDollars = currentText.startsWith("$"); - String compareName = name; - if (hasDollars) - { - compareName = "$" + name; - } - boolean hasPercent = currentText.startsWith("%"); - if (hasPercent) - { - compareName = "%" + name + "%"; - } - - if (compareName.toLowerCase().startsWith(currentText.toLowerCase())) - { - - results.addResult(name, compareName, value, getEnvironmentVariableImage()); - } - } - } - } - } - - private void getCommandCompletions(String currentText, CompletionResults results) - { - IRemoteCmdSubSystem cmdSubsystem = _remoteCommand.getCommandSubSystem(); - if (cmdSubsystem != null) - { - ICandidateCommand[] cmds = cmdSubsystem.getCandidateCommands(_remoteCommand); - if (cmds != null) - { - for (int i = 0; i < cmds.length; i++) - { - ICandidateCommand cmd = cmds[i]; - String name = cmd.getName(); - if (name.toLowerCase().startsWith(currentText.toLowerCase())) - { - - results.addResult(name, name, cmd.getDescription(), getImageFor(cmd)); - } - } - } - } - } - - private void getAbsoluteFileCompletions(String prefix, String currentText, CompletionResults results, int flag) - { - if (!_isWindows) - { - int lastSlashIndex = currentText.lastIndexOf("/"); - String parentPath = currentText.substring(0, lastSlashIndex); - IRemoteFileSubSystem fs = RemoteFileUtility.getFileSubSystem(_remoteCommand.getCommandSubSystem().getHost()); - try - { - IRemoteFile parent = fs.getRemoteFileObject(parentPath); - - Object[] fileList = null; - - if (parent.hasContents(RemoteChildrenContentsType.getInstance())) - { - fileList = parent.getContents(RemoteChildrenContentsType.getInstance()); - } - else - { - fileList = parent.getParentRemoteFileSubSystem().listFoldersAndFiles(parent, currentText + "*", null); - } - - - for (int f1 = 0; f1 < fileList.length; f1++) - { - if (fileList[f1] instanceof IRemoteFile) - { - RemoteFile file = (RemoteFile) fileList[f1]; - if ((flag == FILES_ONLY && file.isFile()) || (flag == FOLDERS_ONLY && file.isDirectory()) || (flag == FILES_AND_FOLDERS)) - { - String name = file.getName(); - String proposal = prefix + name; - - if (name.startsWith(currentText)) - { - results.addResult(name, proposal, file.getAbsolutePath(), getImageFor(file)); - } - else if (_isWindows && name.toLowerCase().startsWith(currentText.toLowerCase())) - { - results.addResult(name, proposal, file.getAbsolutePath(), getImageFor(file)); - } - } - } - } - } - catch (Exception e) - { - } - } - } - - private void getFileCompletions(IRemoteFile workingDirectory, String prefix, String currentText, CompletionResults results, int flag) - { - - Object[] fileList = null; - String filterString = currentText + "*"; //$NON-NLS-1$ - - if (workingDirectory.hasContents(RemoteChildrenContentsType.getInstance()) && !workingDirectory.isStale()) - { - if (flag == FILES_ONLY) - { - fileList = workingDirectory.getContents(RemoteFileChildrenContentsType.getInstance(), filterString); - } - else if (flag == FOLDERS_ONLY) - { - fileList = workingDirectory.getContents(RemoteFolderChildrenContentsType.getInstance(), filterString); - } - else - { - fileList = workingDirectory.getContents(RemoteChildrenContentsType.getInstance(), filterString); - } - } - if (fileList==null || fileList.length==0) - { - try - { - fileList = workingDirectory.getParentRemoteFileSubSystem().listFoldersAndFiles(workingDirectory, filterString, null); - } - catch (SystemMessageException e) - { - } - } - //_provider.getChildren(workingDirectory); - - if (fileList != null && fileList.length > 0) - { - for (int f1 = 0; f1 < fileList.length; f1++) - { - if (fileList[f1] instanceof IRemoteFile) - { - RemoteFile file = (RemoteFile) fileList[f1]; - if ((flag == FILES_ONLY && file.isFile()) || (flag == FOLDERS_ONLY && file.isDirectory()) || (flag == FILES_AND_FOLDERS)) - { - String name = file.getName(); - String proposal = prefix + name; - - if (name.startsWith(currentText)) - { - results.addResult(name, proposal, file.getAbsolutePath(), getImageFor(file)); - } - else if (_isWindows && name.toLowerCase().startsWith(currentText.toLowerCase())) - { - results.addResult(name, proposal, file.getAbsolutePath(), getImageFor(file)); - } - } - } - } - } - } - - /* - * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int) - */ - public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) - { - return null; - } - - /* - * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() - */ - public char[] getCompletionProposalAutoActivationCharacters() - { - return _configurator.getCompletionProposalAutoActivationCharacters(); - } - - /* - * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters() - */ - public char[] getContextInformationAutoActivationCharacters() - { - return null; - } - - /* - * @see IContentAssistProcessor#getErrorMessage() - */ - public String getErrorMessage() - { - return null; - } - - /* - * @see IContentAssistProcessor#getContextInformationValidator() - */ - public IContextInformationValidator getContextInformationValidator() - { - return null; - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/CommandEntryViewerConfiguration.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/CommandEntryViewerConfiguration.java deleted file mode 100644 index 1f678d026..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/CommandEntryViewerConfiguration.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.contentassist.ContentAssistant; -import org.eclipse.jface.text.contentassist.IContentAssistant; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; - - -/** - * Source viewer configuration class for command line content assist. - * - */ -public class CommandEntryViewerConfiguration extends SourceViewerConfiguration -{ - - private CommandEntryContentAssistProcessor _contentAssistantProcessor; - private ContentAssistant _contentAssistant; - /** - * Constructor - */ - public CommandEntryViewerConfiguration() - { - super(); - _contentAssistantProcessor = new CommandEntryContentAssistProcessor(this); - - } - - public void setRemoteCommand(IRemoteCommandShell cmd) - { - _contentAssistantProcessor.setRemoteCommand(cmd); - } - - public IRemoteCommandShell getRemoteCommand() - { - return _contentAssistantProcessor.getRemoteCommand(); - } - - /** - * Parent override. - * Returns the content assistant ready to be used with the given source viewer. - * - * @param sourceViewer the source viewer to be configured by this configuration - * @return a content assistant or <code>null</code> if content assist should not be supported - */ - public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) - { - if (_contentAssistant == null) - { - _contentAssistant = new ContentAssistant(); - _contentAssistant.setContentAssistProcessor(_contentAssistantProcessor, IDocument.DEFAULT_CONTENT_TYPE); - _contentAssistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY); - //_contentAssistant.enableAutoActivation(true); - _contentAssistant.enableAutoInsert(true); - - _contentAssistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); - } - return _contentAssistant; - } - - /** - * Return the characters which trigger the auto-display of the list - * substitution variables. We return '$' by default, but this can be - * overridden. - */ - protected char[] getCompletionProposalAutoActivationCharacters() - { - return new char[] { '/', '\\', '$', '%'}; - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/CommandsViewPage.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/CommandsViewPage.java deleted file mode 100644 index 53eb1a7e3..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/CommandsViewPage.java +++ /dev/null @@ -1,685 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.text.ITextOperationTarget; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.internal.subsystems.shells.subsystems.RemoteOutput; -import org.eclipse.rse.model.ISystemRegistryUI; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.shells.ui.ShellResources; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.ui.ISystemMessages; -import org.eclipse.rse.ui.ISystemThemeConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemResources; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.actions.SystemCopyToClipboardAction; -import org.eclipse.rse.ui.actions.SystemPasteFromClipboardAction; -import org.eclipse.rse.ui.view.ISystemViewElementAdapter; -import org.eclipse.rse.ui.view.SystemTableViewProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.dnd.Clipboard; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.CellEditorActionHandler; -import org.eclipse.ui.texteditor.ITextEditorActionConstants; -import org.eclipse.ui.themes.IThemeManager; - - -/** - * Class for a remote shell session on a connection - */ -public class CommandsViewPage implements SelectionListener, ISystemThemeConstants, IPropertyChangeListener, ISelectionChangedListener, -FocusListener -{ - - private Listener _keyListener = new Listener() - { - private boolean checkState(Event event) - { - boolean isEnabled = !_inputEntry.isInCodeAssist(); - if (event.character == '\r') - { - _inputEntry.setInCodeAssist(false); - } - - return isEnabled; - } - - public void handleEvent(Event e) - { - if (checkState(e)) - { - - if (e.character == '\r' && e.stateMask!=262144) // "enter" key, but not Ctrl+M (bug 160786) - { - sendInput(); - } - else if (e.keyCode == 13) - { - sendInput(); - } - else if (e.keyCode == 16777217) // "up" arrow - { - handleUp(); - } - else if (e.keyCode == 16777218) // "down" arrow - { - handleDown(); - } - else if (e.stateMask == 262144) - { - if (e.character == 3) - { - if (_inputEntry.getSelectedText().length() == 0) - { - sendBreak(); - } - else - { - _inputEntry.doOperation(ITextOperationTarget.COPY); - } - } - } - } - } - }; - - class SelectAllAction extends Action - { - public SelectAllAction() - { - super(SystemResources.ACTION_SELECT_ALL_LABEL, null); - setToolTipText(SystemResources.ACTION_SELECT_ALL_TOOLTIP); - } - - public void checkEnabledState() - { - setEnabled(true); - } - - public void run() - { - SystemCommandsView view = _viewer; - view.getTable().selectAll(); - view.setSelection(view.getSelection()); - } - } - - - private CommandEntryViewerConfiguration _entryViewerConfiguration; - - private SystemCommandsView _viewer; - - private SystemCommandEditor _inputEntry; - - private Button _upButton; - private Button _downButton; - private Composite _inputContainer; - private Composite _tabFolderPage; - - private int _commandHistoryOffset; - private SystemCommandsViewPart _viewPart; - - private String _title; - - private SystemCopyToClipboardAction _copyAction; - private SystemPasteFromClipboardAction _pasteAction; - private SelectAllAction _selectAllAction; - private IActionBars _actionBars; - - public CommandsViewPage(SystemCommandsViewPart viewPart) - { - _commandHistoryOffset = 0; - _entryViewerConfiguration = new CommandEntryViewerConfiguration(); - _viewPart = viewPart; - _actionBars = _viewPart.getViewSite().getActionBars(); - } - - public Composite createTabFolderPage(CTabFolder tabFolder, CellEditorActionHandler editorActionHandler) - { - _tabFolderPage = new Composite(tabFolder, SWT.NULL); - - Font font = tabFolder.getFont(); - _tabFolderPage.setFont(font); - // dummy title so that sizings work - // fix for 138311 - String dummyTitle = ShellResources.RESID_SHELLS_COMMAND_SHELL_LABEL; - -// _tabFolderPage.setText(dummyTitle); - GridLayout gridLayout = new GridLayout(); - _tabFolderPage.setLayout(gridLayout); - createControl(_tabFolderPage); - - ISystemRegistryUI registry = RSEUIPlugin.getTheSystemRegistry(); - - // global actions - Clipboard clipboard = registry.getSystemClipboard(); - _copyAction = new SystemCopyToClipboardAction(_viewer.getShell(), clipboard); - _copyAction.setEnabled(false); - - _pasteAction = new SystemPasteFromClipboardAction(_viewer.getShell(), clipboard); - _pasteAction.setEnabled(false); - - editorActionHandler.setCopyAction(_copyAction); - editorActionHandler.setPasteAction(_pasteAction); - - _selectAllAction = new SelectAllAction(); - _selectAllAction.setEnabled(false); - editorActionHandler.setSelectAllAction(_selectAllAction); - - - _viewer.addSelectionChangedListener(this); - _viewer.getControl().addFocusListener(this); - _inputEntry.getControl().addFocusListener(this); - - return _tabFolderPage; - } - - public void setFocus() - { - _inputEntry.getTextWidget().setFocus(); - - _viewPart.getSite().setSelectionProvider(_viewer); - } - - public IActionBars getActionBars() - { - return _actionBars; - } - - public void selectionChanged(SelectionChangedEvent e) - { - IStructuredSelection sel = (IStructuredSelection) e.getSelection(); - _copyAction.setEnabled(_copyAction.updateSelection(sel)); - _pasteAction.setEnabled(_pasteAction.updateSelection(sel)); - _selectAllAction.setEnabled(true); - - //setActionHandlers(); - } - - - - - public void setEnabled(boolean flag) - { - if (!flag) - { - _inputEntry.getTextWidget().setEnabled(flag); - _inputEntry.setEditable(flag); - - Table table = _viewer.getTable(); - - //Display display = _viewer.getShell().getDisplay(); - Color bgcolour = _tabFolderPage.getBackground(); - - table.setBackground(bgcolour); - _inputEntry.getTextWidget().setBackground(bgcolour); - } - } - - public void createControl(Composite parent) - { - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - parent.setLayout(gridLayout); - - // create table portion - Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.HIDE_SELECTION); - _viewer = new SystemCommandsView(table, _viewPart); - _viewer.setWorkbenchPart(_viewPart); - - _viewer.addDoubleClickListener(new IDoubleClickListener() - { - public void doubleClick(DoubleClickEvent event) - { - handleDoubleClick(event); - } - }); - - - SystemWidgetHelpers.setHelp(_viewer.getControl(), RSEUIPlugin.HELPPREFIX + "ucmd0000"); - - TableLayout layout = new TableLayout(); - table.setLayout(layout); - table.setHeaderVisible(false); - table.setLinesVisible(false); - - GridData gridData = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); - table.setLayoutData(gridData); - - _inputContainer = new Composite(parent, SWT.NONE); - GridLayout ilayout = new GridLayout(); - ilayout.numColumns = 4; - - Label label = new Label(_inputContainer, SWT.NONE); - label.setText(ShellResources.RESID_COMMANDSVIEW_COMMAND_LABEL); - - _inputEntry = new SystemCommandEditor(_viewPart.getViewSite(), _inputContainer, SWT.SINGLE | SWT.BORDER, 50, _entryViewerConfiguration, "", SystemResources.ACTION_CONTENT_ASSIST); - _inputEntry.getTextWidget().setToolTipText(ShellResources.RESID_COMMANDSVIEW_COMMAND_TOOLTIP); - - - _upButton = new Button(_inputContainer, SWT.ARROW | SWT.UP); - _upButton.addSelectionListener(this); - _upButton.setToolTipText(ShellResources.RESID_COMMANDSVIEW_PREVIOUS_TOOLTIP); - - _downButton = new Button(_inputContainer, SWT.ARROW | SWT.DOWN); - _downButton.addSelectionListener(this); - _downButton.setToolTipText(ShellResources.RESID_COMMANDSVIEW_PREVIOUS_TOOLTIP); - - GridData idata = new GridData(GridData.VERTICAL_ALIGN_END | GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL); - idata.heightHint = 22; - _inputEntry.getTextWidget().setLayoutData(idata); - _inputEntry.getTextWidget().addListener(SWT.KeyUp, _keyListener); - - enableEntry(false); - - GridData gridData1 = new GridData(GridData.FILL_HORIZONTAL); - _inputContainer.setLayout(ilayout); - _inputContainer.setLayoutData(gridData1); - - updateTheme(); - IThemeManager mgr = PlatformUI.getWorkbench().getThemeManager(); - mgr.addPropertyChangeListener(this); - - - - } - - public void propertyChange(PropertyChangeEvent e) - { - updateTheme(); - } - public void updateTheme() - { - //Display display = getViewer().getControl().getDisplay(); - IThemeManager mgr = PlatformUI.getWorkbench().getThemeManager(); - Color bg = mgr.getCurrentTheme().getColorRegistry().get(REMOTE_COMMANDS_VIEW_BG_COLOR); - Color fg = mgr.getCurrentTheme().getColorRegistry().get(REMOTE_COMMANDS_VIEW_FG_COLOR); - Font fFont =mgr.getCurrentTheme().getFontRegistry().get(REMOTE_COMMANDS_VIEW_FONT); - - _inputEntry.getControl().setBackground(bg); - _inputEntry.getControl().setForeground(fg); - _inputEntry.getControl().setFont(fFont); - } - - private void handleDoubleClick(DoubleClickEvent event) - { - IStructuredSelection s = (IStructuredSelection) event.getSelection(); - Object element = s.getFirstElement(); - if (element == null) - return; - - ISystemViewElementAdapter adapter = (ISystemViewElementAdapter) ((IAdaptable) element).getAdapter(ISystemViewElementAdapter.class); - //boolean alreadyHandled = false; - if (adapter != null) - { - if (adapter.hasChildren(element)) - { - // special case for folders - if (element instanceof IRemoteFile) - { - IRemoteFile folder = (IRemoteFile) element; - if (folder.isDirectory()) - { - String path = folder.getAbsolutePath(); - ISubSystem cmdSubSystem = adapter.getSubSystem(element); - - String cdCmd = "cd " + "\"" + path + "\""; - if (cmdSubSystem.getHost().getSystemType().equals("Local") - && System.getProperty("os.name").toLowerCase().startsWith("win") - || cmdSubSystem.getHost().getSystemType().equals("Windows")) - { - cdCmd = "cd /d " + path; - } - sendInput(cdCmd); - } - } - } - else if (element instanceof RemoteOutput) - { - RemoteOutput out = (RemoteOutput)element; - if (out.getType().equals("directory")) - { - String path = out.getAbsolutePath(); - ISubSystem cmdSubSystem = adapter.getSubSystem(element); - - String cdCmd = "cd " + "\"" + path + "\""; - if (cmdSubSystem.getHost().getSystemType().equals("Local") - && System.getProperty("os.name").toLowerCase().startsWith("win") - || cmdSubSystem.getHost().getSystemType().equals("Windows")) - { - cdCmd = "cd /d " + path; - } - sendInput(cdCmd); - } - else - { - /*alreadyHandled =*/ adapter.handleDoubleClick(element); - } - } - else - { - /*alreadyHandled =*/ adapter.handleDoubleClick(element); - } - } - } - - public void dispose() - { - IThemeManager mgr = PlatformUI.getWorkbench().getThemeManager(); - mgr.removePropertyChangeListener(this); - - _inputEntry.getTextWidget().removeListener(SWT.KeyUp, _keyListener); - _inputEntry.getTextWidget().dispose(); - _inputContainer.dispose(); - _viewer.dispose(); - _tabFolderPage.dispose(); - } - - private void enableEntry(boolean flag) - { - if (!_inputEntry.getTextWidget().isDisposed()) - _inputEntry.getTextWidget().setEnabled(flag); - } - - public void sendInput() - { - String inputStr = _inputEntry.getTextWidget().getText(); - sendInput(inputStr); - } - - public void sendInput(String inputStr) - { - Object input = _viewer.getInput(); - if (input instanceof IRemoteCommandShell) - { - _commandHistoryOffset = getCommandHistory().length + 1; - IRemoteCommandShell remoteCommand = (IRemoteCommandShell) input; - IRemoteCmdSubSystem commandSubSystem = remoteCommand.getCommandSubSystem(); - try - { - commandSubSystem.sendCommandToShell(inputStr, remoteCommand); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - _inputEntry.getTextWidget().setText(""); - _inputEntry.getTextWidget().setFocus(); - } - - public void sendBreak() - { - Object input = _viewer.getInput(); - if (input instanceof IRemoteCommandShell) - { - IRemoteCommandShell remoteCommand = (IRemoteCommandShell) input; - IRemoteCmdSubSystem commandSubSystem = remoteCommand.getCommandSubSystem(); - try - { - commandSubSystem.sendCommandToShell("#break", remoteCommand); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - } - - public Object getInput() - { - if (_viewer != null) - return _viewer.getInput(); - return null; - } - - public void setInput(IAdaptable object) - { - setInput(object, true); - updateTitle(object); - } - - public void updateTitle(IAdaptable object) - { - if (object instanceof IRemoteCommandShell) - { - IRemoteCommandShell command = (IRemoteCommandShell) object; - String title = command.getType(); - - SystemMessage msg = null; - if (!command.isActive()) - { - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_OPERATION_FINISHED); - } - else - { - msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_OPERATION_RUNNING); - } - - msg.makeSubstitution(title); - _title = msg.getLevelOneText(); -// _tabFolderPage.setText(_title); - } - } - - public String getTitle() - { - return _title; - } - - public void setInput(IAdaptable object, boolean updateHistory) - { - if (_viewer != null && object != null) - { - _viewer.setInput(object); - _entryViewerConfiguration.setRemoteCommand((IRemoteCommandShell) object); - //_inputEntry.getTextWidget().setFocus(); - } - } - - public void clearInput() - { - if (_viewer != null) - { - _viewer.setInput(null); - _entryViewerConfiguration.setRemoteCommand(null); - } - } - - public SystemCommandsView getViewer() - { - return _viewer; - } - - public void updateOutput() - { - if (_viewer != null) - { - ((SystemTableViewProvider) _viewer.getContentProvider()).flushCache(); - _viewer.updateChildren(); - _commandHistoryOffset = getCommandHistory().length; - } - } - - public void updateActionStates() - { - Object input = _viewer.getInput(); - if (input != null) - { - if (input instanceof IRemoteCommandShell) - { - IRemoteCommandShell cmdInput = (IRemoteCommandShell) input; - if (cmdInput.isActive()) - { - enableEntry(true); - } - else - { - enableEntry(false); - } - } - else - { - enableEntry(false); - } - } - else - { - enableEntry(false); - } - - } - - public void widgetDefaultSelected(SelectionEvent e) - { - widgetSelected(e); - } - - public void widgetSelected(SelectionEvent e) - { - Widget source = e.widget; - - if (source == _upButton) - { - handleUp(); - } - else if (source == _downButton) - { - handleDown(); - } - } - - private String[] getCommandHistory() - { - Object input = _viewer.getInput(); - if (input != null && input instanceof IRemoteCommandShell) - { - IRemoteCommandShell command = (IRemoteCommandShell) input; - return command.getHistory(); - } - return null; - } - - private void handleUp() - { - String[] history = getCommandHistory(); - _commandHistoryOffset--; - if (_commandHistoryOffset > 0) - { - if (history.length > _commandHistoryOffset) - { - String lastCommand = history[_commandHistoryOffset]; - _inputEntry.getTextWidget().setText(lastCommand); - _inputEntry.getTextWidget().setCaretOffset(_inputEntry.getTextWidget().getCharCount()); - } - } - else - { - _commandHistoryOffset = 0; - - if (history.length > 0) - { - _inputEntry.getTextWidget().setText(history[0]); - _inputEntry.getTextWidget().setCaretOffset(_inputEntry.getTextWidget().getCharCount()); - } - } - } - - private void handleDown() - { - _commandHistoryOffset++; - if (_commandHistoryOffset >= getCommandHistory().length) - { - _commandHistoryOffset = getCommandHistory().length; - _inputEntry.getTextWidget().setText(""); - } - else - { - String[] history = getCommandHistory(); - if (history.length > 0) - { - String lastCommand = history[_commandHistoryOffset]; - _inputEntry.getTextWidget().setText(lastCommand); - _inputEntry.getTextWidget().setCaretOffset(_inputEntry.getTextWidget().getCharCount()); - } - } - } - - - /* (non-Javadoc) - * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent) - */ - public void focusGained(FocusEvent arg0) - { - IActionBars actionBars = getActionBars(); - if (actionBars != null) - { - if (arg0.widget == _viewer.getControl()) - { - actionBars.setGlobalActionHandler(ITextEditorActionConstants.COPY, _copyAction); - actionBars.setGlobalActionHandler(ITextEditorActionConstants.PASTE, _pasteAction); - actionBars.setGlobalActionHandler(ITextEditorActionConstants.SELECT_ALL, _selectAllAction); - actionBars.updateActionBars(); - - } - else if (arg0.widget == _inputEntry.getControl()) - { - _inputEntry.setActionHandlers(); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent) - */ - public void focusLost(FocusEvent arg0) - { - - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/CommandsViewWorkbook.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/CommandsViewWorkbook.java deleted file mode 100644 index d1358b775..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/CommandsViewWorkbook.java +++ /dev/null @@ -1,252 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.ui.view.ISystemViewElementAdapter; -import org.eclipse.rse.ui.view.SystemTableView; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CTabFolder; -import org.eclipse.swt.custom.CTabItem; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; - - - -/** - * This is the desktop view wrapper of the System View viewer. - */ -public class CommandsViewWorkbook extends Composite -{ - - - private CTabFolder _folder; - private SystemCommandsViewPart _viewPart; - - public CommandsViewWorkbook(Composite parent, SystemCommandsViewPart viewPart) - { - super(parent, SWT.NONE); - - _folder = new CTabFolder(this, SWT.NONE); - _folder.setLayout(new TabFolderLayout()); - _folder.setLayoutData(new GridData(GridData.FILL_BOTH)); - setLayout(new FillLayout()); - _viewPart = viewPart; - } - - public void dispose() - { - if (!_folder.isDisposed()) - { - for (int i = 0; i < _folder.getItemCount(); i++) - { - CTabItem item = _folder.getItem(i); - if (!item.isDisposed()) - { - CommandsViewPage page = (CommandsViewPage) item.getData(); - page.dispose(); - } - } - _folder.dispose(); - } - super.dispose(); - } - - public CTabFolder getFolder() - { - return _folder; - } - - public void remove(Object root) - { - for (int i = 0; i < _folder.getItemCount(); i++) - { - CTabItem item = _folder.getItem(i); - if (!item.isDisposed()) - { - CommandsViewPage page = (CommandsViewPage) item.getData(); - - if (page != null && root == page.getInput()) - { - item.dispose(); - page.dispose(); - - page = null; - item = null; - - _folder.redraw(); - - return; - } - } - } - } - - public CTabItem getSelectedTab() - { - if (_folder.getItemCount() > 0) - { - int index = _folder.getSelectionIndex(); - CTabItem item = _folder.getItem(index); - return item; - } - - return null; - } - - public CommandsViewPage getCurrentTabItem() - { - if (_folder.getItemCount() > 0) - { - int index = _folder.getSelectionIndex(); - CTabItem item = _folder.getItem(index); - return (CommandsViewPage) item.getData(); - } - return null; - } - - public void showCurrentPage() - { - _folder.setFocus(); - } - - public Object getInput() - { - CommandsViewPage page = getCurrentTabItem(); - if (page != null) - { - // page.setFocus(); - return page.getInput(); - } - - return null; - } - - public SystemCommandsView getViewer() - { - if (getCurrentTabItem() != null) - { - return getCurrentTabItem().getViewer(); - } - return null; - } - - public void updateOutput(IRemoteCommandShell root, boolean createTab) - { - if (!_folder.isDisposed()) - { - for (int i = 0; i < _folder.getItemCount(); i++) - { - CTabItem item = _folder.getItem(i); - CommandsViewPage page = (CommandsViewPage) item.getData(); - if (page != null && root == page.getInput()) - { - if (!root.isActive()) - { - setTabTitle((IAdaptable) root, item); - page.updateTitle((IAdaptable) root); - page.setEnabled(false); - } - - page.updateOutput(); - - /* DKM - changing focus can get annoying - * see defect 142978 - * - if (_folder.getSelectionIndex() != i) - { - _folder.setSelection(item); - } - */ - updateActionStates(); - //page.setFocus(); - return; - } - } - - if (/*root.isActive() &&*/ createTab) - { - // never shown this, so add it - createTabItem((IAdaptable) root); - } - } - } - - private void createTabItem(IAdaptable root) - { - CommandsViewPage commandsViewPage = new CommandsViewPage(_viewPart); - - CTabItem titem = new CTabItem(_folder, SWT.NULL); - setTabTitle(root, titem); - - titem.setData(commandsViewPage); - titem.setControl(commandsViewPage.createTabFolderPage(_folder, _viewPart.getEditorActionHandler())); - _folder.setSelection(titem ); - - commandsViewPage.setInput(root); - - SystemTableView viewer = commandsViewPage.getViewer(); - _viewPart.getSite().setSelectionProvider(viewer); - _viewPart.getSite().registerContextMenu(viewer.getContextMenuManager(), viewer); - //commandsViewPage.getViewer().addSelectionChangedListener((SystemCommandsViewPart)_viewPart); - - commandsViewPage.setFocus(); - } - - private void setTabTitle(IAdaptable root, CTabItem titem) - { - ISystemViewElementAdapter va = (ISystemViewElementAdapter) root.getAdapter(ISystemViewElementAdapter.class); - if (va != null) - { - titem.setText(va.getName(root)); - titem.setImage(va.getImageDescriptor(root).createImage()); - } - } - - public void setInput(IAdaptable root) - { - for (int i = 0; i < _folder.getItemCount(); i++) - { - CTabItem item = _folder.getItem(i); - CommandsViewPage page = (CommandsViewPage) item.getData(); - if (root == page.getInput()) - { - _folder.setSelection(i); - page.getViewer().updateChildren(); - return; - } - } - } - - public void updateActionStates() - { - for (int i = 0; i < _folder.getItemCount(); i++) - { - CTabItem item = _folder.getItem(i); - if (!item.isDisposed()) - { - CommandsViewPage page = (CommandsViewPage) item.getData(); - if (page != null) - { - page.updateActionStates(); - } - } - } - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/EncodingForm.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/EncodingForm.java deleted file mode 100644 index 673e50a1f..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/EncodingForm.java +++ /dev/null @@ -1,174 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2005, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import java.io.UnsupportedEncodingException; -import java.util.Collections; -import java.util.List; - -import org.eclipse.rse.shells.ui.ShellResources; -import org.eclipse.rse.ui.SystemBaseForm; -import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; - - - -public class EncodingForm extends SystemBaseForm -{ - // State for encoding group - private String _encoding; - private String _defaultEncoding; - - private Button _defaultEncodingButton; - private Button _otherEncodingButton; - private Combo _encodingCombo; - - - public EncodingForm(Shell shell, ISystemMessageLine line) - { - super(shell, line); - _defaultEncoding = ShellResources.RESID_SHELL_PROPERTYPAGE_DEFAULT_ENCODING; - } - - /* (non-Javadoc) - * @see org.eclipse.rse.core.ui.SystemBaseForm#createContents(org.eclipse.swt.widgets.Composite) - */ - public Control createContents(Composite group) - { - - SelectionAdapter buttonListener = new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) { - updateEncodingState(_defaultEncodingButton.getSelection()); - updateValidState(); - } - }; - - _defaultEncodingButton = new Button(group, SWT.RADIO); - _defaultEncodingButton.setText(ShellResources.RESID_SHELL_PROPERTYPAGE_HOST_ENCODING); - GridData data = new GridData(); - Font font = group.getFont(); - - data.horizontalSpan = 2; - _defaultEncodingButton.setLayoutData(data); - _defaultEncodingButton.addSelectionListener(buttonListener); - _defaultEncodingButton.setFont(font); - - _otherEncodingButton = new Button(group, SWT.RADIO); - _otherEncodingButton.setText(ShellResources.RESID_SHELL_PROPERTYPAGE_OTHER_ENCODING); - _otherEncodingButton.addSelectionListener(buttonListener); - _otherEncodingButton.setFont(font); - - _encodingCombo = new Combo(group, SWT.NONE); - data = new GridData(); - _encodingCombo.setFont(font); - _encodingCombo.setLayoutData(data); - _encodingCombo.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - updateValidState(); - } - }); - - return _encodingCombo; - } - - public void initialize(List defaults, String encoding) - { - _encoding = encoding; - - boolean isDefault = _encoding == null || _encoding.length() == 0 || encoding.equals(_defaultEncoding); - - if (!isDefault && !defaults.contains(_encoding)) - { - defaults.add(_encoding); - } - Collections.sort(defaults); - for (int i = 0; i < defaults.size(); ++i) { - _encodingCombo.add((String) defaults.get(i)); - } - - _encodingCombo.setText(isDefault ? _defaultEncoding : _encoding); - updateEncodingState(isDefault); - } - - public Control getDefaultControl() - { - return _encodingCombo; - } - - public boolean usingDefault() - { - return _defaultEncodingButton.getSelection(); - } - - public String getEncoding() - { - if (usingDefault()) - { - return ""; - } - return _encodingCombo.getText(); - } - - protected void updateValidState() - { - if (!isEncodingValid()) - { - getMessageLine().setErrorMessage(ShellResources.RESID_UNSUPPORTED_ENCODING); - } - else - { - getMessageLine().clearErrorMessage(); - } - } - - private boolean isEncodingValid() - { - return _defaultEncodingButton.getSelection() - || isValidEncoding(_encodingCombo.getText()); - } - - private boolean isValidEncoding(String enc) - { - try { - new String(new byte[0], enc); - return true; - } catch (UnsupportedEncodingException e) { - return false; - } - } - - private void updateEncodingState(boolean useDefault) - { - _defaultEncodingButton.setSelection(useDefault); - _otherEncodingButton.setSelection(!useDefault); - _encodingCombo.setEnabled(!useDefault); - updateValidState(); - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/ISystemCommandTextModifyListener.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/ISystemCommandTextModifyListener.java deleted file mode 100644 index 7e3f152fe..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/ISystemCommandTextModifyListener.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import org.eclipse.rse.services.clientserver.messages.SystemMessage; - -/** - * Interface that is to be implemented by anyone interested in - * listening to modify events on the command widget. - */ -public interface ISystemCommandTextModifyListener -{ - - /** - * Callback from SystemCommandTextField when the user modifies the command. - * @param cmdText - current contents of the field - * @param errorMessage - potential error detected by the default validator - */ - public void commandModified(String cmdText, SystemMessage errorMessage); - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/ShellServiceSubSystemConfigurationAdapter.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/ShellServiceSubSystemConfigurationAdapter.java deleted file mode 100644 index a1e47ccce..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/ShellServiceSubSystemConfigurationAdapter.java +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.ISubSystemConfiguration; -import org.eclipse.rse.shells.ui.RemoteCommandHelpers; -import org.eclipse.rse.shells.ui.actions.SystemCommandAction; -import org.eclipse.rse.shells.ui.actions.SystemExportShellHistoryAction; -import org.eclipse.rse.shells.ui.actions.SystemExportShellOutputAction; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.view.SubSystemConfigurationAdapter; -import org.eclipse.swt.widgets.Shell; - - -public class ShellServiceSubSystemConfigurationAdapter extends SubSystemConfigurationAdapter -{ - protected IAction _exportShellHistoryAction; - protected IAction _exportShellOutputAction; - protected SystemCommandAction _commandAction; - protected ImageDescriptor _activeShellImageDescriptor; - protected ImageDescriptor _inactiveShellImageDescriptor; - - public IAction[] getSubSystemActions(ISubSystemConfiguration factory, ISubSystem selectedSubSystem, Shell shell) - { - List allActions = new ArrayList(); - IAction[] baseActions = super.getSubSystemActions(factory, selectedSubSystem, shell); - for (int i = 0; i < baseActions.length; i++) - { - allActions.add(baseActions[i]); - } - - //launching shells and finding files - if (selectedSubSystem instanceof IRemoteFileSubSystem) - { - IRemoteFileSubSystem fs = (IRemoteFileSubSystem) selectedSubSystem; - IRemoteCmdSubSystem cmdSubSystem = RemoteCommandHelpers.getCmdSubSystem(fs.getHost()); - if (cmdSubSystem != null) - { - allActions.add(getCommandShellAction(cmdSubSystem, shell)); - } - } - else if (selectedSubSystem instanceof IRemoteCmdSubSystem) - { - allActions.add(getCommandShellAction((IRemoteCmdSubSystem)selectedSubSystem, shell)); - } - - return (IAction[])allActions.toArray(new IAction[allActions.size()]); - } - - - - public IAction getCommandShellAction(IRemoteCmdSubSystem selectedSubSystem, Shell shell) - { - if (_commandAction == null) - { - _commandAction = new SystemCommandAction(shell, true, selectedSubSystem); - } - else - { - _commandAction.setSubSystem(selectedSubSystem); - } - return _commandAction; - } - - /** - * Return the command shell history export action for the subsystem. If there is none, return null - */ - public IAction getCommandShellHistoryExportAction(Shell shell) - { - if (_exportShellHistoryAction == null) - { - _exportShellHistoryAction = new SystemExportShellHistoryAction(shell); - } - return _exportShellHistoryAction; - } - - /** - * Return the command shell output export action for the subsystem. If there is none, return null - */ - public IAction getCommandShellOutputExportAction(Shell shell) - { - if (_exportShellOutputAction == null) - { - _exportShellOutputAction = new SystemExportShellOutputAction(shell); - } - return _exportShellOutputAction; - } - - - /** - * Return the active command shell icon for this subsystem - */ - public ImageDescriptor getActiveCommandShellImageDescriptor() - { - if (_activeShellImageDescriptor == null) - { - _activeShellImageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_SHELLLIVE_ID); - - } - return _activeShellImageDescriptor; - } - - /** - * Return the inactive command shell icon for this subsystem - */ - public ImageDescriptor getInactiveCommandShellImageDescriptor() - { - if (_inactiveShellImageDescriptor == null) - { - _inactiveShellImageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_SHELL_ID); - } - return _inactiveShellImageDescriptor; - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/ShellServiceSubSystemConfigurationAdapterFactory.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/ShellServiceSubSystemConfigurationAdapterFactory.java deleted file mode 100644 index 7349e50ac..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/ShellServiceSubSystemConfigurationAdapterFactory.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.core.runtime.IAdapterManager; -import org.eclipse.rse.core.subsystems.util.ISubSystemConfigurationAdapter; -import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystemConfiguration; -import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.ShellServiceSubSystemConfiguration; - - -public class ShellServiceSubSystemConfigurationAdapterFactory implements IAdapterFactory -{ - - private ISubSystemConfigurationAdapter ssFactoryAdapter = new ShellServiceSubSystemConfigurationAdapter(); - - /** - * @see IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() - { - return new Class[] {ISubSystemConfigurationAdapter.class}; - } - /** - * Called by our plugin's startup method to register our adaptable object types - * with the platform. We prefer to do it here to isolate/encapsulate all factory - * logic in this one place. - */ - public void registerWithManager(IAdapterManager manager) - { - manager.registerAdapters(this, IShellServiceSubSystemConfiguration.class); - } - /** - * @see IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) - { - Object adapter = null; - if (adaptableObject instanceof ShellServiceSubSystemConfiguration) - adapter = ssFactoryAdapter; - - return adapter; - } - - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemBuildErrorView.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemBuildErrorView.java deleted file mode 100644 index 664938dba..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemBuildErrorView.java +++ /dev/null @@ -1,177 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.rse.model.ISystemResourceChangeEvent; -import org.eclipse.rse.model.ISystemResourceChangeEvents; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteError; -import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.rse.ui.view.SystemTableView; -import org.eclipse.rse.ui.view.SystemTableViewProvider; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Item; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.ui.views.properties.IPropertyDescriptor; - - -public class SystemBuildErrorView extends SystemTableView -{ - - private class ErrorViewerFilter extends ViewerFilter - { - public boolean select(Viewer viewer, Object obj1, Object obj2) - { - if (obj2 instanceof IRemoteError) - { - return true; - } - return false; - } - } - - - private Color _errColor; - private Color _outColor; - private Color _infColor; - private Color _warColor; - private Color _prmColor; - - - - public SystemBuildErrorView(Table table, ISystemMessageLine msgLine) - { - super(table, msgLine); - - Display display = getControl().getDisplay(); - - _errColor = new Color(display, 255, 0, 0); - _outColor = new Color(display, 50, 50, 50); - _infColor = new Color(display, 0, 0, 255); - _warColor = new Color(display, 200, 150, 0); - _prmColor = new Color(display, 0, 50, 0); - - _provider = new SystemBuildErrorViewProvider(); - setContentProvider(_provider); - addFilter(new ErrorViewerFilter()); - } - - public void refresh() - { - super.refresh(); - - Table table = getTable(); - if (table != null && table.getItemCount() > 0) - { - TableItem lastItem = table.getItem(table.getItemCount() - 1); - table.showItem(lastItem); - } - } - - public IPropertyDescriptor[] getVisibleDescriptors(Object object) - { - SystemViewRemoteErrorAdapter adpt = new SystemViewRemoteErrorAdapter(); - return adpt.getUniquePropertyDescriptors(); - } - - public IPropertyDescriptor getNameDescriptor(Object object) - { - SystemViewRemoteErrorAdapter adpt = new SystemViewRemoteErrorAdapter(); - return adpt.getPropertyDescriptors()[0]; - } - - public void setOffset(int offset) - { - ((SystemBuildErrorViewProvider)_provider).setOffset(offset); - } - - public synchronized void updateChildren() - { - computeLayout(); - internalRefresh(getInput()); - - } - - - public void clearAllItems() - { - Object input = getInput(); - SystemTableViewProvider provider = (SystemTableViewProvider) getContentProvider(); - Object[] children = provider.getChildren(input); - - ((SystemBuildErrorViewProvider)_provider).moveOffsetToEnd(); - clearFirstItems(children, children.length - 1); - provider.flushCache(); - - } - - private void clearFirstItems(Object[] children, int items) - { - Table table = getTable(); - - table.setRedraw(false); - synchronized (table) - { - int count = table.getItemCount(); - table.remove(0, items); - - } - table.setRedraw(true); - } - - protected Item newItem(Widget parent, int flags, int ix) - { - if (parent instanceof Table) - { - return new TableItem((Table) parent, flags); - } - - return null; - } - - public void systemResourceChanged(ISystemResourceChangeEvent event) - { - Object child = event.getSource(); - - if (event.getType() == ISystemResourceChangeEvents.EVENT_REFRESH) - { - if (child == getInput()) - { - SystemTableViewProvider provider = (SystemTableViewProvider) getContentProvider(); - if (provider != null) - { - provider.flushCache(); - - updateChildren(); - return; - } - } - } - - //super.systemResourceChanged(event); - } - - protected Object getParentForContent(Object element) - { - return getAdapter(element).getParent(element); - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemBuildErrorViewPart.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemBuildErrorViewPart.java deleted file mode 100644 index 0ba643fa8..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemBuildErrorViewPart.java +++ /dev/null @@ -1,484 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.rse.core.model.ISystemRegistry; -import org.eclipse.rse.core.subsystems.IRemoteLineReference; -import org.eclipse.rse.model.ISystemResourceChangeEvent; -import org.eclipse.rse.model.ISystemResourceChangeEvents; -import org.eclipse.rse.model.ISystemResourceChangeListener; -import org.eclipse.rse.model.SystemRegistry; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteOutput; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.ISystemMessages; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemResources; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.rse.ui.view.ISystemViewElementAdapter; -import org.eclipse.rse.ui.view.SystemTableViewProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.part.ViewPart; - - - - - -/** - * This is the wrapper class to SystemBuildErrorView. - */ -public class SystemBuildErrorViewPart extends ViewPart implements ISelectionListener, SelectionListener, ISystemResourceChangeListener, ISystemMessageLine -{ - - - class BrowseAction extends Action - { - public BrowseAction(String label, ImageDescriptor des) - { - super(label, des); - - setToolTipText(label); - } - - public void checkEnabledState() - { - if (getViewer().getInput() != null) - { - setEnabled(true); - } - else - { - setEnabled(false); - } - } - - public void run() - { - } - } - - public class ClearAction extends BrowseAction - { - public ClearAction() - { - super(SystemResources.ACTION_CLEAR_LABEL, - // DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_CLEAR)); - RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CLEAR_ID)); - - ImageDescriptor des = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CLEAR_ID); - - /* - setHoverImageDescriptor(DebugPluginImages.getImageDescriptor(IDebugUIConstants.IMG_LCL_CLEAR)); - setDisabledImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_DLCL_CLEAR)); - setImageDescriptor(DebugPluginImages.getImageDescriptor(IInternalDebugUIConstants.IMG_ELCL_CLEAR)); - */ - setImageDescriptor(des); - - // TODO DKM - get help for this! - //PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.CLEAR_CONSOLE_ACTION); - } - - public void checkEnabledState() - { - Object input = getViewer().getInput(); - if (input != null) - { - if (input instanceof IRemoteCommandShell) - { - setEnabled(((IRemoteCommandShell) input).isActive()); - return; - } - } - - setEnabled(false); - } - - public void run() - { - clear(); - } - - // clear contents of the current command viewer - private void clear() - { - getViewer().clearAllItems(); - } - } - - - // constants - public static final String ID = "org.eclipse.rse.shells.ui.view.buildErrorView"; - // matches id in plugin.xml, view tag - - private SystemBuildErrorView _viewer; - private ClearAction _clearAction; - private boolean _enableUpdates = true; - - // for ISystemMessageLine - private String _message, _errorMessage; - private SystemMessage sysErrorMessage; - private IStatusLineManager _statusLine = null; - - public void setFocus() - { - _viewer.getControl().setFocus(); - } - - public SystemBuildErrorView getViewer() - { - return _viewer; - } - - public Shell getShell() - { - return _viewer.getShell(); - } - - public void fillLocalToolBar() - { - boolean firstCall = false; - if (_clearAction == null) - { - firstCall = true; - _clearAction = new ClearAction(); - } - - IActionBars actionBars = getViewSite().getActionBars(); - IToolBarManager toolBarManager = actionBars.getToolBarManager(); - addToolBarItems(toolBarManager); - - if (firstCall) - { - IMenuManager menuManager = actionBars.getMenuManager(); - _statusLine = actionBars.getStatusLineManager(); - //addMenuItems(menuManager); - } - } - - private void addToolBarItems(IToolBarManager toolBarManager) - { - toolBarManager.removeAll(); - - toolBarManager.add(_clearAction); - } - - public void createPartControl(Composite parent) - { - // create table portion - Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.HIDE_SELECTION); - _viewer = new SystemBuildErrorView(table, this); - table.setLinesVisible(true); - - ISelectionService selectionService = getSite().getWorkbenchWindow().getSelectionService(); - selectionService.addSelectionListener(this); - - SystemRegistry registry = RSEUIPlugin.getTheSystemRegistry(); - - registry.addSystemResourceChangeListener(this); - - _viewer.addDoubleClickListener(new IDoubleClickListener() - { - public void doubleClick(DoubleClickEvent event) - { - handleDoubleClick(event); - } - }); - SystemWidgetHelpers.setHelp(_viewer.getControl(), RSEUIPlugin.HELPPREFIX + "uerr0000"); - fillLocalToolBar(); - } - - private void handleDoubleClick(DoubleClickEvent event) - { - IStructuredSelection s = (IStructuredSelection) event.getSelection(); - Object element = s.getFirstElement(); - if (element == null) - return; - - ISystemViewElementAdapter adapter = (ISystemViewElementAdapter) ((IAdaptable) element).getAdapter(ISystemViewElementAdapter.class); - //boolean alreadyHandled = false; - if (adapter != null) - { - if (!adapter.hasChildren(element)) - { - /*alreadyHandled =*/ adapter.handleDoubleClick(element); - } - } - } - - public void selectionChanged(IWorkbenchPart part, ISelection sel) - { - } - - public void dispose() - { - ISelectionService selectionService = getSite().getWorkbenchWindow().getSelectionService(); - selectionService.removeSelectionListener(this); - _viewer.dispose(); - - SystemRegistry registry = RSEUIPlugin.getTheSystemRegistry(); - registry.removeSystemResourceChangeListener(this); - super.dispose(); - } - - - - - - public void selectionChanged(SelectionChangedEvent e) - { - } - - public void resetOffset() - { - SystemBuildErrorViewProvider provider = (SystemBuildErrorViewProvider)_viewer.getContentProvider(); - int size = ((IRemoteCommandShell)_viewer.getInput()).getSize(); - provider.setOffset(size - 1); - } - - public void setInput(IAdaptable object, String cmdString) - { - setInput(object, true, cmdString); - } - - public void setInput(IAdaptable object, boolean updateHistory, String cmdString) - { - _viewer.getTable().removeAll(); - setEnableUpdates(true); - - if (object instanceof IRemoteCommandShell) - { - _viewer.setInput(object); - } - else - { - if (object instanceof IRemoteOutput) - { - IRemoteOutput output = (IRemoteOutput)object; - _viewer.setInput(output.getParent()); - SystemBuildErrorViewProvider provider = (SystemBuildErrorViewProvider)_viewer.getContentProvider(); - provider.setOffset(output.getIndex() - 1); - } - else if (object instanceof IRemoteLineReference) - { - _viewer.setInput(((IRemoteLineReference)object).getParent()); - } - - } - - SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_ERROR_LIST_TITLE); - msg.makeSubstitution(cmdString); - setPartName(msg.getLevelOneText()); - } - - public void updateOutput() - { - if (_viewer != null) - { - ((SystemTableViewProvider) _viewer.getContentProvider()).flushCache(); - _viewer.updateChildren(); - } - } - - - private void updateOutput(IRemoteCommandShell root) - { - if (root != null && _enableUpdates) - { - if (_viewer.getInput() != root) - { - _viewer.clearAllItems(); - _viewer.setInput(root); - } - updateOutput(); - } - } - - /* - * Lock view from updates since the compile has ended - */ - public void setEnableUpdates(boolean enable) - { - if (!enable) - { - // do one last refresh to make sure - // last compile got shown - updateOutput(); - } - _enableUpdates= enable; - } - - public void systemResourceChanged(ISystemResourceChangeEvent event) - { - if (event.getType() == ISystemResourceChangeEvents.EVENT_COMMAND_SHELL_FINISHED) - { - Object source = event.getSource(); - if (source instanceof IRemoteCmdSubSystem) - { - Shell shell = RSEUIPlugin.getTheSystemRegistry().getShell(); - //shell.getDisplay().asyncExec(new CommandSubSystemDisconnectedRunnable((RemoteCmdSubSystem) source)); - } - else - if (source instanceof IRemoteCommandShell) - { - // find out if we're listening to this - updateOutput((IRemoteCommandShell) source); - } - } - else - if (event.getType() == ISystemResourceChangeEvents.EVENT_REFRESH) - { - - Object parent = event.getParent(); - if (parent instanceof IRemoteCommandShell) - { - updateOutput((IRemoteCommandShell) parent); - } - } - } - - public void widgetDefaultSelected(SelectionEvent e) - { - widgetSelected(e); - } - - public void widgetSelected(SelectionEvent e) - { - - - } - - - -// ------------------------------- - // ISystemMessageLine interface... - // ------------------------------- - /** - * Clears the currently displayed error message and redisplayes - * the message which was active before the error message was set. - */ - public void clearErrorMessage() - { - _errorMessage = null; - sysErrorMessage = null; - if (_statusLine != null) - _statusLine.setErrorMessage(_errorMessage); - } - /** - * Clears the currently displayed message. - */ - public void clearMessage() - { - _message = null; - if (_statusLine != null) - _statusLine.setMessage(_message); - } - /** - * Get the currently displayed error text. - * @return The error message. If no error message is displayed <code>null</code> is returned. - */ - public String getErrorMessage() - { - return _errorMessage; - } - /** - * Get the currently displayed message. - * @return The message. If no message is displayed <code>null<code> is returned. - */ - public String getMessage() - { - return _message; - } - /** - * Display the given error message. A currently displayed message - * is saved and will be redisplayed when the error message is cleared. - */ - public void setErrorMessage(String message) - { - this._errorMessage = message; - if (_statusLine != null) - _statusLine.setErrorMessage(message); - } - /** - * Get the currently displayed error text. - * @return The error message. If no error message is displayed <code>null</code> is returned. - */ - public SystemMessage getSystemErrorMessage() - { - return sysErrorMessage; - } - - /** - * Display the given error message. A currently displayed message - * is saved and will be redisplayed when the error message is cleared. - */ - public void setErrorMessage(SystemMessage message) - { - sysErrorMessage = message; - setErrorMessage(message.getLevelOneText()); - } - /** - * Display the given error message. A currently displayed message - * is saved and will be redisplayed when the error message is cleared. - */ - public void setErrorMessage(Throwable exc) - { - setErrorMessage(exc.getMessage()); - } - - /** - * Set the message text. If the message line currently displays an error, - * the message is stored and will be shown after a call to clearErrorMessage - */ - public void setMessage(String message) - { - this._message = message; - if (_statusLine != null) - _statusLine.setMessage(message); - } - /** - *If the message line currently displays an error, - * the message is stored and will be shown after a call to clearErrorMessage - */ - public void setMessage(SystemMessage message) - { - setMessage(message.getLevelOneText()); - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemBuildErrorViewProvider.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemBuildErrorViewProvider.java deleted file mode 100644 index 86ae7778a..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemBuildErrorViewProvider.java +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import java.util.ArrayList; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.rse.core.subsystems.IRemoteLineReference; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteError; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteOutput; -import org.eclipse.rse.ui.view.ISystemViewElementAdapter; -import org.eclipse.rse.ui.view.SystemTableViewProvider; - - - -/** - * This is the content and label provider for the SystemTableView. - * This class is used both to populate the SystemTableView but also - * to resolve the icon and labels for the cells in the table. - * - */ -public class SystemBuildErrorViewProvider extends SystemTableViewProvider -{ - - private int _offset = 0; - private Object[] _unfilteredResults = null; - - public SystemBuildErrorViewProvider() - { - super(); - } - - - public void inputChanged(Viewer visualPart, Object oldInput, Object newInput) - { - if (newInput instanceof IRemoteCommandShell) - { - IRemoteCommandShell cmd = (IRemoteCommandShell)newInput; - Object[] output = cmd.listOutput(); - if (_offset == 0) - setOffset(output.length); - } - else if (newInput instanceof IRemoteOutput) - { - IRemoteOutput output = (IRemoteOutput)newInput; - IRemoteCommandShell cmd = (IRemoteCommandShell)output.getParent(); - setOffset(output.getIndex()); - } - else if (newInput instanceof IRemoteLineReference) - { - IRemoteLineReference output = (IRemoteLineReference)newInput; - IRemoteCommandShell cmd = (IRemoteCommandShell)output.getParent(); - //setOffset(output.getIndex()); - } - } - - - public void setOffset(int offset) - { - _offset = offset; - } - - public void moveOffsetToEnd() - { - if (_unfilteredResults != null) - { - _offset = _unfilteredResults.length; - } - } - - public Object[] getElements(Object object) - { - Object[] results = null; - if (object == _lastObject && _lastResults != null) - { - return _lastResults; - } - else - if (object instanceof IAdaptable) - { - ISystemViewElementAdapter adapter = getAdapterFor(object); - if (adapter != null) - { - results = adapter.getChildren(object); - - ArrayList filterredResults = new ArrayList(); - for (int i = _offset+ 1; i <results.length;i++) - { - if (results[i] instanceof IRemoteError) - { - filterredResults.add(results[i]); - } - } - - _lastResults = filterredResults.toArray();//results; - _unfilteredResults = results; - _lastObject = object; - } - } - if (results == null) - { - return new Object[0]; - } - - return _lastResults; - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandEditor.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandEditor.java deleted file mode 100644 index cf1bd62bb..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandEditor.java +++ /dev/null @@ -1,504 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 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) - fix 158765: content assist miss disables enter - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Vector; - -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.GroupMarker; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.text.Document; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextListener; -import org.eclipse.jface.text.ITextOperationTarget; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.IWidgetTokenKeeper; -import org.eclipse.jface.text.TextEvent; -import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.SystemResources; -import org.eclipse.rse.ui.validators.ISystemValidator; -import org.eclipse.rse.ui.validators.ValidatorUserActionCommand; -import org.eclipse.rse.ui.view.SystemViewMenuListener; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.custom.VerifyKeyListener; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.texteditor.ITextEditorActionConstants; -import org.eclipse.ui.texteditor.IUpdate; - - - -/** - * Class used for constructing a command editor widget with - * UDA substitution variable completion - */ -public class SystemCommandEditor extends SourceViewer -{ - protected boolean menuListenerAdded; - private Map fGlobalActions = new HashMap(10); - private java.util.List fSelectionActions = new ArrayList(3); - protected ISystemValidator cmdValidator; - protected boolean ignoreChanges; - private String contentAssistText; - private boolean isInCodeAssist = false; - private IViewSite _site; - private Vector listeners = new Vector(); - - private TextViewerAction _undoAction = null; - private TextViewerAction _cutAction = null; - private TextViewerAction _copyAction = null; - private TextViewerAction _pasteAction = null; - private TextViewerAction _selectAllAction = null; - private TextViewerAction _caAction = null; - - /** - * Constructor for the editor - * Create the editor widget - */ - public SystemCommandEditor( - IViewSite site, - Composite parent, - int attributes, - int columnSpan, - SourceViewerConfiguration sourceViewerConfiguration, - String cmd, - String contentAssistText) - { - super(parent, null, attributes); - this.contentAssistText = contentAssistText; - _site = site; - init(columnSpan, sourceViewerConfiguration, cmd); - } - private void init(int columnSpan, SourceViewerConfiguration sourceViewerConfiguration, String cmd) - { - if (cmdValidator == null) - { - setCommandValidator(new ValidatorUserActionCommand()); - } - IDocument document = new Document(); - configure(sourceViewerConfiguration); - setEditable(true); - setDocument(document); - Control control = getControl(); - GridData data = new GridData(GridData.FILL_BOTH); - data.horizontalSpan = columnSpan; - data.widthHint = 200; - data.heightHint = 45; - control.setLayoutData(data); - document.set(cmd); - addSelectionChangedListener(new ISelectionChangedListener() - { - public void selectionChanged(SelectionChangedEvent event) - { - updateSelectionDependentActions(); - } - }); - addTextListener(new ITextListener() - { - public void textChanged(TextEvent event) - { - updateUndoAction(); - if (ignoreChanges || !getTextWidget().isEnabled()) - return; - String cmdText = getCommandText(); - updateSelectionDependentActions(); // defect 46369 ... just in case - _selectAllAction.setEnabled(cmdText.length() > 0); // defect 46369 - SystemMessage errorMessage = validateCommand(); - fireModifyEvents(cmdText, errorMessage); - } - }); - getTextWidget().addKeyListener(new KeyAdapter() - { - public void keyReleased(KeyEvent e) - { - - if (!e.doit) - return; - - if (e.stateMask == SWT.CTRL) - { - // DKM - using this now since SWT isn't providing statemask with verify key events - switch (e.character) - { - case ' ' : - //bug 158765: enter may be disabled only when the widget is shown, - //not if content assist is requested (since results may be empty) - //setInCodeAssist(true); - doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); - //e.doit = false; - break; - - case 'z' - 'a' + 1 : - // CTRL-Z - doOperation(ITextOperationTarget.UNDO); - //e.doit = false; - break; - } - } - - } - }); - prependVerifyKeyListener(new VerifyKeyListener() - { - public void verifyKey(VerifyEvent event) - { - handleVerifyKeyPressed(event); - } - }); - initializeActions(); - } - public String getCommandText() - { - return getDocument().get().trim(); - } - - public String getSelectedText() - { - return getTextWidget().getSelectionText(); - } - /** - * Add a modify listener - */ - public void addModifyListener(ISystemCommandTextModifyListener listener) - { - listeners.add(listener); - } - /** - * Remove a modify listener - */ - public void removeModifyListener(ISystemCommandTextModifyListener listener) - { - listeners.remove(listener); - } - /** - * Fire an event to listeners - */ - private void fireModifyEvents(String cmdText, SystemMessage errorMessage) - { - for (int idx = 0; idx < listeners.size(); idx++) - ((ISystemCommandTextModifyListener) listeners.elementAt(idx)).commandModified(cmdText, errorMessage); - } - /** - * Turn on or off event ignoring flag - */ - public void setIgnoreChanges(boolean ignore) - { - ignoreChanges = ignore; - } - /** - * Validate command input - */ - public SystemMessage validateCommand() - { - if (cmdValidator != null) - return cmdValidator.validate(getCommandText()); - else - return null; - } - /** - * Set the command validator to validate contents per keystroke - */ - public void setCommandValidator(ISystemValidator cmdValidator) - { - this.cmdValidator = cmdValidator; - } - private void fillContextMenu(IMenuManager menu) - { - menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_UNDO)); - menu.appendToGroup( - ITextEditorActionConstants.GROUP_UNDO, - (IAction) fGlobalActions.get(ITextEditorActionConstants.UNDO)); - menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT)); - menu.appendToGroup( - ITextEditorActionConstants.GROUP_EDIT, - (IAction) fGlobalActions.get(ITextEditorActionConstants.CUT)); - menu.appendToGroup( - ITextEditorActionConstants.GROUP_EDIT, - (IAction) fGlobalActions.get(ITextEditorActionConstants.COPY)); - menu.appendToGroup( - ITextEditorActionConstants.GROUP_EDIT, - (IAction) fGlobalActions.get(ITextEditorActionConstants.PASTE)); - menu.appendToGroup( - ITextEditorActionConstants.GROUP_EDIT, - (IAction) fGlobalActions.get(ITextEditorActionConstants.SELECT_ALL)); - menu.add(new Separator("group.generate")); - menu.appendToGroup("group.generate", (IAction) fGlobalActions.get("ContentAssistProposal")); //$NON-NLS-1$ - } - private IActionBars getActionBars() - { - if (_site != null) - { - IActionBars actionBars = _site.getActionBars(); - return actionBars; - } - return null; - } - public void setViewSite(IViewSite site) - { - _site = site; - } - private void initializeActions() - { - _undoAction = new TextViewerAction(this, UNDO); - _undoAction.setText(SystemResources.ACTION_UNDO_LABEL); - fGlobalActions.put(ITextEditorActionConstants.UNDO, _undoAction); - _undoAction.setEnabled(false); // defect 46369 - _cutAction = new TextViewerAction(this, CUT); - _cutAction.setText(SystemResources.ACTION_CUT_LABEL); - fGlobalActions.put(ITextEditorActionConstants.CUT, _cutAction); - _cutAction.setEnabled(false); // defect 46369 - _copyAction = new TextViewerAction(this, COPY); - _copyAction.setText(SystemResources.ACTION_COPY_LABEL); - fGlobalActions.put(ITextEditorActionConstants.COPY, _copyAction); - _copyAction.setEnabled(false); // defect 46369 - _pasteAction = new TextViewerAction(this, PASTE); - _pasteAction.setText(SystemResources.ACTION_PASTE_LABEL); - fGlobalActions.put(ITextEditorActionConstants.PASTE, _pasteAction); - _pasteAction.setEnabled(false); // defect 46369 - if (_pasteAction != null) { - _pasteAction.update(); - } - _selectAllAction = new TextViewerAction(this, SELECT_ALL); - _selectAllAction.setText(SystemResources.ACTION_SELECT_ALL_LABEL); - fGlobalActions.put(ITextEditorActionConstants.SELECT_ALL, _selectAllAction); - _selectAllAction.setEnabled(false); // defect 46369 - _caAction = new TextViewerAction(this, CONTENTASSIST_PROPOSALS); - _caAction.setText(contentAssistText); - _caAction.setEnabled(true); - fGlobalActions.put("ContentAssistProposal", _caAction); //$NON-NLS-1$ - - - setActionHandlers(); - - fSelectionActions.add(ITextEditorActionConstants.CUT); - fSelectionActions.add(ITextEditorActionConstants.COPY); - fSelectionActions.add(ITextEditorActionConstants.PASTE); - // create context menu - MenuManager manager = new MenuManager(); - manager.setRemoveAllWhenShown(true); - manager.addMenuListener(new IMenuListener() - { - public void menuAboutToShow(IMenuManager mgr) - { - fillContextMenu(mgr); - if (!menuListenerAdded) - { - if (mgr instanceof MenuManager) - { - Menu m = ((MenuManager) mgr).getMenu(); - if (m != null) - { - menuListenerAdded = true; - SystemViewMenuListener ml = new SystemViewMenuListener(); - //if (messageLine != null) - // ml.setShowToolTipText(true, messageLine); - m.addMenuListener(ml); - } - } - } - } - }); - StyledText text = this.getTextWidget(); - Menu menu = manager.createContextMenu(text); - text.setMenu(menu); - } - - public void setActionHandlers() - { - IActionBars actionBars = getActionBars(); - if (actionBars != null) - { - actionBars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, _undoAction); - actionBars.setGlobalActionHandler(ITextEditorActionConstants.CUT, _cutAction); - actionBars.setGlobalActionHandler(ITextEditorActionConstants.COPY, _copyAction); - actionBars.setGlobalActionHandler(ITextEditorActionConstants.PASTE, _pasteAction); - actionBars.setGlobalActionHandler(ITextEditorActionConstants.SELECT_ALL, _selectAllAction); - actionBars.updateActionBars(); - } - } - - protected void updateSelectionDependentActions() - { - Iterator iterator = fSelectionActions.iterator(); - while (iterator.hasNext()) - updateAction((String) iterator.next()); - } - protected void updateUndoAction() - { - Object obj = fGlobalActions.get(ITextEditorActionConstants.UNDO); - if (obj instanceof IAction) - { - IAction action = (IAction) obj; - if (action instanceof IUpdate) - ((IUpdate) action).update(); - } - } - protected void updateAction(String actionId) - { - Object obj = fGlobalActions.get(actionId); - if (obj instanceof IAction) - { - IAction action = (IAction) obj; - if (action instanceof IUpdate) - ((IUpdate) action).update(); - } - } - private void handleVerifyKeyPressed(VerifyEvent event) - { - if (!event.doit) - return; - - // DKM - moved to key press handler since for some reason SWT doesn't provide statemask anymore - /* - if (event.character == 0 && (event.keyCode & SWT.KEYCODE_BIT) == 0) - { - return; - } - switch (event.character) - { - case ' ' : - doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); - event.doit = false; - break; - // CTRL-Z - case (int) 'z' - (int) 'a' + 1 : - doOperation(ITextOperationTarget.UNDO); - event.doit = false; - break; - } - */ - } - - - public void setInCodeAssist(boolean flag) - { - isInCodeAssist = flag; - } - - public boolean requestWidgetToken(IWidgetTokenKeeper requester) - { - boolean result = super.requestWidgetToken(requester); - if (result) - { - setInCodeAssist(true); - } - return result; - } - public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority) - { - boolean result = super.requestWidgetToken(requester, priority); - if (result) { - setInCodeAssist(true); - } - return result; - } - public void releaseWidgetToken(IWidgetTokenKeeper tokenKeeper) - { - super.releaseWidgetToken(tokenKeeper); - DelayedIsInCodeAssistUntoggler untoggler = new DelayedIsInCodeAssistUntoggler(); - untoggler.start(); - } - public boolean isInCodeAssist() - { - return isInCodeAssist; - } - private class DelayedIsInCodeAssistUntoggler extends Thread - { - public void run() - { - try - { - Thread.sleep(200); - } - catch (InterruptedException e) - { - } - setInCodeAssist(false); - } - } - private static class TextViewerAction extends Action implements IUpdate - { - private int fOperationCode = -1; - private ITextOperationTarget fOperationTarget; - public TextViewerAction(ITextViewer viewer, int operationCode) - { - fOperationCode = operationCode; - fOperationTarget = viewer.getTextOperationTarget(); - update(); - } - /** - * Updates the enabled state of the action. - * Fires a property change if the enabled state changes. - * - * @see Action#firePropertyChange(String, Object, Object) - */ - public void update() - { - boolean wasEnabled = isEnabled(); - boolean isEnabled = (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode)); - setEnabled(isEnabled); - if (wasEnabled != isEnabled) - { - firePropertyChange( - ENABLED, - wasEnabled ? Boolean.TRUE : Boolean.FALSE, - isEnabled ? Boolean.TRUE : Boolean.FALSE); - } - } - /** - * @see Action#run() - */ - public void run() - { - if (fOperationCode != -1 && fOperationTarget != null) - { - fOperationTarget.doOperation(fOperationCode); - } - } - } - - public void doOperation(int operation) - { - //bug 158765: enter may be disabled only when the widget is shown, - //not if content assist is requested (since results may be empty) - //if (operation == CONTENTASSIST_PROPOSALS) - //{ - // isInCodeAssist = true; - //} - super.doOperation(operation); - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandsUI.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandsUI.java deleted file mode 100644 index 2a7abf3c4..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandsUI.java +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2003, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import org.eclipse.rse.core.SystemBasePlugin; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; - - -/** - * A singleton class for dealing with remote commands - */ -public class SystemCommandsUI -{ - - - // singleton instance - private static SystemCommandsUI instance; - private static SystemCommandsViewPart _viewPart; - private static SystemBuildErrorViewPart _errorPart; - - public static final String COMMANDS_VIEW_ID = SystemCommandsViewPart.ID; - public static final String BUILD_ERROR_VIEW_ID = SystemBuildErrorViewPart.ID; - - private SystemCommandsUI() - { - super(); - } - - /** - * Get the singleton instance. - * @return the singleton object of this type - */ - public static SystemCommandsUI getInstance() - { - if (instance == null) - { - instance = new SystemCommandsUI(); - } - - return instance; - } - - public SystemBuildErrorViewPart activateBuildErrorView() - { - try - { - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - _errorPart = (SystemBuildErrorViewPart) page.showView(SystemCommandsUI.BUILD_ERROR_VIEW_ID); - page.bringToTop(_errorPart); - } - catch (PartInitException e) - { - SystemBasePlugin.logError("Can not open build error view", e); - } - - return _errorPart; - } - - public SystemCommandsViewPart activateCommandsView() - { - try - { - IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - _viewPart = (SystemCommandsViewPart) page.showView(SystemCommandsUI.COMMANDS_VIEW_ID); - page.bringToTop(_viewPart); - } - catch (PartInitException e) - { - e.printStackTrace(); - SystemBasePlugin.logError("Can not open commands view", e); - } - - return _viewPart; - } - - public static SystemBuildErrorViewPart getBuildErrorView() - { - return _errorPart; - } - - public static SystemCommandsViewPart getCommandsView() - { - return _viewPart; - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandsView.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandsView.java deleted file mode 100644 index 1c40d0cc4..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandsView.java +++ /dev/null @@ -1,315 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.rse.model.ISystemResourceChangeEvent; -import org.eclipse.rse.model.ISystemResourceChangeEvents; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteOutput; -import org.eclipse.rse.ui.ISystemThemeConstants; -import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.rse.ui.view.SystemTableView; -import org.eclipse.rse.ui.view.SystemTableViewProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.widgets.Item; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.themes.IThemeManager; - -public class SystemCommandsView extends SystemTableView implements ISystemThemeConstants, IPropertyChangeListener -{ - public class CommandsViewFilter extends ViewerFilter - { - public boolean select(Viewer viewer, Object parent, Object element) - { - if (element instanceof IRemoteOutput) - { - IRemoteOutput remoteOutput = (IRemoteOutput) element; - if (remoteOutput.getText().indexOf("BEGIN-END-TAG:") > -1) - { - return false; - } - } - return true; - } - } - - private static int MAX_BUFFER = 20000; - private Color _errColor; - private Color _outColor; - private Color _infColor; - private Color _warColor; - private Color _prmColor; - private int _maxCharWidth = 256; - - public SystemCommandsView(Table table, ISystemMessageLine msgLine) - { - super(table, msgLine); - addFilter(new CommandsViewFilter()); - updateTheme(); - int[] colWidths = new int[1]; - colWidths[0] = 1000; - setLastColumnWidths(colWidths); - } - - // overridden to produce custom provider - protected SystemTableViewProvider getProvider() - { - if (_provider == null) - { - _provider = new SystemCommandsViewProvider(); - } - return _provider; - } - - public void propertyChange(PropertyChangeEvent e) - { - // for now always update - updateTheme(); - } - - public void updateTheme() - { - Table table = getTable(); - if (table != null) - { - IThemeManager mgr = PlatformUI.getWorkbench().getThemeManager(); - Color bg = mgr.getCurrentTheme().getColorRegistry().get(REMOTE_COMMANDS_VIEW_BG_COLOR); - Color fg = mgr.getCurrentTheme().getColorRegistry().get(REMOTE_COMMANDS_VIEW_FG_COLOR); - Font fFont = mgr.getCurrentTheme().getFontRegistry().get(REMOTE_COMMANDS_VIEW_FONT); - table.setBackground(bg); - table.setForeground(fg); - table.setFont(fFont); - if (_errColor == null) - { - mgr.addPropertyChangeListener(this); - } - _errColor = mgr.getCurrentTheme().getColorRegistry().get(MESSAGE_ERROR_COLOR); - _outColor = mgr.getCurrentTheme().getColorRegistry().get(REMOTE_COMMANDS_VIEW_FG_COLOR); - _infColor = mgr.getCurrentTheme().getColorRegistry().get(MESSAGE_INFORMATION_COLOR); - _warColor = mgr.getCurrentTheme().getColorRegistry().get(MESSAGE_WARNING_COLOR); - _prmColor = mgr.getCurrentTheme().getColorRegistry().get(REMOTE_COMMANDS_VIEW_PROMPT_COLOR); - } - } - - public void refresh() - { - super.refresh(); - Table table = getTable(); - if (table != null && table.getItemCount() > 0) - { - TableItem lastItem = table.getItem(table.getItemCount() - 1); - table.showItem(lastItem); - } - } - - public synchronized void updateChildren() - { - // updateTheme(); - Object input = getInput(); - if (input instanceof IRemoteCommandShell) - { - SystemTableViewProvider provider = (SystemTableViewProvider) getContentProvider(); - Table table = getTable(); - Object[] children = provider.getChildren(input); - if (children != null && children.length > 0) - { - boolean needsLayout = false; - TableItem[] tableItems = table.getItems(); - if (tableItems == null || tableItems.length == 0) - { - needsLayout = true; - } else - { - int widest = provider.getMaxCharsInColumnZero(); - if (widest > _maxCharWidth) - { - needsLayout = true; - _maxCharWidth = widest; - } - } - synchronized (children) - { - int index = table.getItemCount(); - if (index > MAX_BUFFER) - { - table.setRedraw(false); - clearFirstItems(children, index - (MAX_BUFFER / 2)); - table.setRedraw(true); - provider.flushCache(); - internalRefresh(input); - } else - { - // update previous item - /* - if (index > 0 && (children.length > index - 1)) - { - Object lastObject = children[index - 1]; - - TableItem lastItem = table.getItem(index - 1); - if (lastObject != null && lastItem != null) - { - colorItem(lastItem, lastObject); - updateItem(lastItem, lastObject); - } - }*/ - for (int i = index; i < children.length; i++) - { - Object child = children[i]; - if (child != null) - { - boolean isVisible = true; - if (isVisible) - { - TableItem newItem = (TableItem) newItem(table, SWT.NONE, index); - colorItem(newItem, child); - updateItem(newItem, child); - index++; - } - } - } - if (index > 0) - { - table.setTopIndex(index - 1); - } - } - } - if (needsLayout) - { - computeLayout(true); - } - } - } - } - - private void colorItem(TableItem newItem, Object child) - { - if (child instanceof IRemoteOutput) - { - IRemoteOutput rmtOutput = (IRemoteOutput) child; - String type = rmtOutput.getType(); - if (type.equals("stderr") || type.equals("error")) - { - newItem.setForeground(_errColor); - } else if (type.equals("warning")) - { - newItem.setForeground(_warColor); - } else if (type.equals("informational")) - { - newItem.setForeground(_infColor); - } else if (type.equals("prompt")) - { - newItem.setForeground(_prmColor); - } else - { - newItem.setForeground(_outColor); - } - } - } - - public void clearAllItems() - { - Object input = getInput(); - SystemTableViewProvider provider = (SystemTableViewProvider) getContentProvider(); - Object[] children = provider.getChildren(input); - clearFirstItems(children, children.length); - } - - public void dispose() - { - IThemeManager mgr = PlatformUI.getWorkbench().getThemeManager(); - mgr.removePropertyChangeListener(this); - } - - private void clearFirstItems(Object[] children, int items) - { - Table table = getTable(); - table.setRedraw(false); - synchronized (table) - { - if (items > 0) - { - int count = table.getItemCount(); - if (count >= items) - { - table.remove(0, items - 1); - IRemoteCommandShell input = (IRemoteCommandShell) getInput(); - // remove items from command - for (int i = 0; i < items && i < children.length; i++) - { - Object item = children[i]; - input.removeOutput(item); - } - } - } - } - table.setRedraw(true); - } - - protected Item newItem(Widget parent, int flags, int ix) - { - if (parent instanceof Table) - { - return new TableItem((Table) parent, flags); - } - return null; - } - - public void systemResourceChanged(ISystemResourceChangeEvent event) - { - Object child = event.getSource(); - if (event.getType() == ISystemResourceChangeEvents.EVENT_REFRESH) - { - if (child == getInput()) - { - SystemTableViewProvider provider = (SystemTableViewProvider) getContentProvider(); - if (provider != null) - { - provider.flushCache(); - updateChildren(); - return; - } - } - } else if (event.getType() == ISystemResourceChangeEvents.EVENT_ICON_CHANGE) - { - try - { - Widget w = findItem(child); - if (w != null) - { - updateItem(w, child); - } - } catch (Exception e) - { - } - } - //super.systemResourceChanged(event); - } - - protected Object getParentForContent(Object element) - { - return getAdapter(element).getParent(element); - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandsViewPart.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandsViewPart.java deleted file mode 100644 index ea103c5aa..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandsViewPart.java +++ /dev/null @@ -1,887 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.rse.core.model.IHost; -import org.eclipse.rse.core.model.ISystemRegistry; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.model.ISystemResourceChangeEvent; -import org.eclipse.rse.model.ISystemResourceChangeEvents; -import org.eclipse.rse.model.ISystemResourceChangeListener; -import org.eclipse.rse.model.SystemRegistry; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.shells.ui.RemoteCommandHelpers; -import org.eclipse.rse.shells.ui.ShellResources; -import org.eclipse.rse.shells.ui.actions.SystemBaseShellAction; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemResources; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.actions.SystemBaseDummyAction; -import org.eclipse.rse.ui.actions.SystemTablePrintAction; -import org.eclipse.rse.ui.messages.ISystemMessageLine; -import org.eclipse.rse.ui.view.IRSEViewPart; -import org.eclipse.rse.ui.view.ISystemViewElementAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.ISelectionListener; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.part.CellEditorActionHandler; -import org.eclipse.ui.part.ViewPart; - - - -/** - * This is the desktop view wrapper of the System View viewer. - */ -public class SystemCommandsViewPart - extends ViewPart - implements - ISelectionListener, - SelectionListener, - ISelectionChangedListener, - ISystemResourceChangeListener, - IRSEViewPart, - IMenuListener, - ISystemMessageLine -{ - - - class RestoreStateRunnable implements Runnable - { - public void run() - { - initDefaultCommandShells(); - } - } - - class BrowseAction extends Action - { - public BrowseAction(String label, ImageDescriptor des) - { - super(label, des); - - setToolTipText(label); - } - - public void checkEnabledState() - { - if (_folder != null && _folder.getInput() != null) - { - setEnabled(true); - } - else - { - setEnabled(false); - } - } - - public void run() - { - } - } - - - - - public class ShellAction extends BrowseAction - { - private IRemoteCmdSubSystem _cmdSubSystem; - - public ShellAction(String title, ImageDescriptor image, IRemoteCmdSubSystem cmdSubSystem) - { - super(title, image); - - setToolTipText(ShellResources.ACTION_RUN_SHELL_TOOLTIP); - _cmdSubSystem = cmdSubSystem; - } - - public void checkEnabledState() - { - setEnabled(_cmdSubSystem.canRunShell()); - } - - public void run() - { - try - { - IRemoteCommandShell cmd = _cmdSubSystem.runShell( null); - if (cmd != null) - { - showInView(cmd); - } - } - catch (Exception e) - { - e.printStackTrace(); - } - - } - - private void showInView(IRemoteCommandShell cmd) - { - SystemCommandsUI commandsUI = SystemCommandsUI.getInstance(); - SystemCommandsViewPart cmdsPart = commandsUI.activateCommandsView(); - cmdsPart.updateOutput(cmd); - } - } - - public class ClearAction extends BrowseAction - { - public ClearAction() - { - - super(SystemResources.ACTION_CLEAR_LABEL, - RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CLEAR_ID)); - - ImageDescriptor des = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_CLEAR_ID); - - setImageDescriptor(des); - - setEnabled(false); - // TODO DKM - get help for this! - //PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.CLEAR_CONSOLE_ACTION); - } - - public void checkEnabledState() - { - Object input = _folder.getInput(); - if (input != null) - { - if (input instanceof IRemoteCommandShell) - { - setEnabled(((IRemoteCommandShell) input).isActive()); - return; - } - } - - setEnabled(false); - } - - public void run() - { - if (_folder.getInput() != null) - { - clear(); - } - } - - // clear contents of the current command viewer - private void clear() - { - _folder.getViewer().clearAllItems(); - } - } - - - public class CommandSubSystemDisconnectedRunnable implements Runnable - { - private IRemoteCmdSubSystem _subsystem; - public CommandSubSystemDisconnectedRunnable(IRemoteCmdSubSystem subsystem) - { - _subsystem = subsystem; - } - - public void run() - { - IRemoteCommandShell[] cmds = _subsystem.getShells(); - if (cmds != null) - { - for (int i = 0; i < cmds.length; i++) - { - _folder.remove(cmds[i]); - } - } - } - } - - public class CommandMenuManager extends MenuManager - { - public CommandMenuManager() - { - super(ShellResources.ACTION_LAUNCH_LABEL); - } - } - - public class CommandSubmenuManager extends MenuManager - { - private IRemoteCmdSubSystem[] _subsystems; - public CommandSubmenuManager(IHost connection, IRemoteCmdSubSystem[] subsystems) - { - super(connection.getAliasName()); - _subsystems = subsystems; - } - - public IRemoteCmdSubSystem[] getSubSystems() - { - return _subsystems; - } - } - - private ClearAction _clearAction = null; - - - - private List _shellActions = null; - - private SystemTablePrintAction _printTableAction = null; - private CommandsViewWorkbook _folder = null; - private IRemoteCommandShell _lastSelected = null; - private CellEditorActionHandler _editorActionHandler = null; - - // for ISystemMessageLine - private String _message, _errorMessage; - private SystemMessage sysErrorMessage; - private IStatusLineManager _statusLine = null; - - // constants - public static final String ID = "org.eclipse.rse.shells.ui.view.commandsView"; //$NON-NLS-1$ - // matches id in plugin.xml, view tag - - public void setFocus() - { - _folder.showCurrentPage(); - } - - public Shell getShell() - { - return _folder.getShell(); - } - - public Viewer getRSEViewer() - { - return _folder.getViewer(); - } - - public CellEditorActionHandler getEditorActionHandler() - { - if (_editorActionHandler == null) - { - _editorActionHandler = new CellEditorActionHandler(getViewSite().getActionBars()); - } - return _editorActionHandler; - } - - public void createPartControl(Composite parent) - { - _folder = new CommandsViewWorkbook(parent, this); - _folder.getFolder().addSelectionListener(this); - - ISelectionService selectionService = getSite().getWorkbenchWindow().getSelectionService(); - selectionService.addSelectionListener(this); - - - SystemWidgetHelpers.setHelp(_folder, RSEUIPlugin.HELPPREFIX + "ucmd0000"); //$NON-NLS-1$ - - SystemRegistry registry = RSEUIPlugin.getTheSystemRegistry(); - - - - registry.addSystemResourceChangeListener(this); - - RestoreStateRunnable restore = new RestoreStateRunnable(); - Display.getCurrent().asyncExec(restore); - - fillLocalToolBar(); - } - - public void selectionChanged(IWorkbenchPart part, ISelection sel) - { - } - - public void dispose() - { - ISelectionService selectionService = getSite().getWorkbenchWindow().getSelectionService(); - selectionService.removeSelectionListener(this); - _folder.dispose(); - - SystemRegistry registry = RSEUIPlugin.getTheSystemRegistry(); - registry.removeSystemResourceChangeListener(this); - super.dispose(); - } - - public void updateActionStates() - { - if (_shellActions == null || (_shellActions.size() == 0 && _folder != null && _folder.getInput() != null)) - fillLocalToolBar(); - - if (_folder != null && _folder.getInput() != null) - { - IRemoteCommandShell currentSelected = (IRemoteCommandShell)_folder.getInput(); - if (currentSelected != null) - { - if (currentSelected != _lastSelected) - { - // reset the actions - IActionBars actionBars = getViewSite().getActionBars(); - IToolBarManager toolBarManager = actionBars.getToolBarManager(); - updateShellActions(); - addToolBarItems(toolBarManager); - } - _lastSelected = currentSelected; - - _folder.updateActionStates(); - CommandsViewPage page = _folder.getCurrentTabItem(); - if (page != null) - { - _printTableAction.setTableView(page.getTitle(), page.getViewer()); - } - else - { - _printTableAction.setTableView("", null); //$NON-NLS-1$ - } - - _clearAction.checkEnabledState(); - - StructuredSelection cmdSelection = new StructuredSelection(_folder.getInput()); - for (int i =0; i < _shellActions.size(); i++) - { - Object action = _shellActions.get(i); - if (action instanceof SystemBaseShellAction) - { - SystemBaseShellAction shellAction = (SystemBaseShellAction)action; - shellAction.setEnabled(shellAction.updateSelection(cmdSelection)); - } - } - - _printTableAction.checkEnabledState(); - } - } - - - } - - protected void updateShellActions() - { - if (_folder != null && _folder.getInput() != null) - { - IRemoteCommandShell cmdShell = (IRemoteCommandShell)_folder.getInput(); - SystemViewRemoteOutputAdapter adapter = (SystemViewRemoteOutputAdapter)((IAdaptable)cmdShell).getAdapter(ISystemViewElementAdapter.class); - - _shellActions = adapter.getShellActions(cmdShell.getCommandSubSystem().getParentRemoteCmdSubSystemConfiguration()); - } - else if (_shellActions != null) - { - _shellActions.clear(); - } - else - { - _shellActions = new ArrayList(); - } - } - - public void fillLocalToolBar() - { - boolean firstCall = false; - if (_folder != null ) - { - firstCall = (_shellActions == null || _shellActions.size() == 0); - - if (firstCall) { - updateShellActions(); - } - - updateActionStates(); - - IActionBars actionBars = getViewSite().getActionBars(); - - if (firstCall) - { - _clearAction = new ClearAction(); - _printTableAction = new SystemTablePrintAction(getTitle(), null); - IMenuManager menuManager = actionBars.getMenuManager(); - addMenuItems(menuManager); - _statusLine = actionBars.getStatusLineManager(); - } - IToolBarManager toolBarManager = actionBars.getToolBarManager(); - addToolBarItems(toolBarManager); - } - } - - private void addToolBarItems(IToolBarManager toolBarManager) - { - toolBarManager.removeAll(); - if (_clearAction != null) - { - toolBarManager.add(_clearAction); - } - if (_shellActions != null && _shellActions.size() > 0) - { - for (int i =0; i < _shellActions.size(); i++) - { - Object shellAction = _shellActions.get(i); - if (shellAction instanceof IContributionItem) - { - toolBarManager.add((IContributionItem)shellAction); - } - else if (shellAction instanceof IAction) - { - toolBarManager.add((IAction)shellAction); - } - } - } - toolBarManager.update(true); - } - - private void addMenuItems(IMenuManager menuManager) - { - menuManager.removeAll(); - - IMenuManager launchMenu = new CommandMenuManager(); - - launchMenu.add(new SystemBaseDummyAction()); - launchMenu.addMenuListener(this); - launchMenu.setRemoveAllWhenShown(true); - menuManager.add(launchMenu); - menuManager.addMenuListener(this); - - menuManager.add(new Separator()); - menuManager.add(_printTableAction); - } - - public void menuAboutToShow(IMenuManager menuManager) - { - if (menuManager instanceof CommandSubmenuManager) - { - IRemoteCmdSubSystem[] cmdSubSystems = ((CommandSubmenuManager)menuManager).getSubSystems(); - for (int c = 0; c < cmdSubSystems.length; c++) - { - IRemoteCmdSubSystem cmdSubSystem = cmdSubSystems[c]; - - if (cmdSubSystem != null && cmdSubSystem.canRunShell()) - { - String name = cmdSubSystem.getName(); - ISystemViewElementAdapter ssva = - (ISystemViewElementAdapter) ((IAdaptable) cmdSubSystem).getAdapter( - ISystemViewElementAdapter.class); - ImageDescriptor icon = ssva.getImageDescriptor(cmdSubSystem); - ShellAction action = - new ShellAction( - name, - icon, - cmdSubSystem); - menuManager.add(action); - } - } - } - else - { - boolean hasItem = false; - - ISystemRegistry registry = RSEUIPlugin.getTheSystemRegistry(); - IHost[] connections = registry.getHosts(); - - for (int i = 0; i < connections.length; i++) - { - IHost connection = connections[i]; - if (registry.isAnySubSystemConnected(connection) || connection.getSystemType().equals("Local")) //$NON-NLS-1$ - { - IRemoteCmdSubSystem[] cmdSubSystems = RemoteCommandHelpers.getCmdSubSystems(connection); - if (cmdSubSystems.length == 1) - { - IRemoteCmdSubSystem cmdSubSystem = cmdSubSystems[0]; - if (cmdSubSystem != null && cmdSubSystem.canRunShell()) - { - hasItem = true; - - if (menuManager instanceof CommandMenuManager) - { - ISystemViewElementAdapter va = - (ISystemViewElementAdapter) ((IAdaptable) connection).getAdapter( - ISystemViewElementAdapter.class); - - String name = connection.getAliasName(); - ImageDescriptor icon = va.getImageDescriptor(connection); - - - ShellAction action = - new ShellAction( - name, - icon, - cmdSubSystem); - menuManager.add(action); - } - } - } - else if (cmdSubSystems.length > 1) - { - if (menuManager instanceof CommandMenuManager) - { - /* - ISystemViewElementAdapter va = - (ISystemViewElementAdapter) ((IAdaptable) connection).getAdapter( - ISystemViewElementAdapter.class); - */ - - IMenuManager sublaunchMenu = new CommandSubmenuManager(connection, cmdSubSystems); - sublaunchMenu.add(new SystemBaseDummyAction()); - sublaunchMenu.addMenuListener(this); - sublaunchMenu.setRemoveAllWhenShown(true); - - menuManager.add(sublaunchMenu); - menuManager.addMenuListener(this); - } - - - } - } - } - - if (!(menuManager instanceof CommandMenuManager)) - { - if (!hasItem) - { - if (menuManager.getItems().length > 0) - { - MenuManager lmgr = (MenuManager) menuManager.getItems()[0]; - if (lmgr.getMenu() != null) - { - lmgr.getMenu().getParentItem().setEnabled(false); - } - } - } - else - { - if (menuManager.getItems().length > 0) - { - MenuManager lmgr = (MenuManager) menuManager.getItems()[0]; - if (lmgr.getMenu() != null) - { - lmgr.getMenu().getParentItem().setEnabled(true); - } - } - } - } - } - } - - public void selectionChanged(SelectionChangedEvent e) - { - } - - /** - * Update or create a view tab for the specified command - * If there is no tab for the command, create one. - * - * @param root command to view - * - */ - public void updateOutput(IRemoteCommandShell root) - { - updateOutput(root, true); - } - - private void updateOutput(IRemoteCommandShell root, boolean createTab) - { - if (root != null) - { - _folder.updateOutput(root, createTab); - if (createTab) - updateActionStates(); - } - } - - public void setInput(IAdaptable object) - { - setInput(object, true); - } - - public void setInput(IAdaptable object, boolean updateHistory) - { - _folder.setInput(object); - } - - - protected void initDefaultCommandShells() - { - ISystemRegistry registry = RSEUIPlugin.getTheSystemRegistry(); - IHost[] connections = registry.getHosts(); - CommandsViewPage curpage = _folder.getCurrentTabItem(); - - for (int i = 0; i < connections.length; i++) - { - IHost connection = connections[i]; - if (registry.isAnySubSystemConnected(connection) || connection.getSystemType().equals("Local")) //$NON-NLS-1$ - { - IRemoteCmdSubSystem[] cmdSubSystems = RemoteCommandHelpers.getCmdSubSystems(connection); - if (cmdSubSystems.length > 0) - { - for (int c= 0; c < cmdSubSystems.length; c++) - { - IRemoteCmdSubSystem cmdSubSystem = cmdSubSystems[c]; - - if (cmdSubSystem != null && cmdSubSystem.canRunShell()) - { - restoreCommandShells(cmdSubSystem); - } - } - } - } - } - - if (curpage != null) - { - updateOutput((IRemoteCommandShell)curpage.getInput()); - //curpage.setFocus(); - } - - } - - protected void restoreCommandShells(IRemoteCmdSubSystem cmdSS) - { - - try - { - IRemoteCommandShell[] cmds = cmdSS.getShells(); - if (cmds == null || cmds.length == 0) - { - cmds = cmdSS.restoreShellState(getShell()); - if (cmds!=null) - { - for (int i = 0; i < cmds.length; i++) - { - updateOutput(cmds[i]); - } - } - } - } - catch (Exception e) - { - } - - - } - - - public void systemResourceChanged(ISystemResourceChangeEvent event) - { - if (event.getType() == ISystemResourceChangeEvents.EVENT_COMMAND_SHELL_FINISHED) - { - Object source = event.getSource(); - if (source instanceof IRemoteCmdSubSystem) - { - Shell shell = RSEUIPlugin.getTheSystemRegistry().getShell(); - shell.getDisplay().asyncExec(new CommandSubSystemDisconnectedRunnable((IRemoteCmdSubSystem) source)); - } - else if (source instanceof IRemoteCommandShell) - { - // find out if we're listening to this - - updateOutput((IRemoteCommandShell) source, false); - updateActionStates(); - } - } - - if (event.getType() == ISystemResourceChangeEvents.EVENT_COMMAND_SHELL_REMOVED) - { - Object source = event.getSource(); - if (source instanceof IRemoteCommandShell) - { - updateOutput((IRemoteCommandShell) source, false); - _folder.remove(source); - updateActionStates(); - } - } - else if (event.getType() == ISystemResourceChangeEvents.EVENT_REFRESH) - { - Object parent = event.getParent(); - if (parent instanceof IRemoteCommandShell) - { - updateOutput((IRemoteCommandShell) parent, false); - } - } - else if (event.getType() == ISystemResourceChangeEvents.EVENT_PROPERTY_CHANGE) - { - IRemoteCmdSubSystem cmdSS = null; - Object parent = event.getSource(); - - if (parent instanceof IRemoteFileSubSystem) - { - IRemoteFileSubSystem ss = (IRemoteFileSubSystem)parent; - cmdSS = RemoteCommandHelpers.getCmdSubSystem(ss.getHost()); - } - else if (parent instanceof IRemoteCmdSubSystem) - { - cmdSS = (IRemoteCmdSubSystem)parent; - } - else if (parent instanceof ISubSystem) - { - // DKM - for now assuming only 1 cmd subsystem - //SystemRegistry registry = RSEUIPlugin.getTheSystemRegistry(); - //registry.getCmdSubSystems() - cmdSS = RemoteCommandHelpers.getCmdSubSystem(((ISubSystem)parent).getHost()); - } - if (cmdSS != null) - { - if (cmdSS.isConnected()) - restoreCommandShells(cmdSS); - } - } - else if (event.getType() == ISystemResourceChangeEvents.EVENT_MUST_COLLAPSE) - { - Object source = event.getSource(); - if (source instanceof IRemoteCmdSubSystem) - { - Shell shell = RSEUIPlugin.getTheSystemRegistry().getShell(); - shell.getDisplay().asyncExec(new CommandSubSystemDisconnectedRunnable((IRemoteCmdSubSystem) source)); - } - } - } - - public void widgetDefaultSelected(SelectionEvent e) - { - widgetSelected(e); - } - - public void widgetSelected(SelectionEvent e) - { - Widget source = e.widget; - - if (source == _folder.getFolder()) - { - if (_folder.getInput() != null) - { - updateActionStates(); - } - } - } - - -// ------------------------------- - // ISystemMessageLine interface... - // ------------------------------- - /** - * Clears the currently displayed error message and redisplayes - * the message which was active before the error message was set. - */ - public void clearErrorMessage() - { - _errorMessage = null; - sysErrorMessage = null; - if (_statusLine != null) - _statusLine.setErrorMessage(_errorMessage); - } - /** - * Clears the currently displayed message. - */ - public void clearMessage() - { - _message = null; - if (_statusLine != null) - _statusLine.setMessage(_message); - } - /** - * Get the currently displayed error text. - * @return The error message. If no error message is displayed <code>null</code> is returned. - */ - public String getErrorMessage() - { - return _errorMessage; - } - /** - * Get the currently displayed message. - * @return The message. If no message is displayed <code>null<code> is returned. - */ - public String getMessage() - { - return _message; - } - /** - * Display the given error message. A currently displayed message - * is saved and will be redisplayed when the error message is cleared. - */ - public void setErrorMessage(String message) - { - this._errorMessage = message; - if (_statusLine != null) - _statusLine.setErrorMessage(message); - } - /** - * Get the currently displayed error text. - * @return The error message. If no error message is displayed <code>null</code> is returned. - */ - public SystemMessage getSystemErrorMessage() - { - return sysErrorMessage; - } - - /** - * Display the given error message. A currently displayed message - * is saved and will be redisplayed when the error message is cleared. - */ - public void setErrorMessage(SystemMessage message) - { - sysErrorMessage = message; - setErrorMessage(message.getLevelOneText()); - } - /** - * Display the given error message. A currently displayed message - * is saved and will be redisplayed when the error message is cleared. - */ - public void setErrorMessage(Throwable exc) - { - setErrorMessage(exc.getMessage()); - } - - /** - * Set the message text. If the message line currently displays an error, - * the message is stored and will be shown after a call to clearErrorMessage - */ - public void setMessage(String message) - { - this._message = message; - if (_statusLine != null) - _statusLine.setMessage(message); - } - /** - *If the message line currently displays an error, - * the message is stored and will be shown after a call to clearErrorMessage - */ - public void setMessage(SystemMessage message) - { - setMessage(message.getLevelOneText()); - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandsViewProvider.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandsViewProvider.java deleted file mode 100644 index 5c05a035a..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemCommandsViewProvider.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import org.eclipse.rse.ui.view.SystemTableViewProvider; - -public class SystemCommandsViewProvider extends SystemTableViewProvider -{ - /** - * Overridden to provide alternate text for special views of - * model objects - */ - public String getText(Object object) - { - String result = getAdapterFor(object).getAlternateText(object); - int len = result.length(); - if (len > _maxCharsInColumnZero) - { - _maxCharsInColumnZero = len; - } - return result; - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewOutputAdapterFactory.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewOutputAdapterFactory.java deleted file mode 100644 index 6ae2f1564..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewOutputAdapterFactory.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.core.runtime.IAdapterManager; -import org.eclipse.rse.core.SystemBasePlugin; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteError; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteOutput; -import org.eclipse.rse.ui.view.ISystemDragDropAdapter; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.ISystemViewElementAdapter; -import org.eclipse.ui.IActionFilter; -import org.eclipse.ui.model.IWorkbenchAdapter; -import org.eclipse.ui.views.properties.IPropertySource; - - -/** - * This factory maps requests for an adapter object from a given - * element object. This is for the universal command subsystem. - */ -public class SystemViewOutputAdapterFactory implements IAdapterFactory -{ - private SystemViewRemoteOutputAdapter outputAdapter = new SystemViewRemoteOutputAdapter(); - private SystemViewRemoteErrorAdapter errorAdapter = new SystemViewRemoteErrorAdapter(); - - /** - * @see IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() - { - return new Class[] {ISystemViewElementAdapter.class, ISystemDragDropAdapter.class, ISystemRemoteElementAdapter.class, IPropertySource.class, IWorkbenchAdapter.class, IActionFilter.class}; - } - /** - * Called by our plugin's startup method to register our adaptable object types - * with the platform. We prefer to do it here to isolate/encapsulate all factory - * logic in this one place. - */ - public void registerWithManager(IAdapterManager manager) - { - manager.registerAdapters(this, IRemoteError.class); - manager.registerAdapters(this, IRemoteOutput.class); - manager.registerAdapters(this, IRemoteCommandShell.class); - } - /** - * @see IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) - { - Object adapter = null; - if (adaptableObject instanceof IRemoteError) - adapter = errorAdapter; - else if (adaptableObject instanceof IRemoteOutput) - adapter = outputAdapter; - else if (adaptableObject instanceof IRemoteCommandShell) - adapter = outputAdapter; - - if ((adapter != null) && (adapterType == IPropertySource.class)) - { - ((ISystemViewElementAdapter)adapter).setPropertySourceInput(adaptableObject); - } - else if (adapter == null) - { - SystemBasePlugin.logWarning("No adapter found for object of type: " + adaptableObject.getClass().getName()); - } - return adapter; - } - - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteErrorAdapter.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteErrorAdapter.java deleted file mode 100644 index cc74c67cc..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteErrorAdapter.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteError; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemMenuManager; -import org.eclipse.rse.ui.view.SystemViewResources; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.views.properties.IPropertyDescriptor; -import org.eclipse.ui.views.properties.PropertyDescriptor; - - -/** - * Comment goes here - */ -public class SystemViewRemoteErrorAdapter extends SystemViewRemoteOutputAdapter -{ - - protected IPropertyDescriptor[] _uniquePropertyDescriptorArray; - /** - * Used to add context menu actions for the given remote output - */ - public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup) - { - super.addActions(menu, selection, shell, menuGroup); - - } - - public IPropertyDescriptor[] getUniquePropertyDescriptors() - { - if (_uniquePropertyDescriptorArray == null) - { - int nbrOfProperties = 2; - - _uniquePropertyDescriptorArray = new PropertyDescriptor[nbrOfProperties]; - //PropertyDescriptor[] defaultProperties = (PropertyDescriptor[]) getDefaultDescriptors(); - - int i = -1; - - // add our unique property descriptors... - RSEUIPlugin plugin = RSEUIPlugin.getDefault(); - - // path - _uniquePropertyDescriptorArray[++i] = createSimplePropertyDescriptor(P_ERROR_FILENAME, SystemViewResources.RESID_PROPERTY_ERROR_FILENAME_LABEL, SystemViewResources.RESID_PROPERTY_ERROR_FILENAME_TOOLTIP); - - // line - _uniquePropertyDescriptorArray[++i] = createSimplePropertyDescriptor(P_ERROR_LINENO, SystemViewResources.RESID_PROPERTY_ERROR_LINENO_LABEL, SystemViewResources.RESID_PROPERTY_ERROR_LINENO_TOOLTIP); - } - - return _uniquePropertyDescriptorArray; - - } - - /** - * Return our unique property descriptors - */ - protected IPropertyDescriptor[] internalGetPropertyDescriptors() - { - if (_propertyDescriptors == null) - { - // unique ones - IPropertyDescriptor[] unique = getUniquePropertyDescriptors(); - // our additional - _propertyDescriptors = new PropertyDescriptor[1+ unique.length]; - int idx = -1; - - // path - _propertyDescriptors[++idx] = createSimplePropertyDescriptor(P_FILE_PATH, SystemViewResources.RESID_PROPERTY_FILE_PATH_LABEL, SystemViewResources.RESID_PROPERTY_FILE_PATH_TOOLTIP); - // append... - for (int i = 0; i < unique.length; i++) - { - _propertyDescriptors[++idx] = unique[i]; - } - } - return _propertyDescriptors; - } - - /** - * Returns the current collection of property descriptors. - * @return an array containing all descriptors. - */ - protected Object internalGetPropertyValue(Object key) - { - String name = (String) key; - if (propertySourceInput instanceof IRemoteError) - { - IRemoteError output = (IRemoteError) propertySourceInput; - - if (name.equals(P_FILE_PATH)) - { - return output.getAbsolutePath(); - } - else if (name.equals(P_ERROR_FILENAME)) - { - return output.getAbsolutePath(); - } - else if (name.equals(P_ERROR_LINENO)) - { - return new Integer(output.getLine()); - } - } - return null; - } - -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteOutputAdapter.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteOutputAdapter.java deleted file mode 100644 index 4bc069485..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/SystemViewRemoteOutputAdapter.java +++ /dev/null @@ -1,1236 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.rse.core.SystemBasePlugin; -import org.eclipse.rse.core.subsystems.IRemoteLineReference; -import org.eclipse.rse.core.subsystems.ISubSystem; -import org.eclipse.rse.core.subsystems.util.ISubSystemConfigurationAdapter; -import org.eclipse.rse.files.ui.actions.SystemRemoteFileLineOpenWithMenu; -import org.eclipse.rse.files.ui.resources.RemoteSourceLookupDirector; -import org.eclipse.rse.files.ui.resources.SystemEditableRemoteFile; -import org.eclipse.rse.files.ui.resources.SystemIFileProperties; -import org.eclipse.rse.shells.ui.ShellResources; -import org.eclipse.rse.shells.ui.actions.SystemShowInShellViewAction; -import org.eclipse.rse.shells.ui.actions.SystemTerminateRemoveShellAction; -import org.eclipse.rse.shells.ui.actions.SystemTerminateShellAction; -import org.eclipse.rse.subsystems.files.core.model.RemoteFileUtility; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; -import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; -import org.eclipse.rse.subsystems.shells.core.model.ISystemOutputRemoteTypes; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystemConfiguration; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCommandShell; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteError; -import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteOutput; -import org.eclipse.rse.ui.ISystemContextMenuConstants; -import org.eclipse.rse.ui.ISystemIconConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemMenuManager; -import org.eclipse.rse.ui.actions.SystemCopyToClipboardAction; -import org.eclipse.rse.ui.actions.SystemPasteFromClipboardAction; -import org.eclipse.rse.ui.view.AbstractSystemViewAdapter; -import org.eclipse.rse.ui.view.ISystemDragDropAdapter; -import org.eclipse.rse.ui.view.ISystemEditableRemoteObject; -import org.eclipse.rse.ui.view.ISystemPropertyConstants; -import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter; -import org.eclipse.rse.ui.view.ISystemViewElementAdapter; -import org.eclipse.rse.ui.view.SystemView; -import org.eclipse.rse.ui.view.SystemViewResources; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorDescriptor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IEditorRegistry; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.ui.views.properties.IPropertyDescriptor; - - -/** - * This is the adapter for smart output from remote commands, such that they can support right click actions and such. - */ -public class SystemViewRemoteOutputAdapter extends AbstractSystemViewAdapter -implements ISystemViewElementAdapter, ISystemRemoteElementAdapter, ISystemOutputRemoteTypes -{ - - - protected IPropertyDescriptor[] _propertyDescriptors; - - private SystemCopyToClipboardAction _copyOutputAction = null; - private SystemPasteFromClipboardAction _pasteToPromptAction = null; - - private SystemShowInShellViewAction _showInShellView = null; - private SystemTerminateShellAction _terminateShellAction = null; - private SystemTerminateRemoveShellAction _terminateRemoveShellAction = null; - private IAction _exportShellHistoryAction = null; - private IAction _exportShellOutputAction = null; - private List _shellActions = null; - - private IPropertyDescriptor _shellPropertyDescriptors[]; - private IPropertyDescriptor _outputPropertyDescriptors[]; - - public SystemViewRemoteOutputAdapter() - { - _shellActions = new ArrayList(); - } - - /** - * Used to add context menu actions for the given remote output - */ - public void addActions(SystemMenuManager menu, IStructuredSelection selection, Shell shell, String menuGroup) - { - Object firstSelection = selection.getFirstElement(); - - if (firstSelection != null) - { - if (firstSelection instanceof IRemoteOutput) - { - if (_copyOutputAction == null) - { - _copyOutputAction = new SystemCopyToClipboardAction(shell, RSEUIPlugin.getTheSystemRegistry().getSystemClipboard()); - } - - menu.add(menuGroup, _copyOutputAction); - - if (selection.size() == 1) - { - if (firstSelection instanceof IRemoteLineReference) - { - IRemoteOutput result = (IRemoteOutput) firstSelection; - String type = result.getType(); - if (type.equals("prompt")) - { - if (_pasteToPromptAction == null) - { - _pasteToPromptAction = new SystemPasteFromClipboardAction(shell, RSEUIPlugin.getTheSystemRegistry().getSystemClipboard()); - } - - menu.add(menuGroup, _pasteToPromptAction); - } - else if (type.equals("directory")) - { - IRemoteOutput output = (IRemoteOutput)firstSelection; - if (output.getAbsolutePath() != null) - { - // TODO - // add directory actions here - } - } - else - { - IRemoteOutput output = (IRemoteOutput)firstSelection; - if (output.getAbsolutePath() != null) - { - //SystemCreateEditLineActions createActions = new SystemCreateEditLineActions(); - //createActions.create(menu, selection, shell, menuGroup); - // open with -> - MenuManager submenu = - new MenuManager(org.eclipse.ui.internal.views.navigator.ResourceNavigatorMessages.ResourceNavigator_openWith, - ISystemContextMenuConstants.GROUP_OPENWITH); - - SystemRemoteFileLineOpenWithMenu openWithMenu = new SystemRemoteFileLineOpenWithMenu(); - openWithMenu.updateSelection(selection); - submenu.add(openWithMenu); - menu.getMenuManager().appendToGroup(ISystemContextMenuConstants.GROUP_OPENWITH, submenu); - - } - } - } - - - - } - } - else if (firstSelection instanceof IRemoteCommandShell) - { - IRemoteCommandShell cmdShell = (IRemoteCommandShell)firstSelection; - if (_showInShellView == null) - { - _showInShellView = new SystemShowInShellViewAction(shell); - - } - menu.add(ISystemContextMenuConstants.GROUP_OPEN,_showInShellView); - - getShellActions(cmdShell.getCommandSubSystem().getParentRemoteCmdSubSystemConfiguration()); - - menu.add(ISystemContextMenuConstants.GROUP_CHANGE, _terminateShellAction); - menu.add(ISystemContextMenuConstants.GROUP_CHANGE, _terminateRemoveShellAction); - menu.add(ISystemContextMenuConstants.GROUP_IMPORTEXPORT, _exportShellOutputAction); - menu.add(ISystemContextMenuConstants.GROUP_IMPORTEXPORT, _exportShellHistoryAction); - } - } - else - { - return; - } - } - - public List getShellActions(IRemoteCmdSubSystemConfiguration factory) - { - getShell(); - _shellActions.clear(); - if (_shellActions.size()== 0) - { - if (_terminateShellAction == null) - { - _terminateShellAction = new SystemTerminateShellAction(shell); - } - _shellActions.add(_terminateShellAction); - if (_terminateRemoveShellAction == null) - { - _terminateRemoveShellAction = new SystemTerminateRemoveShellAction(shell); - } - _shellActions.add(_terminateRemoveShellAction); - - _shellActions.add(new Separator()); - - ShellServiceSubSystemConfigurationAdapter factoryAdapter = (ShellServiceSubSystemConfigurationAdapter)factory.getAdapter(ISubSystemConfigurationAdapter.class); - - _exportShellOutputAction = factoryAdapter.getCommandShellOutputExportAction(shell); - _shellActions.add(_exportShellOutputAction); - _exportShellHistoryAction = factoryAdapter.getCommandShellHistoryExportAction(shell); - _shellActions.add(_exportShellHistoryAction); - - } - return _shellActions; - } - - /** - * Returns the parent command object for a line of output - */ - public Object getParent(Object element) - { - if (element instanceof IRemoteOutput) - { - IRemoteOutput output = (IRemoteOutput) element; - return output.getParent(); - } - return null; - } - - /** - * Returns the text to display in a view for this element. - */ - public String getText(Object element) - { - if (element instanceof IRemoteOutput) - { - IRemoteOutput output = (IRemoteOutput) element; - String text = output.getText(); - - if (text.indexOf('\t') > 0) - { - text = translateTabs(text); - } - - int tagIndex = text.indexOf("BEGIN-END-TAG"); - if (tagIndex == 0) - { - return ""; - } - else if (tagIndex > 0) - { - //return text.substring(0, tagIndex - 6); - return text.substring(0, tagIndex); - } - - return text; - } - else if (element instanceof IRemoteCommandShell) - { - IRemoteCommandShell outputRoot = (IRemoteCommandShell) element; - return outputRoot.getId(); - } - return null; - } - - - protected String translateTabs(String tabbedString) - { - int columnWidth = 8; - - int currentOffset = 0; - StringBuffer untabbedBuf = new StringBuffer(); - for (int i = 0; i < tabbedString.length();i++) - { - char p = '\0'; - char c = tabbedString.charAt(i); - char n = '\0'; - if (i+1 <tabbedString.length()) - { - n = tabbedString.charAt(i + 1); - } - if (i - 1 > -1) - { - p = tabbedString.charAt(i - 1); - } - if (c == '\t') - { - untabbedBuf.append(' '); - currentOffset++; - while ((currentOffset % columnWidth) >0) - { - untabbedBuf.append(' '); - currentOffset++; - } - } - else if (c == ' ') - { - untabbedBuf.append(' '); - currentOffset++; - } - else - { - untabbedBuf.append(c); - currentOffset++; - } - } - - return untabbedBuf.toString(); - } - /** - * Returns the type attribute of a line of output or command. - */ - public String getType(Object element) - { - if (element instanceof IRemoteOutput) - { - IRemoteOutput output = (IRemoteOutput) element; - return output.getType(); - } - else if (element instanceof IRemoteCommandShell) - { - IRemoteCommandShell root = (IRemoteCommandShell) element; - return root.getType(); - } - return null; - } - - /** - * Returns the children of a remote command if the element is a remote command - */ - public Object[] getChildren(Object element) - { - - if (element instanceof IRemoteCommandShell) - { - IRemoteCommandShell output = (IRemoteCommandShell) element; - return output.listOutput(); - } - - return null; - } - - /** - * Returns true if the element is a remote command and false if it is a remote output. - */ - public boolean hasChildren(Object element) - { - if (element instanceof IRemoteCommandShell) - { - if (!(getViewer() instanceof SystemView)) - { - return true; - } - return false; - } - else - { - return false; - } - } - - /** - * Returns the associated IRemoteFile for this line of remote output if one exists - * @param output the line of remote output - * @return the associated remote file - */ - public static IRemoteFile outputToFile(IRemoteOutput output) - { - IRemoteFile file = null; - Object parent = output.getParent(); - IRemoteFileSubSystem fs = null; - if (parent instanceof IRemoteCommandShell) - { - IRemoteCommandShell root = (IRemoteCommandShell) output.getParent(); - fs = RemoteFileUtility.getFileSubSystem(root.getCommandSubSystem().getHost()); - } - else if (parent instanceof IRemoteFile) - { - return (IRemoteFile) parent; - } - - if (fs != null) - { - String path = output.getAbsolutePath(); - if (path != null && path.length() > 0) - { - Object obj = null; - try - { - obj = fs.getObjectWithAbsoluteName(path); - } - catch (Exception e) - { - return null; - } - if (obj != null && obj instanceof IRemoteFile) - { - file = (IRemoteFile) obj; - - return file; - } - } - } - - return file; - } - - - - protected IEditorRegistry getEditorRegistry() - { - return RSEUIPlugin.getDefault().getWorkbench().getEditorRegistry(); - } - - protected IEditorDescriptor getDefaultTextEditor() - { - IEditorRegistry registry = getEditorRegistry(); - return registry.findEditor("org.eclipse.ui.DefaultTextEditor"); - } - - /** - * Open workspace file associated with IRemoteCommandShell. If there is no associated project - * return. - * @param remoteFile - * @param output - * @return - */ - protected boolean openWorkspaceFile(IRemoteFile remoteFile, IRemoteOutput output) - { - IRemoteCommandShell cmd = (IRemoteCommandShell)(output.getParent()); - IProject associatedProject = cmd.getAssociatedProject(); - if (associatedProject != null) - { - ProjectSourceContainer container = new ProjectSourceContainer(associatedProject, false); - ISourceLookupDirector director = new RemoteSourceLookupDirector(); - container.init(director); - try - { - Object[] matches = container.findSourceElements(remoteFile.getName()); - for (int i = 0; i < matches.length; i++) - { - //System.out.println("match="+matches[i]); - } - - if (matches.length == 1) - { - IFile localMatch = (IFile)matches[0]; - - - - IWorkbenchPage activePage = SystemBasePlugin.getActiveWorkbenchWindow().getActivePage(); - - FileEditorInput finput = new FileEditorInput(localMatch); - - - IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(remoteFile.getName()); - if (desc == null) - { - desc = getDefaultTextEditor(); - } - String editorid = desc.getId(); - IEditorPart editor = activePage.openEditor(finput, editorid); - - int line = output.getLine(); - int charStart = output.getCharStart(); - int charEnd = output.getCharEnd(); - - try - { - IMarker marker = null; - - // DKM - should we? this will populate the Problems view..but resources are actually remote - if (output instanceof IRemoteError) - { - IRemoteError error = (IRemoteError)output; - String type = error.getType(); - - marker = localMatch.createMarker(IMarker.TEXT); - - if (type.equals("error")) - { - marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR); - } - else if (type.equals("warning")) - { - marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING); - } - else if (type.equals("informational")) - { - marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO); - } - - marker.setAttribute(IMarker.MESSAGE, output.getText()); - marker.setAttribute(IMarker.LINE_NUMBER, line); - marker.setAttribute(IMarker.CHAR_START, charStart); - marker.setAttribute(IMarker.CHAR_END, charEnd); - - } - else - { - marker = localMatch.createMarker(IMarker.TEXT); - marker.setAttribute(IMarker.LINE_NUMBER, line); - marker.setAttribute(IMarker.CHAR_START, charStart); - marker.setAttribute(IMarker.CHAR_END, charEnd); - } - IDE.gotoMarker(editor, marker); - - - } - catch (CoreException e) - { - e.printStackTrace(); - } - return true; - } - } - catch(Exception e) - { - e.printStackTrace(); - } - } - - return false; - } - - /** - * Opens the appropriate editor for a remote output object - */ - public boolean handleDoubleClick(Object element) - { - boolean result = false; - if (element instanceof IRemoteOutput) - { - IRemoteOutput output = (IRemoteOutput) element; - - IRemoteFile file = outputToFile(output); - if (file != null && file.isFile()) - { - if (!openWorkspaceFile(file, output)) - { - ISystemViewElementAdapter adapter = (ISystemViewElementAdapter) ((IAdaptable) file).getAdapter(ISystemViewElementAdapter.class); - result = adapter.handleDoubleClick(file); - int line = output.getLine(); - - if (result) - { - DelayedGotoLine dgoto = new DelayedGotoLine(file, line, output.getCharStart(), output.getCharEnd()); - Display.getDefault().asyncExec(dgoto); - /* - //if (line > 0) - { - SystemRemoteFileLineOpenWithMenu.handleGotoLine(file, line, output.getCharStart(), output.getCharEnd()); - } - */ - return true; - } - } - } - } - else if (element instanceof IRemoteCommandShell) - { - IRemoteCommandShell cmdshell = (IRemoteCommandShell) element; - if (cmdshell.getType().equals(ShellResources.RESID_SHELLS_COMMAND_SHELL_LABEL)) - { - SystemCommandsViewPart viewPart = SystemCommandsUI.getInstance().activateCommandsView(); - viewPart.updateOutput(cmdshell); - result = true; - } - } - return result; - } - - public class DelayedGotoLine implements Runnable - { - private IRemoteFile _file; - private int _line; - private int _charStart; - private int _charEnd; - - public DelayedGotoLine(IRemoteFile file, int line, int charStart, int charEnd) - { - _file = file; - _line = line; - _charStart = charStart; - _charEnd = charEnd; - } - - public void run() - { - if (checkEditorOpen()) - { - SystemRemoteFileLineOpenWithMenu.handleGotoLine(_file, _line, _charStart, _charEnd); - } - else - { - Display.getDefault().asyncExec(this); - } - } - - private boolean checkEditorOpen() - { - IWorkbench desktop = PlatformUI.getWorkbench(); - IWorkbenchPage persp = desktop.getActiveWorkbenchWindow().getActivePage(); - IEditorPart editor = null; - String fileName = _file.getAbsolutePath(); - IEditorReference[] editors = persp.getEditorReferences(); - for (int i = 0; i < editors.length; i++) - { - IEditorReference ref = editors[i]; - IEditorPart editorp = ref.getEditor(false); - if (editorp != null) - { - IEditorInput einput = editorp.getEditorInput(); - if (einput instanceof IFileEditorInput) - { - IFileEditorInput input = (IFileEditorInput) einput; - IFile efile = input.getFile(); - - SystemIFileProperties properties = new SystemIFileProperties(efile); - String comparePath = properties.getRemoteFilePath(); - - if (comparePath != null && (comparePath.replace('\\','/').equals(fileName.replace('\\','/')))) - { - return true; - } - } - } - } - return false; - } - } - - - /** - * Returns the associated subsystem for this line of remote output or remote command - */ - public ISubSystem getSubSystem(Object element) - { - if (element instanceof IRemoteCommandShell) - { - IRemoteCommandShell cmd = (IRemoteCommandShell) element; - return cmd.getCommandSubSystem(); - } - else if (element instanceof IRemoteOutput) - { - IRemoteOutput output = (IRemoteOutput) element; - Object parent = output.getParent(); - if (parent instanceof IRemoteCommandShell) - { - return getSubSystem(parent); - } - } - - return null; - } - - /** - * Return the fully qualified name of this remote object. - */ - public String getAbsoluteName(Object element) - { - if (element instanceof IRemoteCommandShell) - { - IRemoteCommandShell cmd = (IRemoteCommandShell) element; - return cmd.getId(); - } - else if (element instanceof IRemoteOutput) - { - IRemoteOutput out = (IRemoteOutput) element; - String str = getAbsoluteParentName(element); - return str + ":" + out.getIndex(); - } - return null; - } - - /** - * Return fully qualified name that uniquely identifies this remote object's remote parent within its subsystem - */ - public String getAbsoluteParentName(Object element) - { - return getAbsoluteName(getParent(element)); - } - - /** - * Return the subsystem factory id that owns this remote object - * The value must not be translated, so that property pages registered via xml can subset by it. - */ - public String getSubSystemConfigurationId(Object element) - { - return null; - } - - /** - * Return a value for the type category property for this object - * The value must not be translated, so that property pages registered via xml can subset by it. - */ - public String getRemoteTypeCategory(Object element) - { - return null; - } - - /** - * Return a value for the type property for this object - * The value must not be translated, so that property pages registered via xml can subset by it. - */ - public String getRemoteType(Object element) - { - if (element instanceof IRemoteOutput) - { - return ((IRemoteOutput) element).getType(); - } - else if (element instanceof IRemoteCommandShell) - { - return ((IRemoteCommandShell) element).getType(); - } - return null; - } - - /** - * Return a value for the subtype property for this object. - * Not all object types support a subtype, so returning null is ok. - * The value must not be translated, so that property pages registered via xml can subset by it. - */ - public String getRemoteSubType(Object element) - { - return null; - } - - /** - * Return a value for the sub-subtype property for this object. - * Not all object types support a sub-subtype, so returning null is ok. - * The value must not be translated, so that property pages registered via xml can subset by it. - */ - public String getRemoteSubSubType(Object element) - { - return null; - } - /** - * Return the source type of the selected object. Typically, this only makes sense for compilable - * source members. For non-compilable remote objects, this typically just returns null. - */ - public String getRemoteSourceType(Object element) - { - return null; - } - - /** - * Some view has updated the name or properties of this remote object. As a result, the - * remote object's contents need to be refreshed. You are given the old remote object that has - * old data, and you are given the new remote object that has the new data. For example, on a - * rename the old object still has the old name attribute while the new object has the new - * new attribute. - * <p> - * This is called by viewers like SystemView in response to rename and property change events. - * <p> - * @param oldElement the element that was found in the tree - * @param newElement the updated element that was passed in the REFRESH_REMOTE event - * @return true if you want the viewer that called this to refresh the children of this object, - * such as is needed on a rename of a folder, say. - */ - public boolean refreshRemoteObject(Object oldElement, Object newElement) - { - return false; - } - - /** - * Given a remote object, returns it remote parent object. Eg, given a file, return the folder - * it is contained in. - */ - public Object getRemoteParent(Shell shell, Object element) throws Exception - { - if (element instanceof IRemoteOutput) - { - return ((IRemoteOutput) element).getParent(); - } - return null; - } - - /** - * Given a remote object, return the unqualified names of the objects contained in that parent. This is - * used for testing for uniqueness on a rename operation, for example. Sometimes, it is not - * enough to just enumerate all the objects in the parent for this purpose, because duplicate - * names are allowed if the types are different, such as on iSeries. In this case return only - * the names which should be used to do name-uniqueness validation on a rename operation. - */ - public String[] getRemoteParentNamesInUse(Shell shell, Object element) throws Exception - { - return null; - } - - - /** - * Returns the current collection of property descriptors. - * By default returns descriptors for name and type only. - * Override if desired. - * @return an array containing all descriptors. - */ - protected Object internalGetPropertyValue(Object key) - { - return getPropertyValue(key, true); - } - - /** - * Returns the icon to display for this object - * @param element the remote output object - * @return the associated image descriptor - */ - public ImageDescriptor getImageDescriptor(Object element) - { - if (element instanceof IRemoteOutput) - { - ImageDescriptor imageDescriptor = null; - IRemoteOutput output = (IRemoteOutput) element; - String type = output.getType(); - if (type.equals(TYPE_ERROR)) - { - imageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_ERROR_ID); - } - else if (type.equals(TYPE_WARNING)) - { - imageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_WARNING_ID); - } - else if (type.equals(TYPE_INFORMATIONAL)) - { - imageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_INFO_ID); - } - else if (type.equals(TYPE_DIRECTORY)) - { - imageDescriptor = //PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FOLDER); - RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_FOLDER_ID); - } - else if (type.equals(TYPE_FILE)) - { - imageDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE); - //RSEUIPlugin.getDefault().getImageDescriptor(ISystemConstants.ICON_SYSTEM_FILE_ID); - } - else if (type.equals(TYPE_GREP)) - { - imageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_SEARCH_RESULT_ID); - } - else if (type.equals(TYPE_COMMAND)) - { - imageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_SHELL_ID); - } - else if (type.equals(TYPE_PROMPT)) - { - imageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_SHELL_ID); - } - else if (type.equals(TYPE_PROCESS)) - { - imageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_PROCESS_ID); - } - else if (type.equals(TYPE_ENVVAR)) - { - imageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_ENVVAR_ID); - } - else if (type.equals(TYPE_ENVVAR_LIBPATH)) - { - imageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_ENVVAR_LIBPATH_ID); - } - else if (type.equals(TYPE_ENVVAR_PATH)) - { - imageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_ENVVAR_PATH_ID); - } - else - { - imageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_BLANK_ID); - } - - return imageDescriptor; - } - - else if (element instanceof IRemoteCommandShell) - { - IRemoteCommandShell command = (IRemoteCommandShell) element; - IRemoteCmdSubSystemConfiguration factory = command.getCommandSubSystem().getParentRemoteCmdSubSystemConfiguration(); - ShellServiceSubSystemConfigurationAdapter factoryAdapter = (ShellServiceSubSystemConfigurationAdapter)factory.getAdapter(ISubSystemConfigurationAdapter.class); - ImageDescriptor imageDescriptor = null; - if (command.isActive()) - { - imageDescriptor = factoryAdapter.getActiveCommandShellImageDescriptor(); - } - else - { - imageDescriptor = factoryAdapter.getInactiveCommandShellImageDescriptor(); - } - return imageDescriptor; - } - - else - { // return some default - ImageDescriptor imageDescriptor = RSEUIPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_BLANK_ID); - return imageDescriptor; - } - } - - /** - * Return true if we should show the delete action in the popup for the given element. - * If true, then canDelete will be called to decide whether to enable delete or not. - */ - public boolean showDelete(Object element) - { - return false; - } - /** - * Return true if this object is deletable by the user. If so, when selected, - * the Edit->Delete menu item will be enabled. - * By default, returns false. Override if your object is deletable. - */ - public boolean canDelete(Object element) - { - return false; - } - - // ------------------------------------------ - // METHODS TO SUPPORT COMMON REFRESH ACTION... - // ------------------------------------------ - /** - * Return true if we should show the refresh action in the popup for the given element. - */ - public boolean showRefresh(Object element) - { - return false; - } - - // ------------------------------------------------------------ - // METHODS TO SUPPORT COMMON OPEN-IN-NEW-PERSPECTIVE ACTIONS... - // ------------------------------------------------------------ - /** - * Return true if we should show the refresh action in the popup for the given element. - */ - public boolean showOpenViewActions(Object element) - { - return false; - } - - // ------------------------------------------ - // METHODS TO SUPPORT COMMON RENAME ACTION... - // ------------------------------------------ - - /** - * Return true if we should show the rename action in the popup for the given element. - * If true, then canRename will be called to decide whether to enable rename or not. - */ - public boolean showRename(Object element) - { - return false; - } - /** - * Return true if this object is renamable by the user. If so, when selected, - * the Rename popup menu item will be enabled. - * By default, returns false. Override if your object is renamable. - */ - public boolean canRename(Object element) - { - return false; - } - - /** - * Perform the rename action. By default does nothing. Override if your object is renamable. - * Return true if this was successful. Return false if it failed and you issued a msg. - * Throw an exception if it failed and you want to use the generic msg. - */ - public boolean doRename(Shell shell, Object element, String name) throws Exception - { - return false; - } - - // Drag and drop - - /** - * Indicates whether the specified object can have another object copied to it - * @param element the object to copy to - * @return whether this object can be copied to or not - */ - public boolean canDrop(Object element) - { - /*DKM -for now disabling - the function doesn't - * make sense for other types of prompts like - * RAD4z - if (element instanceof IRemoteOutput) - { - IRemoteOutput output = (IRemoteOutput) element; - if (output.getType().equals(TYPE_PROMPT)) - { - return true; - } - } - */ - - return false; - } - - /** - * Indicates whether the specified object can be copied - * @param element the object to copy - */ - public boolean canDrag(Object element) - { - if (element instanceof IRemoteOutput) - { - return true; - } - else if (element instanceof IRemoteCommandShell) - { - return true; - } - - return false; - } - - /** - * Copy the specified remote output object. This method returns a string representing - * the text of the remote output; - * - * @param element the output to copy - * @param sameSystemType not applicable for remote output - * @param monitor the progress monitor - */ - public Object doDrag(Object element, boolean sameSystemType, IProgressMonitor monitor) - { - if (element instanceof List) - { - List resultSet = new ArrayList(); - List set = (List)element; - for (int i = 0; i < set.size(); i++) - { - resultSet.add(getText(set.get(i))); - } - return resultSet; - } - else - { - return getText(element); - } - } - - /** - * Return true if it is valid for the src object to be dropped in the target - * @param src the object to drop - * @param target the object which src is dropped in - * @param sameSystem whether this is the same system - * @return whether this is a valid operation - */ - public boolean validateDrop(Object src, Object target, boolean sameSystem) - { - if (target instanceof IRemoteOutput) - { - IRemoteOutput targetOutput = (IRemoteOutput) target; - if (targetOutput.getType().equals(TYPE_PROMPT)) - { - if (src instanceof IRemoteFile) - { - return true; - } - else if (src instanceof IResource) - { - return true; - } - else if (src instanceof String) - { - return true; - } - } - } - return false; - } - - /** - * Perform a copy via drag and drop. - * @param src the object to be copied. If the target and source are not on the same system, then this is a - * temporary object produced by the doDrag. - * @param target the object to be copied to. - * @param sameSystem an indication whether the target and source reside on the same type of system - * @param indicates the type of source - * @param monitor the progress monitor - * @return an indication whether the operation was successful or not. - */ - public Object doDrop(Object src, Object target, boolean sameSystemType, boolean sameSystem, int srcType, IProgressMonitor monitor) - { - IRemoteFile folder = outputToFile((IRemoteOutput) target); - if (folder != null) - { - ISystemDragDropAdapter adapter = (ISystemDragDropAdapter) ((IAdaptable) folder).getAdapter(ISystemDragDropAdapter.class); - return adapter.doDrop(src, folder, sameSystemType, sameSystem, srcType, monitor); - } - return null; - } - - /** - * Determines whether the line of remote output can be edited in an editor - * @param element the remote output object - * @return true if this can be edited in an editor - */ - public boolean canEdit(Object element) - { - if (element instanceof IRemoteOutput) - { - IRemoteOutput output = (IRemoteOutput) element; - IRemoteFile file = outputToFile(output); - if (file != null && file.isFile()) - { - return true; - } - } - return false; - } - - /** - * Returns the associated remote editable object for this line of output - * @param element the remote output object - * @return the associated ediable object if one exists - */ - public ISystemEditableRemoteObject getEditableRemoteObject(Object element) - { - if (element instanceof IRemoteOutput) - { - IRemoteOutput output = (IRemoteOutput) element; - IRemoteFile file = outputToFile(output); - if (file != null && file.isFile()) - { - return new SystemEditableRemoteFile(file); - } - } - return null; - } - - /** - * Return a filter string that corresponds to this object. - * @param object the object to obtain a filter string for - * @return the corresponding filter string if applicable - */ - public String getFilterStringFor(Object object) - { - return null; - } - - protected IPropertyDescriptor[] internalGetPropertyDescriptors() - { - return getUniquePropertyDescriptors(); - } - - public IPropertyDescriptor[] getUniquePropertyDescriptors() - { - if (propertySourceInput instanceof IRemoteCommandShell) - { - if (_shellPropertyDescriptors == null) - { - _shellPropertyDescriptors = new IPropertyDescriptor[2]; - - _shellPropertyDescriptors[0] = createSimplePropertyDescriptor(P_SHELL_STATUS, SystemViewResources.RESID_PROPERTY_SHELL_STATUS_LABEL, SystemViewResources.RESID_PROPERTY_SHELL_STATUS_TOOLTIP); - _shellPropertyDescriptors[1] = createSimplePropertyDescriptor(P_SHELL_CONTEXT, SystemViewResources.RESID_PROPERTY_SHELL_CONTEXT_LABEL, SystemViewResources.RESID_PROPERTY_SHELL_CONTEXT_TOOLTIP); - } - return _shellPropertyDescriptors; - } - else - { - if (_outputPropertyDescriptors == null) - { - _outputPropertyDescriptors = new IPropertyDescriptor[0]; - } - return _outputPropertyDescriptors; - } - } - - /** - * Returns the current value for the named property. - * - * @param property the name or key of the property as named by its property descriptor - * @param formatted indication of whether to return the value in formatted or raw form - * @return the current value of the given property - */ - public Object getPropertyValue(Object property, boolean formatted) - { - String name = (String) property; - if (propertySourceInput instanceof IRemoteCommandShell) - { - IRemoteCommandShell cmdShell = (IRemoteCommandShell) propertySourceInput; - if (name.equals(ISystemPropertyConstants.P_SHELL_STATUS)) - { - if (cmdShell.isActive()) - { - return SystemViewResources.RESID_PROPERTY_SHELL_STATUS_ACTIVE_VALUE; - } - else - { - return SystemViewResources.RESID_PROPERTY_SHELL_STATUS_INACTIVE_VALUE; - } - } - else if (name.equals(ISystemPropertyConstants.P_SHELL_CONTEXT)) - { - Object context = cmdShell.getContext(); - if (context instanceof IRemoteFile) - { - IRemoteFile cwd = (IRemoteFile)context; - if (cwd != null) - { - return cwd.getAbsolutePath(); - } - } - else - { - return context; - } - } - } - return ""; - } - - - /** - * Returns <code>false</code>. - * @see org.eclipse.rse.ui.view.ISystemRemoteElementAdapter#supportsUserDefinedActions(java.lang.Object) - */ - public boolean supportsUserDefinedActions(Object object) { - return false; - } -}
\ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/TabFolderLayout.java b/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/TabFolderLayout.java deleted file mode 100644 index 65835a85f..000000000 --- a/rse/plugins/org.eclipse.rse.shells.ui/src/org/eclipse/rse/shells/ui/view/TabFolderLayout.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. 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: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.shells.ui.view; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Layout; - -public class TabFolderLayout extends Layout { - - - - protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) { - if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) - return new Point(wHint, hHint); - - Control [] children = composite.getChildren (); - int count = children.length; - int maxWidth = 0, maxHeight = 0; - for (int i=0; i<count; i++) { - Control child = children [i]; - Point pt = child.computeSize (SWT.DEFAULT, SWT.DEFAULT, flushCache); - maxWidth = Math.max (maxWidth, pt.x); - maxHeight = Math.max (maxHeight, pt.y); - } - - if (wHint != SWT.DEFAULT) - maxWidth= wHint; - if (hHint != SWT.DEFAULT) - maxHeight= hHint; - - return new Point(maxWidth, maxHeight); - - } - - protected void layout (Composite composite, boolean flushCache) { - Rectangle rect= composite.getClientArea(); - - Control[] children = composite.getChildren(); - for (int i = 0; i < children.length; i++) { - children[i].setBounds(rect); - } - } -}
\ No newline at end of file |