initial population
7
rse/plugins/org.eclipse.rse.processes.ui/.classpath
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
1
rse/plugins/org.eclipse.rse.processes.ui/.cvsignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
bin
|
28
rse/plugins/org.eclipse.rse.processes.ui/.project
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>org.eclipse.rse.processes.ui</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.pde.PluginNature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
57
rse/plugins/org.eclipse.rse.processes.ui/HelpContexts.xml
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
<?NLS TYPE="org.eclipse.help.contexts"?>
|
||||||
|
<contexts>
|
||||||
|
<!-- New/Update Process Filter String controls... -->
|
||||||
|
<context id="pfsd0001">
|
||||||
|
<description>Specify a simple executable name or a generic name pattern, containing up to 2 wildcard characters <b>*</b>. For example, <b>abc*def*</b>. Specify <b>*</b> to list all executables.
|
||||||
|
</description>
|
||||||
|
</context>
|
||||||
|
<context id="pfsd0002">
|
||||||
|
<description>Specify a simple username or a generic name pattern, containing up to 2 wildcard characters <b>*</b>. For example, <b>abc*def*</b>. Specify <b>*</b> to list all users.
|
||||||
|
</description>
|
||||||
|
</context>
|
||||||
|
<context id="pfsd0003">
|
||||||
|
<description>Specify an integer group id to list all processes whose owners belong to that group.
|
||||||
|
</description>
|
||||||
|
</context>
|
||||||
|
<context id="pfsd0004">
|
||||||
|
<description>Choose one or more status types to restrict. Only processes with the selected states will be shown for this filter string.
|
||||||
|
</description>
|
||||||
|
</context>
|
||||||
|
<context id="pfsd0005">
|
||||||
|
<description>Set this to any positive long integer to show only processes with virtual memory usage greater than this value.
|
||||||
|
</description>
|
||||||
|
</context>
|
||||||
|
<context id="pfsd0006">
|
||||||
|
<description>Set this to any positive long integer to show only processes with virtual memory usage less than this value.
|
||||||
|
</description>
|
||||||
|
</context>
|
||||||
|
<context id="pfsd0007">
|
||||||
|
<description>Check this box to show only processes with virtual memory usage greater than the value specified in the Minimum VM entry field, but with no maximum VM size.
|
||||||
|
</description>
|
||||||
|
</context>
|
||||||
|
<!-- REMOTE PROCESS ACTIONS: Kill action... -->
|
||||||
|
<context id="actn0001"><description>Kill the selected process or processes. You will be prompted for the type of kill signal to be sent to the process or processes.
|
||||||
|
</description>
|
||||||
|
</context>
|
||||||
|
<!-- Kill Remote Processes Dialog... -->
|
||||||
|
<context id="dkrp0000">
|
||||||
|
<description>Select the process or processes to which you wish to send a kill signal. Select the type of signal to be sent from the combo box. Then press OK to send the signal to the process or processes.
|
||||||
|
</description>
|
||||||
|
</context>
|
||||||
|
</contexts>
|
|
@ -0,0 +1,35 @@
|
||||||
|
Manifest-Version: 1.0
|
||||||
|
Bundle-ManifestVersion: 2
|
||||||
|
Bundle-Name: %plugin.name
|
||||||
|
Bundle-SymbolicName: org.eclipse.rse.processes.ui;singleton:=true
|
||||||
|
Bundle-Version: 1.0.0
|
||||||
|
Bundle-Activator: org.eclipse.rse.processes.ui.ProcessesPlugin
|
||||||
|
Bundle-Localization: plugin
|
||||||
|
Require-Bundle: org.eclipse.ui,
|
||||||
|
org.eclipse.core.runtime,
|
||||||
|
org.eclipse.rse.services,
|
||||||
|
org.eclipse.core.resources,
|
||||||
|
org.eclipse.ui.ide,
|
||||||
|
org.eclipse.ui.views,
|
||||||
|
org.eclipse.debug.core,
|
||||||
|
org.eclipse.ui.workbench.texteditor,
|
||||||
|
org.eclipse.jface.text,
|
||||||
|
org.eclipse.search,
|
||||||
|
org.eclipse.compare,
|
||||||
|
org.eclipse.rse.subsystems.shells.core,
|
||||||
|
org.eclipse.rse.subsystems.files.core,
|
||||||
|
org.eclipse.rse.subsystems.processes.core,
|
||||||
|
org.eclipse.jface,
|
||||||
|
org.eclipse.rse.services,
|
||||||
|
org.eclipse.ui,
|
||||||
|
org.eclipse.ui.views,
|
||||||
|
org.eclipse.core.runtime,
|
||||||
|
org.eclipse.rse.ui
|
||||||
|
Export-Package: org.eclipse.rse.processes.ui,
|
||||||
|
org.eclipse.rse.processes.ui.actions,
|
||||||
|
org.eclipse.rse.processes.ui.dialogs,
|
||||||
|
org.eclipse.rse.processes.ui.propertypages,
|
||||||
|
org.eclipse.rse.processes.ui.view
|
||||||
|
Eclipse-LazyStart: true
|
||||||
|
Bundle-Vendor: Eclipse.org
|
||||||
|
Bundle-ClassPath: processes_ui.jar
|
22
rse/plugins/org.eclipse.rse.processes.ui/about.html
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>About</title>
|
||||||
|
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
|
||||||
|
</head>
|
||||||
|
<body lang="EN-US">
|
||||||
|
<h2>About This Content</h2>
|
||||||
|
|
||||||
|
<p>February 24, 2005</p>
|
||||||
|
<h3>License</h3>
|
||||||
|
|
||||||
|
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
|
||||||
|
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
|
||||||
|
For purposes of the EPL, "Program" will mean the Content.</p>
|
||||||
|
|
||||||
|
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may
|
||||||
|
apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
|
||||||
|
indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
20
rse/plugins/org.eclipse.rse.processes.ui/build.properties
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
bin.includes = META-INF/,\
|
||||||
|
plugin.xml,\
|
||||||
|
HelpContexts.xml,\
|
||||||
|
about.html,\
|
||||||
|
icons/,\
|
||||||
|
messageFile.dtd,\
|
||||||
|
plugin.properties,\
|
||||||
|
systemmessages.xml,\
|
||||||
|
processes_ui.jar
|
||||||
|
src.includes = HelpContexts.xml,\
|
||||||
|
about.html,\
|
||||||
|
META-INF/,\
|
||||||
|
icons/,\
|
||||||
|
messageFile.dtd,\
|
||||||
|
plugin.properties,\
|
||||||
|
plugin.xml,\
|
||||||
|
systemmessages.xml
|
||||||
|
source.processes_ui.jar = src/
|
||||||
|
jars.compile.order = processes_ui.jar
|
||||||
|
output.processes_ui.jar = bin/
|
After Width: | Height: | Size: 352 B |
After Width: | Height: | Size: 582 B |
After Width: | Height: | Size: 962 B |
After Width: | Height: | Size: 582 B |
After Width: | Height: | Size: 344 B |
After Width: | Height: | Size: 574 B |
After Width: | Height: | Size: 594 B |
22
rse/plugins/org.eclipse.rse.processes.ui/messageFile.dtd
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<!ELEMENT Component (Subcomponent+)>
|
||||||
|
<!ATTLIST Component
|
||||||
|
Abbr ID #REQUIRED
|
||||||
|
Name CDATA #REQUIRED
|
||||||
|
>
|
||||||
|
<!ELEMENT LevelOne (#PCDATA)>
|
||||||
|
<!ELEMENT LevelTwo (#PCDATA)>
|
||||||
|
<!ELEMENT Message (LevelOne, LevelTwo)>
|
||||||
|
<!ATTLIST Message
|
||||||
|
ID CDATA #REQUIRED
|
||||||
|
Indicator (I | E | W | U | Q | C) #REQUIRED
|
||||||
|
>
|
||||||
|
<!ELEMENT MessageFile (Component)>
|
||||||
|
<!ATTLIST MessageFile
|
||||||
|
Version CDATA #FIXED "1.0"
|
||||||
|
>
|
||||||
|
<!ELEMENT MessageList (Message+)>
|
||||||
|
<!ELEMENT Subcomponent (MessageList)>
|
||||||
|
<!ATTLIST Subcomponent
|
||||||
|
Abbr ID #REQUIRED
|
||||||
|
Name CDATA #REQUIRED
|
||||||
|
>
|
24
rse/plugins/org.eclipse.rse.processes.ui/plugin.properties
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
################################################################################
|
||||||
|
# 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.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# NLS_MESSAGEFORMAT_VAR
|
||||||
|
|
||||||
|
plugin.name = RSE Processes UI
|
||||||
|
|
||||||
|
Factory.LocalProcesses = Local Processes
|
||||||
|
PropertyPage.ServerLauncherSettings = Server Launcher Settings
|
||||||
|
PropertyPage.ServerConnectionSecurity= Server Connection Security
|
||||||
|
PropertyPage.Service = Service
|
56
rse/plugins/org.eclipse.rse.processes.ui/plugin.xml
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
<?eclipse version="3.1"?>
|
||||||
|
<plugin>
|
||||||
|
|
||||||
|
<!-- ============================================== -->
|
||||||
|
<!-- Define subsystem factories for processes... -->
|
||||||
|
<!-- ============================================== -->
|
||||||
|
<!-- let's wait until this is supported on windows
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.rse.ui.subsystemconfiguration">
|
||||||
|
<factory
|
||||||
|
systemtypes="Local"
|
||||||
|
name="%Factory.LocalProcesses"
|
||||||
|
iconlive="icons/full/obj16/activeprocess.gif"
|
||||||
|
icon="icons/full/obj16/activeprocess.gif"
|
||||||
|
category="processes"
|
||||||
|
class="org.eclipse.rse.subsystems.processes.local.LocalProcessSubSystemConfiguration"
|
||||||
|
vendor="IBM Corporation"
|
||||||
|
id="ibm.localprocesses">
|
||||||
|
</factory>
|
||||||
|
</extension>
|
||||||
|
-->
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.propertyPages">
|
||||||
|
<page
|
||||||
|
objectClass="org.eclipse.rse.subsystems.processes.servicesubsystem.ProcessServiceSubSystem"
|
||||||
|
name="%PropertyPage.ServerLauncherSettings"
|
||||||
|
class="org.eclipse.rse.ui.propertypages.ServerLauncherPropertyPage"
|
||||||
|
id="org.eclipse.rse.ui.propertypages.serverLauncherPropertyPage">
|
||||||
|
<filter name="serverLaunchPP" value="true"/>
|
||||||
|
</page>
|
||||||
|
<page
|
||||||
|
objectClass="org.eclipse.rse.subsystems.processes.servicesubsystem.ProcessServiceSubSystem"
|
||||||
|
name="%PropertyPage.Service"
|
||||||
|
class="org.eclipse.rse.processes.ui.propertypages.ProcessServicesPropertyPage"
|
||||||
|
id="org.eclipse.rse.processes.ui.propertypages.ProcessServicesPropertyPage">
|
||||||
|
</page>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
|
||||||
|
</plugin>
|
|
@ -0,0 +1,167 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui;
|
||||||
|
|
||||||
|
import java.util.MissingResourceException;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IAdapterManager;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.rse.core.SystemBasePlugin;
|
||||||
|
import org.eclipse.rse.processes.ui.view.RemoteProcessSubsystemFactoryAdapterFactory;
|
||||||
|
import org.eclipse.rse.processes.ui.view.SystemViewProcessAdapterFactory;
|
||||||
|
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||||
|
import org.eclipse.rse.services.clientserver.messages.SystemMessageFile;
|
||||||
|
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main plugin class to be used in the desktop.
|
||||||
|
*/
|
||||||
|
public class ProcessesPlugin extends SystemBasePlugin {
|
||||||
|
//The shared instance.
|
||||||
|
private static ProcessesPlugin plugin;
|
||||||
|
//Resource bundle.
|
||||||
|
private ResourceBundle resourceBundle;
|
||||||
|
private SystemViewProcessAdapterFactory svpaf;
|
||||||
|
private static SystemMessageFile messageFile = null;
|
||||||
|
private static SystemMessageFile defaultMessageFile = null;
|
||||||
|
|
||||||
|
public static final String HELPPREFIX = "org.eclipse.rse.processes.ui.";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor.
|
||||||
|
*/
|
||||||
|
public ProcessesPlugin() {
|
||||||
|
super();
|
||||||
|
plugin = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called upon plug-in activation
|
||||||
|
*/
|
||||||
|
public void start(BundleContext context) throws Exception {
|
||||||
|
super.start(context);
|
||||||
|
messageFile = getMessageFile("systemmessages.xml");
|
||||||
|
defaultMessageFile = getDefaultMessageFile("systemmessages.xml");
|
||||||
|
|
||||||
|
IAdapterManager manager = Platform.getAdapterManager();
|
||||||
|
svpaf = new SystemViewProcessAdapterFactory();
|
||||||
|
svpaf.registerWithManager(manager);
|
||||||
|
|
||||||
|
RemoteProcessSubsystemFactoryAdapterFactory rpssfaf = new RemoteProcessSubsystemFactoryAdapterFactory();
|
||||||
|
rpssfaf.registerWithManager(manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called when the plug-in is stopped
|
||||||
|
*/
|
||||||
|
public void stop(BundleContext context) throws Exception {
|
||||||
|
super.stop(context);
|
||||||
|
plugin = null;
|
||||||
|
resourceBundle = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shared instance.
|
||||||
|
*/
|
||||||
|
public static ProcessesPlugin getDefault() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the string from the plugin's resource bundle,
|
||||||
|
* or 'key' if not found.
|
||||||
|
*/
|
||||||
|
public static String getResourceString(String key) {
|
||||||
|
ResourceBundle bundle = ProcessesPlugin.getDefault().getResourceBundle();
|
||||||
|
try {
|
||||||
|
return (bundle != null) ? bundle.getString(key) : key;
|
||||||
|
} catch (MissingResourceException e) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the plugin's resource bundle,
|
||||||
|
*/
|
||||||
|
public ResourceBundle getResourceBundle() {
|
||||||
|
try {
|
||||||
|
if (resourceBundle == null)
|
||||||
|
resourceBundle = ResourceBundle.getBundle("org.eclipse.rse.processes.ui.SystemProcessesResources");
|
||||||
|
} catch (MissingResourceException x) {
|
||||||
|
resourceBundle = null;
|
||||||
|
}
|
||||||
|
return resourceBundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a message from this plugin's message file
|
||||||
|
* @param msgId - the ID of the message to retrieve. This is the concatenation of the
|
||||||
|
* message's component abbreviation, subcomponent abbreviation, and message ID as declared
|
||||||
|
* in the message xml file.
|
||||||
|
*/
|
||||||
|
public static SystemMessage getPluginMessage(String msgId)
|
||||||
|
{
|
||||||
|
SystemMessage msg = getMessage(messageFile, msgId);
|
||||||
|
if (msg == null)
|
||||||
|
{
|
||||||
|
msg = getMessage(defaultMessageFile, msgId);
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a message file for this plugin.
|
||||||
|
* @param messageFileName - the name of the message xml file. Will look for it in this plugin's install folder.
|
||||||
|
* @return a message file object containing the parsed contents of the message file, or null if not found.
|
||||||
|
*/
|
||||||
|
public SystemMessageFile getMessageFile(String messageFileName)
|
||||||
|
{
|
||||||
|
return loadMessageFile(getBundle(), messageFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a default message file for this plugin for cases where messages haven't been translated.
|
||||||
|
* @param messageFileName - the name of the message xml file. Will look for it in this plugin's install folder.
|
||||||
|
* @return a message file object containing the parsed contents of the message file, or null if not found.
|
||||||
|
*/
|
||||||
|
public SystemMessageFile getDefaultMessageFile(String messageFileName)
|
||||||
|
{
|
||||||
|
return loadDefaultMessageFile(getBundle(), messageFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageDescriptor getImageDescriptorFromPath(String path)
|
||||||
|
{
|
||||||
|
return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.rse.processes.ui", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the image registry by declaring all of the required
|
||||||
|
* graphics.
|
||||||
|
*/
|
||||||
|
protected void initializeImageRegistry()
|
||||||
|
{
|
||||||
|
//String path = getIconPath();
|
||||||
|
//putImageInRegistry(ISystemIconConstants.ICON_SYSTEM_NEWPROFILEWIZARD_ID,
|
||||||
|
// path+ISystemIconConstants.ICON_SYSTEM_NEWPROFILEWIZARD);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,734 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui;
|
||||||
|
|
||||||
|
import org.eclipse.jface.viewers.CheckboxTableViewer;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||||
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
import org.eclipse.rse.core.SystemBasePlugin;
|
||||||
|
import org.eclipse.rse.core.SystemPlugin;
|
||||||
|
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||||
|
import org.eclipse.rse.processes.ui.view.SystemProcessStatesContentProvider;
|
||||||
|
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||||
|
import org.eclipse.rse.services.clientserver.processes.HostProcessFilterImpl;
|
||||||
|
import org.eclipse.rse.services.clientserver.processes.ISystemProcessRemoteConstants;
|
||||||
|
import org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcessSubSystemConfiguration;
|
||||||
|
import org.eclipse.rse.ui.ISystemMessages;
|
||||||
|
import org.eclipse.rse.ui.SystemResources;
|
||||||
|
import org.eclipse.rse.ui.SystemWidgetHelpers;
|
||||||
|
import org.eclipse.rse.ui.actions.SystemTestFilterStringAction;
|
||||||
|
import org.eclipse.rse.ui.filters.SystemFilterStringEditPane;
|
||||||
|
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||||
|
import org.eclipse.rse.ui.validators.ValidatorIntegerInput;
|
||||||
|
import org.eclipse.rse.ui.validators.ValidatorIntegerRangeInput;
|
||||||
|
import org.eclipse.rse.ui.validators.ValidatorLongRangeInput;
|
||||||
|
import org.eclipse.rse.ui.validators.ValidatorSpecialChar;
|
||||||
|
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.events.SelectionListener;
|
||||||
|
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.Control;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
|
|
||||||
|
public class SystemProcessFilterStringEditPane extends
|
||||||
|
SystemFilterStringEditPane implements ISystemMessages, ISystemProcessRemoteConstants
|
||||||
|
{
|
||||||
|
|
||||||
|
// GUI widgets
|
||||||
|
|
||||||
|
protected Label lblStatus;
|
||||||
|
protected CheckboxTableViewer chkStatus;
|
||||||
|
protected Label lblExeName, lblUserName, lblGid;
|
||||||
|
protected Text txtExeName, txtUserName, txtGid;
|
||||||
|
|
||||||
|
protected Label lblMinVM, lblMaxVM;
|
||||||
|
protected Text txtMinVM, txtMaxVM;
|
||||||
|
protected Button chkBoxUnlimitedVM;
|
||||||
|
|
||||||
|
// limits
|
||||||
|
protected int gidLimit = Integer.MAX_VALUE;
|
||||||
|
protected long vmMaxValue = Long.MAX_VALUE;
|
||||||
|
protected int exeNameLength = 256;
|
||||||
|
protected int userNameLength = 256;
|
||||||
|
|
||||||
|
// validators
|
||||||
|
protected ValidatorLongRangeInput vmRangeValidator = new ValidatorLongRangeInput(0, vmMaxValue);
|
||||||
|
protected ValidatorIntegerRangeInput gidValidator = new ValidatorIntegerRangeInput(0, gidLimit);
|
||||||
|
protected ValidatorSpecialChar nameValidator = new ValidatorSpecialChar(" \t|", true);
|
||||||
|
|
||||||
|
// inputs
|
||||||
|
protected String[] inputFilterStrings;
|
||||||
|
|
||||||
|
// state
|
||||||
|
protected boolean noValidation = false;
|
||||||
|
protected boolean callerInstanceOfWizardPage, callerInstanceOfSystemPromptDialog;
|
||||||
|
protected boolean skipUniquenessChecking;
|
||||||
|
protected boolean calledFromVerify;
|
||||||
|
protected boolean dontStealFocus;
|
||||||
|
protected IRemoteProcessSubSystemConfiguration inputSubsystemFactory = null;
|
||||||
|
|
||||||
|
// actions
|
||||||
|
protected SystemTestFilterStringAction testAction = null;
|
||||||
|
|
||||||
|
// constants
|
||||||
|
protected final static int SIZING_SELECTION_WIDGET_HEIGHT = 90;
|
||||||
|
protected final static int SIZING_SELECTION_WIDGET_WIDTH = 145;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for SystemProcessFilterStringEditPane.
|
||||||
|
* @param shell
|
||||||
|
*/
|
||||||
|
public SystemProcessFilterStringEditPane(Shell shell)
|
||||||
|
{
|
||||||
|
super(shell);
|
||||||
|
((ValidatorIntegerInput)gidValidator).setBlankAllowed(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------
|
||||||
|
// INPUT/CONFIGURATION METHODS...
|
||||||
|
// ------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call this to override the text limit for the filter name, from the default of 256.
|
||||||
|
*/
|
||||||
|
public void setExeNameLength(int max)
|
||||||
|
{
|
||||||
|
exeNameLength = max;
|
||||||
|
if (txtExeName != null)
|
||||||
|
txtExeName.setTextLimit(max);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Call this to override the text limit for the filter name, from the default of 256.
|
||||||
|
*/
|
||||||
|
public void setUserNameLength(int max)
|
||||||
|
{
|
||||||
|
userNameLength = max;
|
||||||
|
if (txtUserName != null)
|
||||||
|
txtUserName.setTextLimit(max);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Existing strings are used to aid in uniqueness validation.
|
||||||
|
*/
|
||||||
|
public void setExistingStrings(String[] existingStrings)
|
||||||
|
{
|
||||||
|
this.inputFilterStrings = existingStrings;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------
|
||||||
|
// LIFECYCLE METHODS...
|
||||||
|
// ------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populate the pane with the GUI widgets
|
||||||
|
* @param parent
|
||||||
|
* @return Control
|
||||||
|
*/
|
||||||
|
public Control createContents(Composite parent)
|
||||||
|
{
|
||||||
|
Composite composite_prompts = SystemWidgetHelpers.createComposite(parent, 1);
|
||||||
|
int gridColumns = 2;
|
||||||
|
Composite sub_prompts1 = SystemWidgetHelpers.createComposite(composite_prompts, gridColumns);
|
||||||
|
|
||||||
|
// Exe name prompt
|
||||||
|
lblExeName = SystemWidgetHelpers.createLabel(sub_prompts1, SystemProcessesResources.RESID_PROCESSFILTERSTRING_EXENAME_LABEL);
|
||||||
|
lblExeName.setToolTipText(SystemProcessesResources.RESID_PROCESSFILTERSTRING_EXENAME_TOOLTIP);
|
||||||
|
txtExeName = SystemWidgetHelpers.createTextField(sub_prompts1, null);
|
||||||
|
txtExeName.setToolTipText(SystemProcessesResources.RESID_PROCESSFILTERSTRING_EXENAME_TOOLTIP);
|
||||||
|
|
||||||
|
SystemWidgetHelpers.setHelp(txtExeName, ProcessesPlugin.HELPPREFIX+"pfsd0001");
|
||||||
|
updateGridData(txtExeName, gridColumns-1);
|
||||||
|
txtExeName.setText("*");
|
||||||
|
|
||||||
|
// User name prompt
|
||||||
|
lblUserName = SystemWidgetHelpers.createLabel(sub_prompts1, SystemProcessesResources.RESID_PROCESSFILTERSTRING_USERNAME_LABEL);
|
||||||
|
lblUserName.setToolTipText(SystemProcessesResources.RESID_PROCESSFILTERSTRING_USERNAME_TOOLTIP);
|
||||||
|
txtUserName = SystemWidgetHelpers.createTextField(sub_prompts1, null);
|
||||||
|
txtUserName.setToolTipText(SystemProcessesResources.RESID_PROCESSFILTERSTRING_USERNAME_TOOLTIP);
|
||||||
|
|
||||||
|
SystemWidgetHelpers.setHelp(txtUserName, ProcessesPlugin.HELPPREFIX+"pfsd0002");
|
||||||
|
updateGridData(txtUserName, gridColumns-1);
|
||||||
|
txtUserName.setText("*");
|
||||||
|
|
||||||
|
// Group ID prompt
|
||||||
|
lblGid = SystemWidgetHelpers.createLabel(sub_prompts1, SystemProcessesResources.RESID_PROCESSFILTERSTRING_GID_LABEL);
|
||||||
|
lblGid.setToolTipText(SystemProcessesResources.RESID_PROCESSFILTERSTRING_GID_TOOLTIP);
|
||||||
|
txtGid = SystemWidgetHelpers.createTextField(sub_prompts1, null);
|
||||||
|
txtGid.setToolTipText(SystemProcessesResources.RESID_PROCESSFILTERSTRING_GID_TOOLTIP);
|
||||||
|
|
||||||
|
SystemWidgetHelpers.setHelp(txtGid, ProcessesPlugin.HELPPREFIX+"pfsd0003");
|
||||||
|
updateGridData(txtGid, gridColumns-1);
|
||||||
|
txtGid.setText("*");
|
||||||
|
|
||||||
|
// status checkbox table
|
||||||
|
lblStatus = SystemWidgetHelpers.createLabel(sub_prompts1, SystemProcessesResources.RESID_PROCESSFILTERSTRING_STATUS_LABEL);
|
||||||
|
lblStatus.setToolTipText(SystemProcessesResources.RESID_PROCESSFILTERSTRING_STATUS_TOOLTIP);
|
||||||
|
chkStatus = CheckboxTableViewer.newCheckList(sub_prompts1, SWT.BORDER);
|
||||||
|
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
|
||||||
|
data.heightHint = SIZING_SELECTION_WIDGET_HEIGHT;
|
||||||
|
data.widthHint = SIZING_SELECTION_WIDGET_WIDTH;
|
||||||
|
chkStatus.getTable().setLayoutData(data);
|
||||||
|
chkStatus.setLabelProvider(new LabelProvider());
|
||||||
|
|
||||||
|
SystemWidgetHelpers.setHelp(chkStatus.getControl(), ProcessesPlugin.HELPPREFIX+"pfsd0004");
|
||||||
|
SystemWidgetHelpers.createLabel(sub_prompts1, " ");
|
||||||
|
addSelectionButtons(sub_prompts1);
|
||||||
|
|
||||||
|
// Range prompt
|
||||||
|
Composite subsub = SystemWidgetHelpers.createComposite(sub_prompts1, gridColumns, 3, false, null, -1, -1);
|
||||||
|
lblMinVM = SystemWidgetHelpers.createLabel(subsub, SystemProcessesResources.RESID_PROCESSFILTERSTRING_MINVM_LABEL);
|
||||||
|
lblMinVM.setToolTipText(SystemProcessesResources.RESID_PROCESSFILTERSTRING_MINVM_TOOLTIP);
|
||||||
|
txtMinVM = SystemWidgetHelpers.createTextField(subsub, null);
|
||||||
|
txtMinVM.setToolTipText(SystemProcessesResources.RESID_PROCESSFILTERSTRING_MINVM_TOOLTIP);
|
||||||
|
|
||||||
|
SystemWidgetHelpers.setHelp(txtMinVM, ProcessesPlugin.HELPPREFIX+"pfsd0005");
|
||||||
|
txtMinVM.setText("0");
|
||||||
|
SystemWidgetHelpers.createLabel(subsub, " ");
|
||||||
|
|
||||||
|
lblMaxVM = SystemWidgetHelpers.createLabel(subsub, SystemProcessesResources.RESID_PROCESSFILTERSTRING_MAXVM_LABEL);
|
||||||
|
lblMaxVM.setToolTipText(SystemProcessesResources.RESID_PROCESSFILTERSTRING_MAXVM_TOOLTIP);
|
||||||
|
txtMaxVM = SystemWidgetHelpers.createTextField(subsub, null);
|
||||||
|
txtMaxVM.setToolTipText(SystemProcessesResources.RESID_PROCESSFILTERSTRING_MAXVM_TOOLTIP);
|
||||||
|
|
||||||
|
SystemWidgetHelpers.setHelp(txtMaxVM, ProcessesPlugin.HELPPREFIX+"pfsd0006");
|
||||||
|
txtMaxVM.setEnabled(false);
|
||||||
|
|
||||||
|
// Unlimited check box
|
||||||
|
chkBoxUnlimitedVM = SystemWidgetHelpers.createCheckBox(subsub, 1, null,
|
||||||
|
SystemProcessesResources.RESID_PROCESSFILTERSTRING_UNLIMITED_LABEL, SystemProcessesResources.RESID_PROCESSFILTERSTRING_UNLIMITED_TOOLTIP);
|
||||||
|
SystemWidgetHelpers.setHelp(chkBoxUnlimitedVM, ProcessesPlugin.HELPPREFIX+"pfsd0007");
|
||||||
|
|
||||||
|
txtExeName.setFocus();
|
||||||
|
|
||||||
|
if (refProvider != null)
|
||||||
|
inputSubsystemFactory = (IRemoteProcessSubSystemConfiguration)((ISubSystem)refProvider).getSubSystemConfiguration();
|
||||||
|
else if (provider != null)
|
||||||
|
inputSubsystemFactory = (IRemoteProcessSubSystemConfiguration)provider;
|
||||||
|
IStructuredContentProvider p = new SystemProcessStatesContentProvider();
|
||||||
|
|
||||||
|
chkStatus.setContentProvider(p);
|
||||||
|
chkStatus.setInput(p.getElements(null));
|
||||||
|
|
||||||
|
txtExeName.setTextLimit(exeNameLength);
|
||||||
|
txtUserName.setTextLimit(userNameLength);
|
||||||
|
|
||||||
|
resetFields();
|
||||||
|
doInitializeFields();
|
||||||
|
|
||||||
|
txtExeName.addModifyListener(
|
||||||
|
new ModifyListener() {
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
validateNameInput(txtExeName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
txtUserName.addModifyListener(
|
||||||
|
new ModifyListener() {
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
validateNameInput(txtUserName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
txtGid.addModifyListener(
|
||||||
|
new ModifyListener() {
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
validateGidInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
txtMinVM.addModifyListener(
|
||||||
|
new ModifyListener() {
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
if (validateMinVMInput() == null)
|
||||||
|
{
|
||||||
|
if (!chkBoxUnlimitedVM.getSelection() && !txtMaxVM.getText().trim().equals(""))
|
||||||
|
{
|
||||||
|
SystemMessage message = validateMinLessThanMax();
|
||||||
|
fireChangeEvent(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
txtMaxVM.addModifyListener(
|
||||||
|
new ModifyListener() {
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
if (validateMaxVMInput() == null)
|
||||||
|
{
|
||||||
|
if (!txtMinVM.getText().trim().equals(""))
|
||||||
|
{
|
||||||
|
SystemMessage message = validateMinLessThanMax();
|
||||||
|
fireChangeEvent(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
chkBoxUnlimitedVM.addSelectionListener(this);
|
||||||
|
|
||||||
|
return composite_prompts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the selection and deselection buttons to the dialog.
|
||||||
|
* @param composite org.eclipse.swt.widgets.Composite
|
||||||
|
*/
|
||||||
|
private void addSelectionButtons(Composite composite)
|
||||||
|
{
|
||||||
|
Composite buttonComposite = new Composite(composite, SWT.RIGHT);
|
||||||
|
GridLayout layout = new GridLayout();
|
||||||
|
layout.numColumns = 2;
|
||||||
|
buttonComposite.setLayout(layout);
|
||||||
|
GridData data =
|
||||||
|
new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL);
|
||||||
|
data.grabExcessHorizontalSpace = true;
|
||||||
|
composite.setData(data);
|
||||||
|
|
||||||
|
//Button selectButton = createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, WorkbenchMessages.getString("WizardTransferPage.selectAll"), false); //$NON-NLS-1$
|
||||||
|
Button selectButton = SystemWidgetHelpers.createPushButton(buttonComposite, null,
|
||||||
|
SystemResources.RESID_SELECTFILES_SELECTALL_BUTTON_ROOT_LABEL, SystemResources.RESID_SELECTFILES_SELECTALL_BUTTON_ROOT_TOOLTIP);
|
||||||
|
|
||||||
|
SelectionListener listener = new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
chkStatus.setAllChecked(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
selectButton.addSelectionListener(listener);
|
||||||
|
|
||||||
|
|
||||||
|
//Button deselectButton = createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, WorkbenchMessages.getString("WizardTransferPage.deselectAll"), false); //$NON-NLS-1$
|
||||||
|
Button deselectButton = SystemWidgetHelpers.createPushButton(buttonComposite, null,
|
||||||
|
SystemResources.RESID_SELECTFILES_DESELECTALL_BUTTON_ROOT_LABEL, SystemResources.RESID_SELECTFILES_DESELECTALL_BUTTON_ROOT_TOOLTIP);
|
||||||
|
|
||||||
|
listener = new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
chkStatus.setAllChecked(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
deselectButton.addSelectionListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateGridData(Control widget, int gridColumns)
|
||||||
|
{
|
||||||
|
GridData data = (GridData)widget.getLayoutData();
|
||||||
|
data.horizontalSpan = gridColumns;
|
||||||
|
data.grabExcessHorizontalSpace = false;
|
||||||
|
data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the control to recieve initial focus. Should be overridden if you override createContents
|
||||||
|
*/
|
||||||
|
public Control getInitialFocusControl()
|
||||||
|
{
|
||||||
|
return txtExeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override of parent.
|
||||||
|
* Called after reset fields, at first create time or when input is reset to a non-null value.
|
||||||
|
*/
|
||||||
|
protected void doInitializeFields()
|
||||||
|
{
|
||||||
|
if (txtExeName == null) return;
|
||||||
|
|
||||||
|
if (inputFilterString != null)
|
||||||
|
{
|
||||||
|
HostProcessFilterImpl rffs = new HostProcessFilterImpl(inputFilterString);
|
||||||
|
String defaultExeName = rffs.getName();
|
||||||
|
txtExeName.setText((defaultExeName==null) ? "" : defaultExeName);
|
||||||
|
String defaultUserName = rffs.getUsername();
|
||||||
|
txtUserName.setText((defaultUserName==null) ? "" : defaultUserName);
|
||||||
|
|
||||||
|
String defaultGid = rffs.getGid();
|
||||||
|
txtGid.setText((defaultGid==null) ? "" : defaultGid);
|
||||||
|
String defaultMinVM = rffs.getMinVM();
|
||||||
|
txtMinVM.setText((defaultMinVM==null) ? "" : defaultMinVM);
|
||||||
|
String defaultMaxVM = rffs.getMaxVM();
|
||||||
|
if (defaultMaxVM.equals("-1") || defaultMaxVM == null)
|
||||||
|
{
|
||||||
|
txtMaxVM.setText("");
|
||||||
|
txtMaxVM.setEnabled(false);
|
||||||
|
chkBoxUnlimitedVM.setEnabled(true);
|
||||||
|
chkBoxUnlimitedVM.setSelection(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
txtMaxVM.setEnabled(true);
|
||||||
|
chkBoxUnlimitedVM.setEnabled(false);
|
||||||
|
txtMaxVM.setText(defaultMaxVM);
|
||||||
|
}
|
||||||
|
|
||||||
|
chkStatus.setAllChecked(rffs.getAnyStatus());
|
||||||
|
|
||||||
|
String[] stateTypes = SystemProcessStatesContentProvider.getStates();
|
||||||
|
for (int i = 0; i < ALL_STATES_STR.length; i++)
|
||||||
|
{
|
||||||
|
chkStatus.setChecked(stateTypes[i], rffs.getSpecificState(ALL_STATES_STR[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* This is called in the change filter dialog when the user selects "new", or selects another string.
|
||||||
|
* You must override this if you override createContents. Be sure to test if the contents have even been created yet!
|
||||||
|
*/
|
||||||
|
protected void resetFields()
|
||||||
|
{
|
||||||
|
if (txtExeName == null)
|
||||||
|
return;
|
||||||
|
txtExeName.setText("*");
|
||||||
|
txtUserName.setText("*");
|
||||||
|
txtGid.setText("");
|
||||||
|
txtMinVM.setText("0");
|
||||||
|
txtMaxVM.setText("");
|
||||||
|
chkBoxUnlimitedVM.setSelection(true);
|
||||||
|
txtMaxVM.setEnabled(false);
|
||||||
|
chkBoxUnlimitedVM.setEnabled(true);
|
||||||
|
chkStatus.setAllChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must be overridden if createContents is overridden.
|
||||||
|
* <p>
|
||||||
|
* This is called by the isComplete, to decide if the default information
|
||||||
|
* is complete enough to enable finish. It doesn't do validation, that will be done when
|
||||||
|
* finish is pressed.
|
||||||
|
*/
|
||||||
|
protected boolean areFieldsComplete()
|
||||||
|
{
|
||||||
|
if (txtExeName == null) return false;
|
||||||
|
else return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Completes processing of the wizard page or dialog. If this
|
||||||
|
* method returns true, the wizard/dialog will close;
|
||||||
|
* otherwise, it will stay active.
|
||||||
|
*
|
||||||
|
* @return error, if there is one
|
||||||
|
*/
|
||||||
|
public SystemMessage verify()
|
||||||
|
{
|
||||||
|
errorMessage = null;
|
||||||
|
Control controlInError = null;
|
||||||
|
calledFromVerify = true;
|
||||||
|
skipEventFiring = true;
|
||||||
|
|
||||||
|
errorMessage = validateNameInput(txtExeName);
|
||||||
|
if (errorMessage != null)
|
||||||
|
controlInError = txtExeName;
|
||||||
|
|
||||||
|
errorMessage = validateNameInput(txtUserName);
|
||||||
|
if (errorMessage != null)
|
||||||
|
controlInError = txtUserName;
|
||||||
|
|
||||||
|
errorMessage = validateGidInput();
|
||||||
|
if (errorMessage != null)
|
||||||
|
controlInError = txtGid;
|
||||||
|
|
||||||
|
errorMessage = validateMinVMInput();
|
||||||
|
if (errorMessage != null)
|
||||||
|
controlInError = txtMinVM;
|
||||||
|
|
||||||
|
if (errorMessage == null)
|
||||||
|
{
|
||||||
|
if (!chkBoxUnlimitedVM.getSelection())
|
||||||
|
{
|
||||||
|
errorMessage = validateMaxVMInput();
|
||||||
|
if (errorMessage == null)
|
||||||
|
{
|
||||||
|
errorMessage = validateMinLessThanMax();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (errorMessage != null)
|
||||||
|
controlInError = txtMaxVM;
|
||||||
|
|
||||||
|
}
|
||||||
|
if ((errorMessage == null) && (inputFilterStrings!=null) && !skipUniquenessChecking)
|
||||||
|
{
|
||||||
|
boolean notUnique = false;
|
||||||
|
String currFilterString = getFilterString();
|
||||||
|
if (containsFilterString(currFilterString))
|
||||||
|
notUnique = true;
|
||||||
|
if (notUnique)
|
||||||
|
{
|
||||||
|
errorMessage = SystemPlugin.getPluginMessage(FILEMSG_VALIDATE_FILEFILTERSTRING_NOTUNIQUE).makeSubstitution(currFilterString);
|
||||||
|
}
|
||||||
|
controlInError = txtExeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorMessage != null)
|
||||||
|
{
|
||||||
|
if (!dontStealFocus)
|
||||||
|
controlInError.setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
calledFromVerify = false;
|
||||||
|
skipEventFiring = false;
|
||||||
|
fireChangeEvent(errorMessage);
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private boolean containsFilterString(String newString)
|
||||||
|
{
|
||||||
|
if (inputFilterStrings == null)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int idx=0; idx<inputFilterStrings.length; idx++)
|
||||||
|
{
|
||||||
|
if (inputFilterStrings[idx].equals(newString))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------
|
||||||
|
// METHODS FOR VERIFYING INPUT PER KEYSTROKE ...
|
||||||
|
// ---------------------------------------------
|
||||||
|
/**
|
||||||
|
* This hook method is called whenever the text changes in the input field.
|
||||||
|
* The default implementation delegates the request to an <code>ISystemValidator</code> object.
|
||||||
|
* If the <code>ISystemValidator</code> reports an error the error message is displayed
|
||||||
|
* in the Dialog's message line.
|
||||||
|
*/
|
||||||
|
protected SystemMessage validateNameInput(Text txt)
|
||||||
|
{
|
||||||
|
if (noValidation || ignoreChanges)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
errorMessage = null;
|
||||||
|
|
||||||
|
if (nameValidator != null)
|
||||||
|
{
|
||||||
|
errorMessage = nameValidator.validate(txt.getText().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
fireChangeEvent(errorMessage);
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This hook method is called whenever the text changes in the input field.
|
||||||
|
* The default implementation delegates the request to an <code>ISystemValidator</code> object.
|
||||||
|
* If the <code>ISystemValidator</code> reports an error the error message is displayed
|
||||||
|
* in the Dialog's message line.
|
||||||
|
*/
|
||||||
|
protected SystemMessage validateGidInput()
|
||||||
|
{
|
||||||
|
if (noValidation || ignoreChanges)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
errorMessage = null;
|
||||||
|
|
||||||
|
if (gidValidator != null)
|
||||||
|
{
|
||||||
|
errorMessage = gidValidator.validate(txtGid.getText().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
fireChangeEvent(errorMessage);
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This hook method is called whenever the text changes in the input field.
|
||||||
|
* The default implementation delegates the request to an <code>ISystemValidator</code> object.
|
||||||
|
* If the <code>ISystemValidator</code> reports an error the error message is displayed
|
||||||
|
* in the Dialog's message line.
|
||||||
|
*/
|
||||||
|
protected SystemMessage validateMinVMInput()
|
||||||
|
{
|
||||||
|
if (noValidation || ignoreChanges)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
errorMessage = null;
|
||||||
|
|
||||||
|
if (vmRangeValidator != null)
|
||||||
|
{
|
||||||
|
errorMessage = vmRangeValidator.validate(txtMinVM.getText().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
fireChangeEvent(errorMessage);
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This hook method is called whenever the text changes in the input field.
|
||||||
|
* The default implementation delegates the request to an <code>ISystemValidator</code> object.
|
||||||
|
* If the <code>ISystemValidator</code> reports an error the error message is displayed
|
||||||
|
* in the Dialog's message line.
|
||||||
|
*/
|
||||||
|
protected SystemMessage validateMaxVMInput()
|
||||||
|
{
|
||||||
|
if (noValidation || ignoreChanges || chkBoxUnlimitedVM.getSelection())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
errorMessage = null;
|
||||||
|
|
||||||
|
if (vmRangeValidator != null)
|
||||||
|
{
|
||||||
|
errorMessage = vmRangeValidator.validate(txtMaxVM.getText().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
fireChangeEvent(errorMessage);
|
||||||
|
return errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This hook method is called whenever the text changes in the input field.
|
||||||
|
* The default implementation delegates the request to an <code>ISystemValidator</code> object.
|
||||||
|
* If the <code>ISystemValidator</code> reports an error the error message is displayed
|
||||||
|
* in the Dialog's message line.
|
||||||
|
*/
|
||||||
|
protected SystemMessage validateMinLessThanMax()
|
||||||
|
{
|
||||||
|
long minVM = 0;
|
||||||
|
long maxVM = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
minVM = Long.parseLong(txtMinVM.getText());
|
||||||
|
maxVM = Long.parseLong(txtMaxVM.getText());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (maxVM < minVM)
|
||||||
|
{
|
||||||
|
return ProcessesPlugin.getPluginMessage("RSEPG1001");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// ------------------------------
|
||||||
|
// DATA EXTRACTION METHODS
|
||||||
|
// ------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the filter string in its current form.
|
||||||
|
* This should be overridden if createContents is overridden.
|
||||||
|
*/
|
||||||
|
public String getFilterString()
|
||||||
|
{
|
||||||
|
if (txtExeName == null)
|
||||||
|
return inputFilterString;
|
||||||
|
|
||||||
|
HostProcessFilterImpl rpfs = new HostProcessFilterImpl();
|
||||||
|
|
||||||
|
String exeName = txtExeName.getText().trim();
|
||||||
|
if (!exeName.equals("")) rpfs.setName(exeName);
|
||||||
|
|
||||||
|
String userName = txtUserName.getText().trim();
|
||||||
|
if (!userName.equals("")) rpfs.setUsername(userName);
|
||||||
|
|
||||||
|
String gid = txtGid.getText().trim();
|
||||||
|
if (!gid.equals("")) rpfs.setGid(gid);
|
||||||
|
|
||||||
|
String minVM = txtMinVM.getText().trim();
|
||||||
|
if (!minVM.equals("")) rpfs.setMinVM(minVM);
|
||||||
|
|
||||||
|
if (chkBoxUnlimitedVM.getSelection())
|
||||||
|
{
|
||||||
|
rpfs.setMaxVM("-1");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String maxVM = txtMaxVM.getText().trim();
|
||||||
|
if (!maxVM.equals("")) rpfs.setMaxVM(maxVM);
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] stateStrings = SystemProcessStatesContentProvider.getStates();
|
||||||
|
for (int i = 0; i < ALL_STATES_STR.length; i++)
|
||||||
|
{
|
||||||
|
if (chkStatus.getChecked(stateStrings[i])) rpfs.setSpecificState(ALL_STATES_STR[i]);
|
||||||
|
}
|
||||||
|
return rpfs.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------
|
||||||
|
// EVENT LISTENERS...
|
||||||
|
// ------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User has selected something
|
||||||
|
*/
|
||||||
|
public void widgetSelected(SelectionEvent event)
|
||||||
|
{
|
||||||
|
Object src = event.getSource();
|
||||||
|
dontStealFocus = true;
|
||||||
|
if (src == chkBoxUnlimitedVM)
|
||||||
|
{
|
||||||
|
txtMaxVM.setEnabled(!chkBoxUnlimitedVM.getSelection());
|
||||||
|
if (!chkBoxUnlimitedVM.getSelection())
|
||||||
|
{
|
||||||
|
txtMaxVM.setFocus();
|
||||||
|
if (validateMaxVMInput() == null)
|
||||||
|
{
|
||||||
|
if (!txtMinVM.getText().trim().equals(""))
|
||||||
|
{
|
||||||
|
SystemMessage message = validateMinLessThanMax();
|
||||||
|
fireChangeEvent(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else verify();
|
||||||
|
}
|
||||||
|
dontStealFocus = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by us or by owning dialog when common Test button is pressed
|
||||||
|
*/
|
||||||
|
public void processTest(Shell shell)
|
||||||
|
{
|
||||||
|
if (refProvider == null)
|
||||||
|
{
|
||||||
|
SystemBasePlugin.logWarning("Programming Error: input subsystem is not set");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
skipUniquenessChecking = true;
|
||||||
|
if (verify() == null)
|
||||||
|
{
|
||||||
|
SystemTestFilterStringAction testAction = new SystemTestFilterStringAction(getShell());
|
||||||
|
testAction.setSubSystem((ISubSystem)refProvider);
|
||||||
|
testAction.setFilterString(getFilterString());
|
||||||
|
try
|
||||||
|
{
|
||||||
|
testAction.run();
|
||||||
|
}
|
||||||
|
catch (Exception exc)
|
||||||
|
{
|
||||||
|
|
||||||
|
SystemMessage msg = SystemMessageDialog.getExceptionMessage(getShell(), exc);
|
||||||
|
fireChangeEvent(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
skipUniquenessChecking = false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui;
|
||||||
|
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
|
public class SystemProcessesResources extends NLS
|
||||||
|
{
|
||||||
|
private static String BUNDLE_NAME = "org.eclipse.rse.processes.ui.SystemProcessesResources";
|
||||||
|
|
||||||
|
// -------------------------
|
||||||
|
// ACTIONS...
|
||||||
|
// -------------------------
|
||||||
|
public static String ACTION_NEWPROCESSFILTER_LABEL;
|
||||||
|
public static String ACTION_NEWPROCESSFILTER_TOOLTIP;
|
||||||
|
|
||||||
|
public static String ACTION_UPDATEFILTER_LABEL;
|
||||||
|
public static String ACTION_UPDATEFILTER_TOOLTIP;
|
||||||
|
|
||||||
|
public static String ACTION_KILLPROCESS_LABEL;
|
||||||
|
public static String ACTION_KILLPROCESS_TOOLTIP;
|
||||||
|
|
||||||
|
// -------------------------
|
||||||
|
// WIZARDS...
|
||||||
|
// -------------------------
|
||||||
|
|
||||||
|
// New System process Filter wizard...
|
||||||
|
public static String RESID_NEWPROCESSFILTER_PAGE1_TITLE;
|
||||||
|
public static String RESID_NEWPROCESSFILTER_PAGE1_DESCRIPTION;
|
||||||
|
|
||||||
|
// Change process filter
|
||||||
|
public static String RESID_CHGPROCESSFILTER_TITLE;
|
||||||
|
|
||||||
|
// Process Filter String Re-Usable form (used in dialog and wizard)
|
||||||
|
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_EXENAME_LABEL;
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_USERNAME_LABEL;
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_GID_LABEL;
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_MINVM_LABEL;
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_MAXVM_LABEL;
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_UNLIMITED_LABEL;
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_STATUS_LABEL;
|
||||||
|
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_EXENAME_TOOLTIP;
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_USERNAME_TOOLTIP;
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_GID_TOOLTIP;
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_MINVM_TOOLTIP;
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_MAXVM_TOOLTIP;
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_UNLIMITED_TOOLTIP;
|
||||||
|
public static String RESID_PROCESSFILTERSTRING_STATUS_TOOLTIP;
|
||||||
|
|
||||||
|
// Warnings
|
||||||
|
public static String RESID_KILL_WARNING_LABEL;
|
||||||
|
public static String RESID_KILL_WARNING_TOOLTIP;
|
||||||
|
|
||||||
|
// KILL Process dialog
|
||||||
|
public static String RESID_KILL_TITLE;
|
||||||
|
public static String RESID_KILL_PROMPT;
|
||||||
|
public static String RESID_KILL_PROMPT_SINGLE;
|
||||||
|
public static String RESID_KILL_BUTTON;
|
||||||
|
public static String RESID_KILL_TIP;
|
||||||
|
public static String RESID_KILL_SIGNAL_TYPE_LABEL;
|
||||||
|
public static String RESID_KILL_SIGNAL_TYPE_TOOLTIP;
|
||||||
|
public static String RESID_KILL_SIGNAL_TYPE_DEFAULT;
|
||||||
|
public static String RESID_KILL_COLHDG_EXENAME;
|
||||||
|
public static String RESID_KILL_COLHDG_PID;
|
||||||
|
|
||||||
|
// Remote Processes dialog
|
||||||
|
public static String RESID_REMOTE_PROCESSES_EXECUTABLE_LABEL;
|
||||||
|
public static String RESID_REMOTE_PROCESSES_EXECUTABLE_TOOLTIP;
|
||||||
|
|
||||||
|
static {
|
||||||
|
// load message values from bundle file
|
||||||
|
NLS.initializeMessages(BUNDLE_NAME, SystemProcessesResources.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
################################################################################
|
||||||
|
# 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.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
#=============================================================
|
||||||
|
# PROCESS SUBSYSTEM ACTIONS...
|
||||||
|
#=============================================================
|
||||||
|
ACTION_NEWPROCESSFILTER_LABEL=Filter...
|
||||||
|
ACTION_NEWPROCESSFILTER_TOOLTIP=Create a new process filter
|
||||||
|
ACTION_UPDATEFILTER_LABEL=Change...
|
||||||
|
ACTION_UPDATEFILTER_TOOLTIP=Change this filter's name or contents
|
||||||
|
ACTION_KILLPROCESS_LABEL=Kill...
|
||||||
|
ACTION_KILLPROCESS_TOOLTIP=Send this process a kill signal
|
||||||
|
|
||||||
|
#=============================================================
|
||||||
|
# NEW PROCESS FILTER WIZARD...
|
||||||
|
#=============================================================
|
||||||
|
RESID_NEWPROCESSFILTER_PAGE1_TITLE=Process Filter
|
||||||
|
RESID_NEWPROCESSFILTER_PAGE1_DESCRIPTION=Create a process filter
|
||||||
|
|
||||||
|
RESID_PROCESSFILTERSTRING_EXENAME_LABEL=Executable Name
|
||||||
|
RESID_PROCESSFILTERSTRING_USERNAME_LABEL=User Name
|
||||||
|
RESID_PROCESSFILTERSTRING_GID_LABEL=Group ID
|
||||||
|
RESID_PROCESSFILTERSTRING_MINVM_LABEL=Minimum VM Size (kB)
|
||||||
|
RESID_PROCESSFILTERSTRING_MAXVM_LABEL=Maximum VM Size (kB)
|
||||||
|
RESID_PROCESSFILTERSTRING_UNLIMITED_LABEL=Unlimited
|
||||||
|
RESID_PROCESSFILTERSTRING_STATUS_LABEL=Status
|
||||||
|
|
||||||
|
RESID_PROCESSFILTERSTRING_EXENAME_TOOLTIP=The name of the executable owning the process
|
||||||
|
RESID_PROCESSFILTERSTRING_USERNAME_TOOLTIP=The name of the user owning the process
|
||||||
|
RESID_PROCESSFILTERSTRING_GID_TOOLTIP=The group id of the user owning the process
|
||||||
|
RESID_PROCESSFILTERSTRING_MINVM_TOOLTIP=The minimum virtual memory size used by the process
|
||||||
|
RESID_PROCESSFILTERSTRING_MAXVM_TOOLTIP=The maximum virtual memory size used by the process
|
||||||
|
RESID_PROCESSFILTERSTRING_UNLIMITED_TOOLTIP=No limit to virtual memory size
|
||||||
|
RESID_PROCESSFILTERSTRING_STATUS_TOOLTIP=The current status of the process
|
||||||
|
|
||||||
|
#=============================================================
|
||||||
|
# CHANGE FILE FILTER DIALOG...
|
||||||
|
#=============================================================
|
||||||
|
RESID_CHGPROCESSFILTER_TITLE=Change Process Filter
|
||||||
|
|
||||||
|
#=============================================================
|
||||||
|
# KILL PROCESS WARNING...
|
||||||
|
#=============================================================
|
||||||
|
RESID_KILL_WARNING_LABEL=WARNING! Terminating or interrupting a remote process can cause\nsystem instability and other undesirable effects!
|
||||||
|
RESID_KILL_WARNING_TOOLTIP=You are confirming that a signal will be sent to the remote process(es). This action cannot be undone
|
||||||
|
|
||||||
|
#=============================================================
|
||||||
|
# KILL PROCESS DIALOG
|
||||||
|
#=============================================================
|
||||||
|
RESID_KILL_TITLE=Send a kill signal
|
||||||
|
RESID_KILL_PROMPT=Kill selected processes?
|
||||||
|
RESID_KILL_PROMPT_SINGLE=Kill selected process?
|
||||||
|
RESID_KILL_BUTTON=Kill
|
||||||
|
RESID_KILL_TIP=Confirm kill request
|
||||||
|
RESID_KILL_SIGNAL_TYPE_LABEL=Signal Type
|
||||||
|
RESID_KILL_SIGNAL_TYPE_TOOLTIP=The type of kill signal to send to the process
|
||||||
|
RESID_KILL_SIGNAL_TYPE_DEFAULT=default
|
||||||
|
RESID_KILL_COLHDG_EXENAME=Executable Name
|
||||||
|
RESID_KILL_COLHDG_PID=Process ID
|
||||||
|
|
||||||
|
#=============================================================
|
||||||
|
# REMOTE PROCESSES DIALOG
|
||||||
|
#=============================================================
|
||||||
|
RESID_REMOTE_PROCESSES_EXECUTABLE_LABEL=Executable
|
||||||
|
RESID_REMOTE_PROCESSES_EXECUTABLE_TOOLTIP=Name of executable
|
|
@ -0,0 +1,360 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui.actions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
|
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||||
|
import org.eclipse.jface.operation.IRunnableContext;
|
||||||
|
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.rse.core.SystemPlugin;
|
||||||
|
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||||
|
import org.eclipse.rse.filters.ISystemFilterReference;
|
||||||
|
import org.eclipse.rse.model.ISystemRegistry;
|
||||||
|
import org.eclipse.rse.model.ISystemResourceChangeEvents;
|
||||||
|
import org.eclipse.rse.model.SystemResourceChangeEvent;
|
||||||
|
import org.eclipse.rse.processes.ui.ProcessesPlugin;
|
||||||
|
import org.eclipse.rse.processes.ui.SystemProcessesResources;
|
||||||
|
import org.eclipse.rse.processes.ui.dialogs.SystemKillDialog;
|
||||||
|
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||||
|
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||||
|
import org.eclipse.rse.services.clientserver.processes.ISystemProcessRemoteConstants;
|
||||||
|
import org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcess;
|
||||||
|
import org.eclipse.rse.subsystems.processes.core.subsystem.RemoteProcessSubSystem;
|
||||||
|
import org.eclipse.rse.ui.ISystemContextMenuConstants;
|
||||||
|
import org.eclipse.rse.ui.ISystemMessages;
|
||||||
|
import org.eclipse.rse.ui.actions.SystemBaseAction;
|
||||||
|
import org.eclipse.rse.ui.actions.SystemBaseDialogAction;
|
||||||
|
import org.eclipse.rse.ui.messages.SystemMessageDialog;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
|
||||||
|
public class SystemKillProcessAction extends SystemBaseDialogAction implements IRunnableWithProgress
|
||||||
|
{
|
||||||
|
|
||||||
|
protected Exception runException = null;
|
||||||
|
protected Object[] processesDeathRow;
|
||||||
|
protected boolean killedOk = true;
|
||||||
|
protected String signalType = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for subclass
|
||||||
|
*/
|
||||||
|
public SystemKillProcessAction(Shell shell)
|
||||||
|
{
|
||||||
|
super(SystemProcessesResources.ACTION_KILLPROCESS_LABEL,
|
||||||
|
SystemProcessesResources.ACTION_KILLPROCESS_TOOLTIP,
|
||||||
|
ProcessesPlugin.getDefault().getImageDescriptorFromPath("/icons/full/elcl16/killprocessj.gif"),
|
||||||
|
shell);
|
||||||
|
allowOnMultipleSelection(true);
|
||||||
|
setProcessAllSelections(true);
|
||||||
|
setContextMenuGroup(ISystemContextMenuConstants.GROUP_REORGANIZE);
|
||||||
|
setHelp(ProcessesPlugin.HELPPREFIX+"actn0001");
|
||||||
|
setDialogHelp(ProcessesPlugin.HELPPREFIX+"dkrp0000");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We override from parent to do unique checking...
|
||||||
|
* <p>
|
||||||
|
* We simply ensure every selected object is an IRemoteProcess
|
||||||
|
* <p>
|
||||||
|
* @see SystemBaseAction#updateSelection(IStructuredSelection)
|
||||||
|
*/
|
||||||
|
public boolean updateSelection(IStructuredSelection selection)
|
||||||
|
{
|
||||||
|
boolean enable = true;
|
||||||
|
Iterator e= ((IStructuredSelection) selection).iterator();
|
||||||
|
while (enable && e.hasNext())
|
||||||
|
{
|
||||||
|
Object selectedObject = e.next();
|
||||||
|
if (!(selectedObject instanceof IRemoteProcess))
|
||||||
|
enable = false;
|
||||||
|
}
|
||||||
|
return enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required by parent.
|
||||||
|
* It is up to the caller to call wasCancelled() and if not true, do their own killing.
|
||||||
|
*/
|
||||||
|
protected Object getDialogValue(Dialog dlg)
|
||||||
|
{
|
||||||
|
SystemKillDialog killDlg = (SystemKillDialog)dlg;
|
||||||
|
if (!killDlg.wasCancelled())
|
||||||
|
signalType = killDlg.getSignal();
|
||||||
|
if (signalType.equals(SystemProcessesResources.RESID_KILL_SIGNAL_TYPE_DEFAULT))
|
||||||
|
signalType = ISystemProcessRemoteConstants.PROCESS_SIGNAL_TYPE_DEFAULT;
|
||||||
|
if (signalType != null)
|
||||||
|
{
|
||||||
|
IRunnableContext runnableContext = getRunnableContext();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
runnableContext.run(false,false,this); // inthread, cancellable, IRunnableWithProgress
|
||||||
|
}
|
||||||
|
catch (java.lang.reflect.InvocationTargetException exc) // unexpected error
|
||||||
|
{
|
||||||
|
showOperationMessage((Exception)exc.getTargetException(), getShell());
|
||||||
|
}
|
||||||
|
catch (Exception exc)
|
||||||
|
{
|
||||||
|
showOperationMessage(exc, getShell());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If you decide to use the supplied run method as is,
|
||||||
|
* then you must override this method to create and return
|
||||||
|
* the dialog that is displayed by the default run method
|
||||||
|
* implementation.
|
||||||
|
* <p>
|
||||||
|
* If you override run with your own, then
|
||||||
|
* simply implement this to return null as it won't be used.
|
||||||
|
* @see #run()
|
||||||
|
*/
|
||||||
|
protected Dialog createDialog(Shell shell)
|
||||||
|
{
|
||||||
|
SystemKillDialog dlg = new SystemKillDialog(shell);
|
||||||
|
return dlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an IRunnable context to show progress in. If there is currently a dialog or wizard up with
|
||||||
|
* a progress monitor in it, we will use this, else we will create a progress monitor dialog.
|
||||||
|
*/
|
||||||
|
protected IRunnableContext getRunnableContext()
|
||||||
|
{
|
||||||
|
ISystemRegistry sr = SystemPlugin.getTheSystemRegistry();
|
||||||
|
IRunnableContext irc = sr.getRunnableContext();
|
||||||
|
if (irc == null)
|
||||||
|
irc = new ProgressMonitorDialog(getShell());
|
||||||
|
return irc;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------
|
||||||
|
// INTERNAL METHODS...
|
||||||
|
// ----------------------------------
|
||||||
|
/**
|
||||||
|
* Method required by IRunnableWithProgress interface.
|
||||||
|
* Allows execution of a long-running operation modally by via a thread.
|
||||||
|
* In our case, it runs the kill operation with a visible progress monitor
|
||||||
|
*/
|
||||||
|
public void run(IProgressMonitor monitor)
|
||||||
|
throws java.lang.reflect.InvocationTargetException,
|
||||||
|
java.lang.InterruptedException
|
||||||
|
{
|
||||||
|
SystemMessage msg = getKillingMessage();
|
||||||
|
runException = null;
|
||||||
|
populateSelectedObjects();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int steps = processesDeathRow.length;
|
||||||
|
monitor.beginTask(msg.getLevelOneText(), steps);
|
||||||
|
killedOk = true;
|
||||||
|
IRemoteProcess currentProcess = null;
|
||||||
|
for (int idx=0; killedOk && (idx<steps); idx++)
|
||||||
|
{
|
||||||
|
currentProcess = (IRemoteProcess) processesDeathRow[idx];
|
||||||
|
if (signalType.equals(SystemProcessesResources.RESID_KILL_SIGNAL_TYPE_DEFAULT))
|
||||||
|
signalType = ISystemProcessRemoteConstants.PROCESS_SIGNAL_TYPE_DEFAULT;
|
||||||
|
monitor.subTask(getKillingMessage(signalType, currentProcess.getName()).getLevelOneText());
|
||||||
|
killedOk = doKill(monitor, signalType, currentProcess);
|
||||||
|
monitor.worked(1);
|
||||||
|
}
|
||||||
|
monitor.done();
|
||||||
|
}
|
||||||
|
catch(java.lang.InterruptedException exc)
|
||||||
|
{
|
||||||
|
monitor.done();
|
||||||
|
runException = exc;
|
||||||
|
throw (java.lang.InterruptedException)runException;
|
||||||
|
}
|
||||||
|
catch(Exception exc)
|
||||||
|
{
|
||||||
|
monitor.done();
|
||||||
|
runException = new java.lang.reflect.InvocationTargetException(exc);
|
||||||
|
throw (java.lang.reflect.InvocationTargetException)runException;
|
||||||
|
}
|
||||||
|
killComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param monitor Usually not needed
|
||||||
|
* @param signal the signal to be sent to the remote process
|
||||||
|
* @param process the process to send the signal to
|
||||||
|
*/
|
||||||
|
protected boolean doKill(IProgressMonitor monitor, String signal, IRemoteProcess process)
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
RemoteProcessSubSystem ss;
|
||||||
|
boolean ok = false;
|
||||||
|
ss = process.getParentRemoteProcessSubSystem();
|
||||||
|
|
||||||
|
ok = ss.kill(process, signal);
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
SystemMessage msg = ProcessesPlugin.getPluginMessage("RSEPG1300");
|
||||||
|
msg.makeSubstitution(process.getName());
|
||||||
|
throw new SystemMessageException(msg);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after all the copy/move operations end, be it successfully or not.
|
||||||
|
* Your opportunity to display completion or do post-copy selections/refreshes
|
||||||
|
*/
|
||||||
|
public void killComplete()
|
||||||
|
{
|
||||||
|
if (processesDeathRow.length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// refresh all instances of this parent, and all affected filters...
|
||||||
|
ISubSystem processSS = ((IRemoteProcess)processesDeathRow[0]).getParentRemoteProcessSubSystem();
|
||||||
|
|
||||||
|
List results = getAffectedFilters(processesDeathRow, processSS);
|
||||||
|
|
||||||
|
|
||||||
|
// update the ui
|
||||||
|
ISystemRegistry registry = SystemPlugin.getTheSystemRegistry();
|
||||||
|
for (int i = 0; i < results.size(); i++)
|
||||||
|
{
|
||||||
|
ISystemFilterReference ref = (ISystemFilterReference)results.get(i);
|
||||||
|
ref.markStale(true);
|
||||||
|
registry.fireEvent(new SystemResourceChangeEvent(ref, ISystemResourceChangeEvents.EVENT_CHANGE_CHILDREN,ref));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all the filters that are affected by killing the objects in processesDeathRow.
|
||||||
|
* @param processesDeathRow the objects that will be sent a kill signal
|
||||||
|
* @param subSystem the subsystem to search
|
||||||
|
* @return a list of the affected filters
|
||||||
|
*/
|
||||||
|
protected List getAffectedFilters(Object[] processesDeathRow, ISubSystem subSystem)
|
||||||
|
{
|
||||||
|
ISystemRegistry registry = SystemPlugin.getTheSystemRegistry();
|
||||||
|
List result = new ArrayList();
|
||||||
|
for (int i = 0; i < processesDeathRow.length; i++)
|
||||||
|
{
|
||||||
|
List refs = registry.findFilterReferencesFor(processesDeathRow[i], subSystem);
|
||||||
|
|
||||||
|
result.addAll(refs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void populateSelectedObjects()
|
||||||
|
{
|
||||||
|
IStructuredSelection selection = getSelection();
|
||||||
|
Iterator e = selection.iterator();
|
||||||
|
Vector v = new Vector();
|
||||||
|
while (e.hasNext())
|
||||||
|
{
|
||||||
|
v.add(e.next());
|
||||||
|
}
|
||||||
|
processesDeathRow = v.toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SystemMessage getKillingMessage()
|
||||||
|
{
|
||||||
|
return ProcessesPlugin.getPluginMessage("RSEPG1003");
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the specific "kill" message
|
||||||
|
*/
|
||||||
|
protected SystemMessage getKillingMessage(String signal, String processName)
|
||||||
|
{
|
||||||
|
SystemMessage msg = null;
|
||||||
|
msg = ProcessesPlugin.getPluginMessage("RSEPG1004");
|
||||||
|
msg.makeSubstitution(signal, processName);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to show an error message resulting from the attempted operation.
|
||||||
|
*/
|
||||||
|
protected void showOperationMessage(Exception exc, Shell shell)
|
||||||
|
{
|
||||||
|
if (exc instanceof java.lang.InterruptedException)
|
||||||
|
showOperationCancelledMessage(shell);
|
||||||
|
else if (exc instanceof java.lang.reflect.InvocationTargetException)
|
||||||
|
showOperationErrorMessage(shell, ((java.lang.reflect.InvocationTargetException)exc).getTargetException());
|
||||||
|
else
|
||||||
|
showOperationErrorMessage(shell, exc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show an error message when the operation fails.
|
||||||
|
* Shows a common message by default.
|
||||||
|
* Overridable.
|
||||||
|
*/
|
||||||
|
protected void showOperationErrorMessage(Shell shell, Throwable exc)
|
||||||
|
{
|
||||||
|
if (exc instanceof SystemMessageException)
|
||||||
|
showOperationErrorMessage(shell, (SystemMessageException)exc);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String msg = exc.getMessage();
|
||||||
|
if ((msg == null) || (exc instanceof ClassCastException))
|
||||||
|
msg = exc.getClass().getName();
|
||||||
|
SystemMessageDialog msgDlg =
|
||||||
|
new SystemMessageDialog(shell,
|
||||||
|
SystemPlugin.getPluginMessage(ISystemMessages.MSG_OPERATION_FAILED).makeSubstitution(msg));
|
||||||
|
msgDlg.setException(exc);
|
||||||
|
msgDlg.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Show an error message when the operation fails.
|
||||||
|
* Shows a SystemMessage that was encapsulated in a SystemMessage exception
|
||||||
|
* Overridable.
|
||||||
|
*/
|
||||||
|
protected void showOperationErrorMessage(Shell shell, SystemMessageException exc)
|
||||||
|
{
|
||||||
|
SystemMessage msg = exc.getSystemMessage();
|
||||||
|
SystemMessageDialog msgDlg =
|
||||||
|
new SystemMessageDialog(shell, msg);
|
||||||
|
msgDlg.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show an error message when the user cancels the operation.
|
||||||
|
* Shows a common message by default.
|
||||||
|
* Overridable.
|
||||||
|
*/
|
||||||
|
protected void showOperationCancelledMessage(Shell shell)
|
||||||
|
{
|
||||||
|
SystemMessageDialog msgDlg = new SystemMessageDialog(shell, SystemPlugin.getPluginMessage(ISystemMessages.MSG_OPERATION_CANCELLED));
|
||||||
|
msgDlg.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.rse.core.SystemPlugin;
|
||||||
|
import org.eclipse.rse.filters.ISystemFilterPool;
|
||||||
|
import org.eclipse.rse.processes.ui.SystemProcessFilterStringEditPane;
|
||||||
|
import org.eclipse.rse.processes.ui.SystemProcessesResources;
|
||||||
|
import org.eclipse.rse.ui.ISystemIconConstants;
|
||||||
|
import org.eclipse.rse.ui.filters.actions.SystemNewFilterAction;
|
||||||
|
import org.eclipse.rse.ui.filters.dialogs.SystemNewFilterWizard;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
|
||||||
|
public class SystemNewProcessFilterAction extends SystemNewFilterAction implements ISystemIconConstants
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public SystemNewProcessFilterAction(Shell shell, ISystemFilterPool parentPool)
|
||||||
|
|
||||||
|
{
|
||||||
|
super(shell, parentPool, SystemProcessesResources.ACTION_NEWPROCESSFILTER_LABEL,
|
||||||
|
SystemProcessesResources.ACTION_NEWPROCESSFILTER_TOOLTIP, SystemPlugin.getDefault().getImageDescriptor(ICON_SYSTEM_NEWFILTER_ID));
|
||||||
|
setHelp(SystemPlugin.HELPPREFIX+"actn0042");
|
||||||
|
setDialogHelp(SystemPlugin.HELPPREFIX+"wnfr0000");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the parent filter pool that the new-filter actions need.
|
||||||
|
*/
|
||||||
|
public void setParentFilterPool(ISystemFilterPool parentPool)
|
||||||
|
{
|
||||||
|
this.parentPool = parentPool;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Parent intercept.
|
||||||
|
* <p>
|
||||||
|
* Overridable extension. For those cases when you don't want to create your
|
||||||
|
* own wizard subclass, but prefer to simply configure the default wizard.
|
||||||
|
* <p>
|
||||||
|
* Note, at the point this is called, all the base configuration, based on the
|
||||||
|
* setters for this action, have been called.
|
||||||
|
* <p>
|
||||||
|
* We do it here versus via setters as it defers some work until the user actually
|
||||||
|
* selects this action.
|
||||||
|
*/
|
||||||
|
protected void configureNewFilterWizard(SystemNewFilterWizard wizard)
|
||||||
|
{
|
||||||
|
// configuration that used to only be possible via subclasses...
|
||||||
|
wizard.setWizardPageTitle(SystemProcessesResources.RESID_NEWPROCESSFILTER_PAGE1_TITLE);
|
||||||
|
wizard.setWizardImage(SystemPlugin.getDefault().getImageDescriptor(ICON_SYSTEM_NEWFILTERWIZARD_ID));
|
||||||
|
wizard.setPage1Description(SystemProcessesResources.RESID_NEWPROCESSFILTER_PAGE1_DESCRIPTION);
|
||||||
|
wizard.setFilterStringEditPane(new SystemProcessFilterStringEditPane(wizard.getShell()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.rse.processes.ui.SystemProcessFilterStringEditPane;
|
||||||
|
import org.eclipse.rse.processes.ui.SystemProcessesResources;
|
||||||
|
import org.eclipse.rse.ui.filters.actions.SystemChangeFilterAction;
|
||||||
|
import org.eclipse.rse.ui.filters.dialogs.SystemChangeFilterDialog;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
|
||||||
|
public class SystemProcessUpdateFilterAction extends SystemChangeFilterAction
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public SystemProcessUpdateFilterAction(Shell parent)
|
||||||
|
{
|
||||||
|
super(parent, SystemProcessesResources.ACTION_UPDATEFILTER_LABEL, SystemProcessesResources.ACTION_UPDATEFILTER_TOOLTIP);
|
||||||
|
setDialogTitle(SystemProcessesResources.RESID_CHGPROCESSFILTER_TITLE);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Overridable extension point to configure the filter dialog. Typically you don't need
|
||||||
|
* to subclass our default dialog.
|
||||||
|
*/
|
||||||
|
protected void configureFilterDialog(SystemChangeFilterDialog dlg)
|
||||||
|
{
|
||||||
|
// it is cheaper to do this here, as it defers instantiation of the edit pane until the
|
||||||
|
// user actually runs the action!
|
||||||
|
Shell shell = dlg.getShell();
|
||||||
|
if (shell == null)
|
||||||
|
shell = dlg.getParentShell();
|
||||||
|
|
||||||
|
dlg.setFilterStringEditPane(new SystemProcessFilterStringEditPane(shell));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,174 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui.dialogs;
|
||||||
|
|
||||||
|
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||||
|
import org.eclipse.jface.viewers.IDoubleClickListener;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.TableLayout;
|
||||||
|
import org.eclipse.rse.core.SystemPlugin;
|
||||||
|
import org.eclipse.rse.filters.ISystemFilterReference;
|
||||||
|
import org.eclipse.rse.processes.ui.SystemProcessesResources;
|
||||||
|
import org.eclipse.rse.services.clientserver.processes.IHostProcess;
|
||||||
|
import org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcess;
|
||||||
|
import org.eclipse.rse.subsystems.processes.core.subsystem.RemoteProcessSubSystem;
|
||||||
|
import org.eclipse.rse.ui.SystemWidgetHelpers;
|
||||||
|
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
|
||||||
|
import org.eclipse.rse.ui.view.SystemTableView;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.KeyEvent;
|
||||||
|
import org.eclipse.swt.events.KeyListener;
|
||||||
|
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.Shell;
|
||||||
|
import org.eclipse.swt.widgets.Table;
|
||||||
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author dmcknigh
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RemoteProcessesDialog extends SystemPromptDialog implements KeyListener
|
||||||
|
{
|
||||||
|
private Text _nameFilterText;
|
||||||
|
private SystemTableView _viewer;
|
||||||
|
private RemoteProcessSubSystem _subSystem;
|
||||||
|
private String _executableFilter;
|
||||||
|
private Table _table;
|
||||||
|
private IHostProcess _selected;
|
||||||
|
|
||||||
|
public RemoteProcessesDialog(Shell shell, String title, RemoteProcessSubSystem subSystem, String executableFilter)
|
||||||
|
{
|
||||||
|
super(shell, title);
|
||||||
|
_subSystem = subSystem;
|
||||||
|
_executableFilter = executableFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Control createInner(Composite parent)
|
||||||
|
{
|
||||||
|
GridLayout gridLayout = new GridLayout();
|
||||||
|
gridLayout.numColumns = 1;
|
||||||
|
parent.setLayout(gridLayout);
|
||||||
|
|
||||||
|
_nameFilterText = SystemWidgetHelpers.createLabeledTextField(parent, this, SystemProcessesResources.RESID_REMOTE_PROCESSES_EXECUTABLE_LABEL, SystemProcessesResources.RESID_REMOTE_PROCESSES_EXECUTABLE_TOOLTIP);
|
||||||
|
_nameFilterText.addKeyListener(this);
|
||||||
|
|
||||||
|
// create table portion
|
||||||
|
_table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION | SWT.HIDE_SELECTION);
|
||||||
|
_viewer = new SystemTableView(_table,this);
|
||||||
|
|
||||||
|
|
||||||
|
_viewer.addDoubleClickListener(new IDoubleClickListener()
|
||||||
|
{
|
||||||
|
public void doubleClick(DoubleClickEvent event)
|
||||||
|
{
|
||||||
|
//handleDoubleClick(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
SystemWidgetHelpers.setHelp(_viewer.getControl(), SystemPlugin.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);
|
||||||
|
gridData.heightHint = 200;
|
||||||
|
gridData.widthHint = 400;
|
||||||
|
_table.setLayoutData(gridData);
|
||||||
|
init();
|
||||||
|
return _table;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Control getInitialFocusControl()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return _viewer.getControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void doubleClick(DoubleClickEvent event)
|
||||||
|
{
|
||||||
|
IStructuredSelection s = (IStructuredSelection) event.getSelection();
|
||||||
|
Object element = s.getFirstElement();
|
||||||
|
if (element == null)
|
||||||
|
return;
|
||||||
|
processOK();
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected boolean processOK()
|
||||||
|
{
|
||||||
|
StructuredSelection sel = (StructuredSelection)_viewer.getSelection();
|
||||||
|
IRemoteProcess proc = (IRemoteProcess)sel.getFirstElement();
|
||||||
|
if (proc != null)
|
||||||
|
{
|
||||||
|
_selected = proc;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IHostProcess getSelected()
|
||||||
|
{
|
||||||
|
return _selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void init()
|
||||||
|
{
|
||||||
|
_nameFilterText.setText(_executableFilter);
|
||||||
|
Object[] filters = _subSystem.getChildren();
|
||||||
|
|
||||||
|
ISystemFilterReference ref = (ISystemFilterReference)filters[0];
|
||||||
|
ref.markStale(true);
|
||||||
|
updateViewFilter();
|
||||||
|
_viewer.setInput(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateViewFilter()
|
||||||
|
{
|
||||||
|
if (_executableFilter.indexOf("*") == -1)
|
||||||
|
_executableFilter += "*";
|
||||||
|
String[] viewFilters = {_executableFilter};
|
||||||
|
_viewer.setViewFilters(viewFilters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void keyPressed(KeyEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void keyReleased(KeyEvent e)
|
||||||
|
{
|
||||||
|
if (e.widget == _nameFilterText)
|
||||||
|
{
|
||||||
|
if (!_nameFilterText.getText().equals(_executableFilter))
|
||||||
|
{
|
||||||
|
_executableFilter = _nameFilterText.getText();
|
||||||
|
updateViewFilter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,331 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui.dialogs;
|
||||||
|
|
||||||
|
import org.eclipse.jface.viewers.ColumnLayoutData;
|
||||||
|
import org.eclipse.jface.viewers.ColumnPixelData;
|
||||||
|
import org.eclipse.jface.viewers.ColumnWeightData;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.TableLayout;
|
||||||
|
import org.eclipse.jface.viewers.TableViewer;
|
||||||
|
import org.eclipse.rse.core.SystemAdapterHelpers;
|
||||||
|
import org.eclipse.rse.core.SystemBasePlugin;
|
||||||
|
import org.eclipse.rse.processes.ui.ProcessesPlugin;
|
||||||
|
import org.eclipse.rse.processes.ui.SystemProcessesResources;
|
||||||
|
import org.eclipse.rse.processes.ui.view.ISystemProcessPropertyConstants;
|
||||||
|
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||||
|
import org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcess;
|
||||||
|
import org.eclipse.rse.ui.SystemWidgetHelpers;
|
||||||
|
import org.eclipse.rse.ui.dialogs.SystemPromptDialog;
|
||||||
|
import org.eclipse.rse.ui.messages.ISystemMessageLine;
|
||||||
|
import org.eclipse.rse.ui.view.ISystemPropertyConstants;
|
||||||
|
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.graphics.Image;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
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;
|
||||||
|
import org.eclipse.swt.widgets.Table;
|
||||||
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog for confirming killing of a process or group of processes. User
|
||||||
|
* selects the type of signal to be sent to the process.
|
||||||
|
*/
|
||||||
|
public class SystemKillDialog extends SystemPromptDialog
|
||||||
|
{
|
||||||
|
private String warningMessage = SystemProcessesResources.RESID_KILL_WARNING_LABEL;
|
||||||
|
private String warningTip = SystemProcessesResources.RESID_KILL_WARNING_TOOLTIP;
|
||||||
|
private String promptLabel;
|
||||||
|
private SystemKillTableProvider sktp;
|
||||||
|
private Label prompt;
|
||||||
|
private Table table;
|
||||||
|
private TableViewer tableViewer;
|
||||||
|
private GridData tableData;
|
||||||
|
private Combo cmbSignal;
|
||||||
|
private String signalType;
|
||||||
|
|
||||||
|
// column headers
|
||||||
|
private String columnHeaders[] = {
|
||||||
|
"",
|
||||||
|
SystemProcessesResources.RESID_KILL_COLHDG_EXENAME,
|
||||||
|
SystemProcessesResources.RESID_KILL_COLHDG_PID
|
||||||
|
};
|
||||||
|
|
||||||
|
// column layout
|
||||||
|
private ColumnLayoutData columnLayouts[] =
|
||||||
|
{
|
||||||
|
new ColumnPixelData(19, false),
|
||||||
|
new ColumnWeightData(150,150,true),
|
||||||
|
new ColumnWeightData(120,120,true)
|
||||||
|
};
|
||||||
|
|
||||||
|
// give each column a property value to identify it
|
||||||
|
private static String[] tableColumnProperties =
|
||||||
|
{
|
||||||
|
ISystemPropertyConstants.P_OK,
|
||||||
|
ISystemProcessPropertyConstants.P_PROCESS_NAME,
|
||||||
|
ISystemProcessPropertyConstants.P_PROCESS_PID,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for SystemKillDialog
|
||||||
|
*/
|
||||||
|
public SystemKillDialog(Shell shell)
|
||||||
|
{
|
||||||
|
super(shell, SystemProcessesResources.RESID_KILL_TITLE);
|
||||||
|
super.setOkButtonLabel(SystemProcessesResources.RESID_KILL_BUTTON);
|
||||||
|
setHelp(ProcessesPlugin.HELPPREFIX+"dkrp0000");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create message line. Intercept so we can set msg line of form.
|
||||||
|
*/
|
||||||
|
protected ISystemMessageLine createMessageLine(Composite c)
|
||||||
|
{
|
||||||
|
super.createMessageLine(c);
|
||||||
|
return fMessageLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SystemPromptDialog#getInitialFocusControl()
|
||||||
|
*/
|
||||||
|
protected Control getInitialFocusControl()
|
||||||
|
{
|
||||||
|
return tableViewer.getControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see SystemPromptDialog#createInner(Composite)
|
||||||
|
*/
|
||||||
|
protected Control createInner(Composite parent)
|
||||||
|
{
|
||||||
|
// Inner composite
|
||||||
|
int nbrColumns = 2;
|
||||||
|
Composite composite = SystemWidgetHelpers.createComposite(parent, nbrColumns);
|
||||||
|
|
||||||
|
// PROMPT
|
||||||
|
if (promptLabel == null) {
|
||||||
|
Object input = getInputObject();
|
||||||
|
|
||||||
|
if (input != null && input instanceof IStructuredSelection) {
|
||||||
|
int size = ((IStructuredSelection)input).size();
|
||||||
|
|
||||||
|
if (size > 1) {
|
||||||
|
prompt = SystemWidgetHelpers.createLabel(composite, SystemProcessesResources.RESID_KILL_PROMPT, nbrColumns);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
prompt = SystemWidgetHelpers.createLabel(composite, SystemProcessesResources.RESID_KILL_PROMPT_SINGLE, nbrColumns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// should never get here
|
||||||
|
else {
|
||||||
|
prompt = SystemWidgetHelpers.createLabel(composite, SystemProcessesResources.RESID_KILL_PROMPT, nbrColumns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
prompt = (Label)SystemWidgetHelpers.createVerbage(composite, promptLabel, nbrColumns, false, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
// WARNING
|
||||||
|
if (warningMessage != null)
|
||||||
|
{
|
||||||
|
// filler line
|
||||||
|
SystemWidgetHelpers.createLabel(composite, "", nbrColumns);
|
||||||
|
// create image
|
||||||
|
Image image = getShell().getDisplay().getSystemImage(SWT.ICON_WARNING);
|
||||||
|
Label imageLabel = null;
|
||||||
|
if (image != null)
|
||||||
|
{
|
||||||
|
imageLabel = new Label(composite, 0);
|
||||||
|
image.setBackground(imageLabel.getBackground());
|
||||||
|
imageLabel.setImage(image);
|
||||||
|
imageLabel.setLayoutData(new GridData(
|
||||||
|
GridData.HORIZONTAL_ALIGN_CENTER |
|
||||||
|
GridData.VERTICAL_ALIGN_BEGINNING));
|
||||||
|
}
|
||||||
|
Label warningLabel = SystemWidgetHelpers.createLabel(composite, warningMessage);
|
||||||
|
if (warningTip != null)
|
||||||
|
{
|
||||||
|
warningLabel.setToolTipText(warningTip);
|
||||||
|
imageLabel.setToolTipText(warningTip);
|
||||||
|
}
|
||||||
|
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
|
||||||
|
data.widthHint = 350;
|
||||||
|
data.grabExcessVerticalSpace = true;
|
||||||
|
warningLabel.setLayoutData(data);
|
||||||
|
|
||||||
|
// filler line
|
||||||
|
SystemWidgetHelpers.createLabel(composite, "", nbrColumns);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TABLE
|
||||||
|
tableViewer = createTableViewer(composite, nbrColumns);
|
||||||
|
createColumns();
|
||||||
|
tableViewer.setColumnProperties(tableColumnProperties);
|
||||||
|
|
||||||
|
sktp = new SystemKillTableProvider();
|
||||||
|
|
||||||
|
int width = tableData.widthHint;
|
||||||
|
int nbrRows = Math.min(getRows().length,8);
|
||||||
|
int rowHeight = table.getItemHeight() + table.getGridLineWidth();
|
||||||
|
int sbHeight = table.getHorizontalBar().getSize().y;
|
||||||
|
int height = (nbrRows * rowHeight) + sbHeight;
|
||||||
|
|
||||||
|
tableData.heightHint = height;
|
||||||
|
table.setLayoutData(tableData);
|
||||||
|
table.setSize(width, height);
|
||||||
|
|
||||||
|
tableViewer.setLabelProvider(sktp);
|
||||||
|
tableViewer.setContentProvider(sktp);
|
||||||
|
|
||||||
|
Object input = getInputObject();
|
||||||
|
tableViewer.setInput(input);
|
||||||
|
|
||||||
|
// Signal Type combo box
|
||||||
|
cmbSignal = SystemWidgetHelpers.createLabeledReadonlyCombo(composite, null, SystemProcessesResources.RESID_KILL_SIGNAL_TYPE_LABEL, SystemProcessesResources.RESID_KILL_SIGNAL_TYPE_TOOLTIP);
|
||||||
|
cmbSignal.addModifyListener(
|
||||||
|
new ModifyListener() {
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
selectionChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
cmbSignal.setItems(getSignalTypes());
|
||||||
|
cmbSignal.add(SystemProcessesResources.RESID_KILL_SIGNAL_TYPE_DEFAULT, 0);
|
||||||
|
cmbSignal.setText(cmbSignal.getItem(0));
|
||||||
|
signalType = cmbSignal.getText();
|
||||||
|
cmbSignal.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
|
||||||
|
|
||||||
|
return composite;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return all the possible signal types that can be sent to the selected processes
|
||||||
|
* on that system
|
||||||
|
*/
|
||||||
|
private String[] getSignalTypes()
|
||||||
|
{
|
||||||
|
Object selObj = getInputObject();
|
||||||
|
if (selObj instanceof IStructuredSelection)
|
||||||
|
{
|
||||||
|
IStructuredSelection selection = (IStructuredSelection) selObj;
|
||||||
|
IRemoteProcess process = (IRemoteProcess) selection.getFirstElement();
|
||||||
|
String[] types = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
types = process.getParentRemoteProcessSubSystem().getSignalTypes();
|
||||||
|
}
|
||||||
|
catch (SystemMessageException e)
|
||||||
|
{
|
||||||
|
SystemBasePlugin.logMessage(e.getSystemMessage(), e);
|
||||||
|
return new String[] { SystemProcessesResources.RESID_KILL_SIGNAL_TYPE_DEFAULT };
|
||||||
|
}
|
||||||
|
if (types == null) types = new String[] { SystemProcessesResources.RESID_KILL_SIGNAL_TYPE_DEFAULT };
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
else return new String[] { SystemProcessesResources.RESID_KILL_SIGNAL_TYPE_DEFAULT };
|
||||||
|
}
|
||||||
|
|
||||||
|
private TableViewer createTableViewer(Composite parent, int nbrColumns)
|
||||||
|
{
|
||||||
|
table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.HIDE_SELECTION);
|
||||||
|
table.setLinesVisible(true);
|
||||||
|
tableViewer = new TableViewer(table);
|
||||||
|
tableData = new GridData();
|
||||||
|
tableData.horizontalAlignment = GridData.BEGINNING;
|
||||||
|
tableData.grabExcessHorizontalSpace = false;
|
||||||
|
tableData.widthHint = 350;
|
||||||
|
tableData.heightHint = 30;
|
||||||
|
tableData.verticalAlignment = GridData.CENTER;
|
||||||
|
tableData.grabExcessVerticalSpace = true;
|
||||||
|
tableData.horizontalSpan = nbrColumns;
|
||||||
|
table.setLayoutData(tableData);
|
||||||
|
return tableViewer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createColumns()
|
||||||
|
{
|
||||||
|
TableLayout layout = new TableLayout();
|
||||||
|
table.setLayout(layout);
|
||||||
|
table.setHeaderVisible(true);
|
||||||
|
for (int i = 0; i < columnHeaders.length; i++)
|
||||||
|
{
|
||||||
|
layout.addColumnData(columnLayouts[i]);
|
||||||
|
TableColumn tc = new TableColumn(table, SWT.NONE,i);
|
||||||
|
tc.setResizable(columnLayouts[i].resizable);
|
||||||
|
tc.setText(columnHeaders[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectionChanged()
|
||||||
|
{
|
||||||
|
signalType = cmbSignal.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override of parent. Must pass selected object onto the form for initializing fields.
|
||||||
|
* Called by SystemDialogAction's default run() method after dialog instantiated.
|
||||||
|
*/
|
||||||
|
public void setInputObject(Object inputObject)
|
||||||
|
{
|
||||||
|
super.setInputObject(inputObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when user presses OK button.
|
||||||
|
* Return true to close dialog.
|
||||||
|
* Return false to not close dialog.
|
||||||
|
*/
|
||||||
|
protected boolean processOK()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the rows of deletable items.
|
||||||
|
*/
|
||||||
|
public SystemKillTableRow[] getRows()
|
||||||
|
{
|
||||||
|
return (SystemKillTableRow[])sktp.getElements(getInputObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the implementation of ISystemViewElement for the given
|
||||||
|
* object. Returns null if the adapter is not defined or the
|
||||||
|
* object is not adaptable.
|
||||||
|
*/
|
||||||
|
protected ISystemViewElementAdapter getAdapter(Object o)
|
||||||
|
{
|
||||||
|
return SystemAdapterHelpers.getAdapter(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSignal()
|
||||||
|
{
|
||||||
|
if (cmbSignal == null) return "";
|
||||||
|
if (cmbSignal.isDisposed()) return signalType;
|
||||||
|
String signal = cmbSignal.getText();
|
||||||
|
if (signal == null) return "";
|
||||||
|
return signal;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui.dialogs;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
|
import org.eclipse.rse.ui.dialogs.SystemDeleteTableProvider;
|
||||||
|
|
||||||
|
|
||||||
|
public class SystemKillTableProvider extends SystemDeleteTableProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
static final int COLUMN_IMAGE = 0;
|
||||||
|
static final int COLUMN_NAME = 1;
|
||||||
|
static final int COLUMN_TYPE = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return rows. Input must be an IStructuredSelection.
|
||||||
|
*/
|
||||||
|
public Object[] getElements(Object inputElement)
|
||||||
|
{
|
||||||
|
if (children == null)
|
||||||
|
{
|
||||||
|
IStructuredSelection iss = (IStructuredSelection)inputElement;
|
||||||
|
children = new SystemKillTableRow[iss.size()];
|
||||||
|
Iterator i = iss.iterator();
|
||||||
|
int idx = 0;
|
||||||
|
while (i.hasNext())
|
||||||
|
{
|
||||||
|
children[idx] = new SystemKillTableRow(i.next(), idx);
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the 0-based row number of the given element.
|
||||||
|
*/
|
||||||
|
public int getRowNumber(SystemKillTableRow row)
|
||||||
|
{
|
||||||
|
return row.getRowNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see ITableLabelProvider#getColumnText(java.lang.Object, int)
|
||||||
|
*/
|
||||||
|
public String getColumnText(Object element, int column)
|
||||||
|
{
|
||||||
|
String text = "";
|
||||||
|
if (column == COLUMN_NAME)
|
||||||
|
text = getTableRow(element).getName();
|
||||||
|
else if (column == COLUMN_TYPE)
|
||||||
|
text = getTableRow(element).getType();
|
||||||
|
//System.out.println("INSIDE GETCOLUMNTEXT: " + column + ", " + text + ", " + getTableRow(element));
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SystemKillTableRow getTableRow(Object element)
|
||||||
|
{
|
||||||
|
return (SystemKillTableRow)element;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,150 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui.dialogs;
|
||||||
|
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.rse.core.SystemAdapterHelpers;
|
||||||
|
import org.eclipse.rse.core.SystemPlugin;
|
||||||
|
import org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcess;
|
||||||
|
import org.eclipse.rse.ui.ISystemIconConstants;
|
||||||
|
import org.eclipse.rse.ui.dialogs.SystemDeleteTableRow;
|
||||||
|
import org.eclipse.rse.ui.dialogs.SystemSimpleContentElement;
|
||||||
|
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||||
|
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
||||||
|
|
||||||
|
|
||||||
|
public class SystemKillTableRow extends SystemDeleteTableRow
|
||||||
|
{
|
||||||
|
|
||||||
|
private Object element;
|
||||||
|
private String exename;
|
||||||
|
private String pid;
|
||||||
|
private ImageDescriptor imageDescriptor;
|
||||||
|
private ISystemViewElementAdapter adapter;
|
||||||
|
private ISystemRemoteElementAdapter remoteAdapter;
|
||||||
|
private int rowNbr = 0;
|
||||||
|
|
||||||
|
public SystemKillTableRow(Object element, int rowNbr)
|
||||||
|
{
|
||||||
|
super(element, rowNbr);
|
||||||
|
if (element instanceof SystemSimpleContentElement)
|
||||||
|
element = ((SystemSimpleContentElement)element).getData();
|
||||||
|
this.element = element;
|
||||||
|
this.adapter = getAdapter(element);
|
||||||
|
this.remoteAdapter = getRemoteAdapter(element);
|
||||||
|
this.rowNbr = rowNbr;
|
||||||
|
if (adapter != null)
|
||||||
|
this.exename = adapter.getName(element);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (element instanceof IRemoteProcess)
|
||||||
|
this.exename = ((IRemoteProcess)element).getName();
|
||||||
|
}
|
||||||
|
if (element instanceof IRemoteProcess)
|
||||||
|
this.pid = "" + ((IRemoteProcess)element).getPid();
|
||||||
|
if (adapter != null)
|
||||||
|
this.imageDescriptor = adapter.getImageDescriptor(element);
|
||||||
|
else this.imageDescriptor = SystemPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_PROCESS_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the name of the item to be deleted
|
||||||
|
* @return display name of the item.
|
||||||
|
*/
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return exename;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return the resource type of the item to be deleted
|
||||||
|
* @return resource type of the item
|
||||||
|
*/
|
||||||
|
public String getType()
|
||||||
|
{
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return the 0-based row number of this item
|
||||||
|
* @return 0-based row number
|
||||||
|
*/
|
||||||
|
public int getRowNumber()
|
||||||
|
{
|
||||||
|
return rowNbr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an image descriptor for the image. More efficient than getting the image.
|
||||||
|
*/
|
||||||
|
public ImageDescriptor getImageDescriptor()
|
||||||
|
{
|
||||||
|
return imageDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the input object this row represents
|
||||||
|
*/
|
||||||
|
public Object getElement()
|
||||||
|
{
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the input object adapter for the input object this row represents
|
||||||
|
*/
|
||||||
|
public ISystemViewElementAdapter getAdapter()
|
||||||
|
{
|
||||||
|
return adapter;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the input object remote adapter for the input object this row represents
|
||||||
|
*/
|
||||||
|
public ISystemRemoteElementAdapter getRemoteAdapter()
|
||||||
|
{
|
||||||
|
return remoteAdapter;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return true if this is a remote object
|
||||||
|
*/
|
||||||
|
public boolean isRemote()
|
||||||
|
{
|
||||||
|
return (remoteAdapter != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the implementation of ISystemViewElement for the given
|
||||||
|
* object. Returns null if the adapter is not defined or the
|
||||||
|
* object is not adaptable.
|
||||||
|
*/
|
||||||
|
protected ISystemViewElementAdapter getAdapter(Object o)
|
||||||
|
{
|
||||||
|
return SystemAdapterHelpers.getAdapter(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the implementation of ISystemRemoteElement for the given
|
||||||
|
* object. Returns null if this object does not adaptable to this.
|
||||||
|
*/
|
||||||
|
protected ISystemRemoteElementAdapter getRemoteAdapter(Object o)
|
||||||
|
{
|
||||||
|
return SystemAdapterHelpers.getRemoteAdapter(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return exename;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui.propertypages;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.rse.core.SystemPlugin;
|
||||||
|
import org.eclipse.rse.core.servicesubsystem.IServiceSubSystemConfiguration;
|
||||||
|
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||||
|
import org.eclipse.rse.model.IHost;
|
||||||
|
import org.eclipse.rse.model.ISystemRegistry;
|
||||||
|
import org.eclipse.rse.subsystems.processes.servicesubsystem.IProcessServiceSubSystemConfiguration;
|
||||||
|
import org.eclipse.rse.subsystems.processes.servicesubsystem.ProcessServiceSubSystem;
|
||||||
|
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 ProcessServicesPropertyPage extends ServicesPropertyPage
|
||||||
|
{
|
||||||
|
private IProcessServiceSubSystemConfiguration _currentFactory;
|
||||||
|
protected ProcessServiceSubSystem getProcessServiceSubSystem()
|
||||||
|
{
|
||||||
|
return (ProcessServiceSubSystem)getElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ServiceElement[] getServiceElements()
|
||||||
|
{
|
||||||
|
ProcessServiceSubSystem subSystem = getProcessServiceSubSystem();
|
||||||
|
|
||||||
|
IHost host = subSystem.getHost();
|
||||||
|
_currentFactory = (IProcessServiceSubSystemConfiguration)subSystem.getParentRemoteProcessSubSystemFactory();
|
||||||
|
IProcessServiceSubSystemConfiguration[] factories = getProcessServiceSubSystemFactories(host.getSystemType());
|
||||||
|
|
||||||
|
|
||||||
|
// create elements for each
|
||||||
|
ServiceElement[] elements = new ServiceElement[factories.length];
|
||||||
|
for (int i = 0; i < factories.length; i++)
|
||||||
|
{
|
||||||
|
IProcessServiceSubSystemConfiguration factory = factories[i];
|
||||||
|
elements[i] = new FactoryServiceElement(host, factory);
|
||||||
|
if (factory == _currentFactory)
|
||||||
|
{
|
||||||
|
elements[i].setSelected(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return elements;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IProcessServiceSubSystemConfiguration[] getProcessServiceSubSystemFactories(String systemType)
|
||||||
|
{
|
||||||
|
List results = new ArrayList();
|
||||||
|
ISystemRegistry sr = SystemPlugin.getTheSystemRegistry();
|
||||||
|
ISubSystemConfiguration[] factories = sr.getSubSystemConfigurationsBySystemType(systemType);
|
||||||
|
|
||||||
|
for (int i = 0; i < factories.length; i++)
|
||||||
|
{
|
||||||
|
ISubSystemConfiguration factory = factories[i];
|
||||||
|
if (factory instanceof IProcessServiceSubSystemConfiguration)
|
||||||
|
{
|
||||||
|
results.add(factory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (IProcessServiceSubSystemConfiguration[])results.toArray(new IProcessServiceSubSystemConfiguration[results.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IServiceSubSystemConfiguration getCurrentServiceSubSystemFactory()
|
||||||
|
{
|
||||||
|
return _currentFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubSystemFactory(ISubSystemConfiguration factory)
|
||||||
|
{
|
||||||
|
_currentFactory = (IProcessServiceSubSystemConfiguration)factory;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui.view;
|
||||||
|
|
||||||
|
public interface ISystemProcessPropertyConstants
|
||||||
|
{
|
||||||
|
public static final String P_PREFIX = org.eclipse.rse.ui.ISystemIconConstants.PREFIX;
|
||||||
|
|
||||||
|
// PROCESS PROPERTIES
|
||||||
|
public static String P_PROCESS_PID = P_PREFIX+"process.pid";
|
||||||
|
public static String P_PROCESS_NAME = P_PREFIX+"process.name";
|
||||||
|
public static String P_PROCESS_UID = P_PREFIX+"process.uid";
|
||||||
|
public static String P_PROCESS_USERNAME = P_PREFIX+"process.username";
|
||||||
|
public static String P_PROCESS_PPID = P_PREFIX+"process.ppid";
|
||||||
|
public static String P_PROCESS_GID = P_PREFIX+"process.gid";
|
||||||
|
public static String P_PROCESS_STATE = P_PREFIX+"process.state";
|
||||||
|
public static String P_PROCESS_TGID = P_PREFIX+"process.tgid";
|
||||||
|
public static String P_PROCESS_TRACERPID = P_PREFIX+"process.tracerpid";
|
||||||
|
public static String P_PROCESS_VMSIZE = P_PREFIX+"process.vmsize";
|
||||||
|
public static String P_PROCESS_VMRSS = P_PREFIX+"process.vmrss";
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui.view;
|
||||||
|
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.rse.core.subsystems.ISubSystemConfiguration;
|
||||||
|
import org.eclipse.rse.filters.ISystemFilter;
|
||||||
|
import org.eclipse.rse.filters.ISystemFilterPool;
|
||||||
|
import org.eclipse.rse.processes.ui.actions.SystemNewProcessFilterAction;
|
||||||
|
import org.eclipse.rse.processes.ui.actions.SystemProcessUpdateFilterAction;
|
||||||
|
import org.eclipse.rse.ui.view.SubsystemFactoryAdapter;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
|
||||||
|
public class RemoteProcessSubSystemFactoryAdapter extends SubsystemFactoryAdapter
|
||||||
|
{
|
||||||
|
|
||||||
|
SystemNewProcessFilterAction _newProcessFilterAction;
|
||||||
|
SystemProcessUpdateFilterAction _changeProcessFilterAction;
|
||||||
|
|
||||||
|
Vector _additionalActions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overridable parent method to return the action for creating a new filter.
|
||||||
|
* Returns new SystemNewFileFilterAction.
|
||||||
|
*/
|
||||||
|
protected IAction getNewFilterPoolFilterAction(ISubSystemConfiguration factory, ISystemFilterPool selectedPool, Shell shell)
|
||||||
|
{
|
||||||
|
if (_newProcessFilterAction == null)
|
||||||
|
{
|
||||||
|
_newProcessFilterAction = new SystemNewProcessFilterAction(shell, selectedPool);
|
||||||
|
}
|
||||||
|
return _newProcessFilterAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overridable method to return the action for changing an existing filter.
|
||||||
|
* Returns new SystemProcessUpdateFilterAction.
|
||||||
|
*/
|
||||||
|
protected IAction getChangeFilterAction(ISubSystemConfiguration factory, ISystemFilter selectedFilter, Shell shell)
|
||||||
|
{
|
||||||
|
if (_changeProcessFilterAction == null)
|
||||||
|
{
|
||||||
|
_changeProcessFilterAction = new SystemProcessUpdateFilterAction(shell);
|
||||||
|
}
|
||||||
|
return _changeProcessFilterAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.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.processes.core.subsystem.IRemoteProcessSubSystemConfiguration;
|
||||||
|
|
||||||
|
|
||||||
|
public class RemoteProcessSubsystemFactoryAdapterFactory implements IAdapterFactory
|
||||||
|
{
|
||||||
|
|
||||||
|
private ISubsystemConfigurationAdapter ssFactoryAdapter = new RemoteProcessSubSystemFactoryAdapter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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, IRemoteProcessSubSystemConfiguration.class);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @see IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
|
||||||
|
*/
|
||||||
|
public Object getAdapter(Object adaptableObject, Class adapterType)
|
||||||
|
{
|
||||||
|
Object adapter = null;
|
||||||
|
if (adaptableObject instanceof IRemoteProcessSubSystemConfiguration)
|
||||||
|
adapter = ssFactoryAdapter;
|
||||||
|
|
||||||
|
return adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,135 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui.view;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||||
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
import org.eclipse.rse.services.clientserver.processes.ISystemProcessRemoteConstants;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Content provider for any widget that wishes to get the names of all possible
|
||||||
|
* states of a process. Also contains a utility methods for getting the translated
|
||||||
|
* information about individual process states.
|
||||||
|
* @author mjberger
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SystemProcessStatesContentProvider implements ISystemProcessRemoteConstants, IStructuredContentProvider
|
||||||
|
{
|
||||||
|
private HashMap strIndices;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public SystemProcessStatesContentProvider()
|
||||||
|
{
|
||||||
|
strIndices = new HashMap();
|
||||||
|
// construct a mapping from unique state names to integers. Each integer
|
||||||
|
// is the index of the associated state name in the array of translated
|
||||||
|
// state name strings.
|
||||||
|
for (int i = 0; i < ALL_STATES_STR.length; i++)
|
||||||
|
{
|
||||||
|
strIndices.put(ALL_STATES_STR[i], new Integer(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a String array containing the translated names of all the process states.
|
||||||
|
*/
|
||||||
|
public static String[] getStates()
|
||||||
|
{
|
||||||
|
return new String[]
|
||||||
|
{
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ACTIVE_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_IDLE_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_NONEXISTENT_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_PAGING_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_RUNNING_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_SLEEPING_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_TRACED_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_WAITING_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOMBIE_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_SINGLE_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_MSGQRECEIVEWAIT_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_MSGQSENDWAIT_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_COMSYSKERNELWAIT_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_SEMAPHOREWAIT_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_QUIESCEFROZEN_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_FILESYSKERNELWAIT_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_MVSPAUSEWAIT_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_PTHREADCREATEDTASKS_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_SWAPPEDOUT_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_PTHREADCREATED_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_OTHERKERNELWAIT_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_CANCELLED_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_MULTITHREAD_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_MEDIUMWEIGHTTHREAD_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_ASYNCHRONOUSTHREAD_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_PTRACEKERNELWAIT_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_RUNNING_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_SLEEPING_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_STOPPED_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_INITIALPROCESSTHREAD_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_DETACHED_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_WAITINGFORCHILD_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_FORKING_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_MVSWAIT_VALUE,
|
||||||
|
SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ZOS_ZOMBIE_VALUE
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given the unique name/code representing a process state, returns
|
||||||
|
* the translated string for the process state.
|
||||||
|
* @param state the unique name/code for a process state.
|
||||||
|
* @return the associated translated name, or "" if a matching one cannot be found
|
||||||
|
*/
|
||||||
|
public String getStateString(String state)
|
||||||
|
{
|
||||||
|
Integer index = (Integer) strIndices.get(state);
|
||||||
|
if (index == null) return "";
|
||||||
|
String[] resources = getStates();
|
||||||
|
if (index.intValue() >= resources.length) return "";
|
||||||
|
return resources[index.intValue()];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public Object[] getElements(Object inputElement)
|
||||||
|
{
|
||||||
|
return getStates();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
||||||
|
*/
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||||
|
*/
|
||||||
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui.view;
|
||||||
|
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
|
|
||||||
|
public class SystemProcessesViewResources extends NLS
|
||||||
|
{
|
||||||
|
private static String BUNDLE_NAME = "org.eclipse.rse.processes.ui.view.SystemProcessesViewResources";
|
||||||
|
|
||||||
|
// PROCESS PROPERTIES
|
||||||
|
public static String RESID_PROPERTY_PROCESS_PID_LABEL;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_NAME_LABEL;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_UID_LABEL;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_USERNAME_LABEL;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_PPID_LABEL;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_GID_LABEL;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_STATE_LABEL;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TGID_LABEL;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TRACERPID_LABEL;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_VMSIZE_LABEL;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_VMRSS_LABEL;
|
||||||
|
|
||||||
|
public static String RESID_PROPERTY_PROCESS_PID_TOOLTIP;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_NAME_TOOLTIP;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_UID_TOOLTIP;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_USERNAME_TOOLTIP;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_PPID_TOOLTIP;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_GID_TOOLTIP;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_STATE_TOOLTIP;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TGID_TOOLTIP;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TRACERPID_TOOLTIP;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_VMSIZE_TOOLTIP;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_VMSIZE_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_VMRSS_TOOLTIP;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_VMRSS_VALUE;
|
||||||
|
|
||||||
|
public static String RESID_PROPERTY_PROCESS_DEFAULTFILTER_LABEL;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_MYPROCESSESFILTER_LABEL;
|
||||||
|
|
||||||
|
// Property sheet values: Processes
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ROOT;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ERROR_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_RUNNING_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_SLEEPING_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_WAITING_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOMBIE_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_TRACED_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_PAGING_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ACTIVE_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_IDLE_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_NONEXISTENT_VALUE;
|
||||||
|
|
||||||
|
// zOS states
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_SINGLE_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_MSGQRECEIVEWAIT_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_MSGQSENDWAIT_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_COMSYSKERNELWAIT_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_SEMAPHOREWAIT_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_QUIESCEFROZEN_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_FILESYSKERNELWAIT_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_MVSPAUSEWAIT_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_PTHREADCREATEDTASKS_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_SWAPPEDOUT_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_PTHREADCREATED_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_OTHERKERNELWAIT_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_CANCELLED_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_MULTITHREAD_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_MEDIUMWEIGHTTHREAD_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_ASYNCHRONOUSTHREAD_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_PTRACEKERNELWAIT_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_RUNNING_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_SLEEPING_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_STOPPED_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_INITIALPROCESSTHREAD_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_DETACHED_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_WAITINGFORCHILD_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_FORKING_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_MVSWAIT_VALUE;
|
||||||
|
public static String RESID_PROPERTY_PROCESS_TYPE_ZOS_ZOMBIE_VALUE;
|
||||||
|
|
||||||
|
|
||||||
|
static {
|
||||||
|
// load message values from bundle file
|
||||||
|
NLS.initializeMessages(BUNDLE_NAME, SystemProcessesViewResources.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
################################################################################
|
||||||
|
# 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.
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
#=============================================================
|
||||||
|
# PROCESS PROPERTIES
|
||||||
|
#=============================================================
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE=Process
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ROOT=Init (Root Process)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ERROR_VALUE=Error
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_RUNNING_VALUE=Running
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_SLEEPING_VALUE=Sleeping (Interruptible)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_WAITING_VALUE=Waiting (Disk Sleep)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOMBIE_VALUE=Zombie
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_TRACED_VALUE=Traced (Stopped)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_PAGING_VALUE=Paging
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ACTIVE_VALUE=Active (AIX only)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_IDLE_VALUE=Idle (AIX only)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_NONEXISTENT_VALUE=Non-existent (AIX only)
|
||||||
|
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_SINGLE_VALUE=Single task (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_MSGQRECEIVEWAIT_VALUE=Message queue receive wait (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_MSGQSENDWAIT_VALUE=Message queue send wait (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_COMSYSKERNELWAIT_VALUE=Communication system kernel wait (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_SEMAPHOREWAIT_VALUE=Semaphore operation wait (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_QUIESCEFROZEN_VALUE=Quiesce frozen (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_FILESYSKERNELWAIT_VALUE=File system kernel wait (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_MVSPAUSEWAIT_VALUE=MVS Pause wait (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_PTHREADCREATEDTASKS_VALUE=One or more pthread created tasks (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_SWAPPEDOUT_VALUE=Swapped out (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_PTHREADCREATED_VALUE=Pthread created (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_OTHERKERNELWAIT_VALUE=Other kernel wait (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_CANCELLED_VALUE=Canceled (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_MULTITHREAD_VALUE=Multi-thread (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_MEDIUMWEIGHTTHREAD_VALUE=Medium weight thread (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_ASYNCHRONOUSTHREAD_VALUE=Asynchronous thread (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_PTRACEKERNELWAIT_VALUE=Ptrace kernel wait (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_RUNNING_VALUE=Running (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_SLEEPING_VALUE=Sleeping (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_STOPPED_VALUE=Stopped (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_INITIALPROCESSTHREAD_VALUE=Initial process thread (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_DETACHED_VALUE=Detached thread (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_WAITINGFORCHILD_VALUE=Waiting for child (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_FORKING_VALUE=Forking (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_MVSWAIT_VALUE=MVS wait (z/OS)
|
||||||
|
RESID_PROPERTY_PROCESS_TYPE_ZOS_ZOMBIE_VALUE=Zombie (z/OS)
|
||||||
|
|
||||||
|
RESID_PROPERTY_PROCESS_PID_LABEL=Process ID
|
||||||
|
RESID_PROPERTY_PROCESS_NAME_LABEL=Executable Name
|
||||||
|
RESID_PROPERTY_PROCESS_UID_LABEL=User ID
|
||||||
|
RESID_PROPERTY_PROCESS_USERNAME_LABEL=Username
|
||||||
|
RESID_PROPERTY_PROCESS_PPID_LABEL=Parent PID
|
||||||
|
RESID_PROPERTY_PROCESS_GID_LABEL=Group ID
|
||||||
|
RESID_PROPERTY_PROCESS_STATE_LABEL=State
|
||||||
|
RESID_PROPERTY_PROCESS_TGID_LABEL=Task Group ID
|
||||||
|
RESID_PROPERTY_PROCESS_TRACERPID_LABEL=Tracer PID
|
||||||
|
RESID_PROPERTY_PROCESS_VMSIZE_LABEL=VM Size
|
||||||
|
RESID_PROPERTY_PROCESS_VMRSS_LABEL=VM RSS
|
||||||
|
RESID_PROPERTY_PROCESS_PID_TOOLTIP=The system ID number of the process
|
||||||
|
RESID_PROPERTY_PROCESS_NAME_TOOLTIP=The executable associated with the process
|
||||||
|
RESID_PROPERTY_PROCESS_UID_TOOLTIP=The user ID of the owner of the process
|
||||||
|
RESID_PROPERTY_PROCESS_USERNAME_TOOLTIP=The username of the owner of the process
|
||||||
|
RESID_PROPERTY_PROCESS_PPID_TOOLTIP=The process ID of the parent of the process
|
||||||
|
RESID_PROPERTY_PROCESS_GID_TOOLTIP=The group ID of the owner of the process
|
||||||
|
RESID_PROPERTY_PROCESS_STATE_TOOLTIP=The state in which the process currently is
|
||||||
|
RESID_PROPERTY_PROCESS_TGID_TOOLTIP=The task group to which process belongs
|
||||||
|
RESID_PROPERTY_PROCESS_TRACERPID_TOOLTIP=The tracer process ID of the process
|
||||||
|
RESID_PROPERTY_PROCESS_VMSIZE_TOOLTIP=The amount of virtual memory taken up by this process
|
||||||
|
RESID_PROPERTY_PROCESS_VMSIZE_VALUE=&1 kilobytes
|
||||||
|
RESID_PROPERTY_PROCESS_VMRSS_TOOLTIP=The amount of virtual memory resident set size of this process (actual RAM taken up by the process)
|
||||||
|
RESID_PROPERTY_PROCESS_VMRSS_VALUE=&1 kilobytes
|
|
@ -0,0 +1,60 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.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.processes.core.subsystem.IRemoteProcess;
|
||||||
|
import org.eclipse.rse.ui.view.AbstractSystemRemoteAdapterFactory;
|
||||||
|
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
||||||
|
import org.eclipse.ui.views.properties.IPropertySource;
|
||||||
|
|
||||||
|
|
||||||
|
public class SystemViewProcessAdapterFactory extends AbstractSystemRemoteAdapterFactory
|
||||||
|
{
|
||||||
|
private SystemViewRemoteProcessAdapter processAdapter = new SystemViewRemoteProcessAdapter();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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, IRemoteProcess.class);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @see IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
|
||||||
|
*/
|
||||||
|
public Object getAdapter(Object adaptableObject, Class adapterType)
|
||||||
|
{
|
||||||
|
Object adapter = null;
|
||||||
|
if (adaptableObject instanceof IRemoteProcess)
|
||||||
|
adapter = processAdapter;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,485 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.processes.ui.view;
|
||||||
|
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.rse.core.SystemBasePlugin;
|
||||||
|
import org.eclipse.rse.core.SystemPlugin;
|
||||||
|
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||||
|
import org.eclipse.rse.model.ISystemMessageObject;
|
||||||
|
import org.eclipse.rse.model.ISystemResourceSet;
|
||||||
|
import org.eclipse.rse.model.SystemMessageObject;
|
||||||
|
import org.eclipse.rse.model.SystemRemoteResourceSet;
|
||||||
|
import org.eclipse.rse.processes.ui.ProcessesPlugin;
|
||||||
|
import org.eclipse.rse.processes.ui.actions.SystemKillProcessAction;
|
||||||
|
import org.eclipse.rse.services.clientserver.processes.IHostProcessFilter;
|
||||||
|
import org.eclipse.rse.services.clientserver.processes.ISystemProcessRemoteConstants;
|
||||||
|
import org.eclipse.rse.services.clientserver.processes.ISystemProcessRemoteTypes;
|
||||||
|
import org.eclipse.rse.subsystems.processes.core.subsystem.IRemoteProcess;
|
||||||
|
import org.eclipse.rse.subsystems.processes.core.subsystem.RemoteProcessSubSystem;
|
||||||
|
import org.eclipse.rse.ui.ISystemContextMenuConstants;
|
||||||
|
import org.eclipse.rse.ui.ISystemMessages;
|
||||||
|
import org.eclipse.rse.ui.SystemMenuManager;
|
||||||
|
import org.eclipse.rse.ui.actions.SystemCopyToClipboardAction;
|
||||||
|
import org.eclipse.rse.ui.view.AbstractSystemViewAdapter;
|
||||||
|
import org.eclipse.rse.ui.view.ISystemRemoteElementAdapter;
|
||||||
|
import org.eclipse.rse.ui.view.ISystemViewElementAdapter;
|
||||||
|
import org.eclipse.swt.dnd.Clipboard;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.views.properties.IPropertyDescriptor;
|
||||||
|
import org.eclipse.ui.views.properties.PropertyDescriptor;
|
||||||
|
|
||||||
|
|
||||||
|
public class SystemViewRemoteProcessAdapter extends AbstractSystemViewAdapter
|
||||||
|
implements ISystemViewElementAdapter, ISystemRemoteElementAdapter, ISystemMessages,
|
||||||
|
ISystemProcessPropertyConstants, ISystemProcessRemoteConstants
|
||||||
|
{
|
||||||
|
private SystemCopyToClipboardAction copyClipboardAction;
|
||||||
|
public boolean canDrag(Object element)
|
||||||
|
{
|
||||||
|
// DKM - this is just for copy
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canDrag(SystemRemoteResourceSet elements)
|
||||||
|
{
|
||||||
|
// DKM - this is just for copy
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object doDrag(Object element, boolean sameSystemType, IProgressMonitor monitor)
|
||||||
|
{
|
||||||
|
return getText(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISystemResourceSet doDrag(SystemRemoteResourceSet set, IProgressMonitor monitor)
|
||||||
|
{
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Object[] EMPTY_LIST = new Object[0];
|
||||||
|
private static PropertyDescriptor[] propertyDescriptorArray = null;
|
||||||
|
private SystemKillProcessAction killProcessAction;
|
||||||
|
|
||||||
|
public void addActions(SystemMenuManager menu,
|
||||||
|
IStructuredSelection selection, Shell parent, String menuGroup)
|
||||||
|
{
|
||||||
|
if (killProcessAction == null)
|
||||||
|
killProcessAction = new SystemKillProcessAction(shell);
|
||||||
|
menu.add(ISystemContextMenuConstants.GROUP_CHANGE, killProcessAction);
|
||||||
|
|
||||||
|
|
||||||
|
if (copyClipboardAction == null)
|
||||||
|
{
|
||||||
|
Clipboard clipboard = SystemPlugin.getTheSystemRegistry().getSystemClipboard();
|
||||||
|
copyClipboardAction = new SystemCopyToClipboardAction(shell, clipboard);
|
||||||
|
}
|
||||||
|
menu.add(menuGroup, copyClipboardAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISubSystem getSubSystem(Object element)
|
||||||
|
{
|
||||||
|
if (element instanceof IRemoteProcess)
|
||||||
|
{
|
||||||
|
IRemoteProcess process = (IRemoteProcess)element;
|
||||||
|
return process.getParentRemoteProcessSubSystem();
|
||||||
|
}
|
||||||
|
return super.getSubSystem(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImageDescriptor getImageDescriptor(Object element)
|
||||||
|
{
|
||||||
|
//return SystemPlugin.getDefault().getImageDescriptor(ISystemIconConstants.ICON_SYSTEM_PROCESS_ID);
|
||||||
|
return ProcessesPlugin.getDefault().getImageDescriptorFromPath("icons/full/obj16/activeprocess_obj.gif");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText(Object element)
|
||||||
|
{
|
||||||
|
String text = ((IRemoteProcess) element).getLabel();
|
||||||
|
return (text == null) ? "" : text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for stuff like clipboard text copy
|
||||||
|
*/
|
||||||
|
public String getAlternateText(Object element)
|
||||||
|
{
|
||||||
|
IRemoteProcess process = (IRemoteProcess)element;
|
||||||
|
String allProperties = process.getAllProperties();
|
||||||
|
return allProperties.replace('|', '\t');
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAbsoluteName(Object object)
|
||||||
|
{
|
||||||
|
IRemoteProcess process = (IRemoteProcess) object;
|
||||||
|
return "" + process.getPid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType(Object element)
|
||||||
|
{
|
||||||
|
IRemoteProcess process = (IRemoteProcess) element;
|
||||||
|
if (process.isRoot())
|
||||||
|
return SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE_ROOT;
|
||||||
|
else return SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getParent(Object element)
|
||||||
|
{
|
||||||
|
IRemoteProcess process = (IRemoteProcess) element;
|
||||||
|
IRemoteProcess parent = process.getParentRemoteProcess();
|
||||||
|
if ((parent != null) && parent.getAbsolutePath().equals(process.getAbsolutePath()))
|
||||||
|
// should never happen but sometimes it does, leading to infinite loop.
|
||||||
|
parent = null;
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasChildren(Object element)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object[] getChildren(Object element)
|
||||||
|
{
|
||||||
|
IRemoteProcess process = (IRemoteProcess) element;
|
||||||
|
RemoteProcessSubSystem ss = process.getParentRemoteProcessSubSystem();
|
||||||
|
IHostProcessFilter orgRpfs = process.getFilterString();
|
||||||
|
|
||||||
|
Object[] children = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
children = ss.listAllProcesses(orgRpfs, process.getContext());
|
||||||
|
if ((children == null) || (children.length == 0))
|
||||||
|
{
|
||||||
|
children = EMPTY_LIST;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*catch (InterruptedException exc)
|
||||||
|
{
|
||||||
|
children = new SystemMessageObject[1];
|
||||||
|
children[0] = new SystemMessageObject(SystemPlugin.getPluginMessage(MSG_EXPAND_CANCELLED), ISystemMessageObject.MSGTYPE_CANCEL, element);
|
||||||
|
}*/
|
||||||
|
catch (Exception exc)
|
||||||
|
{
|
||||||
|
children = new SystemMessageObject[1];
|
||||||
|
children[0] = new SystemMessageObject(SystemPlugin.getPluginMessage(MSG_EXPAND_FAILED), ISystemMessageObject.MSGTYPE_ERROR, element);
|
||||||
|
SystemBasePlugin.logError("Exception resolving file filter strings", exc);
|
||||||
|
}
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IPropertyDescriptor[] internalGetPropertyDescriptors()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (propertyDescriptorArray == null)
|
||||||
|
{
|
||||||
|
int nbrOfProperties = ISystemProcessRemoteConstants.PROCESS_ATTRIBUTES_COUNT;
|
||||||
|
|
||||||
|
propertyDescriptorArray = new PropertyDescriptor[nbrOfProperties];
|
||||||
|
|
||||||
|
int idx = -1;
|
||||||
|
|
||||||
|
// pid
|
||||||
|
propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PROCESS_PID, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_PID_LABEL, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_PID_TOOLTIP);
|
||||||
|
|
||||||
|
// name
|
||||||
|
propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PROCESS_NAME, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_NAME_LABEL, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_NAME_TOOLTIP);
|
||||||
|
|
||||||
|
// state
|
||||||
|
propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PROCESS_STATE, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_STATE_LABEL, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_STATE_TOOLTIP);
|
||||||
|
|
||||||
|
// uid
|
||||||
|
propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PROCESS_UID, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_UID_LABEL, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_UID_TOOLTIP);
|
||||||
|
|
||||||
|
// username
|
||||||
|
propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PROCESS_USERNAME, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_USERNAME_LABEL, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_USERNAME_TOOLTIP);
|
||||||
|
|
||||||
|
// ppid
|
||||||
|
propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PROCESS_PPID, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_PPID_LABEL, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_PPID_TOOLTIP);
|
||||||
|
|
||||||
|
// gid
|
||||||
|
propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PROCESS_GID, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_GID_LABEL, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_GID_TOOLTIP);
|
||||||
|
|
||||||
|
// tgid
|
||||||
|
propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PROCESS_TGID, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TGID_LABEL, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TGID_TOOLTIP);
|
||||||
|
|
||||||
|
// tracerpid
|
||||||
|
propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PROCESS_TRACERPID, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TRACERPID_LABEL, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_TRACERPID_TOOLTIP);
|
||||||
|
|
||||||
|
// virtual memory size
|
||||||
|
propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PROCESS_VMSIZE, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_VMSIZE_LABEL, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_VMSIZE_TOOLTIP);
|
||||||
|
|
||||||
|
// virtual memory rss
|
||||||
|
propertyDescriptorArray[++idx] = createSimplePropertyDescriptor(P_PROCESS_VMRSS, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_VMRSS_LABEL, SystemProcessesViewResources.RESID_PROPERTY_PROCESS_VMRSS_TOOLTIP);
|
||||||
|
|
||||||
|
}
|
||||||
|
return propertyDescriptorArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current value for the named property.
|
||||||
|
* @return the current value of the given property
|
||||||
|
*/
|
||||||
|
protected Object internalGetPropertyValue(Object key)
|
||||||
|
{
|
||||||
|
return getPropertyValue(key, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
IRemoteProcess process = (IRemoteProcess) propertySourceInput;
|
||||||
|
|
||||||
|
if (name.equals(ISystemProcessPropertyConstants.P_PROCESS_GID))
|
||||||
|
{
|
||||||
|
if (formatted)
|
||||||
|
{
|
||||||
|
return "" + process.getGid();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Long(process.getGid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name.equals(ISystemProcessPropertyConstants.P_PROCESS_NAME))
|
||||||
|
{
|
||||||
|
return process.getName();
|
||||||
|
}
|
||||||
|
if (name.equals(ISystemProcessPropertyConstants.P_PROCESS_PID))
|
||||||
|
{
|
||||||
|
if (formatted)
|
||||||
|
{
|
||||||
|
return "" + process.getPid();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Long(process.getPid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name.equals(ISystemProcessPropertyConstants.P_PROCESS_PPID))
|
||||||
|
{
|
||||||
|
if (formatted)
|
||||||
|
{
|
||||||
|
return "" + process.getPPid();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Long(process.getPPid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name.equals(ISystemProcessPropertyConstants.P_PROCESS_STATE))
|
||||||
|
{
|
||||||
|
if (formatted)
|
||||||
|
{
|
||||||
|
return formatState(process.getState());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return process.getState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name.equals(ISystemProcessPropertyConstants.P_PROCESS_TGID))
|
||||||
|
{
|
||||||
|
if (formatted)
|
||||||
|
{
|
||||||
|
return "" + process.getTgid();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Long(process.getTgid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name.equals(ISystemProcessPropertyConstants.P_PROCESS_TRACERPID))
|
||||||
|
{
|
||||||
|
if (formatted)
|
||||||
|
{
|
||||||
|
return "" + process.getTracerPid();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Long(process.getTracerPid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name.equals(ISystemProcessPropertyConstants.P_PROCESS_UID))
|
||||||
|
{
|
||||||
|
if (formatted)
|
||||||
|
{
|
||||||
|
return "" + process.getUid();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Long(process.getUid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name.equals(ISystemProcessPropertyConstants.P_PROCESS_USERNAME))
|
||||||
|
{
|
||||||
|
return process.getUsername();
|
||||||
|
}
|
||||||
|
if (name.equals(ISystemProcessPropertyConstants.P_PROCESS_VMSIZE))
|
||||||
|
{
|
||||||
|
if (formatted)
|
||||||
|
{
|
||||||
|
return sub(SystemProcessesViewResources.RESID_PROPERTY_PROCESS_VMSIZE_VALUE, MSG_SUB1, Long.toString(process.getVmSizeInKB()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Long(process.getVmSizeInKB());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name.equals(ISystemProcessPropertyConstants.P_PROCESS_VMRSS))
|
||||||
|
{
|
||||||
|
if (formatted)
|
||||||
|
{
|
||||||
|
return sub(SystemProcessesViewResources.RESID_PROPERTY_PROCESS_VMRSS_VALUE, MSG_SUB1, Long.toString(process.getVmRSSInKB()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new Long(process.getVmRSSInKB());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return null; //super.getPropertyValue(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String formatState(String state)
|
||||||
|
{
|
||||||
|
if (state == null) return "";
|
||||||
|
state = state.trim();
|
||||||
|
String longState = "";
|
||||||
|
String[] allStates = state.split(",");
|
||||||
|
if (allStates == null) return longState;
|
||||||
|
|
||||||
|
SystemProcessStatesContentProvider zstates = new SystemProcessStatesContentProvider();
|
||||||
|
for (int i = 0; i < allStates.length; i++)
|
||||||
|
{
|
||||||
|
longState = longState + allStates[i].charAt(0) + "-" + zstates.getStateString(allStates[i]);
|
||||||
|
if (i < allStates.length - 1)
|
||||||
|
longState = longState + ", ";
|
||||||
|
}
|
||||||
|
return longState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return fully qualified name that uniquely identifies this remote object's remote parent within its subsystem
|
||||||
|
*/
|
||||||
|
public String getAbsoluteParentName(Object element)
|
||||||
|
{
|
||||||
|
IRemoteProcess process = (IRemoteProcess) element;
|
||||||
|
IRemoteProcess parent = process.getParentRemoteProcess();
|
||||||
|
if (parent != null) return parent.getAbsolutePath();
|
||||||
|
else return "/proc/0";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a remote object, returns it remote parent object. Eg, given a process, return the process that
|
||||||
|
* spawned it.
|
||||||
|
* <p>
|
||||||
|
* The shell is required in order to set the cursor to a busy state if a remote trip is required.
|
||||||
|
*
|
||||||
|
* @return an IRemoteProcess object for the parent
|
||||||
|
*/
|
||||||
|
public Object getRemoteParent(Shell shell, Object element) throws Exception
|
||||||
|
{
|
||||||
|
return ((IRemoteProcess) element).getParentRemoteProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* @return an array of all file and folder names in the parent of the given IRemoteFile object
|
||||||
|
*/
|
||||||
|
public String[] getRemoteParentNamesInUse(Shell shell, Object element) throws Exception
|
||||||
|
{
|
||||||
|
String[] pids = EMPTY_STRING_LIST;
|
||||||
|
|
||||||
|
IRemoteProcess process = (IRemoteProcess) element;
|
||||||
|
String parentName = "" + process.getPPid();
|
||||||
|
if (parentName.equals("-1")) // given a root?
|
||||||
|
return pids; // not much we can do. Should never happen: you can't rename a root!
|
||||||
|
|
||||||
|
Object[] children = getChildren(process.getParentRemoteProcess());
|
||||||
|
if ((children == null) || (children.length == 0))
|
||||||
|
return pids;
|
||||||
|
|
||||||
|
pids = new String[children.length];
|
||||||
|
for (int idx = 0; idx < pids.length; idx++)
|
||||||
|
pids[idx] = "" + ((IRemoteProcess) children[idx]).getPid();
|
||||||
|
|
||||||
|
return pids;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemoteSubType(Object element)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemoteType(Object element)
|
||||||
|
{
|
||||||
|
IRemoteProcess process = (IRemoteProcess) element;
|
||||||
|
if (process.isRoot())
|
||||||
|
return ISystemProcessRemoteTypes.TYPE_ROOT;
|
||||||
|
else
|
||||||
|
return ISystemProcessRemoteTypes.TYPE_PROCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemoteTypeCategory(Object element)
|
||||||
|
{
|
||||||
|
return ISystemProcessRemoteTypes.TYPECATEGORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 getSubSystemFactoryId(Object element)
|
||||||
|
{
|
||||||
|
IRemoteProcess process = (IRemoteProcess) element;
|
||||||
|
return process.getParentRemoteProcessSubSystem().getSubSystemConfiguration().getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean refreshRemoteObject(Object oldElement, Object newElement)
|
||||||
|
{
|
||||||
|
/*if (oldElement instanceof IRemoteProcess)
|
||||||
|
{
|
||||||
|
IRemoteProcess oldProcess = (IRemoteProcess) oldElement;
|
||||||
|
IRemoteProcess newProcess = (IRemoteProcess) newElement;
|
||||||
|
oldProcess.getParentRemoteProcessSubSystem().setAllProperties(newProcess.getAllProperties());
|
||||||
|
return hasChildren(oldElement);
|
||||||
|
}*/
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean supportsUserDefinedActions(Object object)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
50
rse/plugins/org.eclipse.rse.processes.ui/systemmessages.xml
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?xml version="1.0" encoding='UTF-8'?>
|
||||||
|
<!--
|
||||||
|
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.
|
||||||
|
-->
|
||||||
|
<!DOCTYPE MessageFile SYSTEM "messageFile.dtd">
|
||||||
|
|
||||||
|
<MessageFile Version="1.0">
|
||||||
|
<Component Name="Remote_System_Explorer_Processes" Abbr="RSEP">
|
||||||
|
<Subcomponent Name="General" Abbr="G">
|
||||||
|
<MessageList>
|
||||||
|
<Message ID="1001" Indicator="E">
|
||||||
|
<LevelOne>Maximum VM size must be greater than minimum VM size.</LevelOne>
|
||||||
|
<LevelTwo></LevelTwo>
|
||||||
|
</Message>
|
||||||
|
<Message ID="1002" Indicator="E">
|
||||||
|
<LevelOne>You do not have permission to kill the process.</LevelOne>
|
||||||
|
<LevelTwo>You must own the process or be root in order to kill this process.</LevelTwo>
|
||||||
|
</Message>
|
||||||
|
<Message ID="1003" Indicator="I">
|
||||||
|
<LevelOne>Sending a kill signal...</LevelOne>
|
||||||
|
<LevelTwo></LevelTwo>
|
||||||
|
</Message>
|
||||||
|
<Message ID="1004" Indicator="I">
|
||||||
|
<LevelOne>Sending the signal %1 to the process %2...</LevelOne>
|
||||||
|
<LevelTwo></LevelTwo>
|
||||||
|
</Message>
|
||||||
|
<Message ID="1300" Indicator="E">
|
||||||
|
<LevelOne>Kill of the process %1 failed</LevelOne>
|
||||||
|
<LevelTwo>The remote system reported the following: %2</LevelTwo>
|
||||||
|
</Message>
|
||||||
|
<Message ID="1301" Indicator="E">
|
||||||
|
<LevelOne>Problem occurred during remote process query</LevelOne>
|
||||||
|
<LevelTwo>Could not access the /proc filesystem. You might not have permission to access it.</LevelTwo>
|
||||||
|
</Message>
|
||||||
|
</MessageList>
|
||||||
|
</Subcomponent>
|
||||||
|
</Component>
|
||||||
|
</MessageFile>
|
8
rse/plugins/org.eclipse.rse.services/.classpath
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||||
|
<classpathentry kind="src" path="clientserver"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
1
rse/plugins/org.eclipse.rse.services/.cvsignore
Normal file
|
@ -0,0 +1 @@
|
||||||
|
bin
|
28
rse/plugins/org.eclipse.rse.services/.project
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>org.eclipse.rse.services</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.pde.PluginNature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
26
rse/plugins/org.eclipse.rse.services/META-INF/MANIFEST.MF
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
Manifest-Version: 1.0
|
||||||
|
Bundle-ManifestVersion: 2
|
||||||
|
Bundle-Name: %plugin.name
|
||||||
|
Bundle-SymbolicName: org.eclipse.rse.services
|
||||||
|
Bundle-Version: 1.0.0
|
||||||
|
Bundle-Activator: org.eclipse.rse.services.Activator
|
||||||
|
Bundle-Vendor: Eclipse.org
|
||||||
|
Bundle-Localization: plugin
|
||||||
|
Require-Bundle: org.eclipse.ui,
|
||||||
|
org.eclipse.core.runtime
|
||||||
|
Eclipse-LazyStart: true
|
||||||
|
Export-Package: org.eclipse.rse.services,
|
||||||
|
org.eclipse.rse.services.clientserver,
|
||||||
|
org.eclipse.rse.services.clientserver.archiveutils,
|
||||||
|
org.eclipse.rse.services.clientserver.java,
|
||||||
|
org.eclipse.rse.services.clientserver.messages,
|
||||||
|
org.eclipse.rse.services.clientserver.processes,
|
||||||
|
org.eclipse.rse.services.clientserver.processes.handlers,
|
||||||
|
org.eclipse.rse.services.clientserver.search,
|
||||||
|
org.eclipse.rse.services.clientserver.util.tar,
|
||||||
|
org.eclipse.rse.services.files,
|
||||||
|
org.eclipse.rse.services.processes,
|
||||||
|
org.eclipse.rse.services.search,
|
||||||
|
org.eclipse.rse.services.shells
|
||||||
|
Bundle-ClassPath: clientserver.jar,
|
||||||
|
services.jar
|
22
rse/plugins/org.eclipse.rse.services/about.html
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>About</title>
|
||||||
|
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
|
||||||
|
</head>
|
||||||
|
<body lang="EN-US">
|
||||||
|
<h2>About This Content</h2>
|
||||||
|
|
||||||
|
<p>February 24, 2005</p>
|
||||||
|
<h3>License</h3>
|
||||||
|
|
||||||
|
<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
|
||||||
|
Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
|
||||||
|
For purposes of the EPL, "Program" will mean the Content.</p>
|
||||||
|
|
||||||
|
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party ("Redistributor") and different terms and conditions may
|
||||||
|
apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
|
||||||
|
indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
14
rse/plugins/org.eclipse.rse.services/build.properties
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
bin.includes = META-INF/,\
|
||||||
|
about.html,\
|
||||||
|
plugin.properties,\
|
||||||
|
services.jar,\
|
||||||
|
clientserver.jar
|
||||||
|
src.includes = META-INF/,\
|
||||||
|
about.html,\
|
||||||
|
plugin.properties
|
||||||
|
jars.compile.order = clientserver.jar,\
|
||||||
|
services.jar
|
||||||
|
source.clientserver.jar = clientserver/
|
||||||
|
output.clientserver.jar = bin/
|
||||||
|
source.services.jar = src/
|
||||||
|
output.services.jar = bin/
|
|
@ -0,0 +1,286 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class offers file type matching. A file type is the extension part of a file
|
||||||
|
* name, minus the dot. For example, "java" and "class" are types.
|
||||||
|
* <p>
|
||||||
|
* Recently added is support for full file names, such as "manifest.mf", and even
|
||||||
|
* extension-less names which use the placeholder ".null" for the extension, as in
|
||||||
|
* "makefile.null" so as to dis-ambiguate from extensions like "cpp".
|
||||||
|
* <p>
|
||||||
|
* This supports being given a list of file types, via the constructor, to match on. It
|
||||||
|
* will return true from the {@link #matches(String)} method if the given file name ends
|
||||||
|
* in an extension that matches one of the given types.
|
||||||
|
* <p>
|
||||||
|
* By default, all matching is done case-insensitive, but this can be overridden in the
|
||||||
|
* constructor or by calling {@link #setCaseSensitive(boolean)}.
|
||||||
|
* <p>
|
||||||
|
* For file name matching, use {@link org.eclipse.rse.services.clientserver.NamePatternMatcher} instead.
|
||||||
|
*/
|
||||||
|
public class FileTypeMatcher implements IMatcher
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The delimiter that starts the extension part
|
||||||
|
*/
|
||||||
|
public static final char SEP_EXTENSION = '.';
|
||||||
|
private String[] orgTypes, types;
|
||||||
|
private String[] orgNames, names;
|
||||||
|
private boolean caseSensitive = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for case-insensitive matching
|
||||||
|
*
|
||||||
|
* @param types Array of file types to match on. These should not include the dot. Eg, "java"
|
||||||
|
*/
|
||||||
|
public FileTypeMatcher(String[] types)
|
||||||
|
{
|
||||||
|
this(types, false);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Constructor when specifying if matching is case-sensitive or not
|
||||||
|
*
|
||||||
|
* @param types Array of file types to match on. These should not include the dot. Eg, "java"
|
||||||
|
* @param caseSensitive true if to consider case when matching
|
||||||
|
*/
|
||||||
|
public FileTypeMatcher(String[] types, boolean caseSensitive)
|
||||||
|
{
|
||||||
|
setTypes(types);
|
||||||
|
setCaseSensitive(caseSensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the types used to match on
|
||||||
|
*/
|
||||||
|
public void setTypes(String[] types)
|
||||||
|
{
|
||||||
|
this.types = types;
|
||||||
|
this.orgTypes = types;
|
||||||
|
setCaseSensitive(caseSensitive);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Reset the types and names used to match on
|
||||||
|
*/
|
||||||
|
public void setTypesAndNames(String[] types, String[] names)
|
||||||
|
{
|
||||||
|
this.types = types;
|
||||||
|
this.orgTypes = types;
|
||||||
|
this.names = names;
|
||||||
|
this.orgNames = names;
|
||||||
|
setCaseSensitive(caseSensitive);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Reset the types and names used to match on
|
||||||
|
*/
|
||||||
|
public void setTypesAndNames(String[] typesAndNames)
|
||||||
|
{
|
||||||
|
Vector typesVector = new Vector();
|
||||||
|
Vector namesVector = new Vector();
|
||||||
|
for (int idx=0; idx<typesAndNames.length; idx++)
|
||||||
|
{
|
||||||
|
if (typesAndNames[idx].indexOf('.')!=-1) // this is a full name!
|
||||||
|
namesVector.add(typesAndNames[idx]);
|
||||||
|
else
|
||||||
|
typesVector.add(typesAndNames[idx]);
|
||||||
|
}
|
||||||
|
this.orgTypes = new String[typesVector.size()];
|
||||||
|
this.orgNames = new String[namesVector.size()];
|
||||||
|
for (int idx=0; idx<orgTypes.length; idx++)
|
||||||
|
orgTypes[idx] = (String)typesVector.elementAt(idx);
|
||||||
|
for (int idx=0; idx<orgNames.length; idx++)
|
||||||
|
orgNames[idx] = (String)namesVector.elementAt(idx);
|
||||||
|
|
||||||
|
this.types = orgTypes;
|
||||||
|
this.names = orgNames;
|
||||||
|
|
||||||
|
setCaseSensitive(caseSensitive);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the types used to match on.
|
||||||
|
* @see #toString()
|
||||||
|
*/
|
||||||
|
public String[] getTypes()
|
||||||
|
{
|
||||||
|
return orgTypes;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return the names used to match on.
|
||||||
|
* @see #toString()
|
||||||
|
*/
|
||||||
|
public String[] getNames()
|
||||||
|
{
|
||||||
|
return orgNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether case should be considered when matching
|
||||||
|
*/
|
||||||
|
public void setCaseSensitive(boolean caseSensitive)
|
||||||
|
{
|
||||||
|
this.caseSensitive = caseSensitive;
|
||||||
|
if (!caseSensitive && (types!=null))
|
||||||
|
{
|
||||||
|
types = new String[orgTypes.length];
|
||||||
|
for (int idx=0; idx<types.length; idx++)
|
||||||
|
types[idx] = orgTypes[idx].toLowerCase();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
types = orgTypes;
|
||||||
|
if (!caseSensitive && (names!=null))
|
||||||
|
{
|
||||||
|
names = new String[orgNames.length];
|
||||||
|
for (int idx=0; idx<names.length; idx++)
|
||||||
|
names[idx] = orgNames[idx].toLowerCase();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
names = orgNames;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Return whether case should be considered when matching
|
||||||
|
*/
|
||||||
|
public boolean isCaseSensitive()
|
||||||
|
{
|
||||||
|
return caseSensitive;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if a host name matches the pattern of this generic name.
|
||||||
|
* @param fileName file name such as MyClass.java
|
||||||
|
* @return true if given extension part of name matches any of the given types
|
||||||
|
* @see #setCaseSensitive(boolean)
|
||||||
|
*/
|
||||||
|
public boolean matches(String fileName)
|
||||||
|
{
|
||||||
|
boolean matches = false;
|
||||||
|
String type = null;
|
||||||
|
if (fileName != null)
|
||||||
|
{
|
||||||
|
// check for a match of the given file's name with any of the input fullnames
|
||||||
|
if (names != null)
|
||||||
|
{
|
||||||
|
String name = null;
|
||||||
|
if (!caseSensitive)
|
||||||
|
name = fileName.toLowerCase();
|
||||||
|
else
|
||||||
|
name = fileName;
|
||||||
|
for (int idx=0; !matches && (idx<names.length); idx++)
|
||||||
|
{
|
||||||
|
if (name.equals(names[idx]))
|
||||||
|
matches = true;
|
||||||
|
else if (names[idx].endsWith(".null") &&
|
||||||
|
name.equals(names[idx].substring(0,names[idx].indexOf(".null"))) )
|
||||||
|
matches = true;
|
||||||
|
}
|
||||||
|
if (matches)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for a match of the given file's extension with any of the input extensions
|
||||||
|
int dotIdx = fileName.lastIndexOf(SEP_EXTENSION);
|
||||||
|
int lastPos = fileName.length() - 1;
|
||||||
|
if ((dotIdx >= 0) && (dotIdx < lastPos))
|
||||||
|
{
|
||||||
|
if (!caseSensitive)
|
||||||
|
type = fileName.substring(dotIdx+1).toLowerCase(); // strip off
|
||||||
|
else
|
||||||
|
type = fileName.substring(dotIdx+1);
|
||||||
|
for (int idx=0; !matches && (idx<types.length); idx++)
|
||||||
|
if (type.equals(types[idx]))
|
||||||
|
matches = true;
|
||||||
|
}
|
||||||
|
// check for an extenion-less name, and if so see if one of the types is the special-case "null" type...
|
||||||
|
else if (dotIdx == -1)
|
||||||
|
{
|
||||||
|
for (int idx=0; !matches && (idx<types.length); idx++)
|
||||||
|
if ("null".equals(types[idx]))
|
||||||
|
matches = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matches;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For writing this object out.
|
||||||
|
* Writes out the list of types given in the constructor, as a comma-separated list.
|
||||||
|
* This is in the format directly usable in org.eclipse.rse.subsystems.files.core.model.RemoteFileFilterString
|
||||||
|
*/
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
StringBuffer typesBuffer = new StringBuffer("");
|
||||||
|
if (orgTypes != null)
|
||||||
|
{
|
||||||
|
for (int idx=0; idx<orgTypes.length; idx++)
|
||||||
|
typesBuffer.append(orgTypes[idx]+",");
|
||||||
|
}
|
||||||
|
if (orgNames != null)
|
||||||
|
{
|
||||||
|
for (int idx=0; idx<orgNames.length; idx++)
|
||||||
|
typesBuffer.append(orgNames[idx]+",");
|
||||||
|
}
|
||||||
|
return typesBuffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a comma-separated list of strings into an array of strings representing
|
||||||
|
* extensions. This ignores any full-names in the input list, and only parses
|
||||||
|
* out the extensions...
|
||||||
|
*/
|
||||||
|
public static String[] parseTypes(String typeList)
|
||||||
|
{
|
||||||
|
StringTokenizer tokens = new StringTokenizer(typeList,",");
|
||||||
|
Vector v = new Vector();
|
||||||
|
while (tokens.hasMoreTokens())
|
||||||
|
{
|
||||||
|
String token = tokens.nextToken().trim();
|
||||||
|
if ((token.length()>0) &&
|
||||||
|
(token.indexOf('.') == -1))
|
||||||
|
v.addElement(token);
|
||||||
|
}
|
||||||
|
String[] types = new String[v.size()];
|
||||||
|
for (int idx=0; idx<v.size(); idx++)
|
||||||
|
types[idx] = (String)v.elementAt(idx);
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a comma-separated list of strings into an array of full-names. This ignores
|
||||||
|
* the extensions and only parses out the full names.
|
||||||
|
*/
|
||||||
|
public static String[] parseNames(String typeList)
|
||||||
|
{
|
||||||
|
StringTokenizer tokens = new StringTokenizer(typeList,",");
|
||||||
|
Vector v = new Vector();
|
||||||
|
while (tokens.hasMoreTokens())
|
||||||
|
{
|
||||||
|
String token = tokens.nextToken().trim();
|
||||||
|
if ((token.length()>0) &&
|
||||||
|
(token.indexOf('.') != -1))
|
||||||
|
v.addElement(token);
|
||||||
|
}
|
||||||
|
String[] names = new String[v.size()];
|
||||||
|
for (int idx=0; idx<v.size(); idx++)
|
||||||
|
names[idx] = (String)v.elementAt(idx);
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface defines some constants for classifiers.
|
||||||
|
*/
|
||||||
|
public interface IClassifierConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default type.
|
||||||
|
*/
|
||||||
|
public static final String TYPE_DEFAULT = "file";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Link type, "link".
|
||||||
|
*/
|
||||||
|
public static final String TYPE_LINK = "link";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Java executable type, "executable(java:*)".
|
||||||
|
*/
|
||||||
|
public static final String TYPE_EXECUTABLE_JAVA = "executable(java:*)";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binary executable type, "executable(binary)".
|
||||||
|
*/
|
||||||
|
public static final String TYPE_EXECUTABLE_BINARY = "executable(binary)";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Script executable type, "executable(script)".
|
||||||
|
*/
|
||||||
|
public static final String TYPE_EXECUTABLE_SCRIPT = "executable(script)";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match java executable type, "*executable(java:*)*".
|
||||||
|
*/
|
||||||
|
public static final String MATCH_EXECUTABLE_JAVA = "*executable(java:*)*";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match binary executable type, "*executable(java:*)*".
|
||||||
|
*/
|
||||||
|
public static final String MATCH_EXECUTABLE_BINARY = "*executable(binary)*";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match script executable type, "*executable(java:*)*".
|
||||||
|
*/
|
||||||
|
public static final String MATCH_EXECUTABLE_SCRIPT = "*executable(script)*";
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants used by the Client and Server
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface IClientServerConstants {
|
||||||
|
|
||||||
|
|
||||||
|
// public static final String PLUGIN_ID ="org.eclipse.rse";
|
||||||
|
// public static final String PREFIX = PLUGIN_ID+".";
|
||||||
|
// // Resource Bundle ids
|
||||||
|
// public static final String RESID_PREFIX = PREFIX+"ui.";
|
||||||
|
// // Messages
|
||||||
|
// public static final String MSG_PREFIX = RESID_PREFIX+"msg.";
|
||||||
|
|
||||||
|
public static final String MSG_EXCEPTION_OCCURRED = "RSEG1003";
|
||||||
|
public static final String MSG_EXCEPTION_DELETING = "RSEG1063"; //""RSEG1004";
|
||||||
|
public static final String MSG_EXCEPTION_RENAMING = "RSEG1064"; //"RSEG1005"; //MSG_EXCEPTION_PREFIX + "Renaming";
|
||||||
|
public static final String MSG_EXCEPTION_MOVING = "RSEG1065"; //MSG_EXCEPTION_PREFIX + "Moving";
|
||||||
|
|
||||||
|
public static final String FILEMSG_DELETE_FILE_FAILED = "RSEF1300";
|
||||||
|
public static final String FILEMSG_RENAME_FILE_FAILED = "RSEF1301";
|
||||||
|
public static final String FILEMSG_CREATE_FILE_FAILED = "RSEF1302";
|
||||||
|
public static final String FILEMSG_CREATE_FILE_FAILED_EXIST = "RSEF1303";
|
||||||
|
public static final String FILEMSG_CREATE_FOLDER_FAILED = "RSEF1304";
|
||||||
|
public static final String FILEMSG_CREATE_FOLDER_FAILED_EXIST = "RSEF1309";
|
||||||
|
public static final String FILEMSG_CREATE_RESOURCE_NOTVISIBLE = "RSEF1310";
|
||||||
|
public static final String FILEMSG_RENAME_RESOURCE_NOTVISIBLE = "RSEF1311";
|
||||||
|
public static final String FILEMSG_ERROR_NOFILETYPES = "RSEF1010";
|
||||||
|
public static final String FILEMSG_COPY_FILE_FAILED = "RSEF1306";
|
||||||
|
public static final String FILEMSG_MOVE_FILE_FAILED = "RSEF1307";
|
||||||
|
public static final String FILEMSG_MOVE_TARGET_EQUALS_SOURCE = "RSEF1308";
|
||||||
|
public static final String FILEMSG_ARCHIVE_CORRUPTED = "RSEG1122";
|
||||||
|
public static final String FILEMSG_NO_PERMISSION = "RSEF5001";
|
||||||
|
|
||||||
|
public static final String FILEMSG_REMOTE_SAVE_FAILED = "RSEF5006";
|
||||||
|
/**
|
||||||
|
* Flag to indicate "include files only, not folders"
|
||||||
|
*/
|
||||||
|
public static final int INCLUDE_FILES_ONLY = 2;
|
||||||
|
/**
|
||||||
|
* Flag to indicate "include files only, not folders"
|
||||||
|
*/
|
||||||
|
public static final int INCLUDE_FOLDERS_ONLY = 4;
|
||||||
|
/**
|
||||||
|
* Flag to indicate "include files only, not folders"
|
||||||
|
*/
|
||||||
|
public static final int INCLUDE_ALL = 8;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic interface for any class whose job is to test if a given name matches
|
||||||
|
* some filtering criteria
|
||||||
|
*/
|
||||||
|
public interface IMatcher
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if the given name matches the given filtering criteria
|
||||||
|
*/
|
||||||
|
public boolean matches(String input);
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Interface for different pattern matchers used in search
|
||||||
|
*/
|
||||||
|
public interface ISearchPatternMatcher
|
||||||
|
{
|
||||||
|
public boolean stringMatches(String compareStr);
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
public interface IServiceConstants
|
||||||
|
{
|
||||||
|
public static final String TOKEN_SEPARATOR = "|";
|
||||||
|
|
||||||
|
// Unexpected Error
|
||||||
|
public static final String UNEXPECTED_ERROR = "unexpectedError";
|
||||||
|
|
||||||
|
// Failure strings
|
||||||
|
public static final String FAILED_WITH_EXIST = "failed with exist";
|
||||||
|
public static final String FAILED_WITH_DOES_NOT_EXIST = "failed with does not exist";
|
||||||
|
public static final String FAILED_WITH_EXCEPTION = "failed with exception";
|
||||||
|
public static final String FAILED_WITH_SECURITY = "failed with security";
|
||||||
|
public static final String FAILED_TO_DELETE_DIR = "failed to delete directory";
|
||||||
|
public static final String SUCCESS = "success";
|
||||||
|
public static final String FAILED = "failed";
|
||||||
|
public static final String VERSION_1 = "version_1";
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dmcknigh
|
||||||
|
*/
|
||||||
|
public interface ISystemFileTypes
|
||||||
|
{
|
||||||
|
public boolean isBinary(File file);
|
||||||
|
public boolean isText(File file);
|
||||||
|
public boolean isBinary(String file);
|
||||||
|
public boolean isText(String file);
|
||||||
|
}
|
|
@ -0,0 +1,466 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class offers generic name pattern matching.
|
||||||
|
* <p>
|
||||||
|
* This supports one wildcard character ('*") anywhere in
|
||||||
|
* the name, or one at the beginning and end of the name.
|
||||||
|
* <ol>
|
||||||
|
* <li>ABC </li>
|
||||||
|
* <li>* </li>
|
||||||
|
* <li>ABC* </li>
|
||||||
|
* <li>*ABC </li>
|
||||||
|
* <li>AB*C </li>
|
||||||
|
* <li>*ABC* </li>
|
||||||
|
* </ol>
|
||||||
|
* <p>
|
||||||
|
* This pattern matching class also <i>optionally</i> supports additional
|
||||||
|
* advanced patterns beyond the stricter PDM style. These allow
|
||||||
|
* for two '*'s anywhere in the name.
|
||||||
|
* <ol>
|
||||||
|
* <li>AB*C* </li>
|
||||||
|
* <li>*A*C </li>
|
||||||
|
* <li>A*B*C </li>
|
||||||
|
* </ol>
|
||||||
|
* <p>
|
||||||
|
* Quoted names are supported.
|
||||||
|
* <p>
|
||||||
|
* All matching is case-sensitive!
|
||||||
|
* <p>
|
||||||
|
* Instantiate this class for a given generic name, and then
|
||||||
|
* call matches(String input) for each input name to see if it
|
||||||
|
* matches the pattern.
|
||||||
|
* <p>
|
||||||
|
* To enable the advanced patterns, pass <code>true</code> to the constructor.
|
||||||
|
*/
|
||||||
|
public class NamePatternMatcher implements IMatcher
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wildcard character: *
|
||||||
|
*/
|
||||||
|
public static final char WILDCARD = '*';
|
||||||
|
private static final String WILDCARD_DOUBLED = "**";
|
||||||
|
/**
|
||||||
|
* Example: Quoted name delimiter: "
|
||||||
|
*/
|
||||||
|
public static final char QUOTE = '"';
|
||||||
|
/**
|
||||||
|
* Example: ABC
|
||||||
|
*/
|
||||||
|
public static final int SCALAR = 0;
|
||||||
|
/**
|
||||||
|
* Example: *
|
||||||
|
*/
|
||||||
|
public static final int ALL = 1;
|
||||||
|
/**
|
||||||
|
* Example: ABC*
|
||||||
|
*/
|
||||||
|
public static final int WILDCARD_END = 2;
|
||||||
|
/**
|
||||||
|
* Example: *ABC
|
||||||
|
*/
|
||||||
|
public static final int WILDCARD_START = 4;
|
||||||
|
/**
|
||||||
|
* Example: A*C
|
||||||
|
*/
|
||||||
|
public static final int WILDCARD_MIDDLE = 8;
|
||||||
|
/**
|
||||||
|
* Example: *ABC*
|
||||||
|
*/
|
||||||
|
public static final int WILDCARD_START_END = 16;
|
||||||
|
/*
|
||||||
|
* Example: A*C*
|
||||||
|
*/
|
||||||
|
public static final int WILDCARD_MIDDLE_END = 32;
|
||||||
|
/**
|
||||||
|
* Example: *A*F
|
||||||
|
*/
|
||||||
|
public static final int WILDCARD_START_MIDDLE = 64;
|
||||||
|
/**
|
||||||
|
* Example: A*C*F
|
||||||
|
*/
|
||||||
|
public static final int WILDCARD_MIDDLE_MIDDLE = 128;
|
||||||
|
|
||||||
|
|
||||||
|
// used in writeInfo debugging method
|
||||||
|
private static final int[] TYPES_IDX = {SCALAR,ALL,WILDCARD_END,WILDCARD_START,WILDCARD_MIDDLE,
|
||||||
|
WILDCARD_START_END,WILDCARD_MIDDLE_END,WILDCARD_START_MIDDLE,WILDCARD_MIDDLE_MIDDLE};
|
||||||
|
private static final String[] TYPES = {"SCALAR","ALL","END","START","MIDDLE","START_END","MIDDLE_END","START_MIDDLE","MIDDLE_MIDDLE"};
|
||||||
|
|
||||||
|
private String genericName, part1, part2, part3;
|
||||||
|
private int part1len,part2len,part3len,part12len,part123len;
|
||||||
|
private int patternType;
|
||||||
|
private boolean quotedName, validName;
|
||||||
|
private boolean caseSensitive = true;
|
||||||
|
/**
|
||||||
|
* Constructor for traditional-style only patterns, which allows
|
||||||
|
* for one asterisk anywhere in the name,or one asterisk each at the
|
||||||
|
* beginning or end of the name.
|
||||||
|
* <p>
|
||||||
|
* If you don't know for sure the input is generic or valid, after
|
||||||
|
* constructing call:
|
||||||
|
* <sl>
|
||||||
|
* <li> {@link #isValid()} to determine if given generic name was valid. </li>
|
||||||
|
* <li> {@link #isGeneric()} to determine if given generic name had a wildcard. </li>
|
||||||
|
* </sl>
|
||||||
|
* <p>
|
||||||
|
* If curious, you can also subsequently call:
|
||||||
|
* <sl>
|
||||||
|
* <li> {@link #getPatternType()} to determine which type of pattern the generic name follows. </li>
|
||||||
|
* </sl>
|
||||||
|
* <p>
|
||||||
|
* Once constructed for a valid name, you can call
|
||||||
|
* <sl>
|
||||||
|
* <li> {@link #matches(String)} for each name to see if it matches this generic name pattern.
|
||||||
|
* </sl>
|
||||||
|
* <p>
|
||||||
|
* Quoted names are supported.
|
||||||
|
* <p>
|
||||||
|
* All matching is case-sensitive!
|
||||||
|
*
|
||||||
|
* @param genericName generic name to do pattern matching for (ie, ABC*DEF)
|
||||||
|
*/
|
||||||
|
public NamePatternMatcher(String genericName)
|
||||||
|
{
|
||||||
|
this(genericName, false, true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Constructor for traditional-style patterns PLUS advanced
|
||||||
|
* patterns ABC*DEF* and A*C*F.
|
||||||
|
* <p>
|
||||||
|
* If you don't know for sure the input is generic or valid, after
|
||||||
|
* constructing call:
|
||||||
|
* <sl>
|
||||||
|
* <li> {@link #isValid()} to determine if given generic name was valid. </li>
|
||||||
|
* <li> {@link #isGeneric()} to determine if given generic name had a wildcard. </li>
|
||||||
|
* </sl>
|
||||||
|
* <p>
|
||||||
|
* If curious, you can also subsequently call:
|
||||||
|
* <sl>
|
||||||
|
* <li> {@link #getPatternType()} to determine which type of pattern the generic name follows. </li>
|
||||||
|
* </sl>
|
||||||
|
* <p>
|
||||||
|
* Once constructed for a valid name, you can call
|
||||||
|
* <sl>
|
||||||
|
* <li> {@link #matches(String)} for each name to see if it matches this generic name pattern.
|
||||||
|
* </sl>
|
||||||
|
* <p>
|
||||||
|
* Quoted names are supported.
|
||||||
|
*
|
||||||
|
* @param genericName generic name to do pattern matching for (ie, ABC*DEF)
|
||||||
|
* @param advanced true if you want to support the advanced patterns.
|
||||||
|
* @param caseSensitive true if the names are case-sensitive, false if case insensitive
|
||||||
|
*/
|
||||||
|
public NamePatternMatcher(String genericName, boolean advanced, boolean caseSensitive)
|
||||||
|
{
|
||||||
|
this.caseSensitive = caseSensitive;
|
||||||
|
genericName = genericName.trim();
|
||||||
|
int len = 0;
|
||||||
|
// determine if given a null name
|
||||||
|
if ((genericName == null) || (genericName.length()==0))
|
||||||
|
validName = false;
|
||||||
|
else
|
||||||
|
validName = true; // for now
|
||||||
|
if (validName)
|
||||||
|
{
|
||||||
|
len = genericName.length();
|
||||||
|
// determine if given generic name is a quoted name
|
||||||
|
quotedName = genericName.charAt(0) == QUOTE;
|
||||||
|
if (quotedName && ((len==1) || (genericName.charAt(len-1)!=QUOTE)))
|
||||||
|
validName = false;
|
||||||
|
if (!quotedName && !caseSensitive)
|
||||||
|
genericName = genericName.toLowerCase();
|
||||||
|
}
|
||||||
|
if (validName)
|
||||||
|
{
|
||||||
|
// change *BLANK into 10 blanks
|
||||||
|
if (genericName.equals("*BLANK"))
|
||||||
|
genericName = " ";
|
||||||
|
// away we go...
|
||||||
|
int firstCharPos = quotedName ? 1 : 0;
|
||||||
|
int lastCharPos = quotedName ? len-2 : len-1;
|
||||||
|
char firstChar = genericName.charAt(firstCharPos);
|
||||||
|
char lastChar = genericName.charAt(lastCharPos);
|
||||||
|
// determine type of generic name. 6 flavors including SCALAR...
|
||||||
|
int wildcardOccurrences = countOccurrencesOf(genericName, WILDCARD);
|
||||||
|
if (wildcardOccurrences==0)
|
||||||
|
{
|
||||||
|
patternType = SCALAR;
|
||||||
|
}
|
||||||
|
else if (wildcardOccurrences==1)
|
||||||
|
{
|
||||||
|
if ((!quotedName && (len == 1)) || (quotedName && (len ==3)) || genericName.equals("*ALL") || genericName.equals("\"*ALL\"") || genericName.equals("*LIBL"))
|
||||||
|
patternType = ALL;
|
||||||
|
else if (firstChar == WILDCARD)
|
||||||
|
{
|
||||||
|
patternType = WILDCARD_START;
|
||||||
|
part2 = genericName.substring(firstCharPos+1,lastCharPos+1);
|
||||||
|
}
|
||||||
|
else if (lastChar == WILDCARD)
|
||||||
|
{
|
||||||
|
patternType = WILDCARD_END;
|
||||||
|
part1 = genericName.substring(firstCharPos,lastCharPos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
patternType = WILDCARD_MIDDLE;
|
||||||
|
int wcPos = genericName.indexOf(WILDCARD);
|
||||||
|
part1 = genericName.substring(firstCharPos,wcPos);
|
||||||
|
part2 = genericName.substring(wcPos+1,lastCharPos+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (wildcardOccurrences==2)
|
||||||
|
{
|
||||||
|
if (!advanced && (lastChar != WILDCARD) && (firstChar != WILDCARD))
|
||||||
|
validName = false;
|
||||||
|
else if (genericName.indexOf(WILDCARD_DOUBLED) >= 0)
|
||||||
|
validName = false;
|
||||||
|
else if ((firstChar == WILDCARD) && (lastChar == WILDCARD)) // pdm-style
|
||||||
|
{
|
||||||
|
patternType = WILDCARD_START_END;
|
||||||
|
part1 = genericName.substring(firstCharPos+1,lastCharPos);
|
||||||
|
}
|
||||||
|
else if (lastChar == WILDCARD) // advanced: A*C*
|
||||||
|
{
|
||||||
|
patternType = WILDCARD_MIDDLE_END;
|
||||||
|
int wcPos = genericName.indexOf(WILDCARD);
|
||||||
|
part1 = genericName.substring(firstCharPos,wcPos);
|
||||||
|
part2 = genericName.substring(wcPos+1,lastCharPos);
|
||||||
|
part1len = part1.length();
|
||||||
|
part2len = part2.length();
|
||||||
|
part12len = part1len + part2len;
|
||||||
|
}
|
||||||
|
else if (firstChar == WILDCARD) // advanced: *B*C
|
||||||
|
{
|
||||||
|
patternType = WILDCARD_START_MIDDLE;
|
||||||
|
int wcPos = genericName.lastIndexOf(WILDCARD);
|
||||||
|
part1 = genericName.substring(firstCharPos+1,wcPos);
|
||||||
|
part2 = genericName.substring(wcPos+1,lastCharPos+1);
|
||||||
|
part1len = part1.length();
|
||||||
|
part2len = part2.length();
|
||||||
|
part12len = part1len + part2len;
|
||||||
|
}
|
||||||
|
else // advanced: A*C*F
|
||||||
|
{
|
||||||
|
patternType = WILDCARD_MIDDLE_MIDDLE;
|
||||||
|
int wcPos1 = genericName.indexOf(WILDCARD);
|
||||||
|
int wcPos2 = genericName.lastIndexOf(WILDCARD);
|
||||||
|
part1 = genericName.substring(firstCharPos,wcPos1);
|
||||||
|
part2 = genericName.substring(wcPos1+1,wcPos2);
|
||||||
|
part3 = genericName.substring(wcPos2+1,lastCharPos+1);
|
||||||
|
part1len = part1.length();
|
||||||
|
part2len = part2.length();
|
||||||
|
part12len = part1len + part2len;
|
||||||
|
part123len = part12len + part3.length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
validName = false;
|
||||||
|
}
|
||||||
|
this.genericName = genericName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Test if a host name matches the pattern of this generic name.
|
||||||
|
* @param input Scalar name like ABCDEF
|
||||||
|
* @return true if given name matches this generic name pattern.
|
||||||
|
*/
|
||||||
|
public boolean matches(String input)
|
||||||
|
{
|
||||||
|
boolean matches = false;
|
||||||
|
if (validName)
|
||||||
|
{
|
||||||
|
if ((input.length()>2) &&
|
||||||
|
(input.charAt(0) == QUOTE))
|
||||||
|
input = input.substring(1,input.length()-1);
|
||||||
|
else if (!caseSensitive)
|
||||||
|
input = input.toLowerCase();
|
||||||
|
switch (patternType)
|
||||||
|
{
|
||||||
|
case SCALAR:
|
||||||
|
matches = input.equals(genericName);
|
||||||
|
break;
|
||||||
|
case ALL:
|
||||||
|
matches = true;
|
||||||
|
break;
|
||||||
|
case WILDCARD_END:
|
||||||
|
matches = input.startsWith(part1);
|
||||||
|
break;
|
||||||
|
case WILDCARD_START:
|
||||||
|
matches = input.endsWith(part2);
|
||||||
|
break;
|
||||||
|
case WILDCARD_MIDDLE:
|
||||||
|
matches = input.startsWith(part1) && input.endsWith(part2);
|
||||||
|
break;
|
||||||
|
case WILDCARD_START_END:
|
||||||
|
matches = (input.indexOf(part1) >= 0);
|
||||||
|
break;
|
||||||
|
case WILDCARD_MIDDLE_END:
|
||||||
|
if (input.startsWith(part1) && (input.length()>=part12len))
|
||||||
|
matches = (input.indexOf(part2,part1len) >= 0);
|
||||||
|
else
|
||||||
|
matches = false;
|
||||||
|
break;
|
||||||
|
case WILDCARD_START_MIDDLE: // *B*F
|
||||||
|
if (input.endsWith(part2) && (input.length()>=part12len))
|
||||||
|
{
|
||||||
|
int idx = input.indexOf(part1);
|
||||||
|
int startOfEndPart = input.length() - part2len;
|
||||||
|
matches = ((idx >= 0) && (idx+part1len <= startOfEndPart));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
matches = false;
|
||||||
|
break;
|
||||||
|
case WILDCARD_MIDDLE_MIDDLE: // A*C*D
|
||||||
|
if (input.startsWith(part1) && input.endsWith(part3) && (input.length()>=part123len))
|
||||||
|
{
|
||||||
|
int idx = input.indexOf(part2);
|
||||||
|
int startOfEndPart = input.length() - part3len;
|
||||||
|
matches = ((idx >= 0) && (idx >= part1len) && (idx <= startOfEndPart));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
matches = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matches;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Was generic name given in the constructor a valid scalar or generic name?
|
||||||
|
* @return true if name contained 0, 1 or 2 wildcards.
|
||||||
|
*/
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
return validName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Was generic name given in the constructor a valid generic name (one or 2 '*'s)?
|
||||||
|
*/
|
||||||
|
public boolean isGeneric()
|
||||||
|
{
|
||||||
|
return patternType != SCALAR;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Was quoted name given in the constructor a quoted name like "abcDEF"?
|
||||||
|
*/
|
||||||
|
public boolean isQuoted()
|
||||||
|
{
|
||||||
|
return quotedName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* What type of pattern is it? One of:
|
||||||
|
* {@link #SCALAR}, {@link #ALL}, {@link #WILDCARD_END}, {@link #WILDCARD_START}, {@link #WILDCARD_MIDDLE},
|
||||||
|
* {@link #WILDCARD_START_END}, or {@link #WILDCARD_MIDDLE_END}
|
||||||
|
*/
|
||||||
|
public int getPatternType()
|
||||||
|
{
|
||||||
|
return patternType;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Helper method.
|
||||||
|
* Count occurrences of given character in given string.
|
||||||
|
* Does NOT take into account quoted names.
|
||||||
|
*/
|
||||||
|
private static int countOccurrencesOf(String haystack, char needle)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (int idx=0; idx<haystack.length(); idx++)
|
||||||
|
{
|
||||||
|
if (haystack.charAt(idx) == needle)
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For writing this object out.
|
||||||
|
* Writes out the original generic name specified in the constructor.
|
||||||
|
*/
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return genericName;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* For debugging/testing purposes.
|
||||||
|
* Writes out information about this generic name to the given stream file.
|
||||||
|
*/
|
||||||
|
public void writeInfo(PrintWriter stream)
|
||||||
|
{
|
||||||
|
stream.println("GENERIC NAME: " + genericName);
|
||||||
|
stream.println(" isValid: " + isValid());
|
||||||
|
stream.println(" isGeneric: " + isGeneric());
|
||||||
|
stream.println(" isQuoted: " + isQuoted());
|
||||||
|
int type = getPatternType();
|
||||||
|
int typeidx = 0;
|
||||||
|
boolean match=false;
|
||||||
|
for (int idx=0; !match && (idx<TYPES_IDX.length); idx++)
|
||||||
|
if (type == TYPES_IDX[idx])
|
||||||
|
{
|
||||||
|
typeidx = idx;
|
||||||
|
match = true;
|
||||||
|
}
|
||||||
|
stream.println(" patternType: " + TYPES[typeidx]);
|
||||||
|
if (part1 != null)
|
||||||
|
stream.println(" part1: " + part1);
|
||||||
|
if (part2 != null)
|
||||||
|
stream.println(" part2: " + part2);
|
||||||
|
if (part3 != null)
|
||||||
|
stream.println(" part3: " + part3);
|
||||||
|
stream.println();
|
||||||
|
stream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Static method to test if a given pattern is a valid generic name
|
||||||
|
* @param genericName pattern to test
|
||||||
|
* @param advanced true if advanced pattern allowed: ABC*DEF* and A*C*F
|
||||||
|
* @true if there are no obvious syntactical errors, like two asterisks together.
|
||||||
|
*/
|
||||||
|
public static boolean verifyPattern(String genericName, boolean advanced)
|
||||||
|
{
|
||||||
|
if (genericName != null)
|
||||||
|
genericName = genericName.trim();
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
// determine if given a null name
|
||||||
|
if (genericName.length()==0)
|
||||||
|
return false;
|
||||||
|
int len = genericName.length();
|
||||||
|
// determine if given generic name is a quoted name
|
||||||
|
boolean quotedName = (genericName.charAt(0) == QUOTE);
|
||||||
|
if (quotedName && ((len==1) || (genericName.charAt(len-1)!=QUOTE)))
|
||||||
|
return false;
|
||||||
|
int wildcardOccurrences = countOccurrencesOf(genericName, WILDCARD);
|
||||||
|
if (wildcardOccurrences==2)
|
||||||
|
{
|
||||||
|
char firstChar = genericName.charAt((quotedName ? 1 : 0));
|
||||||
|
char lastChar = genericName.charAt((quotedName ? (len-2) : (len-1)));
|
||||||
|
if (!advanced && (lastChar != WILDCARD) && (firstChar != WILDCARD))
|
||||||
|
return false;
|
||||||
|
else if (genericName.indexOf(WILDCARD_DOUBLED) >= 0)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (wildcardOccurrences > 2)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,140 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
import org.eclipse.rse.services.clientserver.archiveutils.AbsoluteVirtualPath;
|
||||||
|
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||||
|
|
||||||
|
public class PathUtility
|
||||||
|
{
|
||||||
|
|
||||||
|
public static String normalizeWindows(String path)
|
||||||
|
{
|
||||||
|
if (path == null || path.length() < 2) return path;
|
||||||
|
boolean containsForwardSlash = false;
|
||||||
|
boolean containsDoubleSlashes = false;
|
||||||
|
boolean endsWithSlash = false;
|
||||||
|
|
||||||
|
if (path.indexOf("/") != -1) containsForwardSlash = true;
|
||||||
|
if (path.indexOf("\\\\") != -1) containsDoubleSlashes = true;
|
||||||
|
if (path.endsWith("\\") || path.endsWith("/")) endsWithSlash = true;
|
||||||
|
|
||||||
|
boolean needsNormalizing = containsForwardSlash || containsDoubleSlashes || endsWithSlash;
|
||||||
|
if (!needsNormalizing) return path;
|
||||||
|
|
||||||
|
if (containsForwardSlash)
|
||||||
|
{
|
||||||
|
path = path.replace('/', '\\');
|
||||||
|
containsDoubleSlashes = (path.indexOf("\\\\") != -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* DKM - replaceAll is causing exception
|
||||||
|
while (containsDoubleSlashes)
|
||||||
|
{
|
||||||
|
path = path.replaceAll("\\\\", "\\");
|
||||||
|
containsDoubleSlashes = (path.indexOf("\\\\") != -1);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
if (endsWithSlash)
|
||||||
|
{
|
||||||
|
if (!(path.length() == 3)) path = path.substring(0, path.length() - 1);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String normalizeUnix(String path)
|
||||||
|
{
|
||||||
|
if (path == null || path.length() < 2) return path;
|
||||||
|
boolean containsBackSlash = false;
|
||||||
|
boolean containsDoubleSlashes = false;
|
||||||
|
boolean endsWithSlash = false;
|
||||||
|
|
||||||
|
if (path.indexOf("\\") != -1) containsBackSlash = true;
|
||||||
|
if (path.indexOf("//") != -1) containsDoubleSlashes = true;
|
||||||
|
if (path.endsWith("\\") || path.endsWith("/")) endsWithSlash = true;
|
||||||
|
|
||||||
|
boolean needsNormalizing = containsBackSlash || containsDoubleSlashes || endsWithSlash;
|
||||||
|
if (!needsNormalizing) return path;
|
||||||
|
|
||||||
|
if (containsBackSlash)
|
||||||
|
{
|
||||||
|
path = path.replaceAll("\\", "/");
|
||||||
|
containsDoubleSlashes = (path.indexOf("//") != -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (containsDoubleSlashes)
|
||||||
|
{
|
||||||
|
path = path.replaceAll("//", "/");
|
||||||
|
containsDoubleSlashes = (path.indexOf("//") != -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (endsWithSlash)
|
||||||
|
{
|
||||||
|
if (!(path.length() == 1)) path = path.substring(0, path.length() - 1);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String normalizeVirtualWindows(String path)
|
||||||
|
{
|
||||||
|
if (path == null || path.length() < 2) return path;
|
||||||
|
AbsoluteVirtualPath avp = new AbsoluteVirtualPath(path);
|
||||||
|
String realPart = avp.getContainingArchiveString();
|
||||||
|
if (ArchiveHandlerManager.isVirtual(realPart))
|
||||||
|
realPart = normalizeVirtualWindows(realPart);
|
||||||
|
else realPart = normalizeWindows(realPart);
|
||||||
|
return realPart + ArchiveHandlerManager.VIRTUAL_SEPARATOR + avp.getVirtualPart();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String normalizeVirtualUnix(String path)
|
||||||
|
{
|
||||||
|
if (path == null || path.length() < 2) return path;
|
||||||
|
AbsoluteVirtualPath avp = new AbsoluteVirtualPath(path);
|
||||||
|
String realPart = avp.getContainingArchiveString();
|
||||||
|
if (ArchiveHandlerManager.isVirtual(realPart))
|
||||||
|
realPart = normalizeVirtualUnix(realPart);
|
||||||
|
else realPart = normalizeUnix(realPart);
|
||||||
|
return realPart + ArchiveHandlerManager.VIRTUAL_SEPARATOR + avp.getVirtualPart();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String normalizeUnknown(String path)
|
||||||
|
{
|
||||||
|
if (path == null || path.length() < 2) return path;
|
||||||
|
if (path.charAt(1) == ':')
|
||||||
|
if (path.indexOf(ArchiveHandlerManager.VIRTUAL_CANONICAL_SEPARATOR) == -1)
|
||||||
|
return normalizeWindows(path);
|
||||||
|
else return normalizeVirtualWindows(path);
|
||||||
|
else if (path.charAt(0) == '/')
|
||||||
|
if (path.indexOf(ArchiveHandlerManager.VIRTUAL_CANONICAL_SEPARATOR) == -1)
|
||||||
|
return normalizeUnix(path);
|
||||||
|
else return normalizeVirtualUnix(path);
|
||||||
|
else return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getSeparator(String path)
|
||||||
|
{
|
||||||
|
if (path.length() > 1 && path.charAt(1) == ':')
|
||||||
|
{
|
||||||
|
return "\\";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A pattern matcher used for search that uses regex
|
||||||
|
*/
|
||||||
|
public class RegexPatternMatcher implements ISearchPatternMatcher
|
||||||
|
{
|
||||||
|
private Pattern _regexPattern;
|
||||||
|
|
||||||
|
public RegexPatternMatcher(String pattern)
|
||||||
|
{
|
||||||
|
_regexPattern = Pattern.compile(pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean stringMatches(String compareString)
|
||||||
|
{
|
||||||
|
Matcher matcher = _regexPattern.matcher(compareString);
|
||||||
|
return matcher.matches();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,125 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility class for comparing a wildcard string to another string
|
||||||
|
*/
|
||||||
|
public class StringCompare
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
public StringCompare()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compare two strings
|
||||||
|
*
|
||||||
|
* @param pattern the pattern to match
|
||||||
|
* @param compareStr the string to compare against the pattern
|
||||||
|
* @param noCase indicates whether the strings should be compared based on case
|
||||||
|
* @return true if the compare string matches the pattern
|
||||||
|
*/
|
||||||
|
public static boolean compare(String pattern, String compareStr, boolean noCase)
|
||||||
|
{
|
||||||
|
if ((pattern == null) || (compareStr == null))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (noCase)
|
||||||
|
{
|
||||||
|
pattern = pattern.toUpperCase();
|
||||||
|
compareStr = compareStr.toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
String currentMatch = new String("");
|
||||||
|
|
||||||
|
int iText = 0;
|
||||||
|
int iPattern = 0;
|
||||||
|
int lastStar = 0;
|
||||||
|
int len = compareStr.length();
|
||||||
|
|
||||||
|
int patternLen = pattern.length();
|
||||||
|
|
||||||
|
while (iPattern < patternLen)
|
||||||
|
{
|
||||||
|
char p = pattern.charAt(iPattern++);
|
||||||
|
if (p == '*')
|
||||||
|
{
|
||||||
|
|
||||||
|
if (iPattern >= patternLen)
|
||||||
|
{
|
||||||
|
while (iText < len)
|
||||||
|
{
|
||||||
|
iText++;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lastStar = iPattern;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (iText >= len)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char t = compareStr.charAt(iText++);
|
||||||
|
if (p == t)
|
||||||
|
{
|
||||||
|
if ((lastStar > 0) && (iPattern >= patternLen) && (iText < len))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (lastStar == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int matched = iPattern - lastStar - 1;
|
||||||
|
iPattern = lastStar;
|
||||||
|
|
||||||
|
iText -= matched;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iText >= len)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A pattern matcher for search that uses wildcard based compares
|
||||||
|
*/
|
||||||
|
public class StringComparePatternMatcher implements ISearchPatternMatcher
|
||||||
|
{
|
||||||
|
private String _pattern;
|
||||||
|
|
||||||
|
public StringComparePatternMatcher(String pattern)
|
||||||
|
{
|
||||||
|
_pattern = pattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean stringMatches(String compareString)
|
||||||
|
{
|
||||||
|
return StringCompare.compare(_pattern, compareString, true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,387 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A singleton class that contains useful methods related to encodings.
|
||||||
|
*/
|
||||||
|
public class SystemEncodingUtil {
|
||||||
|
|
||||||
|
private static SystemEncodingUtil instance;
|
||||||
|
public static String ENCODING_UTF_8 = "UTF-8";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor to create the utility class.
|
||||||
|
*/
|
||||||
|
private SystemEncodingUtil() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the singleton instance of the utility class.
|
||||||
|
* @return the singleton instance.
|
||||||
|
*/
|
||||||
|
public static SystemEncodingUtil getInstance() {
|
||||||
|
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new SystemEncodingUtil();
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the encoding of the environment. This is the encoding being used by the JVM,
|
||||||
|
* which by default is the machine encoding, unless changed explicitly.
|
||||||
|
* @return the evironment encoding.
|
||||||
|
*/
|
||||||
|
public String getEnvironmentEncoding() {
|
||||||
|
return System.getProperty("file.encoding");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the file is an XML file.
|
||||||
|
* @param filePath the file path.
|
||||||
|
* @return <code>true</code> if the file is an XML file, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public boolean isXML(String filePath) {
|
||||||
|
|
||||||
|
int index = filePath.lastIndexOf(".");
|
||||||
|
|
||||||
|
// check if there is a "."
|
||||||
|
if (index == -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
// check if the name ends with "."
|
||||||
|
if (index == filePath.length() - 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
String extension = filePath.substring(index+1);
|
||||||
|
|
||||||
|
if (extension.equalsIgnoreCase("xml") || extension.equalsIgnoreCase("xmi")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the encoding of an XML file.
|
||||||
|
* @param filePath the file path.
|
||||||
|
* @return the encoding, or <code>null</code> if the encoding could not be determined.
|
||||||
|
*/
|
||||||
|
public String getXMLFileEncoding(String filePath) throws IOException {
|
||||||
|
|
||||||
|
String encoding = null;
|
||||||
|
|
||||||
|
// this is an implementation of the encoding detection algorithm
|
||||||
|
// as specified in Appendix F of the XML specification
|
||||||
|
|
||||||
|
FileInputStream stream = new FileInputStream(filePath);
|
||||||
|
|
||||||
|
// try to get the encoding if the file starts with a BOM
|
||||||
|
String encodingGuess = getEncodingFromBOM(stream);
|
||||||
|
|
||||||
|
stream.close();
|
||||||
|
|
||||||
|
// if no BOM, read in bytes corresponding to the first four chars in the header, i.e. "<?xm"
|
||||||
|
// and try to determine the encoding from that
|
||||||
|
if (encodingGuess == null) {
|
||||||
|
|
||||||
|
stream = new FileInputStream(filePath);
|
||||||
|
|
||||||
|
byte[] temp = new byte[4];
|
||||||
|
|
||||||
|
stream.read(temp);
|
||||||
|
|
||||||
|
|
||||||
|
// UCS-4 or other encoding with a 32-bit code unit and ASCII characters encoded as
|
||||||
|
// ASCII values, in respectively big-endian (1234), little-endian (4321) and two
|
||||||
|
// unusual byte orders (2143 and 3412). The encoding declaration must be read to
|
||||||
|
// determine which of UCS-4 or other supported 32-bit encodings applies.
|
||||||
|
|
||||||
|
// UCS-4, big-endian order (1234 order)
|
||||||
|
if (temp[0] == 0x00 && temp[1] == 0x00 && temp[2] == 0x00 && temp[3] == 0x3C) {
|
||||||
|
encodingGuess = null;
|
||||||
|
}
|
||||||
|
// UCS-4, little-endian order (4321 order)
|
||||||
|
else if (temp[0] == 0x3C && temp[1] == 0x00 && temp[2] == 0x00 && temp[3] == 0x00) {
|
||||||
|
encodingGuess = null;
|
||||||
|
}
|
||||||
|
// UCS-4, unusual octet order (2143)
|
||||||
|
else if (temp[0] == 0x00 && temp[1] == 0x00 && temp[2] == 0x3C && temp[3] == 0x00) {
|
||||||
|
encodingGuess = null;
|
||||||
|
}
|
||||||
|
// UCS-4, unusual octet order (3412)
|
||||||
|
else if (temp[0] == 0x00 && temp[1] == 0x3C && temp[2] == 0x00 && temp[3] == 0x00) {
|
||||||
|
encodingGuess = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// UTF-16BE or big-endian ISO-10646-UCS-2 or other encoding with a 16-bit code unit
|
||||||
|
// in big-endian order and ASCII characters encoded as ASCII values (the encoding
|
||||||
|
// declaration must be read to determine which)
|
||||||
|
else if (temp[0] == 0x00 && temp[1] == 0x3C && temp[2] == 0x00 && temp[3] == 0x3F) {
|
||||||
|
encodingGuess = "UnicodeBigUnmarked";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// UTF-16LE or little-endian ISO-10646-UCS-2 or other encoding with a 16-bit code unit
|
||||||
|
// in little-endian order and ASCII characters encoded as ASCII values (the encoding
|
||||||
|
// declaration must be read to determine which)
|
||||||
|
else if (temp[0] == 0x3C && temp[1] == 0x00 && temp[2] == 0x3F && temp[3] == 0x00) {
|
||||||
|
encodingGuess = "UnicodeLittleUnmarked";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// UTF-8, ISO 646, ASCII, some part of ISO 8859, Shift-JIS, EUC, or any other 7-bit,
|
||||||
|
// 8-bit, or mixed-width encoding which ensures that the characters of ASCII have their
|
||||||
|
// normal positions, width, and values; the actual encoding declaration must be read to
|
||||||
|
// detect which of these applies, but since all of these encodings use the same bit patterns
|
||||||
|
// for the relevant ASCII characters, the encoding declaration itself may be read reliably
|
||||||
|
else if (temp[0] == 0x3C && temp[1] == 0x3F && temp[2] == 0x78 && temp[3] == 0x6D) {
|
||||||
|
encodingGuess = SystemEncodingUtil.ENCODING_UTF_8;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// EBCDIC (in some flavor; the full encoding declaration must be read to tell which
|
||||||
|
// code page is in use)
|
||||||
|
else if (temp[0] == 0x4C && temp[1] == 0x6F && temp[2] == 0xA7 && temp[3] == 0x94) {
|
||||||
|
encodingGuess = "Cp037";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// UTF-8 without an encoding declaration, or else the data stream is mislabeled
|
||||||
|
// (lacking a required encoding declaration), corrupt, fragmentary, or enclosed in a
|
||||||
|
// wrapper of some kind
|
||||||
|
else {
|
||||||
|
|
||||||
|
// From section 4.3.3 of the XML specification:
|
||||||
|
// In the absence of information provided by an external transport protocol
|
||||||
|
// (e.g. HTTP or MIME), it is an error for an entity including an encoding declaration
|
||||||
|
// to be presented to the XML processor in an encoding other than that named in the
|
||||||
|
// declaration, or for an entity which begins with neither a Byte Order Mark nor an
|
||||||
|
// encoding declaration to use an encoding other than UTF-8. Note that since ASCII is
|
||||||
|
// a subset of UTF-8, ordinary ASCII entities do not strictly need an encoding declaration.
|
||||||
|
|
||||||
|
// We'll assume that this is UTF-8 or ASCII encoding without an encoding declaration.
|
||||||
|
// Of course, it could also be another encoding that doesn't have an encoding declaration
|
||||||
|
// in which case it has violated the XML specification (any encoding beside UTF-8 or UTF-16
|
||||||
|
// must specify the character encoding). From section 4.3.3 of the XML specification:
|
||||||
|
// In the absence of external character encoding information (such as MIME headers),
|
||||||
|
// parsed entities which are stored in an encoding other than UTF-8 or UTF-16 must begin
|
||||||
|
// with a text declaration (see 4.3.1 The Text Declaration) containing an encoding declaration.
|
||||||
|
encodingGuess = SystemEncodingUtil.ENCODING_UTF_8;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we have a guess, we need to read in the encoding declaration to get the actula encoding
|
||||||
|
// the guess tells us the encoding of the family
|
||||||
|
if (encodingGuess != null) {
|
||||||
|
|
||||||
|
stream = new FileInputStream(filePath);
|
||||||
|
InputStreamReader reader = new InputStreamReader(stream, encodingGuess);
|
||||||
|
BufferedReader bufReader = new BufferedReader(reader);
|
||||||
|
|
||||||
|
String line = bufReader.readLine();
|
||||||
|
|
||||||
|
while (line != null) {
|
||||||
|
|
||||||
|
int encodingIndex = line.indexOf("encoding");
|
||||||
|
|
||||||
|
// look for the encoding attribute
|
||||||
|
if (encodingIndex != -1) {
|
||||||
|
|
||||||
|
// we look in the same line first
|
||||||
|
boolean sameLine = true;
|
||||||
|
|
||||||
|
boolean doubleQuoteFound = false;
|
||||||
|
boolean singleQuoteFound = false;
|
||||||
|
|
||||||
|
while (line != null) {
|
||||||
|
|
||||||
|
// now look for the begin quote, which does not have to be
|
||||||
|
// on the same line as the encoding attribute declaration
|
||||||
|
int beginQuote = -1;
|
||||||
|
|
||||||
|
// search in same line first
|
||||||
|
if (sameLine) {
|
||||||
|
|
||||||
|
// look for double quote
|
||||||
|
beginQuote = line.indexOf('\"', encodingIndex+9);
|
||||||
|
|
||||||
|
// if double quote not found, then try single quote
|
||||||
|
if (beginQuote == -1) {
|
||||||
|
beginQuote = line.indexOf('\'', encodingIndex+9);
|
||||||
|
|
||||||
|
// single quote found, so flag it
|
||||||
|
if (beginQuote != -1) {
|
||||||
|
singleQuoteFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// double quote found, so flag it
|
||||||
|
else {
|
||||||
|
doubleQuoteFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// search in another line now
|
||||||
|
else {
|
||||||
|
|
||||||
|
// look for double quote
|
||||||
|
beginQuote = line.indexOf('\"');
|
||||||
|
|
||||||
|
// if single quote not found, then try single quote
|
||||||
|
if (beginQuote == -1) {
|
||||||
|
beginQuote = line.indexOf('\'');
|
||||||
|
|
||||||
|
// single quote found, so flag it
|
||||||
|
if (beginQuote != -1) {
|
||||||
|
singleQuoteFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// double quote found, so flag it
|
||||||
|
else {
|
||||||
|
doubleQuoteFound = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if begin quote found, look for endquote which should be on the same line
|
||||||
|
if (beginQuote != -1) {
|
||||||
|
int endQuote = -1;
|
||||||
|
|
||||||
|
if (doubleQuoteFound) {
|
||||||
|
endQuote = line.indexOf('\"', beginQuote+1);
|
||||||
|
}
|
||||||
|
else if (singleQuoteFound){
|
||||||
|
endQuote = line.indexOf('\'', beginQuote+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if end quote found, encoding is in between begin quote and end quote
|
||||||
|
if (endQuote != -1) {
|
||||||
|
encoding = line.substring(beginQuote+1, endQuote);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
line = bufReader.readLine();
|
||||||
|
|
||||||
|
if (sameLine) {
|
||||||
|
sameLine = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
line = bufReader.readLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the encoding declaration was not found
|
||||||
|
if (encoding == null) {
|
||||||
|
|
||||||
|
// check if our initial guess was UTF-8 or UTF-16
|
||||||
|
// those do not have to have an encoding declaration
|
||||||
|
if (encodingGuess.equals(SystemEncodingUtil.ENCODING_UTF_8) || encodingGuess.startsWith("UnicodeBig") ||
|
||||||
|
encodingGuess.equals("UnicodeLittle")) {
|
||||||
|
encoding = encodingGuess;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the encoding from the Byte Order Mark (BOM).
|
||||||
|
* @param filePath the file path.
|
||||||
|
* @return the encoding, or <code>null</code> if there is no BOM.
|
||||||
|
*/
|
||||||
|
public String getEncodingFromBOM(String filePath) throws IOException {
|
||||||
|
FileInputStream stream = new FileInputStream(filePath);
|
||||||
|
|
||||||
|
String encoding = getEncodingFromBOM(stream);
|
||||||
|
|
||||||
|
stream.close();
|
||||||
|
|
||||||
|
return encoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the encoding from the Byte Order Mark (BOM).
|
||||||
|
* @param filePath the file path.
|
||||||
|
* @return the encoding, or <code>null</code> if there is no BOM.
|
||||||
|
*/
|
||||||
|
private String getEncodingFromBOM(InputStream stream) throws IOException {
|
||||||
|
|
||||||
|
byte[] bomBytes = new byte[4];
|
||||||
|
|
||||||
|
// read the first three bytes
|
||||||
|
stream.read(bomBytes, 0, 3);
|
||||||
|
|
||||||
|
// check if UTF-8 BOM
|
||||||
|
if (bomBytes[0] == 0xEF && bomBytes[1] == 0xBB && bomBytes[2] == 0xBF) {
|
||||||
|
return SystemEncodingUtil.ENCODING_UTF_8;
|
||||||
|
}
|
||||||
|
|
||||||
|
// now read the fourth byte
|
||||||
|
stream.read(bomBytes, 3, 1);
|
||||||
|
|
||||||
|
// check if it matches some other encoding BOM
|
||||||
|
|
||||||
|
// UCS-4, big-endian order (1234 order)
|
||||||
|
if (bomBytes[0] == 0x00 && bomBytes[1] == 0x00 && bomBytes[2] == 0xFE && bomBytes[3] == 0xFF) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// UCS-4, little-endian order (4321 order)
|
||||||
|
else if (bomBytes[0] == 0xFF && bomBytes[1] == 0xFE && bomBytes[2] == 0x00 && bomBytes[3] == 0x00) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// UCS-4, unusual octet order (2143)
|
||||||
|
else if (bomBytes[0] == 0x00 && bomBytes[1] == 0x00 && bomBytes[2] == 0xFF && bomBytes[3] == 0xFE) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// UCS-4, unusual octet order (3412)
|
||||||
|
else if (bomBytes[0] == 0xFE && bomBytes[1] == 0xFF && bomBytes[2] == 0x00 && bomBytes[3] == 0x00) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// UTF-16, big-endian order
|
||||||
|
else if (bomBytes[0] == 0xFE && bomBytes[1] == 0xFF && !(bomBytes[2] == 0x00 && bomBytes[3] == 0x00)) {
|
||||||
|
return "UnicodeBig";
|
||||||
|
}
|
||||||
|
// UTF-16, little-endian order
|
||||||
|
else if (bomBytes[0] == 0xFF && bomBytes[1] == 0xFE && !(bomBytes[2] == 0x00 && bomBytes[3] == 0x00)) {
|
||||||
|
return "UnicodeLittle";
|
||||||
|
}
|
||||||
|
// not a BOM
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,324 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
|
||||||
|
import org.eclipse.rse.services.clientserver.archiveutils.AbsoluteVirtualPath;
|
||||||
|
import org.eclipse.rse.services.clientserver.archiveutils.ArchiveHandlerManager;
|
||||||
|
import org.eclipse.rse.services.clientserver.java.BasicClassFileParser;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This singleton class classifies a file on the remote system.
|
||||||
|
*/
|
||||||
|
public class SystemFileClassifier {
|
||||||
|
|
||||||
|
private static SystemFileClassifier instance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
private SystemFileClassifier() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the singleton instance.
|
||||||
|
* @return the singleton instance.
|
||||||
|
*/
|
||||||
|
public static SystemFileClassifier getInstance() {
|
||||||
|
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new SystemFileClassifier();
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classifies the file with the given absolute path. The absolute path can represent a virtual file.
|
||||||
|
* By default, returns <code>"file"</code>.
|
||||||
|
* @param absolutePath the absolute path.
|
||||||
|
* @return the classification.
|
||||||
|
*/
|
||||||
|
public String classifyFile(String absolutePath) {
|
||||||
|
|
||||||
|
// first check if the absolute path is virtual
|
||||||
|
boolean isVirtual = ArchiveHandlerManager.isVirtual(absolutePath);
|
||||||
|
|
||||||
|
// if virtual, classify using archive handler manager
|
||||||
|
if (isVirtual) {
|
||||||
|
return classifyVirtual(absolutePath);
|
||||||
|
}
|
||||||
|
// otherwise, we classify using our way
|
||||||
|
else {
|
||||||
|
return classifyNonVirtual(absolutePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classifies a virtual file with the given path.
|
||||||
|
* @param absolutePath the absolute path of the virtual file.
|
||||||
|
* @return the classification.
|
||||||
|
*/
|
||||||
|
protected String classifyVirtual(String absolutePath) {
|
||||||
|
|
||||||
|
// create an abolute virtual path object
|
||||||
|
AbsoluteVirtualPath avp = new AbsoluteVirtualPath(absolutePath);
|
||||||
|
|
||||||
|
// get the path of the containing archive
|
||||||
|
String archivePath = avp.getContainingArchiveString();
|
||||||
|
|
||||||
|
// get the virtual part of the file path
|
||||||
|
String virtualPath = avp.getVirtualPart();
|
||||||
|
|
||||||
|
// get archive file
|
||||||
|
File archiveFile = new File(archivePath);
|
||||||
|
|
||||||
|
// get classification of virtual file
|
||||||
|
return ArchiveHandlerManager.getInstance().getClassification(archiveFile, virtualPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classifies a non-virtual file with the given path.
|
||||||
|
* @param absolutePath the absolute path of the file.
|
||||||
|
* @return the classification.
|
||||||
|
*/
|
||||||
|
protected String classifyNonVirtual(String absolutePath) {
|
||||||
|
|
||||||
|
// default type
|
||||||
|
String type = "file";
|
||||||
|
|
||||||
|
File file = new File(absolutePath);
|
||||||
|
|
||||||
|
// check if file exists
|
||||||
|
if (!file.exists()) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
// find out if we are on Windows
|
||||||
|
boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("win");
|
||||||
|
|
||||||
|
// for Windows, we only detect *.exe and *.dll files
|
||||||
|
if (isWindows)
|
||||||
|
{
|
||||||
|
absolutePath = absolutePath.toLowerCase();
|
||||||
|
// classify *.class file
|
||||||
|
if (absolutePath.endsWith(".class")) {
|
||||||
|
type = classifyClassFile(absolutePath);
|
||||||
|
}
|
||||||
|
// *.exe files are binary executables
|
||||||
|
else if (absolutePath.endsWith(".exe")) {
|
||||||
|
type = "executable(binary)";
|
||||||
|
}
|
||||||
|
// *.dll files are of type "module"
|
||||||
|
else if (absolutePath.endsWith(".dll")) {
|
||||||
|
type = "module";
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get specified encoding if any
|
||||||
|
String encoding = System.getProperty("dstore.stdin.encoding");
|
||||||
|
|
||||||
|
// otherwise, default to system encoding
|
||||||
|
if (encoding == null || encoding.equals("")) {
|
||||||
|
encoding = System.getProperty("file.encoding");
|
||||||
|
}
|
||||||
|
|
||||||
|
// create command "sh -c file <absolutePath>"
|
||||||
|
String args[] = new String[3];
|
||||||
|
args[0] = "sh";
|
||||||
|
args[1] = "-c";
|
||||||
|
args[2] = "file " + absolutePath;
|
||||||
|
|
||||||
|
BufferedReader poutReader = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Process childProcess = Runtime.getRuntime().exec(args);
|
||||||
|
InputStreamReader reader = new InputStreamReader(childProcess.getInputStream(), encoding);
|
||||||
|
poutReader = new BufferedReader(reader);
|
||||||
|
|
||||||
|
// get line of output
|
||||||
|
String line = poutReader.readLine();
|
||||||
|
|
||||||
|
if (line != null) {
|
||||||
|
line = line.trim();
|
||||||
|
|
||||||
|
// classify from line of output
|
||||||
|
type = getClassification(absolutePath, line);
|
||||||
|
|
||||||
|
// close stream
|
||||||
|
poutReader.close();
|
||||||
|
|
||||||
|
// if it a symbolic link, then get the canonical path and classify it as well
|
||||||
|
if (type.equals("link")) {
|
||||||
|
String canonicalPath = file.getCanonicalPath();
|
||||||
|
return type + "(" + classifyNonVirtual(canonicalPath) + ")" + ":" + canonicalPath;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (UnsupportedEncodingException e) {
|
||||||
|
// TODO: log it
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// TODO: log it
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classifies from the given line of classification output.
|
||||||
|
* @param absolutePath the absolute path of the file that was classified.
|
||||||
|
* @param line the line of output to parse.
|
||||||
|
* @return the classification.
|
||||||
|
*/
|
||||||
|
protected String getClassification(String absolutePath, String line) {
|
||||||
|
|
||||||
|
// default type
|
||||||
|
String type = "file";
|
||||||
|
|
||||||
|
// look for colon
|
||||||
|
int colon = line.indexOf(':');
|
||||||
|
|
||||||
|
// name appears before colon
|
||||||
|
String name = line.substring(0, colon);
|
||||||
|
|
||||||
|
// the full type appears after the colon
|
||||||
|
String fulltype = line.substring(colon + 1, line.length()).trim();
|
||||||
|
|
||||||
|
// if it is a *.class file, then we look for main method and qulaified class name
|
||||||
|
// as part of the classification
|
||||||
|
if (name.endsWith(".class")) {
|
||||||
|
type = classifyClassFile(absolutePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if it is a shared library
|
||||||
|
boolean matchesLib = (fulltype.indexOf("shared object") > -1) ||
|
||||||
|
(fulltype.indexOf("object module") > -1) ||
|
||||||
|
(fulltype.indexOf("archive") > -1);
|
||||||
|
|
||||||
|
// check if it is an executable
|
||||||
|
boolean matchesExe = (fulltype.indexOf("executable") > -1);
|
||||||
|
|
||||||
|
// check if it is a script
|
||||||
|
boolean matchesScript = (fulltype.indexOf("script") > -1);
|
||||||
|
|
||||||
|
// shared library
|
||||||
|
if (matchesLib) {
|
||||||
|
|
||||||
|
// all *.a, *.so and *.so.* files are of type "module"
|
||||||
|
if (name.endsWith(".a") || name.endsWith(".so") || (name.indexOf(".so.") > 0)) {
|
||||||
|
type = "module";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// a script file
|
||||||
|
else if (matchesScript) {
|
||||||
|
|
||||||
|
// an executable script file
|
||||||
|
if (matchesExe) {
|
||||||
|
type = "executable(script)";
|
||||||
|
}
|
||||||
|
// non-executable script file
|
||||||
|
else {
|
||||||
|
type = "script";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// binary executable
|
||||||
|
else if (matchesExe) {
|
||||||
|
type = "executable(binary)";
|
||||||
|
}
|
||||||
|
|
||||||
|
// on iSeries we look for "OS/400 object" as a type
|
||||||
|
else if (fulltype.indexOf("OS/400 object") > -1) {
|
||||||
|
type = "OS/400 object";
|
||||||
|
}
|
||||||
|
|
||||||
|
// finally, if the full type contains the symbolic link string, then type is simply "link"
|
||||||
|
else if (fulltype.startsWith("symbolic link to")) {
|
||||||
|
type = "link";
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classifies a class file.
|
||||||
|
* @param absolutePath the absolute path of the class file.
|
||||||
|
* @return the classification.
|
||||||
|
*/
|
||||||
|
protected String classifyClassFile(String absolutePath) {
|
||||||
|
|
||||||
|
// default type
|
||||||
|
String type = "file";
|
||||||
|
|
||||||
|
// input stream to file
|
||||||
|
FileInputStream stream = null;
|
||||||
|
|
||||||
|
// class file parser
|
||||||
|
BasicClassFileParser parser = null;
|
||||||
|
|
||||||
|
boolean isExecutable = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
stream = new FileInputStream(absolutePath);
|
||||||
|
|
||||||
|
// use class file parser to parse the class file
|
||||||
|
parser = new BasicClassFileParser(stream);
|
||||||
|
parser.parse();
|
||||||
|
|
||||||
|
// query if it is executable, i.e. whether it has main method
|
||||||
|
isExecutable = parser.isExecutable();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
// TODO: log it
|
||||||
|
|
||||||
|
// we assume not executable
|
||||||
|
isExecutable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if it is executable, then also get qualified class name
|
||||||
|
if (isExecutable) {
|
||||||
|
type = "executable(java";
|
||||||
|
|
||||||
|
String qualifiedClassName = parser.getQualifiedClassName();
|
||||||
|
|
||||||
|
if (qualifiedClassName != null) {
|
||||||
|
type = type + ":" + qualifiedClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
type = type + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,153 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents search string.
|
||||||
|
*/
|
||||||
|
public class SystemSearchString {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constant indicating that the depth is infinite, -1.
|
||||||
|
*/
|
||||||
|
public static final int DEPTH_INFINITE = -1;
|
||||||
|
|
||||||
|
protected String textString;
|
||||||
|
protected boolean isCaseSensitive;
|
||||||
|
protected boolean isTextStringRegex;
|
||||||
|
protected String fileNamesString;
|
||||||
|
protected boolean isFileNamesRegex;
|
||||||
|
protected boolean includeArchives;
|
||||||
|
protected boolean includeSubfolders;
|
||||||
|
protected String classificationString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new search string.
|
||||||
|
* @param textString the text string.
|
||||||
|
* @param isCaseSensitive <code>true</code> if the search should be case sensitive, <code>false</code> otherwise.
|
||||||
|
* @param isTextStringRegex <code>true</code> if the text string is a regular expression, <code>false</code> otherwise.
|
||||||
|
* @param fileNamesString the file names pattern.
|
||||||
|
* @param isFileNamesRegex <code>true</code> if the file names string is a regular expression, <code>false</code> otherwise.
|
||||||
|
* @param includeArchives <code>true</code> to search inside archives, <code>false</code> otherwise.
|
||||||
|
* @param includeSubfolders <code>true</code> to search subfolders, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public SystemSearchString(String textString, boolean isCaseSensitive, boolean isTextStringRegex,
|
||||||
|
String fileNamesString, boolean isFileNamesRegex, boolean includeArchives,
|
||||||
|
boolean includeSubfolders) {
|
||||||
|
this(textString, isCaseSensitive, isTextStringRegex, fileNamesString, isFileNamesRegex, includeArchives,
|
||||||
|
includeSubfolders, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new search string that allows search to be restricted to files with a certain classification.
|
||||||
|
* @param textString the text string.
|
||||||
|
* @param isCaseSensitive <code>true</code> if the search should be case sensitive, <code>false</code> otherwise.
|
||||||
|
* @param isTextStringRegex <code>true</code> if the text string is a regular expression, <code>false</code> otherwise.
|
||||||
|
* @param fileNamesString the file names pattern.
|
||||||
|
* @param isFileNamesRegex <code>true</code> if the file names string is a regular expression, <code>false</code> otherwise.
|
||||||
|
* @param includeArchives <code>true</code> to search inside archives, <code>false</code> otherwise.
|
||||||
|
* @param includeSubfolders <code>true</code> to search subfolders, <code>false</code> otherwise.
|
||||||
|
* @param classificationString the classification string that file classifications should match with.
|
||||||
|
*/
|
||||||
|
public SystemSearchString(String textString, boolean isCaseSensitive, boolean isTextStringRegex,
|
||||||
|
String fileNamesString, boolean isFileNamesRegex, boolean includeArchives,
|
||||||
|
boolean includeSubfolders, String classificationString) {
|
||||||
|
this.textString = textString;
|
||||||
|
this.isCaseSensitive = isCaseSensitive;
|
||||||
|
this.isTextStringRegex = isTextStringRegex;
|
||||||
|
this.fileNamesString = fileNamesString;
|
||||||
|
this.isFileNamesRegex = isFileNamesRegex;
|
||||||
|
this.includeArchives = includeArchives;
|
||||||
|
this.includeSubfolders = includeSubfolders;
|
||||||
|
this.classificationString = classificationString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the text string.
|
||||||
|
* @return the text string.
|
||||||
|
*/
|
||||||
|
public String getTextString() {
|
||||||
|
return textString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the search is case sensitive.
|
||||||
|
* @return <code>true</code> if the search is case sensitive, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public boolean isCaseSensitive() {
|
||||||
|
return isCaseSensitive;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the text string is a regular expression.
|
||||||
|
* @return <code>true</code> if the text string is a regular expression, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public boolean isTextStringRegex() {
|
||||||
|
return isTextStringRegex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the file names string.
|
||||||
|
* @return the file names string.
|
||||||
|
*/
|
||||||
|
public String getFileNamesString() {
|
||||||
|
return fileNamesString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the file names string is a regular expression.
|
||||||
|
* @return <code>true</code> if the file names string is a regular expression, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public boolean isFileNamesRegex() {
|
||||||
|
return isFileNamesRegex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether archives should be searched.
|
||||||
|
* @return <code>true</code> to search archives, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public boolean isIncludeArchives() {
|
||||||
|
return includeArchives;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether subfolders should be searched.
|
||||||
|
* @return <code>true</code> to search subfolders, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public boolean isIncludeSubfolders() {
|
||||||
|
return includeSubfolders;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the classification string that file classifications should match with.
|
||||||
|
* @return the classification.
|
||||||
|
*/
|
||||||
|
public String getClassificationString() {
|
||||||
|
return classificationString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes the contents of the search string
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
public String toString() {
|
||||||
|
return textString + " - " + isCaseSensitive + " - " + isTextStringRegex + " - " +
|
||||||
|
fileNamesString + " - " + isFileNamesRegex + " - " + includeArchives + " - " +
|
||||||
|
includeSubfolders + " - " + classificationString;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver;
|
||||||
|
|
||||||
|
import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author mjberger
|
||||||
|
*
|
||||||
|
* Represents a search result in a virtual file.
|
||||||
|
*/
|
||||||
|
public final class VirtualSearchResult
|
||||||
|
{
|
||||||
|
private VirtualChild _virtualChild;
|
||||||
|
private long _lineNumber;
|
||||||
|
private String _matchingLine;
|
||||||
|
|
||||||
|
public VirtualSearchResult(VirtualChild vc, long lineNumber, String matchingLine)
|
||||||
|
{
|
||||||
|
_virtualChild = vc;
|
||||||
|
_lineNumber = lineNumber;
|
||||||
|
_matchingLine = matchingLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLineNumber()
|
||||||
|
{
|
||||||
|
return _lineNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMatchingLine() {
|
||||||
|
return _matchingLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VirtualChild getVirtualChild() {
|
||||||
|
return _virtualChild;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,138 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.archiveutils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author mjberger
|
||||||
|
*
|
||||||
|
* Represents an absolute virtual path, which contains a real part
|
||||||
|
* (the part of the path that locates the containing archive) and a
|
||||||
|
* virtual part (the part that locates the file in the virtual file
|
||||||
|
* system within the archive).
|
||||||
|
*/
|
||||||
|
public class AbsoluteVirtualPath
|
||||||
|
{
|
||||||
|
|
||||||
|
protected AbsoluteVirtualPath _realPart;
|
||||||
|
protected String _realPartName;
|
||||||
|
protected String _virtualPart;
|
||||||
|
protected boolean _isVirtual;
|
||||||
|
protected String _absVirtualPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up a new AbsoluteVirtualPath object, by parsing <code>absolutePath</code>
|
||||||
|
* into a "real" part (the containing archive) and a "virtual" part (the path to
|
||||||
|
* the entry in the archive). Note that the real part is also an AbsoluteVirtualPath
|
||||||
|
* in order to account for nested archives.
|
||||||
|
*/
|
||||||
|
public AbsoluteVirtualPath(String absolutePath)
|
||||||
|
{
|
||||||
|
String sep = ArchiveHandlerManager.VIRTUAL_SEPARATOR;
|
||||||
|
_absVirtualPath = ArchiveHandlerManager.cleanUpVirtualPath(absolutePath);
|
||||||
|
int i = _absVirtualPath.lastIndexOf(sep);
|
||||||
|
if (i == -1)
|
||||||
|
{
|
||||||
|
// no more nesting, this is the actual container archive.
|
||||||
|
_absVirtualPath = absolutePath; // fix for defect 51898 and related defects
|
||||||
|
_virtualPart = "";
|
||||||
|
_realPartName = _absVirtualPath;
|
||||||
|
_realPart = this;
|
||||||
|
_isVirtual = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// there could be nesting further below, so parse out the real part
|
||||||
|
// by recursively calling the constructor.
|
||||||
|
_virtualPart = _absVirtualPath.substring(i+sep.length());
|
||||||
|
_realPartName = _absVirtualPath.substring(0,i);
|
||||||
|
_realPart = new AbsoluteVirtualPath(_realPartName);
|
||||||
|
_isVirtual = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether or not this AbsoluteVirtualPath is virtual.
|
||||||
|
*/
|
||||||
|
public boolean isVirtual()
|
||||||
|
{
|
||||||
|
return _isVirtual;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The AbsoluteVirtualPath of the archive that contains the object specified
|
||||||
|
* by this AbsoluteVirtualPath. Note that the archive can itself be virtual as well.
|
||||||
|
*/
|
||||||
|
public AbsoluteVirtualPath getContainingArchivePath()
|
||||||
|
{
|
||||||
|
return _realPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The name of the AbsoluteVirtualPath of the archive that contains the object
|
||||||
|
* specified by this AbsoluteVirtualPath.
|
||||||
|
*/
|
||||||
|
public String getContainingArchiveString()
|
||||||
|
{
|
||||||
|
return _realPartName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The virtual path to the virtual object referred to by this AbsoluteVirtualPath.
|
||||||
|
*/
|
||||||
|
public String getVirtualPart()
|
||||||
|
{
|
||||||
|
return _virtualPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns this AbsoluteVirtualPath as a string.
|
||||||
|
*/
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return _absVirtualPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the virtual part of this AbsoluteVirtualPath to be newVirtualPart
|
||||||
|
*/
|
||||||
|
public void setVirtualPart(String newVirtualPart)
|
||||||
|
{
|
||||||
|
_virtualPart = newVirtualPart;
|
||||||
|
if (newVirtualPart == "")
|
||||||
|
{
|
||||||
|
int i = _absVirtualPath.lastIndexOf(ArchiveHandlerManager.VIRTUAL_SEPARATOR);
|
||||||
|
_absVirtualPath = _absVirtualPath.substring(0, i);
|
||||||
|
_isVirtual = _realPart._isVirtual;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_absVirtualPath = _realPartName + ArchiveHandlerManager.VIRTUAL_SEPARATOR + newVirtualPart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return _absVirtualPath.substring(_absVirtualPath.lastIndexOf("/") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath()
|
||||||
|
{
|
||||||
|
String path = _absVirtualPath.substring(0, _absVirtualPath.lastIndexOf("/"));
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,500 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.archiveutils;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class manages all the Archive Handlers that correspond to the archive file that the system
|
||||||
|
* would like to deal with. It contains methods for registering handlers with file types, as well as
|
||||||
|
* utilities for getting at the contents of archives that the Manager represents.
|
||||||
|
* This class is designed to be a singleton class, so the best way to use it is
|
||||||
|
* to use statements of the form "ArchiveHandlerManager.getInstance().method".
|
||||||
|
* @author mjberger
|
||||||
|
*/
|
||||||
|
public class ArchiveHandlerManager
|
||||||
|
{
|
||||||
|
// The string that separates the virtual part of an absolute path from the real part
|
||||||
|
public static final String VIRTUAL_SEPARATOR = "#virtual#/";
|
||||||
|
public static final String VIRTUAL_CANONICAL_SEPARATOR = "#virtual#";
|
||||||
|
|
||||||
|
// the singleton instance
|
||||||
|
protected static ArchiveHandlerManager _instance = new ArchiveHandlerManager();
|
||||||
|
|
||||||
|
// a mapping from Files to ISystemArchiveHandlers
|
||||||
|
protected HashMap _handlers;
|
||||||
|
|
||||||
|
// a mapping from Strings (file extensions) to Classes (the type of handler to use)
|
||||||
|
protected HashMap _handlerTypes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The singleton instance of this class.
|
||||||
|
*/
|
||||||
|
public static ArchiveHandlerManager getInstance()
|
||||||
|
{
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArchiveHandlerManager()
|
||||||
|
{
|
||||||
|
_handlers = new HashMap();
|
||||||
|
_handlerTypes = new HashMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the children of an object in the virtual file system.
|
||||||
|
* @param file The archive in whose virtual file system the children reside.
|
||||||
|
* @param virtualpath The parent virtual object whose children this method is to return. To
|
||||||
|
* get the top level virtualchildren in the archive, set virtualpath to "" or null.
|
||||||
|
* @return An array of VirtualChild objects representing the children of the virtual object
|
||||||
|
* in <code>file</code> referred to by <code>virtualpath</code>. If no class implementing
|
||||||
|
* ISystemArchiveHandler can be found that corresponds to file, then this method returns null.
|
||||||
|
* If the virtual object has no children, this method also returns null.
|
||||||
|
* @throws IOException if there was a problem getting the registered handler for the
|
||||||
|
* file. This usually means the archive is corrupted.
|
||||||
|
*/
|
||||||
|
public VirtualChild[] getContents(File file, String virtualpath) throws IOException
|
||||||
|
{
|
||||||
|
if (virtualpath == null) virtualpath = "";
|
||||||
|
ISystemArchiveHandler handler = getRegisteredHandler(file);
|
||||||
|
if (handler == null || !handler.exists()) throw new IOException();
|
||||||
|
return handler.getVirtualChildren(virtualpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the children of an object in the virtual file system that are folders.
|
||||||
|
* @param file The archive in whose virtual file system the children reside.
|
||||||
|
* @param virtualpath The parent virtual object whose children this method is to return. To
|
||||||
|
* get the top level virtualchildren in the archive, set virtualpath to "" or null.
|
||||||
|
* @return An array of VirtualChild objects representing the children of the virtual object
|
||||||
|
* in <code>file</code> referred to by <code>virtualpath</code> that are themselves folders.
|
||||||
|
* If no class implementing ISystemArchiveHandler can be found that corresponds to file, then
|
||||||
|
* this method returns null. If the virtual object has no children, this method also returns null.
|
||||||
|
*/
|
||||||
|
public VirtualChild[] getFolderContents(File file, String virtualpath)
|
||||||
|
{
|
||||||
|
if (virtualpath == null) virtualpath = "";
|
||||||
|
ISystemArchiveHandler handler = getRegisteredHandler(file);
|
||||||
|
if (handler == null) return null;
|
||||||
|
return handler.getVirtualChildFolders(virtualpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether a file is an known type of archive.
|
||||||
|
* @param file the file to test.
|
||||||
|
* @return true if and only if the file is an archive whose
|
||||||
|
* type is registered with the ArchiveHandlerManager.
|
||||||
|
*/
|
||||||
|
public boolean isArchive(File file)
|
||||||
|
{
|
||||||
|
if (_handlers.containsKey(file))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_handlerTypes.containsKey(getExtension(file)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether a file is an known type of archive, based on the file name.
|
||||||
|
* @param file the name of the file to test.
|
||||||
|
* @return true if and only if the file is an archive whose
|
||||||
|
* type is registered with the ArchiveHandlerManager.
|
||||||
|
*/
|
||||||
|
public boolean isRegisteredArchive(String filename)
|
||||||
|
{
|
||||||
|
if (_handlerTypes.containsKey(getExtension(filename)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param file the file whose extension we are computing.
|
||||||
|
* @return the extension of <code>file</code>. "Extension" is
|
||||||
|
* defined as any letters in the filename after the last ".".
|
||||||
|
* Returns "" if there is no extension.
|
||||||
|
*/
|
||||||
|
protected String getExtension(File file)
|
||||||
|
{
|
||||||
|
String filename = file.getName();
|
||||||
|
int i = filename.lastIndexOf(".");
|
||||||
|
if (i == -1) return "";
|
||||||
|
return filename.substring(i+1).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param filename the name of the file whose extension we are computing.
|
||||||
|
* @return the extension of <code>filename</code>. "Extension" is
|
||||||
|
* defined as any letters in the filename after the last ".".
|
||||||
|
* Returns "" if there is no extension.
|
||||||
|
*/
|
||||||
|
protected String getExtension(String filename)
|
||||||
|
{
|
||||||
|
int i = filename.lastIndexOf(".");
|
||||||
|
if (i == -1) return "";
|
||||||
|
return filename.substring(i+1).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given the absolute path to a virtual object, returns that object
|
||||||
|
* as a VirtualChild.
|
||||||
|
* @param fullyQualifiedName The absolute path to the object. Usually consists
|
||||||
|
* of the fullyQualifiedName of the archive, followed by the virtual path separator
|
||||||
|
* (defined in ArchiveHandlerManager.VIRTUAL_SEPARATOR) followed by the virtual path to
|
||||||
|
* the object within the archive's virtual file system.
|
||||||
|
*/
|
||||||
|
public VirtualChild getVirtualObject(String fullyQualifiedName)
|
||||||
|
{
|
||||||
|
String cleanName = cleanUpVirtualPath(fullyQualifiedName);
|
||||||
|
AbsoluteVirtualPath avp = new AbsoluteVirtualPath(cleanName);
|
||||||
|
if (!avp.isVirtual()) return new VirtualChild("", new File(avp.getContainingArchiveString()));
|
||||||
|
String zipfile = avp.getContainingArchiveString();
|
||||||
|
File file = new File(zipfile);
|
||||||
|
ISystemArchiveHandler handler = getRegisteredHandler(file);
|
||||||
|
if (handler == null) return new VirtualChild(avp.getVirtualPart(), new File(avp.getContainingArchiveString()));
|
||||||
|
VirtualChild vc = handler.getVirtualFile(avp.getVirtualPart());
|
||||||
|
return vc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the registered handler for the File <code>file</code>. If
|
||||||
|
* no handler exists for that file yet, create it. If the extension of
|
||||||
|
* <code>file</code> is not registered, then returns null.
|
||||||
|
*/
|
||||||
|
public ISystemArchiveHandler getRegisteredHandler(File file)
|
||||||
|
{
|
||||||
|
ISystemArchiveHandler handler = null;
|
||||||
|
if (_handlers.containsKey(file))
|
||||||
|
{
|
||||||
|
handler = (ISystemArchiveHandler) _handlers.get(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handler != null && handler.exists())
|
||||||
|
{
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// find registered handler based on file's extension
|
||||||
|
String ext = getExtension(file);
|
||||||
|
if (!_handlerTypes.containsKey(ext))
|
||||||
|
{
|
||||||
|
System.out.println("Unknown archive file type: " + ext);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Class handlerType = (Class) _handlerTypes.get(ext);
|
||||||
|
Constructor newHandlerType = getProperConstructor(handlerType);
|
||||||
|
Object[] files = new Object[1];
|
||||||
|
files[0] = file;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
handler = (ISystemArchiveHandler) newHandlerType.newInstance(files);
|
||||||
|
}
|
||||||
|
catch (InvocationTargetException e)
|
||||||
|
{
|
||||||
|
Throwable target = e.getCause();
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
System.out.println("Could not instantiate handler for " + file.getName());
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
System.out.println("Could not instantiate handler for " + file.getName());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_handlers.put(file, handler);
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Constructor getProperConstructor(Class handlerType)
|
||||||
|
{
|
||||||
|
Constructor[] constructors = handlerType.getConstructors();
|
||||||
|
for (int i = 0; i < constructors.length; i++)
|
||||||
|
{
|
||||||
|
if (constructors[i].getParameterTypes().length != 1)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (!constructors[i].getParameterTypes()[0].equals(File.class))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else return constructors[i];
|
||||||
|
}
|
||||||
|
return null; // should never get to this point
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers an extension and a handler type.
|
||||||
|
* @param ext The extension to register with the ArchiveHandlerManager
|
||||||
|
* @param handlerType The class of handler to register with <code>ext</code>.
|
||||||
|
* Note that any class passed in must implement ISystemArchiveHandler.
|
||||||
|
* @return Whether or not the registration was successful.
|
||||||
|
*/
|
||||||
|
public boolean setRegisteredHandler(String ext, Class handlerType)
|
||||||
|
{
|
||||||
|
if (!handlerHasProperConstructor(handlerType))
|
||||||
|
{
|
||||||
|
System.out.println("Cannot register archive handler " + handlerType);
|
||||||
|
System.out.println(handlerType + " does not contain a constructor whose signature is 'Constructor(File file)'");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (handlerImplementsISystemArchiveHandler(handlerType))
|
||||||
|
{
|
||||||
|
if (_handlerTypes.containsKey(ext)) _handlerTypes.remove(ext);
|
||||||
|
_handlerTypes.put(ext, handlerType);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println("Cannot register archive handler " + handlerType);
|
||||||
|
System.out.println("Neither " + handlerType + ", nor any of its superclasses implements ISystemArchiveHandler.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not handlerType has a constructor that takes only one
|
||||||
|
* parameter, a java.io.File.
|
||||||
|
*/
|
||||||
|
protected boolean handlerHasProperConstructor(Class handlerType)
|
||||||
|
{
|
||||||
|
Constructor[] constructors = handlerType.getConstructors();
|
||||||
|
boolean ok = false;
|
||||||
|
for (int i = 0; i < constructors.length; i++)
|
||||||
|
{
|
||||||
|
if (constructors[i].getParameterTypes().length == 1)
|
||||||
|
{
|
||||||
|
if (constructors[i].getParameterTypes()[0].equals(File.class))
|
||||||
|
{
|
||||||
|
ok = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not handlerType or one of its superclasses implements ISystemArchiveHandler.
|
||||||
|
*/
|
||||||
|
protected boolean handlerImplementsISystemArchiveHandler(Class handlerType)
|
||||||
|
{
|
||||||
|
Class[] interfaces = handlerType.getInterfaces();
|
||||||
|
boolean okay = false;
|
||||||
|
for (int i = 0; i < interfaces.length; i++)
|
||||||
|
{
|
||||||
|
if (interfaces[i].getName().equals(ISystemArchiveHandler.class.getName())) okay = true;
|
||||||
|
}
|
||||||
|
if (!okay)
|
||||||
|
{
|
||||||
|
Class superclass = handlerType.getSuperclass();
|
||||||
|
if (superclass.getName().equals(Object.class.getName())) return false;
|
||||||
|
return handlerImplementsISystemArchiveHandler(superclass);
|
||||||
|
}
|
||||||
|
else return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the handler associated with <code>file</code>, freeing the file
|
||||||
|
* to be used by other processes.
|
||||||
|
*/
|
||||||
|
public void disposeOfRegisteredHandlerFor(File file)
|
||||||
|
{
|
||||||
|
_handlers.remove(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests whether the absolute path given by <code>path</code>
|
||||||
|
* refers to a virtual object.
|
||||||
|
* @param path
|
||||||
|
* @return True if and only if the absolute path refers to a virtual object.
|
||||||
|
*/
|
||||||
|
public static boolean isVirtual(String path)
|
||||||
|
{
|
||||||
|
return path.indexOf(VIRTUAL_CANONICAL_SEPARATOR) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the virtual path given by <code>fullVirtualName</code>
|
||||||
|
* to the standard virtual form ('/' as separator, no leading or trailing '/'s)
|
||||||
|
* @param fullVirtualName the path to convert
|
||||||
|
* @return the new path in standard form
|
||||||
|
*/
|
||||||
|
public static String cleanUpVirtualPath(String fullVirtualName)
|
||||||
|
{
|
||||||
|
int j = fullVirtualName.indexOf(VIRTUAL_CANONICAL_SEPARATOR);
|
||||||
|
if (j == -1 && fullVirtualName.indexOf(":") != -1) return fullVirtualName;
|
||||||
|
String realPart = "";
|
||||||
|
String newPath = fullVirtualName;
|
||||||
|
if (j != -1)
|
||||||
|
{
|
||||||
|
realPart = fullVirtualName.substring(0, j) + VIRTUAL_SEPARATOR;
|
||||||
|
newPath = fullVirtualName.substring(j + VIRTUAL_SEPARATOR.length());
|
||||||
|
}
|
||||||
|
// use only forward slash separator
|
||||||
|
newPath = newPath.replace('\\', '/');
|
||||||
|
|
||||||
|
//get rid of any double slashes
|
||||||
|
int i = newPath.indexOf("//");
|
||||||
|
while (i != -1)
|
||||||
|
{
|
||||||
|
newPath = newPath.substring(0,i) + newPath.substring(i+1);
|
||||||
|
i = newPath.indexOf("//");
|
||||||
|
}
|
||||||
|
|
||||||
|
// get rid of any leading or trailing slashes
|
||||||
|
if (j != -1 && newPath.startsWith("/")) newPath = newPath.substring(1);
|
||||||
|
if (newPath.endsWith("/")) newPath = newPath.substring(0, newPath.length() - 1);
|
||||||
|
return realPart + newPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disposes of all registered handlers.
|
||||||
|
*/
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
_handlers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean createEmptyArchive(File newFile)
|
||||||
|
{
|
||||||
|
if (!isRegisteredArchive(newFile.getName()))
|
||||||
|
{
|
||||||
|
System.out.println("Could not create new archive.");
|
||||||
|
System.out.println(newFile + " is not a registered type of archive.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newFile.exists())
|
||||||
|
{
|
||||||
|
if (!newFile.isFile())
|
||||||
|
{
|
||||||
|
System.out.println("Could not create new archive.");
|
||||||
|
System.out.println(newFile + " is not a file.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!newFile.delete())
|
||||||
|
{
|
||||||
|
System.out.println("Could not create new archive.");
|
||||||
|
System.out.println(newFile + " could not be deleted.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!newFile.createNewFile())
|
||||||
|
{
|
||||||
|
System.out.println("Could not create new archive.");
|
||||||
|
System.out.println(newFile + " could not be created.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
System.out.println("Could not create new archive.");
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ISystemArchiveHandler handler = getRegisteredHandler(newFile);
|
||||||
|
return handler.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the extensions for archive types that have been registered
|
||||||
|
* with the ArchiveHandlerManager.
|
||||||
|
*/
|
||||||
|
public String[] getRegisteredExtensions()
|
||||||
|
{
|
||||||
|
Object[] exts = _handlerTypes.keySet().toArray();
|
||||||
|
String[] extensions = new String[exts.length];
|
||||||
|
for (int i = 0; i < exts.length; i++)
|
||||||
|
{
|
||||||
|
extensions[i] = (String) exts[i];
|
||||||
|
}
|
||||||
|
return extensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComment(File archive)
|
||||||
|
{
|
||||||
|
ISystemArchiveHandler handler = getRegisteredHandler(archive);
|
||||||
|
if (handler == null || !handler.exists()) return "";
|
||||||
|
return handler.getArchiveComment();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getExpandedSize(File archive)
|
||||||
|
{
|
||||||
|
ISystemArchiveHandler handler = getRegisteredHandler(archive);
|
||||||
|
if (handler == null || !handler.exists()) return 0;
|
||||||
|
VirtualChild[] allEntries = handler.getVirtualChildrenList();
|
||||||
|
int total = 0;
|
||||||
|
for (int i = 0; i < allEntries.length; i++)
|
||||||
|
{
|
||||||
|
total += allEntries[i].getSize();
|
||||||
|
}
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the classification for the entry in a archive with the given virtual path.
|
||||||
|
* @param file the archive file.
|
||||||
|
* @param virtualPath the virtual path.
|
||||||
|
* @return the classification for the virtual file.
|
||||||
|
*/
|
||||||
|
public String getClassification(File file, String virtualPath) {
|
||||||
|
|
||||||
|
// if archive file is null, or if it does not exist, or if the virtual path
|
||||||
|
// is null, then return null for the classification
|
||||||
|
if (file == null || !file.exists()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get archive handler
|
||||||
|
ISystemArchiveHandler handler = getRegisteredHandler(file);
|
||||||
|
|
||||||
|
if (handler == null || !handler.exists()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return handler.getClassification(virtualPath);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,371 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.archiveutils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import org.eclipse.rse.services.clientserver.ISystemFileTypes;
|
||||||
|
import org.eclipse.rse.services.clientserver.search.SystemSearchLineMatch;
|
||||||
|
import org.eclipse.rse.services.clientserver.search.SystemSearchStringMatcher;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author mjberger
|
||||||
|
* An interface that allows implementing classes to create their own
|
||||||
|
* Handlers for various types of Archive files, ie: zip, jar, tar, rpm
|
||||||
|
*/
|
||||||
|
public interface ISystemArchiveHandler
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns the archive that this handler represents into a new, empty archive.
|
||||||
|
* (The archive could not exist before, in which case this would be a true
|
||||||
|
* creation).
|
||||||
|
* @return Whether or not the blank archive was successfuly created.
|
||||||
|
*/
|
||||||
|
public boolean create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return an array containing all the entries in the archive file
|
||||||
|
* in a flat format, where the entries' filenames are prepended by
|
||||||
|
* the path to the entry within the virtual file system. If there
|
||||||
|
* are no entries in the file, returns an array of size 0.
|
||||||
|
*/
|
||||||
|
public VirtualChild[] getVirtualChildrenList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return an array containing all the entries in the archive file
|
||||||
|
* in a flat format, whose full paths begin with the String <code>parent</code>.
|
||||||
|
* Returns an array of length 0 if there are no such entries.
|
||||||
|
*/
|
||||||
|
public VirtualChild[] getVirtualChildrenList(String parent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return an array containing the virtual children of the virtual
|
||||||
|
* directory named <code>fullVirtualName</code>. If <code>fullVirtualName</code> is "",
|
||||||
|
* returns the top level in the virtual file system tree. If there are no
|
||||||
|
* values to return, returns null.
|
||||||
|
*/
|
||||||
|
public VirtualChild[] getVirtualChildren(String fullVirtualName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return an array containing the virtual children of the virtual
|
||||||
|
* directory named <code>fullVirtualName</code> that are themselves directories.
|
||||||
|
* If <code>fullVirtualName</code> is "",
|
||||||
|
* returns the top level of directories in the virtual file system tree.
|
||||||
|
* If there are no values to return, returns null.
|
||||||
|
*/
|
||||||
|
public VirtualChild[] getVirtualChildFolders(String fullVirtualName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the virtual File or Folder referred to by <code>fullVirtualName</code>.
|
||||||
|
* This method never returns null. In cases where the VirtualChild does not
|
||||||
|
* physically exist in the archive, this method returns a new VirtualChild object
|
||||||
|
* whose exists() method returns false.
|
||||||
|
*/
|
||||||
|
public VirtualChild getVirtualFile(String fullVirtualName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether or not the virtual file or folder named <code>fullVirtualName</code>
|
||||||
|
* exists in the archive (physically).
|
||||||
|
*/
|
||||||
|
public boolean exists(String fullVirtualName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether or not the handler exists. Usually false if the archive
|
||||||
|
* is corrupted or unreadable.
|
||||||
|
*/
|
||||||
|
public boolean exists();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the archive that this handler deals with
|
||||||
|
*/
|
||||||
|
public File getArchive();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the current timestamp (last modified) for the entry in the archive named
|
||||||
|
* <code>fullVirtualName</code>
|
||||||
|
*/
|
||||||
|
public long getTimeStampFor(String fullVirtualName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the current size (uncompressed) for the entry in the archive named
|
||||||
|
* <code>fullVirtualName</code>
|
||||||
|
*/
|
||||||
|
public long getSizeFor(String fullVirtualName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the virtual file named <code>fullVirtualName</code> from the archive,
|
||||||
|
* placing the results in <code>destination</code>.
|
||||||
|
* @param fullVirtualName The full path and name of the virtual file in the archive.
|
||||||
|
* @param destination The destination file for the extracted virtual file.
|
||||||
|
* @return true iff the extraction is successful
|
||||||
|
*/
|
||||||
|
public boolean extractVirtualFile(String fullVirtualName, File destination);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the virtual file named <code>fullVirtualName</code> from the archive,
|
||||||
|
* placing the results in <code>destination</code>. Extracts to the native encoding, but assumes
|
||||||
|
* that the source was archived using <code>sourceEncoding</code> if <code>isText</code> is true.
|
||||||
|
* @param fullVirtualName The full path and name of the virtual file in the archive.
|
||||||
|
* @param destination The destination file for the extracted virtual file.
|
||||||
|
* @param sourceEncoding The encoding of the file in the archive.
|
||||||
|
* @param isText Whether or not the virtual file is a text file.
|
||||||
|
* @return true iff the extraction is successful
|
||||||
|
*/
|
||||||
|
public boolean extractVirtualFile(String fullVirtualName, File destination, String sourceEncoding, boolean isText);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the directory <code>dir</code> (and its children) from
|
||||||
|
* the archive and places the results in the directory <code>destinationParent</code>.
|
||||||
|
* @param dir The full name of the virtual directory to extract
|
||||||
|
* @param destinationParent A handle to the directory in which the extracted
|
||||||
|
* directory will be placed as a subdirectory.
|
||||||
|
* @return true iff the extraction is successful
|
||||||
|
*/
|
||||||
|
public boolean extractVirtualDirectory(String dir, File destinationParent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the directory <code>dir</code> (and its children) from
|
||||||
|
* the archive and places the results in the directory <code>destinationParent</code>.
|
||||||
|
* Extracts to the native encoding (if <code>isText</code>), but assumes
|
||||||
|
* that the source was archived using <code>sourceEncoding</code>.
|
||||||
|
* @param dir The full name of the virtual directory to extract
|
||||||
|
* @param destinationParent A handle to the directory in which the extracted
|
||||||
|
* directory will be placed as a subdirectory.
|
||||||
|
* @param sourceEncoding The encoding of the files in the archive.
|
||||||
|
* @param isText Whether or not the files in the directory are text files
|
||||||
|
* @return true iff the extraction is successful
|
||||||
|
*/
|
||||||
|
public boolean extractVirtualDirectory(String dir, File destinationParent, String sourceEncoding, boolean isText);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the directory <code>dir</code> (and its children) from
|
||||||
|
* the archive and places the results in the directory <code>destinationParent</code>.
|
||||||
|
* The results will be named destination.getName() rather than <code>dir</code>'s name.
|
||||||
|
* @param dir The full name of the virtual directory to extract
|
||||||
|
* @param destinationParent A handle to the directory in which the extracted
|
||||||
|
* directory will be placed as a subdirectory.
|
||||||
|
* @param destination A handle to the directory that will be created. Whatever
|
||||||
|
* contents are in that directory will be replaced with what is extracted from
|
||||||
|
* the archive.
|
||||||
|
* @return true iff the extraction is successful
|
||||||
|
*/
|
||||||
|
public boolean extractVirtualDirectory(String dir, File destinationParent, File destination);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the directory <code>dir</code> (and its children) from
|
||||||
|
* the archive and places the results in the directory <code>destinationParent</code>.
|
||||||
|
* The results will be named destination.getName() rather than <code>dir</code>'s name.
|
||||||
|
* Extracts to the native encoding (if <code>isText</code>), but assumes
|
||||||
|
* that the source was archived using <code>sourceEncoding</code>.
|
||||||
|
* @param dir The full name of the virtual directory to extract
|
||||||
|
* @param destinationParent A handle to the directory in which the extracted
|
||||||
|
* directory will be placed as a subdirectory.
|
||||||
|
* @param destination A handle to the directory that will be created. Whatever
|
||||||
|
* contents are in that directory will be replaced with what is extracted from
|
||||||
|
* the archive.
|
||||||
|
* @param sourceEncoding The encoding of the files in the archive.
|
||||||
|
* @param isText Whether or not the files to be extracted in the directory are all text files
|
||||||
|
* @return true iff the extraction is successful
|
||||||
|
*/
|
||||||
|
public boolean extractVirtualDirectory(String dir, File destinationParent, File destination, String sourceEncoding, boolean isText);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compresses the file <code>file</code> and adds it to the archive,
|
||||||
|
* placing it in the virtual directory <code>virtualPath</code>. Pass the
|
||||||
|
* name as the parameter <code>name</code>. If the virtual path does not exist
|
||||||
|
* in the archive, create it. If <code>file</code> is a directory, copy it and
|
||||||
|
* its contents into the archive, maintaining the tree structure.
|
||||||
|
* @return true if and only if the add was successful
|
||||||
|
*/
|
||||||
|
public boolean add(File file, String virtualPath, String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compresses the file <code>file</code> and adds it to the archive,
|
||||||
|
* saving it in the encoding specified by <code>encoding</code> if the isText is true.
|
||||||
|
* placing it in the virtual directory <code>virtualPath</code>. Pass the
|
||||||
|
* name as the parameter <code>name</code>. If the virtual path does not exist
|
||||||
|
* in the archive, create it. If <code>file</code> is a directory, copy it and
|
||||||
|
* its contents into the archive, maintaining the tree structure.
|
||||||
|
* @return true if and only if the add was successful
|
||||||
|
*/
|
||||||
|
public boolean add(File file, String virtualPath, String name, String sourceEncoding, String targetEncoding, boolean isText);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compresses the bytes in the InputStream <code>stream</code> and adds them as an entry to the archive,
|
||||||
|
* saving them in the encoding specified by <code>encoding</code> if <code>isText</code> is true, and
|
||||||
|
* placing it in the virtual directory <code>virtualPath</code>. Pass the
|
||||||
|
* name as the parameter <code>name</code>. If the virtual path does not exist
|
||||||
|
* in the archive, create it.
|
||||||
|
* @return true if and only if the add was successful
|
||||||
|
*/
|
||||||
|
public boolean add(InputStream stream, String virtualPath, String name, String sourceEncoding, String targetEncoding, boolean isText);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compresses the file <code>file</code> and adds it to the archive,
|
||||||
|
* saving it in the encoding specified by <code>encoding</code> if the isText is true.
|
||||||
|
* placing it in the virtual directory <code>virtualPath</code>. Pass the
|
||||||
|
* name as the parameter <code>name</code>. If the virtual path does not exist
|
||||||
|
* in the archive, create it. If <code>file</code> is a directory, copy it and
|
||||||
|
* its contents into the archive, maintaining the tree structure.
|
||||||
|
* @return true if and only if the add was successful
|
||||||
|
*/
|
||||||
|
public boolean add(File file, String virtualPath, String name, String sourceEncoding, String targetEncoding, ISystemFileTypes typeRegistery);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A generalization of the add method.
|
||||||
|
* Compresses the array of files <code>files</code> and adds each of them to the archive, placing them
|
||||||
|
* in the virtual directory <code>virtualPath</code>. Pass the names of the files
|
||||||
|
* as the parameter <code>names</code>, where <code>files[i]</code> has the name <code>names[i]</code>.
|
||||||
|
* If the virtual path does not exist in the archive, create it.
|
||||||
|
* @return true if and only if the add was successful
|
||||||
|
*/
|
||||||
|
public boolean add(File[] files, String virtualPath, String[] names);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A generalization of the add method.
|
||||||
|
* Compresses the array of files <code>files</code> and adds each of them to the archive, placing them
|
||||||
|
* in the virtual directory <code>virtualPath</code>. Save the i'th file in the i'th encoding (if isText[i] is true)
|
||||||
|
* specified by <code>encodings</code>. Pass the names of the files
|
||||||
|
* as the parameter <code>names</code>, where <code>files[i]</code> has the name <code>names[i]</code>.
|
||||||
|
* If the virtual path does not exist in the archive, create it.
|
||||||
|
* @return true if and only if the add was successful
|
||||||
|
*/
|
||||||
|
public boolean add(File[] files, String virtualPath, String[] names, String[] sourceEncodings, String[] targetEncodings, boolean[] isText);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compress the file <code>file</code> and replace the virtual file
|
||||||
|
* referred to by <code>fullVirtualName</code> with the compressed file.
|
||||||
|
* Pass the name of the file as the parameter <code>name</code>.
|
||||||
|
* @return true if and only if the replace was successful
|
||||||
|
*/
|
||||||
|
public boolean replace(String fullVirtualName, File file, String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compress the InputStream <code>stream</code> and replace the virtual file
|
||||||
|
* referred to by <code>fullVirtualName</code> with the compressed stream.
|
||||||
|
* Pass the name of the new entry as the parameter <code>name</code>, the
|
||||||
|
* encoding of the entry as <code>encoding</code> and whether or not the entry
|
||||||
|
* <code>isText</code> or not.
|
||||||
|
* @return true if and only if the replace was successful
|
||||||
|
*/
|
||||||
|
public boolean replace(String fullVirtualName, InputStream stream, String name, String sourceEncoding, String targetEncoding, boolean isText);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes the entry <code>fullVirtualName</code> from the archive, and returns
|
||||||
|
* whether or not the deletion was successful.
|
||||||
|
*/
|
||||||
|
public boolean delete(String fullVirtualName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renames the entry <code>fullVirtualName</code> to the new name
|
||||||
|
* <code>newName</code> while still leaving the entry in the same virtual
|
||||||
|
* directory. Returns true if and only if the rename was successfull.
|
||||||
|
*/
|
||||||
|
public boolean rename(String fullVirtualName, String newName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves the entry <code>fullVirtualName</code> to the location
|
||||||
|
* specified by <code>destinationVirtualPath</code>, while leaving the entry with
|
||||||
|
* the same name as before. Returns true if and only if the move was successfull.
|
||||||
|
*/
|
||||||
|
public boolean move(String fullVirtualName, String destinationVirtualPath);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the full name and path of the entry <code>fullVirtualName</code>
|
||||||
|
* with the new full name and path <code>newFullVirtualName</code>.
|
||||||
|
* Returns true if and only if the operation was successfull.
|
||||||
|
*/
|
||||||
|
public boolean fullRename(String fullVirtualName, String newFullVirtualName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts and returns the specified list of virtual files from the archive.
|
||||||
|
* @param fullNames The list of files to return
|
||||||
|
* @return An array of handles to the extracted files. If fullNames has length 0
|
||||||
|
* then this method returns an array of length 0.
|
||||||
|
*/
|
||||||
|
public File[] getFiles(String[] fullNames);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new, empty folder in the archive. If parent folders do not exist either, creates them.
|
||||||
|
* @param fullVirtualName The full name and path of the new folder within the virtual file system.
|
||||||
|
* @return Whether or not the creation was successful.
|
||||||
|
*/
|
||||||
|
public boolean createFolder(String fullVirtualName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new, empty file in the archive. If parent folders do not exist either, creates them.
|
||||||
|
* @param fullVirtualName The full name and path of the new file within the virtual file system.
|
||||||
|
* @return Whether or not the creation was successful.
|
||||||
|
*/
|
||||||
|
public boolean createFile(String fullVirtualName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the archive-type specific standard name for the VirtualChild
|
||||||
|
* <code>vc</code>. For example, for Zips, if vc is a directory, then
|
||||||
|
* the standard name must end with a "/".
|
||||||
|
*/
|
||||||
|
public String getStandardName(VirtualChild vc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches for text within a virtual file in this archive.
|
||||||
|
* A good implementation will not actually extract the file to disk.
|
||||||
|
* @param fullVirtualName the virtual file to search.
|
||||||
|
* @param matcher the pattern matcher to use.
|
||||||
|
* @return an array of match objects corresponding to lines where matches were found.
|
||||||
|
* Returns an empty array if there are no results.
|
||||||
|
*/
|
||||||
|
public SystemSearchLineMatch[] search(String fullVirtualName, SystemSearchStringMatcher matcher);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the user-defined comment for a specific entry in the archive.
|
||||||
|
* @param fullVirtualName The entry who's comment is desired
|
||||||
|
* @return the comment as a String or "" if there is none
|
||||||
|
*/
|
||||||
|
public String getCommentFor(String fullVirtualName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of space taken up by a specific entry in the archive
|
||||||
|
* when it is in compressed form. Compare with getSizeFor(String) which gets
|
||||||
|
* the size of the entry after it is decompressed.
|
||||||
|
* @param fullVirtualName The entry who's compressed size is desired
|
||||||
|
* @return the compressed size of the specified entry, or 0 if the entry is not
|
||||||
|
* found. If the archive is not a compression type (ie. tar), return the same as getSizeFor(String).
|
||||||
|
*/
|
||||||
|
public long getCompressedSizeFor(String fullVirtualName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the method used to compress a specific entry in the archive.
|
||||||
|
* @param fullVirtualName The entry who's compression method is desired
|
||||||
|
* @return The compression method of the specified entry, or "" if none.
|
||||||
|
*/
|
||||||
|
public String getCompressionMethodFor(String fullVirtualName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The comment associated with this archive, or "" if there is none.
|
||||||
|
*/
|
||||||
|
public String getArchiveComment();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the classification for the entry with the given path.
|
||||||
|
* @param fullVirtualName the virtual name.
|
||||||
|
* @return the classification.
|
||||||
|
*/
|
||||||
|
public String getClassification(String fullVirtualName);
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.archiveutils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface for general archive handler constants.
|
||||||
|
*/
|
||||||
|
public interface ISystemArchiveHandlerConstants {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zip archive extension, "zip".
|
||||||
|
*/
|
||||||
|
public static final String ZIP_ARCHIVE_EXTENSION = "zip";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Jar archive extension, "jar".
|
||||||
|
*/
|
||||||
|
public static final String JAR_ARCHIVE_EXTENSION = "jar";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tar archive extension, "tar".
|
||||||
|
*/
|
||||||
|
public static final String TAR_ARCHIVE_EXTENSION = "tar";
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.archiveutils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
public class SystemArchiveUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to delete a directory. Deletes the children of the directory before
|
||||||
|
* deleting the directory itself. This method is required because a directory can not be deleted if it
|
||||||
|
* is not empty.
|
||||||
|
* @return <code>true</code> if the deletion was successful, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public static boolean delete(File file) {
|
||||||
|
HashSet set = new HashSet();
|
||||||
|
return recursiveDelete(file, set);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively delete a file.
|
||||||
|
* @param file the file or directory.
|
||||||
|
* @param found a set of files that have been considered.
|
||||||
|
* @return <code>true</code> if deletion successful, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
protected static boolean recursiveDelete(File file, HashSet found) {
|
||||||
|
boolean success = true;
|
||||||
|
found.add(file);
|
||||||
|
File[] children = file.listFiles();
|
||||||
|
|
||||||
|
if (children != null) {
|
||||||
|
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
|
||||||
|
if (!found.contains(children[i])) {
|
||||||
|
|
||||||
|
success = recursiveDelete(children[i], found);
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file.exists()) {
|
||||||
|
success = file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.archiveutils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author mjberger
|
||||||
|
* Implements an ISystemArchiveHandler for Java JAR files.
|
||||||
|
*/
|
||||||
|
public class SystemJarHandler extends SystemZipHandler
|
||||||
|
{
|
||||||
|
|
||||||
|
public SystemJarHandler(File file) throws IOException
|
||||||
|
{
|
||||||
|
super(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,148 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.archiveutils;
|
||||||
|
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author mjberger
|
||||||
|
*
|
||||||
|
* This is a wrapper class for a ZipEntry object that contains some
|
||||||
|
* extra helper methods for processing the ZipEntry that are not included
|
||||||
|
* in java.util.zip.ZipEntry.
|
||||||
|
*/
|
||||||
|
public class SystemUniversalZipEntry
|
||||||
|
{
|
||||||
|
|
||||||
|
protected ZipEntry _entry;
|
||||||
|
protected String _entryFullName;
|
||||||
|
protected String _entryFullPath;
|
||||||
|
protected String _entryName;
|
||||||
|
protected String _extension;
|
||||||
|
protected boolean _nested;
|
||||||
|
|
||||||
|
public SystemUniversalZipEntry(ZipEntry entry)
|
||||||
|
{
|
||||||
|
_entry = entry;
|
||||||
|
doNameProcessing();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ZipEntry associated with this SystemUniversalZipEntry
|
||||||
|
*/
|
||||||
|
public ZipEntry getEntry()
|
||||||
|
{
|
||||||
|
return _entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the ZipEntry associated with this SystemUniversalZipEntry
|
||||||
|
*/
|
||||||
|
public void setEntry(ZipEntry newEntry)
|
||||||
|
{
|
||||||
|
_entry = newEntry;
|
||||||
|
doNameProcessing();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doNameProcessing()
|
||||||
|
{
|
||||||
|
if (_entry.isDirectory())
|
||||||
|
{
|
||||||
|
_entryFullName = _entry.getName().substring(0, _entry.getName().length()-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_entryFullName = _entry.getName();
|
||||||
|
}
|
||||||
|
int endOfPathPosition = _entryFullName.lastIndexOf("/");
|
||||||
|
if (endOfPathPosition != -1)
|
||||||
|
{
|
||||||
|
_entryFullPath = _entryFullName.substring(0,endOfPathPosition);
|
||||||
|
_entryName = _entryFullName.substring(endOfPathPosition+1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_entryFullPath = "";
|
||||||
|
_entryName = _entryFullName;
|
||||||
|
}
|
||||||
|
int i = _entryFullName.lastIndexOf(".");
|
||||||
|
if (i == -1)
|
||||||
|
{
|
||||||
|
_extension = "";
|
||||||
|
} else _extension = _entryFullName.substring(i + 1);
|
||||||
|
if (_entryFullName.indexOf("/") != -1) _nested = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the full path to the entry within the ZipFile file structure.
|
||||||
|
* Note: this is NOT the full path to the ZipFile in the regular file
|
||||||
|
* system.
|
||||||
|
* @return a String containing the full path leading to the ZipEntry within
|
||||||
|
* the ZipFile file structure. Does not include the file name.
|
||||||
|
*/
|
||||||
|
public String getFullPath()
|
||||||
|
{
|
||||||
|
return _entryFullPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the full name associated with this entry (including path to the
|
||||||
|
* entry) within the ZipFile file structure. Note: this is NOT the full path to the
|
||||||
|
* ZipFile in the regular file system.
|
||||||
|
* @return a String containing the full name including path of the ZipEntry
|
||||||
|
* within the ZipFile file structure. Includes the file name.
|
||||||
|
*/
|
||||||
|
public String getFullName()
|
||||||
|
{
|
||||||
|
return _entryFullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns only the filename associated with this entry in the ZipFile
|
||||||
|
* file structure.
|
||||||
|
* @return a String containing only the file name of this ZipEntry.
|
||||||
|
*/
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return _entryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the extension of this entry, if the entry is a file,
|
||||||
|
* null string otherwise.
|
||||||
|
*/
|
||||||
|
public String getExtension()
|
||||||
|
{
|
||||||
|
return _extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether or not this entry is nested within folders within the zip file.
|
||||||
|
*/
|
||||||
|
public boolean isNested()
|
||||||
|
{
|
||||||
|
return _nested;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether or not this zipentry is a directory.
|
||||||
|
*/
|
||||||
|
public boolean isDirectory()
|
||||||
|
{
|
||||||
|
return _entry.isDirectory();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,321 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.archiveutils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.eclipse.rse.services.clientserver.SystemEncodingUtil;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author mjberger
|
||||||
|
* A simple structure for passing information about virtual files and folders.
|
||||||
|
*/
|
||||||
|
public final class VirtualChild {
|
||||||
|
|
||||||
|
public String fullName;
|
||||||
|
public String name;
|
||||||
|
public String path;
|
||||||
|
public boolean isDirectory;
|
||||||
|
protected ISystemArchiveHandler _handler;
|
||||||
|
protected File _extractedFile;
|
||||||
|
protected File _containingArchive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new VirtualChild given a reference to its parent archive's
|
||||||
|
* handler, but does not populate any fields in the child. Clients must
|
||||||
|
* populate the fullName, name, path, and isDirectory fields.
|
||||||
|
*/
|
||||||
|
public VirtualChild(ISystemArchiveHandler handler)
|
||||||
|
{
|
||||||
|
fullName = "";
|
||||||
|
name = "";
|
||||||
|
path = "";
|
||||||
|
isDirectory = false;
|
||||||
|
_handler = handler;
|
||||||
|
_extractedFile = null;
|
||||||
|
_containingArchive = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new VirtualChild given a reference to its parent archive's
|
||||||
|
* handler (<code>handler</code>), and immediately populates the name and path info
|
||||||
|
* for the VirtualChild given its <code>fullVirtualName</code>. Clients
|
||||||
|
* must still populate the isDirectory field.
|
||||||
|
*/
|
||||||
|
public VirtualChild(ISystemArchiveHandler handler, String fullVirtualName)
|
||||||
|
{
|
||||||
|
this(handler);
|
||||||
|
renameTo(fullVirtualName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new VirtualChild given the name of its parent archive,
|
||||||
|
* and immediately populates the name and path info
|
||||||
|
* for the VirtualChild given its <code>fullVirtualName</code>. Clients
|
||||||
|
* must still populate the isDirectory field.
|
||||||
|
* NOTE: This constructor is intended only to be used for creating NON-EXISTENT
|
||||||
|
* virtual children.
|
||||||
|
*/
|
||||||
|
public VirtualChild(String fullVirtualName, File containingArchive)
|
||||||
|
{
|
||||||
|
this(null);
|
||||||
|
renameTo(fullVirtualName);
|
||||||
|
_containingArchive = containingArchive;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return This VirtualChild's parent archive's Handler.
|
||||||
|
*/
|
||||||
|
public ISystemArchiveHandler getHandler()
|
||||||
|
{
|
||||||
|
return _handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return This VirtualChild's time stamp (retrieves the latest one
|
||||||
|
* from the archive).
|
||||||
|
*/
|
||||||
|
public long getTimeStamp()
|
||||||
|
{
|
||||||
|
if (_handler == null) return 0;
|
||||||
|
return _handler.getTimeStampFor(fullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return This VirtualChild's uncompressed size (retrieves the latest one
|
||||||
|
* from the archive).
|
||||||
|
*/
|
||||||
|
public long getSize()
|
||||||
|
{
|
||||||
|
if (_handler == null) return 0;
|
||||||
|
return _handler.getSizeFor(fullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The comment associated with this VirtualChild.
|
||||||
|
*/
|
||||||
|
public String getComment()
|
||||||
|
{
|
||||||
|
if (_handler == null) return "";
|
||||||
|
return _handler.getCommentFor(fullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The amount of space this VirtualChild takes up in the archive
|
||||||
|
* in compressed form.
|
||||||
|
*/
|
||||||
|
public long getCompressedSize()
|
||||||
|
{
|
||||||
|
if (_handler == null) return 0;
|
||||||
|
return _handler.getCompressedSizeFor(fullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The method used to compress this VirtualChild.
|
||||||
|
*/
|
||||||
|
public String getCompressionMethod()
|
||||||
|
{
|
||||||
|
if (_handler == null) return "";
|
||||||
|
return _handler.getCompressionMethodFor(fullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The actual minus compressed size of this VirtualChild, divided
|
||||||
|
* by the actual size.
|
||||||
|
*/
|
||||||
|
public double getCompressionRatio()
|
||||||
|
{
|
||||||
|
if (getSize() == 0)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else return ((double)getSize() - (double)getCompressedSize()) / getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The extracted file or directory represented by this VirtualChild from the archive.
|
||||||
|
* Note that the extracted file is cached after it is extracted once, but if the
|
||||||
|
* timestamps on the cached and archived files do not match, the cached file is erased,
|
||||||
|
* and reextracted from the archive.
|
||||||
|
*/
|
||||||
|
public File getExtractedFile()
|
||||||
|
{
|
||||||
|
return getExtractedFile(SystemEncodingUtil.ENCODING_UTF_8, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The extracted file or directory represented by this VirtualChild from the archive.
|
||||||
|
* Assumes that the file has been encoded in the encoding specified.
|
||||||
|
* Note that the extracted file is cached after it is extracted once, but if the
|
||||||
|
* timestamps on the cached and archived files do not match, the cached file is erased,
|
||||||
|
* and reextracted from the archive.
|
||||||
|
*/
|
||||||
|
public File getExtractedFile(String sourceEncoding, boolean isText)
|
||||||
|
{
|
||||||
|
if (_extractedFile == null || _extractedFile.lastModified() != getTimeStamp())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int i = name.lastIndexOf(".");
|
||||||
|
String ext = "";
|
||||||
|
if (i != -1) ext = name.substring(i+1);
|
||||||
|
if (i < 3)
|
||||||
|
{
|
||||||
|
_extractedFile = File.createTempFile(name + "123", "virtual." + ext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_extractedFile = File.createTempFile(name, "virtual." + ext);
|
||||||
|
}
|
||||||
|
_extractedFile.deleteOnExit();
|
||||||
|
if (_handler == null) return _extractedFile;
|
||||||
|
if (isDirectory)
|
||||||
|
{
|
||||||
|
if (!_extractedFile.isDirectory())
|
||||||
|
{
|
||||||
|
if (!(_extractedFile.delete() && _extractedFile.mkdirs()))
|
||||||
|
{
|
||||||
|
System.out.println("VirtualChild.getExtractedFile(): Could not create temp dir.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_handler.extractVirtualDirectory(fullName, _extractedFile, sourceEncoding, isText);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_handler.extractVirtualFile(fullName, _extractedFile, sourceEncoding, isText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
System.out.println("VirtualChild.getExtractedFile(): ");
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDirectory)
|
||||||
|
{
|
||||||
|
return new File(_extractedFile, name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _extractedFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the extracted file or directory represented by this VirtualChild from the archive,
|
||||||
|
* and replaces the object referred to by <code>destination</code> with that extracted file or directory.
|
||||||
|
* Note that the extracted file is cached after it is extracted once, but if the
|
||||||
|
* timestamps on the cached and archived files do not match, the cached file is erased,
|
||||||
|
* and reextracted from the archive.
|
||||||
|
* <code>destination</code> is always overwritten with either what is cached, or
|
||||||
|
* what is in the archive.
|
||||||
|
* @return true if and only if the extraction succeeded.
|
||||||
|
*/
|
||||||
|
public boolean getExtractedFile(File destination)
|
||||||
|
{
|
||||||
|
return getExtractedFile(destination, SystemEncodingUtil.ENCODING_UTF_8, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the extracted file or directory represented by this VirtualChild from the archive,
|
||||||
|
* and replaces the object referred to by <code>destination</code> with that extracted file or directory.
|
||||||
|
* Note that the extracted file is cached after it is extracted once, but if the
|
||||||
|
* timestamps on the cached and archived files do not match, the cached file is erased,
|
||||||
|
* and reextracted from the archive.
|
||||||
|
* <code>destination</code> is always overwritten with either what is cached, or
|
||||||
|
* what is in the archive.
|
||||||
|
* @return true if and only if the extraction succeeded.
|
||||||
|
*/
|
||||||
|
public boolean getExtractedFile(File destination, String sourceEncoding, boolean isText)
|
||||||
|
{
|
||||||
|
boolean success = true;
|
||||||
|
if (_handler == null) return false;
|
||||||
|
if (_extractedFile == null ||
|
||||||
|
_extractedFile.lastModified() != getTimeStamp() ||
|
||||||
|
!destination.getAbsolutePath().equals(_extractedFile.getAbsolutePath())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (isDirectory)
|
||||||
|
{
|
||||||
|
success = _handler.extractVirtualDirectory(fullName, destination.getParentFile(), destination, sourceEncoding, isText);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
success = _handler.extractVirtualFile(fullName, destination, sourceEncoding, isText);
|
||||||
|
}
|
||||||
|
_extractedFile = destination;
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Whether or not this VirtualChild exists in the archive.
|
||||||
|
*/
|
||||||
|
public boolean exists()
|
||||||
|
{
|
||||||
|
if (_handler == null) return false;
|
||||||
|
return _handler.exists(fullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renames this virtual child to newName. WARNING!!
|
||||||
|
* This method does not change the underlying zip file,
|
||||||
|
* you must rename the entry in the zip file for subsequent
|
||||||
|
* calls to any of the getters to work.
|
||||||
|
*/
|
||||||
|
public void renameTo(String newName)
|
||||||
|
{
|
||||||
|
newName = ArchiveHandlerManager.cleanUpVirtualPath(newName);
|
||||||
|
fullName = newName;
|
||||||
|
int i = newName.lastIndexOf("/");
|
||||||
|
if (i == -1)
|
||||||
|
{
|
||||||
|
name = newName;
|
||||||
|
path = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name = newName.substring(i+1);
|
||||||
|
path = newName.substring(0, i);
|
||||||
|
}
|
||||||
|
// force reextraction of temp file
|
||||||
|
_extractedFile = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The "standard" name for this VirtualChild, based on
|
||||||
|
* the handler type.
|
||||||
|
*/
|
||||||
|
public String getArchiveStandardName()
|
||||||
|
{
|
||||||
|
if (_handler == null) return fullName;
|
||||||
|
return _handler.getStandardName(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getContainingArchive()
|
||||||
|
{
|
||||||
|
if (_handler == null) return _containingArchive;
|
||||||
|
return _handler.getArchive();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents 4 byte numeric information.
|
||||||
|
*/
|
||||||
|
public abstract class Abstract4ByteNumericInfo extends AbstractCPInfo {
|
||||||
|
|
||||||
|
protected long bytes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param bytes the bytes.
|
||||||
|
*/
|
||||||
|
public Abstract4ByteNumericInfo(short tag, long bytes) {
|
||||||
|
super(tag);
|
||||||
|
setBytes(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bytes.
|
||||||
|
* @return the bytes.
|
||||||
|
*/
|
||||||
|
public long getBytes() {
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the bytes.
|
||||||
|
* @param bytes the bytes.
|
||||||
|
*/
|
||||||
|
private void setBytes(long bytes) {
|
||||||
|
this.bytes = bytes;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents 8 byte numeric information.
|
||||||
|
*/
|
||||||
|
public abstract class Abstract8ByteNumericInfo extends AbstractCPInfo {
|
||||||
|
|
||||||
|
protected long highBytes;
|
||||||
|
protected long lowBytes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param highBytes high bytes.
|
||||||
|
* @param lowBytes low bytes.
|
||||||
|
*/
|
||||||
|
public Abstract8ByteNumericInfo(short tag, long highBytes, long lowBytes) {
|
||||||
|
super(tag);
|
||||||
|
setHighBytes(highBytes);
|
||||||
|
setLowBytes(lowBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the high bytes.
|
||||||
|
* @return the high bytes.
|
||||||
|
*/
|
||||||
|
public long getHighBytes() {
|
||||||
|
return highBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the high bytes.
|
||||||
|
* @param highBytes the high bytes.
|
||||||
|
*/
|
||||||
|
private void setHighBytes(long highBytes) {
|
||||||
|
this.highBytes = highBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the low bytes.
|
||||||
|
* @return the low bytes.
|
||||||
|
*/
|
||||||
|
public long getLowBytes() {
|
||||||
|
return lowBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the low bytes.
|
||||||
|
* @param lowBytes the low bytes.
|
||||||
|
*/
|
||||||
|
private void setLowBytes(long lowBytes) {
|
||||||
|
this.lowBytes = lowBytes;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents a attribute.
|
||||||
|
*/
|
||||||
|
public class AbstractAttributeInfo {
|
||||||
|
|
||||||
|
protected int attributeNameIndex;
|
||||||
|
protected long attributeLength;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param attributeNameIndex the attribute name index.
|
||||||
|
* @param attributeLength the attribute length.
|
||||||
|
*/
|
||||||
|
public AbstractAttributeInfo(int attributeNameIndex, long attributeLength) {
|
||||||
|
super();
|
||||||
|
setAttributeNameIndex(attributeNameIndex);
|
||||||
|
setAttributeLength(attributeLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the attribute length.
|
||||||
|
* @return the attribute length.
|
||||||
|
*/
|
||||||
|
public long getAttributeLength() {
|
||||||
|
return attributeLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the attribute length.
|
||||||
|
* @param attributeLength the attribute length.
|
||||||
|
*/
|
||||||
|
public void setAttributeLength(long attributeLength) {
|
||||||
|
this.attributeLength = attributeLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the attribute name index.
|
||||||
|
* @return the attribute name index.
|
||||||
|
*/
|
||||||
|
public int getAttributeNameIndex() {
|
||||||
|
return attributeNameIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the attribute name index.
|
||||||
|
* @param attributeNameIndex the attribute name index.
|
||||||
|
*/
|
||||||
|
public void setAttributeNameIndex(int attributeNameIndex) {
|
||||||
|
this.attributeNameIndex = attributeNameIndex;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents various string constants, class and interface names, field names, and other constants
|
||||||
|
* that are referred to within the BasicClassFileParser structure.
|
||||||
|
*
|
||||||
|
* @see BasicClassFileParser
|
||||||
|
*/
|
||||||
|
public abstract class AbstractCPInfo {
|
||||||
|
|
||||||
|
protected short tag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
*/
|
||||||
|
public AbstractCPInfo(short tag) {
|
||||||
|
super();
|
||||||
|
setTag(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the tag.
|
||||||
|
* @return the tag.
|
||||||
|
*/
|
||||||
|
public int getTag() {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the tag.
|
||||||
|
* @param tag the tag.
|
||||||
|
*/
|
||||||
|
private void setTag(short tag) {
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,125 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents information about a field or method.
|
||||||
|
*/
|
||||||
|
public abstract class AbstractCommonInfo {
|
||||||
|
|
||||||
|
protected int accessFlags;
|
||||||
|
protected int nameIndex;
|
||||||
|
protected int descriptorIndex;
|
||||||
|
protected int attributesCount;
|
||||||
|
protected AbstractAttributeInfo[] attributes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param accessFlags the access flags.
|
||||||
|
* @param nameIndex the name index.
|
||||||
|
* @param descriptorIndex the descriptor index.
|
||||||
|
* @param attributesCount the number of attributes.
|
||||||
|
* @param attributes the attributes.
|
||||||
|
*/
|
||||||
|
public AbstractCommonInfo(int accessFlags, int nameIndex, int descriptorIndex, int attributesCount, AbstractAttributeInfo[] attributes) {
|
||||||
|
super();
|
||||||
|
setAccessFlags(accessFlags);
|
||||||
|
setNameIndex(nameIndex);
|
||||||
|
setDescriptorIndex(descriptorIndex);
|
||||||
|
setAttributesCount(attributesCount);
|
||||||
|
setAttributes(attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the access flags.
|
||||||
|
* @return the access flags.
|
||||||
|
*/
|
||||||
|
public int getAccessFlags() {
|
||||||
|
return accessFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the access flags.
|
||||||
|
* @param accessFlags the access flags.
|
||||||
|
*/
|
||||||
|
public void setAccessFlags(int accessFlags) {
|
||||||
|
this.accessFlags = accessFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the attributes.
|
||||||
|
* @return the array of attributes.
|
||||||
|
*/
|
||||||
|
public AbstractAttributeInfo[] getAttributes() {
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Sets the attributes.
|
||||||
|
* @param attributes the attributes.
|
||||||
|
*/
|
||||||
|
public void setAttributes(AbstractAttributeInfo[] attributes) {
|
||||||
|
this.attributes = attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of attributes.
|
||||||
|
* @return the number of attributes.
|
||||||
|
*/
|
||||||
|
public int getAttributesCount() {
|
||||||
|
return attributesCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the number of attributes.
|
||||||
|
* @param attributesCount the number of attributes.
|
||||||
|
*/
|
||||||
|
public void setAttributesCount(int attributesCount) {
|
||||||
|
this.attributesCount = attributesCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the descriptor index.
|
||||||
|
* @return the descriptor index.
|
||||||
|
*/
|
||||||
|
public int getDescriptorIndex() {
|
||||||
|
return descriptorIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the descriptor index.
|
||||||
|
* @param descriptorIndex the descriptor index.
|
||||||
|
*/
|
||||||
|
public void setDescriptorIndex(int descriptorIndex) {
|
||||||
|
this.descriptorIndex = descriptorIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name index.
|
||||||
|
* @return the name index.
|
||||||
|
*/
|
||||||
|
public int getNameIndex() {
|
||||||
|
return nameIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name index.
|
||||||
|
* @param nameIndex the name index.
|
||||||
|
*/
|
||||||
|
public void setNameIndex(int nameIndex) {
|
||||||
|
this.nameIndex = nameIndex;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents reference information.
|
||||||
|
*/
|
||||||
|
public abstract class AbstractRefInfo extends AbstractCPInfo {
|
||||||
|
|
||||||
|
protected int classIndex;
|
||||||
|
protected int nameAndTypeIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param classIndex the class index.
|
||||||
|
* @param nameAndTypeIndex
|
||||||
|
*/
|
||||||
|
public AbstractRefInfo(short tag, int classIndex, int nameAndTypeIndex) {
|
||||||
|
super(tag);
|
||||||
|
setClassIndex(classIndex);
|
||||||
|
setNameAndTypeIndex(nameAndTypeIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the class index.
|
||||||
|
* @return the class index.
|
||||||
|
*/
|
||||||
|
public int getClassIndex() {
|
||||||
|
return classIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the class index.
|
||||||
|
* @param classIndex the class index.
|
||||||
|
*/
|
||||||
|
private void setClassIndex(int classIndex) {
|
||||||
|
this.classIndex = classIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name and type index.
|
||||||
|
* @return the name and type index.
|
||||||
|
*/
|
||||||
|
public int getNameAndTypeIndex() {
|
||||||
|
return nameAndTypeIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name and type index.
|
||||||
|
* @param nameAndTypeIndex the name and type index.
|
||||||
|
*/
|
||||||
|
private void setNameAndTypeIndex(int nameAndTypeIndex) {
|
||||||
|
this.nameAndTypeIndex = nameAndTypeIndex;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,342 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a basic class file parser that returns a package name from a class file.
|
||||||
|
*/
|
||||||
|
public class BasicClassFileParser implements IClassFileConstants {
|
||||||
|
|
||||||
|
private long magic;
|
||||||
|
private int minor_version;
|
||||||
|
private int major_version;
|
||||||
|
private int constant_pool_count;
|
||||||
|
private List constant_pool;
|
||||||
|
private int access_flags;
|
||||||
|
private int this_class;
|
||||||
|
private int super_class;
|
||||||
|
private int interfaces_count;
|
||||||
|
private int[] interfaces;
|
||||||
|
private int fields_count;
|
||||||
|
private int methods_count;
|
||||||
|
private MethodInfo[] methods;
|
||||||
|
private int attributes_count;
|
||||||
|
private InputStream stream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constuctor.
|
||||||
|
* @param the input stream to parse.
|
||||||
|
*/
|
||||||
|
public BasicClassFileParser(InputStream stream) {
|
||||||
|
this.stream = stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the package.
|
||||||
|
* @return the package.
|
||||||
|
*/
|
||||||
|
public String getQualifiedClassName() {
|
||||||
|
|
||||||
|
ClassInfo info = (ClassInfo)(getCPInfo(this_class));
|
||||||
|
|
||||||
|
int nameIndex = info.getNameIndex();
|
||||||
|
String name = getString(nameIndex);
|
||||||
|
|
||||||
|
return name.replace('/', '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether there is a <code>public static void main(String[])</code> method.
|
||||||
|
* @return <code>true</code> if there is, otherwise <code>false</code>.
|
||||||
|
*/
|
||||||
|
public boolean isExecutable() {
|
||||||
|
|
||||||
|
for (int i = 0; i < methods_count; i++) {
|
||||||
|
MethodInfo info = methods[i];
|
||||||
|
|
||||||
|
// first ensure method name is "main"
|
||||||
|
int nameIndex = info.getNameIndex();
|
||||||
|
String name = getString(nameIndex);
|
||||||
|
|
||||||
|
if (name.equals("main")) {
|
||||||
|
|
||||||
|
// check access flags for public and static
|
||||||
|
int accessFlags = info.getAccessFlags();
|
||||||
|
|
||||||
|
if ((accessFlags & 0x000F) == 0x0009) {
|
||||||
|
|
||||||
|
// now check descriptor for parameter and return value
|
||||||
|
int descriptorIndex = info.getDescriptorIndex();
|
||||||
|
String descriptor = getString(descriptorIndex);
|
||||||
|
|
||||||
|
if (descriptor.equals("([Ljava/lang/String;)V")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a class file.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
public void parse() throws IOException {
|
||||||
|
|
||||||
|
EnhancedDataInputStream dataStream = new EnhancedDataInputStream(stream);
|
||||||
|
|
||||||
|
magic = dataStream.readUnsignedInt();
|
||||||
|
minor_version = dataStream.readUnsignedShort();
|
||||||
|
major_version = dataStream.readUnsignedShort();
|
||||||
|
constant_pool_count = dataStream.readUnsignedShort();
|
||||||
|
|
||||||
|
readConstantPool(dataStream);
|
||||||
|
|
||||||
|
access_flags = dataStream.readUnsignedShort();
|
||||||
|
|
||||||
|
this_class = dataStream.readUnsignedShort();
|
||||||
|
|
||||||
|
super_class = dataStream.readUnsignedShort();
|
||||||
|
|
||||||
|
interfaces_count = dataStream.readUnsignedShort();
|
||||||
|
|
||||||
|
readInterfaces(dataStream);
|
||||||
|
|
||||||
|
fields_count = dataStream.readUnsignedShort();
|
||||||
|
|
||||||
|
readFields(dataStream);
|
||||||
|
|
||||||
|
methods_count = dataStream.readUnsignedShort();
|
||||||
|
|
||||||
|
readMethods(dataStream);
|
||||||
|
|
||||||
|
dataStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the constant pool.
|
||||||
|
* @param dataStream the data stream.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
protected void readConstantPool(EnhancedDataInputStream dataStream) throws IOException {
|
||||||
|
|
||||||
|
constant_pool = new ArrayList();
|
||||||
|
|
||||||
|
for (int i = 0; i < constant_pool_count-1; i++) {
|
||||||
|
AbstractCPInfo info = readConstantInfo(dataStream);
|
||||||
|
constant_pool.add(i, info);
|
||||||
|
|
||||||
|
// each long or double info takes two spaces, so fill in the next entry with an empty object
|
||||||
|
// this entry is not usable according to the VM Specification
|
||||||
|
if (info instanceof LongInfo || info instanceof DoubleInfo) {
|
||||||
|
i++;
|
||||||
|
constant_pool.add(i, new Object());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the constant info.
|
||||||
|
* @param dataStream the data stream.
|
||||||
|
* @return the constant info.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
protected AbstractCPInfo readConstantInfo(EnhancedDataInputStream dataStream) throws IOException {
|
||||||
|
short tag = (short)(dataStream.readUnsignedByte());
|
||||||
|
|
||||||
|
switch (tag) {
|
||||||
|
|
||||||
|
case CONSTANT_CLASS: {
|
||||||
|
int nameIndex = dataStream.readUnsignedShort();
|
||||||
|
return new ClassInfo(tag, nameIndex);
|
||||||
|
}
|
||||||
|
case CONSTANT_FIELD_REF: {
|
||||||
|
int classIndex = dataStream.readUnsignedShort();
|
||||||
|
int nameAndTypeIndex = dataStream.readUnsignedShort();
|
||||||
|
return new FieldRefInfo(tag, classIndex, nameAndTypeIndex);
|
||||||
|
}
|
||||||
|
case CONSTANT_METHOD_REF: {
|
||||||
|
int classIndex = dataStream.readUnsignedShort();
|
||||||
|
int nameAndTypeIndex = dataStream.readUnsignedShort();
|
||||||
|
return new MethodRefInfo(tag, classIndex, nameAndTypeIndex);
|
||||||
|
}
|
||||||
|
case CONSTANT_INTERFACE_METHOD_REF: {
|
||||||
|
int classIndex = dataStream.readUnsignedShort();
|
||||||
|
int nameAndTypeIndex = dataStream.readUnsignedShort();
|
||||||
|
return new InterfaceMethodRefInfo(tag, classIndex, nameAndTypeIndex);
|
||||||
|
}
|
||||||
|
case CONSTANT_STRING: {
|
||||||
|
int stringIndex = dataStream.readUnsignedShort();
|
||||||
|
return new StringInfo(tag, stringIndex);
|
||||||
|
}
|
||||||
|
case CONSTANT_INTEGER: {
|
||||||
|
long bytes = dataStream.readUnsignedInt();
|
||||||
|
return new IntegerInfo(tag, bytes);
|
||||||
|
}
|
||||||
|
case CONSTANT_FLOAT: {
|
||||||
|
long bytes = dataStream.readUnsignedInt();
|
||||||
|
return new FloatInfo(tag, bytes);
|
||||||
|
}
|
||||||
|
case CONSTANT_LONG: {
|
||||||
|
long highBytes = dataStream.readUnsignedInt();
|
||||||
|
long lowBytes = dataStream.readUnsignedInt();
|
||||||
|
return new LongInfo(tag, highBytes, lowBytes);
|
||||||
|
}
|
||||||
|
case CONSTANT_DOUBLE: {
|
||||||
|
long highBytes = dataStream.readUnsignedInt();
|
||||||
|
long lowBytes = dataStream.readUnsignedInt();
|
||||||
|
return new DoubleInfo(tag, highBytes, lowBytes);
|
||||||
|
}
|
||||||
|
case CONSTANT_NAME_AND_TYPE: {
|
||||||
|
int nameIndex = dataStream.readUnsignedShort();
|
||||||
|
int descriptorIndex = dataStream.readUnsignedShort();
|
||||||
|
return new NameAndTypeInfo(tag, nameIndex, descriptorIndex);
|
||||||
|
}
|
||||||
|
case CONSTANT_UTF8: {
|
||||||
|
int length = dataStream.readUnsignedShort();
|
||||||
|
short[] bytes = new short[length];
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
bytes[i] = (short)(dataStream.readUnsignedByte());
|
||||||
|
}
|
||||||
|
|
||||||
|
return new UTF8Info(tag, length, bytes);
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the interfaces.
|
||||||
|
* @param dataStream the data stream.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
protected void readInterfaces(EnhancedDataInputStream dataStream) throws IOException {
|
||||||
|
interfaces = new int[interfaces_count];
|
||||||
|
|
||||||
|
for (int i = 0; i < interfaces_count; i++) {
|
||||||
|
interfaces[i] = dataStream.readUnsignedShort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the fields.
|
||||||
|
* @param dataStream the data stream.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
protected void readFields(EnhancedDataInputStream dataStream) throws IOException {
|
||||||
|
|
||||||
|
for (int i = 0; i < fields_count; i++) {
|
||||||
|
readField(dataStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a field.
|
||||||
|
* @param dataStream the data stream.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
protected FieldInfo readField(EnhancedDataInputStream dataStream) throws IOException {
|
||||||
|
int accessFlags = dataStream.readUnsignedShort();
|
||||||
|
int nameIndex = dataStream.readUnsignedShort();
|
||||||
|
int descriptorIndex = dataStream.readUnsignedShort();
|
||||||
|
int attributesCount = dataStream.readUnsignedShort();
|
||||||
|
|
||||||
|
for (int i = 0; i < attributesCount; i++) {
|
||||||
|
readAttribute(dataStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the methods.
|
||||||
|
* @param dataStream the data stream.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
protected void readMethods(EnhancedDataInputStream dataStream) throws IOException {
|
||||||
|
|
||||||
|
methods = new MethodInfo[methods_count];
|
||||||
|
|
||||||
|
for (int i = 0; i < methods_count; i++) {
|
||||||
|
methods[i] = readMethod(dataStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a method.
|
||||||
|
* @param dataStream the data stream.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
protected MethodInfo readMethod(EnhancedDataInputStream dataStream) throws IOException {
|
||||||
|
|
||||||
|
int accessFlags = dataStream.readUnsignedShort();
|
||||||
|
int nameIndex = dataStream.readUnsignedShort();
|
||||||
|
int descriptorIndex = dataStream.readUnsignedShort();
|
||||||
|
int attributesCount = dataStream.readUnsignedShort();
|
||||||
|
|
||||||
|
for (int i = 0; i < attributesCount; i++) {
|
||||||
|
readAttribute(dataStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new MethodInfo(accessFlags, nameIndex, descriptorIndex, attributes_count, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads an attribute.
|
||||||
|
* @param dataStream the data stream.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
protected AbstractAttributeInfo readAttribute(EnhancedDataInputStream dataStream) throws IOException {
|
||||||
|
dataStream.skip(2);
|
||||||
|
long length = dataStream.readUnsignedInt();
|
||||||
|
|
||||||
|
if (length > 0) {
|
||||||
|
dataStream.skip(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the entry at the constant pool index.
|
||||||
|
* @param index the index.
|
||||||
|
* @return the constant pool table entry.
|
||||||
|
*/
|
||||||
|
protected AbstractCPInfo getCPInfo(int index) {
|
||||||
|
return (AbstractCPInfo)(constant_pool.get(index-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name given an index to the constant pool table.
|
||||||
|
* The entry at the index must be a UTF8 string entry
|
||||||
|
*/
|
||||||
|
protected String getString(int index) {
|
||||||
|
UTF8Info nameInfo = (UTF8Info)(getCPInfo(index));
|
||||||
|
String name = ClassFileUTF8Reader.getInstance().getString(nameInfo.getBytes());
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This singleton class converts an array of unsigned bytes (represented by shorts) to UTF-8
|
||||||
|
* strings as per the UTF-8 format that the JVM uses. Note that the JVM's version
|
||||||
|
* of UTF8 is different to the standard UTF-8 format.
|
||||||
|
*/
|
||||||
|
public class ClassFileUTF8Reader {
|
||||||
|
|
||||||
|
private static ClassFileUTF8Reader instance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
private ClassFileUTF8Reader() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the singleton instance of the reader.
|
||||||
|
* @return the singleton instance.
|
||||||
|
*/
|
||||||
|
public static final ClassFileUTF8Reader getInstance() {
|
||||||
|
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new ClassFileUTF8Reader();
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string given an unsigned array of bytes (represented as an array of shorts). Converts to
|
||||||
|
* a string assuming the bytes represent the UTF8 format used by JVM.
|
||||||
|
* @param bytes the bytes.
|
||||||
|
* @return the string.
|
||||||
|
*/
|
||||||
|
public String getString(short[] bytes) {
|
||||||
|
StringBuffer buf = new StringBuffer();
|
||||||
|
|
||||||
|
char c;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
while (i < bytes.length) {
|
||||||
|
|
||||||
|
// first bit is 0
|
||||||
|
// char is represented by one byte
|
||||||
|
// char is in the range '\u0001' to '\u007F'
|
||||||
|
// format: x byte
|
||||||
|
// x: 0xxxxxxx
|
||||||
|
if ((bytes[i] & 0x80) == 0) {
|
||||||
|
c = (char)(bytes[i]);
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
// first three bits are 110 and first two bits of next byte are 10
|
||||||
|
// char is represented by two bytes
|
||||||
|
// char is either null character ('\u0000') or in the range '\u0080' to '\u07FF'
|
||||||
|
// format: x byte followed by y byte
|
||||||
|
// x: 110xxxxx
|
||||||
|
// y: 10xxxxxx
|
||||||
|
else if (((bytes[i] & 0xE0) == 0xC0) && ((bytes[i+1] & 0xC0) == 0x80)) {
|
||||||
|
c = (char)(((bytes[i] & 0x1F) << 6) + (bytes[i+1] & 0x3F));
|
||||||
|
i = i + 2;
|
||||||
|
}
|
||||||
|
// first three bits are 1110 and first two bits of next bytes are 10
|
||||||
|
// char is represented by three bytes
|
||||||
|
// char is in the range '\u0800' to '\uFFFF'
|
||||||
|
// format: x byte, y byte and z byte
|
||||||
|
// x: 1110xxxx
|
||||||
|
// y: 10xxxxxx
|
||||||
|
// z: 10xxxxxx
|
||||||
|
else if (((bytes[i] & 0xF0) == 0xE0) && ((bytes[i+1] & 0xC0) == 0x80) && ((bytes[i+2] & 0xC0) == 0x80)) {
|
||||||
|
c = (char)(((bytes[i] & 0x0F) << 12) + ((bytes[i+1] & 0x3F) << 6) + (bytes[i+2] & 0x3F));
|
||||||
|
i = i + 3;
|
||||||
|
}
|
||||||
|
// we should not never be here
|
||||||
|
else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// append character
|
||||||
|
buf.append(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Singleton class for obtaining various information about class files.
|
||||||
|
*/
|
||||||
|
public class ClassFileUtil {
|
||||||
|
|
||||||
|
private static ClassFileUtil instance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*/
|
||||||
|
private ClassFileUtil() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the singleton instance.
|
||||||
|
* @return the singleton instance.
|
||||||
|
*/
|
||||||
|
public static final ClassFileUtil getInstance() {
|
||||||
|
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new ClassFileUtil();
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the class with the given path is runnable, i.e. whether it contains <code>public
|
||||||
|
* static void main (String[])</code> method.
|
||||||
|
* @param classFilePath the class file path.
|
||||||
|
* @return <code>true</code> if the class file is runnable, <code>false</code> otherwise.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
public boolean isRunnable(String classFilePath) throws IOException {
|
||||||
|
File classFile = new File(classFilePath);
|
||||||
|
return isRunnable(classFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the class is runnable, i.e. whether it contains <code>public
|
||||||
|
* static void main (String[])</code> method.
|
||||||
|
* @param classFile the class file.
|
||||||
|
* @return <code>true</code> if the class file is runnable, <code>false</code> otherwise.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
public boolean isRunnable(File classFile) throws IOException {
|
||||||
|
FileInputStream stream = new FileInputStream(classFile);
|
||||||
|
return isRunnable(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the class represented by the given input stream is runnable,
|
||||||
|
* i.e. whether it contains <code>public static void main (String[])</code> method.
|
||||||
|
* @param stream the input stream.
|
||||||
|
* @return <code>true</code> if the class file is runnable, <code>false</code> otherwise.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
public boolean isRunnable(InputStream stream) throws IOException {
|
||||||
|
BasicClassFileParser parser = new BasicClassFileParser(stream);
|
||||||
|
parser.parse();
|
||||||
|
return parser.isExecutable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the qualified class name for the file with the given path.
|
||||||
|
* @param classFilePath the class file path.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
public String getQualifiedClassName(String classFilePath) throws IOException {
|
||||||
|
File classFile = new File(classFilePath);
|
||||||
|
return getQualifiedClassName(classFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the qualified class name.
|
||||||
|
* @param classFile the class file.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
public String getQualifiedClassName(File classFile) throws IOException {
|
||||||
|
FileInputStream stream = new FileInputStream(classFile);
|
||||||
|
return getQualifiedClassName(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the qualified class name for the class represented by the given input stream.
|
||||||
|
* @param classFilePath the class file path.
|
||||||
|
* @throws IOException if an I/O error occurs.
|
||||||
|
*/
|
||||||
|
public String getQualifiedClassName(InputStream stream) throws IOException {
|
||||||
|
BasicClassFileParser parser = new BasicClassFileParser(stream);
|
||||||
|
parser.parse();
|
||||||
|
return parser.getQualifiedClassName();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents class information.
|
||||||
|
*/
|
||||||
|
public class ClassInfo extends AbstractCPInfo {
|
||||||
|
|
||||||
|
protected int nameIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param nameIndex the name index.
|
||||||
|
*/
|
||||||
|
public ClassInfo(short tag, int nameIndex) {
|
||||||
|
super(tag);
|
||||||
|
setNameIndex(nameIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name index.
|
||||||
|
* @return the name index.
|
||||||
|
*/
|
||||||
|
public int getNameIndex() {
|
||||||
|
return nameIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name index.
|
||||||
|
* @param nameIndex the name index.
|
||||||
|
*/
|
||||||
|
private void setNameIndex(int nameIndex) {
|
||||||
|
this.nameIndex = nameIndex;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents double information.
|
||||||
|
*/
|
||||||
|
public class DoubleInfo extends Abstract8ByteNumericInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param highBytes the high bytes.
|
||||||
|
* @param lowBytes the low bytes.
|
||||||
|
*/
|
||||||
|
public DoubleInfo(short tag, long highBytes, long lowBytes) {
|
||||||
|
super(tag, highBytes, lowBytes);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,131 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class loader is used to load classes given a root path.
|
||||||
|
*/
|
||||||
|
public class EnhancedClassLoader extends ClassLoader {
|
||||||
|
|
||||||
|
private String rootPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param rootPath the root path.
|
||||||
|
*/
|
||||||
|
public EnhancedClassLoader(String rootPath) {
|
||||||
|
super();
|
||||||
|
setRootPath(rootPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the root path.
|
||||||
|
* @return the root path.
|
||||||
|
*/
|
||||||
|
public String getRootPath() {
|
||||||
|
return rootPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the root path.
|
||||||
|
* @param rootPath the root path.
|
||||||
|
*/
|
||||||
|
public void setRootPath(String rootPath) {
|
||||||
|
this.rootPath = rootPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds the class with the given name.
|
||||||
|
* @see java.lang.ClassLoader#findClass(java.lang.String)
|
||||||
|
*/
|
||||||
|
protected Class findClass(String name) throws ClassNotFoundException {
|
||||||
|
|
||||||
|
try {
|
||||||
|
byte[] b = loadClassData(name);
|
||||||
|
return defineClass(name, b, 0, b.length);
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
throw new ClassNotFoundException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the class data.
|
||||||
|
* @param name the name of the class.
|
||||||
|
* @return the contents of the class.
|
||||||
|
*/
|
||||||
|
private byte[] loadClassData(String name) throws IOException {
|
||||||
|
|
||||||
|
// parent path
|
||||||
|
String parentPath = rootPath;
|
||||||
|
|
||||||
|
// system file separator
|
||||||
|
String fileSep = System.getProperty("file.separator");
|
||||||
|
|
||||||
|
// add file separator to the parent path if it does not end with it
|
||||||
|
if (!parentPath.endsWith(fileSep)) {
|
||||||
|
parentPath = parentPath + fileSep;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuffer buf = new StringBuffer(parentPath);
|
||||||
|
|
||||||
|
// replace '.' in class name with file separator
|
||||||
|
for (int i = 0; i < name.length(); i++) {
|
||||||
|
char c = name.charAt(i);
|
||||||
|
|
||||||
|
if (c == '.') {
|
||||||
|
buf.append(fileSep);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
buf.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String filePath = buf.append(".class").toString();
|
||||||
|
|
||||||
|
File file = new File(filePath);
|
||||||
|
|
||||||
|
FileInputStream fileStream = new FileInputStream(file);
|
||||||
|
|
||||||
|
int length = (int)(file.length());
|
||||||
|
byte[] classData = new byte[length];
|
||||||
|
|
||||||
|
int bytesRead = 0;
|
||||||
|
int offset = 0;
|
||||||
|
|
||||||
|
int available = fileStream.available();
|
||||||
|
|
||||||
|
while (available > 0) {
|
||||||
|
int bytesToRead = Math.min(available, 256000);
|
||||||
|
bytesRead = fileStream.read(classData, offset, bytesToRead);
|
||||||
|
|
||||||
|
if (bytesRead == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
offset += bytesRead;
|
||||||
|
|
||||||
|
available = fileStream.available();
|
||||||
|
}
|
||||||
|
|
||||||
|
return classData;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.EOFException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A data input stream that adds a method for reading an unsigned integer.
|
||||||
|
*/
|
||||||
|
public class EnhancedDataInputStream extends DataInputStream {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a data input stream that uses the specified underlying input stream.
|
||||||
|
* @param in the specified input stream.
|
||||||
|
*/
|
||||||
|
public EnhancedDataInputStream(InputStream in) {
|
||||||
|
super(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the next four bytes of this input stream as an unsigned 32-bit long.
|
||||||
|
* <p>
|
||||||
|
* Bytes
|
||||||
|
* for this operation are read from the contained
|
||||||
|
* input stream.
|
||||||
|
*
|
||||||
|
* @return the next four bytes of this input stream, interpreted as an
|
||||||
|
* unsigned 32-bit long.
|
||||||
|
* @exception EOFException if this input stream reaches the end before
|
||||||
|
* reading four bytes.
|
||||||
|
* @exception IOException if an I/O error occurs.
|
||||||
|
* @see java.io.FilterInputStream#in
|
||||||
|
*/
|
||||||
|
public final long readUnsignedInt() throws IOException {
|
||||||
|
long ch1 = in.read();
|
||||||
|
long ch2 = in.read();
|
||||||
|
long ch3 = in.read();
|
||||||
|
long ch4 = in.read();
|
||||||
|
|
||||||
|
if ((ch1 | ch2 | ch3 | ch4) < 0) {
|
||||||
|
throw new EOFException();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents a field.
|
||||||
|
*/
|
||||||
|
public class FieldInfo extends AbstractCommonInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param accessFlags the access flags.
|
||||||
|
* @param nameIndex the name index.
|
||||||
|
* @param descriptorIndex the descriptor index.
|
||||||
|
* @param attributesCount the number of attributes.
|
||||||
|
* @param attributes the attributes.
|
||||||
|
*/
|
||||||
|
public FieldInfo(int accessFlags, int nameIndex, int descriptorIndex, int attributesCount, AbstractAttributeInfo[] attributes) {
|
||||||
|
super(accessFlags, nameIndex, descriptorIndex, attributesCount, attributes);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents field reference inforamtion.
|
||||||
|
*/
|
||||||
|
public class FieldRefInfo extends AbstractRefInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param classIndex the class index.
|
||||||
|
* @param nameAndTypeIndex the name and type index.
|
||||||
|
*/
|
||||||
|
public FieldRefInfo(short tag, int classIndex, int nameAndTypeIndex) {
|
||||||
|
super(tag, classIndex, nameAndTypeIndex);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents float information.
|
||||||
|
*/
|
||||||
|
public class FloatInfo extends Abstract4ByteNumericInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param bytes the bytes.
|
||||||
|
*/
|
||||||
|
public FloatInfo(short tag, long bytes) {
|
||||||
|
super(tag, bytes);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
public interface IClassFileConstants {
|
||||||
|
|
||||||
|
public static final int CONSTANT_CLASS = 7;
|
||||||
|
public static final int CONSTANT_FIELD_REF = 9;
|
||||||
|
public static final int CONSTANT_METHOD_REF = 10;
|
||||||
|
public static final int CONSTANT_INTERFACE_METHOD_REF = 11;
|
||||||
|
public static final int CONSTANT_STRING = 8;
|
||||||
|
public static final int CONSTANT_INTEGER = 3;
|
||||||
|
public static final int CONSTANT_FLOAT = 4;
|
||||||
|
public static final int CONSTANT_LONG = 5;
|
||||||
|
public static final int CONSTANT_DOUBLE = 6;
|
||||||
|
public static final int CONSTANT_NAME_AND_TYPE = 12;
|
||||||
|
public static final int CONSTANT_UTF8 = 1;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents integer information.
|
||||||
|
*/
|
||||||
|
public class IntegerInfo extends Abstract4ByteNumericInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param bytes the bytes.
|
||||||
|
*/
|
||||||
|
public IntegerInfo(short tag, long bytes) {
|
||||||
|
super(tag, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents
|
||||||
|
*/
|
||||||
|
public class InterfaceMethodRefInfo extends AbstractRefInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param classIndex the class index.
|
||||||
|
* @param nameAndTypeIndex the name and type index.
|
||||||
|
*/
|
||||||
|
public InterfaceMethodRefInfo(short tag, int classIndex, int nameAndTypeIndex) {
|
||||||
|
super(tag, classIndex, nameAndTypeIndex);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents long information.
|
||||||
|
*/
|
||||||
|
public class LongInfo extends Abstract8ByteNumericInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param highBytes the high bytes.
|
||||||
|
* @param lowBytes the low bytes.
|
||||||
|
*/
|
||||||
|
public LongInfo(short tag, long highBytes, long lowBytes) {
|
||||||
|
super(tag, highBytes, lowBytes);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents a method.
|
||||||
|
*/
|
||||||
|
public class MethodInfo extends AbstractCommonInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param accessFlags the access flags.
|
||||||
|
* @param nameIndex the name index.
|
||||||
|
* @param descriptorIndex the descriptor index.
|
||||||
|
* @param attributesCount the number of attributes.
|
||||||
|
* @param attributes the attributes.
|
||||||
|
*/
|
||||||
|
public MethodInfo(int accessFlags, int nameIndex, int descriptorIndex, int attributesCount, AbstractAttributeInfo[] attributes) {
|
||||||
|
super(accessFlags, nameIndex, descriptorIndex, attributesCount, attributes);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents method reference information.
|
||||||
|
*/
|
||||||
|
public class MethodRefInfo extends AbstractRefInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param classIndex the class index.
|
||||||
|
* @param nameAndTypeIndex the name and type index.
|
||||||
|
*/
|
||||||
|
public MethodRefInfo(short tag, int classIndex, int nameAndTypeIndex) {
|
||||||
|
super(tag, classIndex, nameAndTypeIndex);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents name and type information.
|
||||||
|
*/
|
||||||
|
public class NameAndTypeInfo extends ClassInfo {
|
||||||
|
|
||||||
|
protected int descriptorIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param nameIndex the name index.
|
||||||
|
* @param descriptorIndex the descriptor index.
|
||||||
|
*/
|
||||||
|
public NameAndTypeInfo(short tag, int nameIndex, int descriptorIndex) {
|
||||||
|
super(tag, nameIndex);
|
||||||
|
setDescriptorIndex(descriptorIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the descriptor index.
|
||||||
|
* @return the descriptorIndex.
|
||||||
|
*/
|
||||||
|
public int getDescriptorIndex() {
|
||||||
|
return descriptorIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the descriptor index.
|
||||||
|
* @param descriptorIndex the descriptor index.
|
||||||
|
*/
|
||||||
|
private void setDescriptorIndex(int descriptorIndex) {
|
||||||
|
this.descriptorIndex = descriptorIndex;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents a string information.
|
||||||
|
*/
|
||||||
|
public class StringInfo extends AbstractCPInfo {
|
||||||
|
|
||||||
|
protected int stringIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param stringIndex the string index.
|
||||||
|
*/
|
||||||
|
public StringInfo(short tag, int stringIndex) {
|
||||||
|
super(tag);
|
||||||
|
setStringIndex(stringIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the stringIndex.
|
||||||
|
*/
|
||||||
|
public int getStringIndex() {
|
||||||
|
return stringIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the stringIndex.
|
||||||
|
* @param stringIndex the stringIndex.
|
||||||
|
*/
|
||||||
|
private void setStringIndex(int stringIndex) {
|
||||||
|
this.stringIndex = stringIndex;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.java;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents a UTF-8 string.
|
||||||
|
*/
|
||||||
|
public class UTF8Info extends AbstractCPInfo {
|
||||||
|
|
||||||
|
protected int length;
|
||||||
|
protected short[] bytes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
* @param tag the tag.
|
||||||
|
* @param length the length;
|
||||||
|
* @param bytes the array of bytes with the given length.
|
||||||
|
*/
|
||||||
|
public UTF8Info(short tag, int length, short[] bytes) {
|
||||||
|
super(tag);
|
||||||
|
setLength(length);
|
||||||
|
setBytes(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the bytes.
|
||||||
|
* @return the bytes.
|
||||||
|
*/
|
||||||
|
public short[] getBytes() {
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the bytes.
|
||||||
|
* @param bytes the bytes.
|
||||||
|
*/
|
||||||
|
private void setBytes(short[] bytes) {
|
||||||
|
this.bytes = bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the length.
|
||||||
|
* @return the length.
|
||||||
|
*/
|
||||||
|
public int getLength() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the length.
|
||||||
|
* @param length the length.
|
||||||
|
*/
|
||||||
|
private void setLength(int length) {
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.messages;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* used to indicate that the indicator is not valid.
|
||||||
|
*/
|
||||||
|
public class IndicatorException extends Exception
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 3884986031505435750L;
|
||||||
|
|
||||||
|
public IndicatorException(String text)
|
||||||
|
{
|
||||||
|
super(text);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,510 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.messages;
|
||||||
|
|
||||||
|
// To dos:
|
||||||
|
// 1) can remove the following import when deprecated stuff is removed....
|
||||||
|
// 2) remove deprecated classes....
|
||||||
|
// ... done. Phil.
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Error message window class.
|
||||||
|
*/
|
||||||
|
public class SystemMessage
|
||||||
|
//implements ISystemMessages
|
||||||
|
{
|
||||||
|
|
||||||
|
// start of the new stuff!!! Violaine Batthish
|
||||||
|
// Indicators
|
||||||
|
/**
|
||||||
|
* Completion message indicator (added by DWD)
|
||||||
|
*/
|
||||||
|
public static final char COMPLETION='C';
|
||||||
|
/**
|
||||||
|
* Inquiry message indicator
|
||||||
|
*/
|
||||||
|
public static final char INQUIRY='Q';
|
||||||
|
/**
|
||||||
|
* Information message indicator
|
||||||
|
*/
|
||||||
|
public static final char INFORMATION='I';
|
||||||
|
/**
|
||||||
|
* Error message indicator
|
||||||
|
*/
|
||||||
|
public static final char ERROR='E';
|
||||||
|
/**
|
||||||
|
* Warning message indicator
|
||||||
|
*/
|
||||||
|
public static final char WARNING='W';
|
||||||
|
/**
|
||||||
|
* Unexpected message indicator (same as warning but will log exception & stack in message log)
|
||||||
|
*/
|
||||||
|
public static final char UNEXPECTED='U';
|
||||||
|
|
||||||
|
// Private variables
|
||||||
|
private char subPrefix='%';
|
||||||
|
private char indicator;
|
||||||
|
private String level1NS, level2NS; // level 1 & 2 with NO substitution made
|
||||||
|
private String level1WS, level2WS; // level 1 & 2 with substitutions made.
|
||||||
|
private String component, subComponent;
|
||||||
|
private String messageNumber;
|
||||||
|
private int numSubs=-1;
|
||||||
|
private Object[] subs=null;
|
||||||
|
|
||||||
|
protected static final String NESTING_INDENT = " "; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
|
/** SystemMesssage constructor
|
||||||
|
* <p>Throws:
|
||||||
|
* <li>IndicatorException: the indicator specified is not a valid indicator
|
||||||
|
* @param comp: Component
|
||||||
|
* @param sub: Subcomponent
|
||||||
|
* @param ind: Indicator
|
||||||
|
* @param number: message number
|
||||||
|
* @param l1: Level 1 text
|
||||||
|
* @param l2: Level 2 text
|
||||||
|
*/
|
||||||
|
public SystemMessage(String comp, String sub, String number, char ind, String l1, String l2) throws IndicatorException {
|
||||||
|
component=comp.toUpperCase();
|
||||||
|
subComponent=sub.toUpperCase();
|
||||||
|
messageNumber=number.toUpperCase();
|
||||||
|
setIndicator(ind);
|
||||||
|
level1NS=l1.trim();
|
||||||
|
level2NS=l2.trim();
|
||||||
|
level1WS=l1.trim();
|
||||||
|
level2WS=l2.trim();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to override the default severity of a message
|
||||||
|
* Throws SeverityException if the severity is not valid
|
||||||
|
*/
|
||||||
|
public void setIndicator(char ind) throws IndicatorException {
|
||||||
|
// check that a valid indicator was specified
|
||||||
|
if (ind != INQUIRY &&
|
||||||
|
ind != INFORMATION &&
|
||||||
|
ind != ERROR &&
|
||||||
|
ind != WARNING &&
|
||||||
|
ind != UNEXPECTED &&
|
||||||
|
ind != COMPLETION)
|
||||||
|
throw(new IndicatorException("Indicator specified not valid. Unable to set Indicator."));
|
||||||
|
|
||||||
|
// to do: decide if there are other indicator change violations....
|
||||||
|
|
||||||
|
// set indicator
|
||||||
|
indicator=ind;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to get the severity. Will be one of:
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link #INQUIRY} for a question message.
|
||||||
|
* <li>{@link #COMPLETION} for a completion message.
|
||||||
|
* <li>{@link #INFORMATION} for an informational message.
|
||||||
|
* <li>{@link #ERROR} for an error message.
|
||||||
|
* <li>{@link #WARNING} for a warning message.
|
||||||
|
* <li>{@link #UNEXPECTED} for an unexpected-situation-encountered message.
|
||||||
|
* </ul>
|
||||||
|
**/
|
||||||
|
public char getIndicator() {
|
||||||
|
return indicator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the message number of this message.
|
||||||
|
*/
|
||||||
|
public String getMessageNumber() {
|
||||||
|
return messageNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the component of this message.
|
||||||
|
*/
|
||||||
|
public String getComponent() {
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the subcomponent of this message.
|
||||||
|
*/
|
||||||
|
public String getSubComponent() {
|
||||||
|
return subComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to retrieve the unique number of substitution variables
|
||||||
|
* in this message (this would include level 1 and 2 text
|
||||||
|
* @return (int) number of unique substitution variables variables
|
||||||
|
**/
|
||||||
|
public int getNumSubstitutionVariables() {
|
||||||
|
// see if we already have this information stored
|
||||||
|
if (numSubs>=0)
|
||||||
|
return numSubs;
|
||||||
|
// otherwise we need to count the substitution variables.
|
||||||
|
else {
|
||||||
|
numSubs=0; // initial value
|
||||||
|
String allText=level1NS+" "+level2NS;
|
||||||
|
String subVar=subPrefix+new Integer(numSubs+1).toString();
|
||||||
|
int subLoc=allText.indexOf(subVar);
|
||||||
|
while (subLoc>=0) {
|
||||||
|
// in first position
|
||||||
|
if ((subLoc==0 &&
|
||||||
|
!Character.isDigit(allText.substring(subVar.length()).toCharArray()[0])) ||
|
||||||
|
// in last position
|
||||||
|
(subLoc==allText.length()-subVar.length() &&
|
||||||
|
allText.substring(subLoc-1).toCharArray()[0]!=subPrefix) ||
|
||||||
|
// somewhere in the middle
|
||||||
|
(!Character.isDigit(allText.substring(subLoc+subVar.length()).toCharArray()[0]) &&
|
||||||
|
allText.substring(subLoc-1).toCharArray()[0]!=subPrefix))
|
||||||
|
numSubs++;
|
||||||
|
subVar=subPrefix+new Integer(numSubs+1).toString();
|
||||||
|
subLoc=allText.indexOf(subVar);
|
||||||
|
}
|
||||||
|
return numSubs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to retrieve level one text
|
||||||
|
* @return String - level one text with subsitutions made.
|
||||||
|
**/
|
||||||
|
public String getLevelOneText() {
|
||||||
|
return level1WS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to retrieve level two text
|
||||||
|
* @return String - level two text with subsitutions made.
|
||||||
|
**/
|
||||||
|
public String getLevelTwoText() {
|
||||||
|
return level2WS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to retrieve the full message ID:
|
||||||
|
* Component + SubComponent + Number + indicator
|
||||||
|
* @return String - the full message ID
|
||||||
|
**/
|
||||||
|
public String getFullMessageID() {
|
||||||
|
return component+subComponent+messageNumber+indicator;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to retrieve 'long' message ID format:
|
||||||
|
* Component + SubComponent + Number.
|
||||||
|
* The long message ID is used for retrieving messages from a message file.
|
||||||
|
* @return String - the long message ID
|
||||||
|
**/
|
||||||
|
public String getLongMessageID() {
|
||||||
|
return component + subComponent + messageNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to retrieve 'standard' message ID format:
|
||||||
|
* Component + Number
|
||||||
|
* @return String - the full message ID
|
||||||
|
**/
|
||||||
|
public String getMessageID() {
|
||||||
|
return component + messageNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if this message has a long id equal to the one supplied in the argument.
|
||||||
|
* @param messageId the long message id to compare against.
|
||||||
|
* @return a boolean indicating if the message ids are equal.
|
||||||
|
*/
|
||||||
|
public boolean hasLongID(String messageId) {
|
||||||
|
return getLongMessageID().equals(messageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to set substitution value %1.
|
||||||
|
* <br>Generally toString() is used on the substitution objects, but there is
|
||||||
|
* special case handling for exception objects and IStatus objects.
|
||||||
|
*/
|
||||||
|
public SystemMessage makeSubstitution(Object sub1) {
|
||||||
|
level1WS=level1NS;
|
||||||
|
level2WS=level2NS;
|
||||||
|
makeSub(1, sub1);
|
||||||
|
// save subs
|
||||||
|
subs=new Object[1];
|
||||||
|
subs[0]=sub1;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Use this method to set substitution value %1 %2
|
||||||
|
* <br>Generally toString() is used on the substitution objects, but there is
|
||||||
|
* special case handling for exception objects and IStatus objects.
|
||||||
|
*/
|
||||||
|
public SystemMessage makeSubstitution(Object sub1, Object sub2) {
|
||||||
|
level1WS=level1NS;
|
||||||
|
level2WS=level2NS;
|
||||||
|
makeSub(1, sub1);
|
||||||
|
makeSub(2, sub2);
|
||||||
|
// save subs
|
||||||
|
subs=new Object[2];
|
||||||
|
subs[0]=sub1;
|
||||||
|
subs[1]=sub2;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Use this method to set substitution value %1 %2 %3
|
||||||
|
* <br>Generally toString() is used on the substitution objects, but there is
|
||||||
|
* special case handling for exception objects and IStatus objects.
|
||||||
|
*/
|
||||||
|
public SystemMessage makeSubstitution(Object sub1, Object sub2, Object sub3) {
|
||||||
|
level1WS=level1NS;
|
||||||
|
level2WS=level2NS;
|
||||||
|
makeSub(1, sub1);
|
||||||
|
makeSub(2, sub2);
|
||||||
|
makeSub(3, sub3);
|
||||||
|
// save subs
|
||||||
|
subs=new Object[3];
|
||||||
|
subs[0]=sub1;
|
||||||
|
subs[1]=sub2;
|
||||||
|
subs[2]=sub3;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Use this method to set substitution value %1 %2 %3 %4
|
||||||
|
* <br>Generally toString() is used on the substitution objects, but there is
|
||||||
|
* special case handling for exception objects and IStatus objects.
|
||||||
|
*/
|
||||||
|
public SystemMessage makeSubstitution(Object sub1, Object sub2, Object sub3, Object sub4) {
|
||||||
|
level1WS=level1NS;
|
||||||
|
level2WS=level2NS;
|
||||||
|
makeSub(1, sub1);
|
||||||
|
makeSub(2, sub2);
|
||||||
|
makeSub(3, sub3);
|
||||||
|
makeSub(4, sub4);
|
||||||
|
// save subs
|
||||||
|
subs=new Object[4];
|
||||||
|
subs[0]=sub1;
|
||||||
|
subs[1]=sub2;
|
||||||
|
subs[2]=sub3;
|
||||||
|
subs[3]=sub4;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to set substitution values
|
||||||
|
* <br>Generally toString() is used on the substitution objects, but there is
|
||||||
|
* special case handling for exception objects and IStatus objects.
|
||||||
|
*/
|
||||||
|
public SystemMessage makeSubstitution(Object [] subsList)
|
||||||
|
{
|
||||||
|
level1WS=level1NS;
|
||||||
|
level2WS=level2NS;
|
||||||
|
|
||||||
|
if ((subsList!=null) && (subsList.length>0))
|
||||||
|
for (int i=0; i<subsList.length; i++)
|
||||||
|
makeSub(i+1, subsList[i]);
|
||||||
|
// save subs
|
||||||
|
subs=subsList;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* retrieves an array of substitution variables
|
||||||
|
* @return Object[] array of substitution variables used
|
||||||
|
*/
|
||||||
|
public Object[] getSubVariables() {
|
||||||
|
return subs;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* private method to make a substitution
|
||||||
|
*/
|
||||||
|
private void makeSub(int subNumber, Object sub)
|
||||||
|
{
|
||||||
|
if (sub == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
String subValue = getSubValue(sub);
|
||||||
|
|
||||||
|
// check that substitution is needed
|
||||||
|
if (subNumber>getNumSubstitutionVariables())
|
||||||
|
return;
|
||||||
|
|
||||||
|
String subVar=subPrefix+new Integer(subNumber).toString();
|
||||||
|
int subLoc = -1;
|
||||||
|
|
||||||
|
// set level 1
|
||||||
|
// - quick test added by Phil
|
||||||
|
if (level1WS.equals(subVar))
|
||||||
|
level1WS = subValue;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
subLoc=level1WS.indexOf(subVar);
|
||||||
|
|
||||||
|
// FIXES BY PHIL
|
||||||
|
// 1.
|
||||||
|
// in the following code we were doing toCharArray only to index and get the first char.
|
||||||
|
// this is not required! there is a charAt method in String for this. Phil. EG:
|
||||||
|
//!Character.isDigit(level1WS.substring(subVar.length()).toCharArray()[0])) ||
|
||||||
|
|
||||||
|
// 2. compared subLoc to gt zero, vs gte zero
|
||||||
|
// 3. fixing that exposed a bug for the case when level one or two is only '%1'
|
||||||
|
//
|
||||||
|
// This code is hard to read and maintain and should be fixed up someday.
|
||||||
|
// -- why do we check if the next or previous char is a digit? For double digit sub vars like %11?
|
||||||
|
|
||||||
|
//while (subLoc>0) fixed. phil
|
||||||
|
while (subLoc>=0)
|
||||||
|
{
|
||||||
|
// in first position
|
||||||
|
if ((subLoc==0 &&
|
||||||
|
!Character.isDigit(level1WS.substring(subVar.length()).charAt(0))) ||
|
||||||
|
// in last position
|
||||||
|
(subLoc==level1WS.length()-subVar.length() &&
|
||||||
|
level1WS.substring(subLoc-1).charAt(0)!=subPrefix) ||
|
||||||
|
// somewhere in the middle
|
||||||
|
(!Character.isDigit(level1WS.substring(subLoc+subVar.length()).charAt(0)) &&
|
||||||
|
level1WS.substring(subLoc-1).charAt(0)!=subPrefix))
|
||||||
|
level1WS=level1WS.substring(0,subLoc)+subValue+level1WS.substring(subLoc+subVar.length());
|
||||||
|
subLoc=level1WS.indexOf(subVar, subLoc + subValue.length() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// set level 2
|
||||||
|
// - quick test added by Phil
|
||||||
|
if (level2WS.equals(subVar))
|
||||||
|
level2WS = subValue;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
subLoc=level2WS.indexOf(subVar);
|
||||||
|
//while (subLoc>0) fixed. phil
|
||||||
|
while (subLoc>=0)
|
||||||
|
{
|
||||||
|
// in first position
|
||||||
|
if ((subLoc==0 &&
|
||||||
|
//!Character.isDigit(level2WS.substring(subVar.length()).charAt(0))) ||
|
||||||
|
!Character.isDigit(level2WS.charAt(subVar.length()))) ||
|
||||||
|
// in last position
|
||||||
|
(subLoc==level2WS.length()-subVar.length() &&
|
||||||
|
level2WS.substring(subLoc-1).charAt(0)!=subPrefix) ||
|
||||||
|
// somewhere in the middle
|
||||||
|
(!Character.isDigit(level2WS.substring(subLoc+subVar.length()).charAt(0)) &&
|
||||||
|
level2WS.substring(subLoc-1).charAt(0)!=subPrefix))
|
||||||
|
level2WS=level2WS.substring(0,subLoc)+subValue+level2WS.substring(subLoc+subVar.length());
|
||||||
|
subLoc=level2WS.indexOf(subVar, subLoc + subValue.length() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setPrefixChar(char prefixChar) {
|
||||||
|
subPrefix = prefixChar;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do message variable substitution. Using you are replacing &1 (say) with
|
||||||
|
* a string.
|
||||||
|
* Still need this for non-message substitution capability. Phil.
|
||||||
|
* @param string - string containing substring to be substituted.
|
||||||
|
* @param subOld - substitution variable. Eg "%1"
|
||||||
|
* @param subNew - substitution data. Eg "001"
|
||||||
|
* @return message with all occurrences of subOld substituted with subNew.
|
||||||
|
*/
|
||||||
|
public static String sub(String msg, String subOld, String subNew)
|
||||||
|
{
|
||||||
|
StringBuffer temp = new StringBuffer();
|
||||||
|
int lastHit = 0;
|
||||||
|
int newHit = 0;
|
||||||
|
for (newHit = msg.indexOf(subOld,lastHit); newHit != -1;
|
||||||
|
lastHit = newHit, newHit = msg.indexOf(subOld,lastHit))
|
||||||
|
{
|
||||||
|
if (newHit >= 0)
|
||||||
|
temp.append(msg.substring(lastHit,newHit));
|
||||||
|
temp.append(subNew);
|
||||||
|
newHit += subOld.length();
|
||||||
|
}
|
||||||
|
if (lastHit >= 0)
|
||||||
|
temp.append(msg.substring(lastHit));
|
||||||
|
return temp.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Housekeeping...
|
||||||
|
/**
|
||||||
|
* Convert this message to a string.
|
||||||
|
* Returns string of the form: msgId + severity + ":" + first-level-text
|
||||||
|
*/
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return getFullMessageID() + ": " + getLevelOneText();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* used to determine the string value of the object
|
||||||
|
* it calls toString for all object types except for Exceptions
|
||||||
|
* where the stack is also rendered
|
||||||
|
* @param sub the substitution object
|
||||||
|
* @return the string value for the object
|
||||||
|
*/
|
||||||
|
public String getSubValue(Object sub)
|
||||||
|
{
|
||||||
|
|
||||||
|
// the following code caused a crash so I changed it. Phil.
|
||||||
|
/*
|
||||||
|
Class subClass=sub.getClass();
|
||||||
|
// loop through all the classes for the object
|
||||||
|
try {
|
||||||
|
while (subClass!=null) {
|
||||||
|
if (subClass.equals(Class.forName("Exception"))) {
|
||||||
|
Exception exc=(Exception)sub;
|
||||||
|
StringWriter excWriter = new StringWriter();
|
||||||
|
exc.printStackTrace(new PrintWriter(excWriter));
|
||||||
|
return exc.toString()+"\n"+ excWriter.toString();
|
||||||
|
}
|
||||||
|
subClass=subClass.getSuperclass();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(ClassNotFoundException e) {
|
||||||
|
// class was not found
|
||||||
|
SystemBasePlugin.logError("SystemMessge: getSubValue (Class not found) "+e.toString(), e);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (sub == null)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
if (sub instanceof Exception)
|
||||||
|
{
|
||||||
|
Exception exc=(Exception)sub;
|
||||||
|
StringWriter excWriter = new StringWriter();
|
||||||
|
exc.printStackTrace(new PrintWriter(excWriter));
|
||||||
|
String msg = exc.toString();
|
||||||
|
//String msg = exc.getMessage();
|
||||||
|
if ((msg == null) || (exc instanceof ClassCastException))
|
||||||
|
msg = exc.getClass().getName();
|
||||||
|
return msg+"\n"+ excWriter.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return sub.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (c) 2000, 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.services.clientserver.messages;
|
||||||
|
/**
|
||||||
|
* Encapsulates a system message
|
||||||
|
*/
|
||||||
|
public class SystemMessageException extends Exception
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 6695260563678942200L;
|
||||||
|
private SystemMessage msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param msg - a message to wrap.
|
||||||
|
*/
|
||||||
|
protected SystemMessageException(String msg)
|
||||||
|
{
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param msg - a system message to wrap.
|
||||||
|
*/
|
||||||
|
public SystemMessageException(SystemMessage msg)
|
||||||
|
{
|
||||||
|
super(msg.getLevelOneText());
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the SystemMessage we wrap
|
||||||
|
*/
|
||||||
|
public SystemMessage getSystemMessage()
|
||||||
|
{
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if the SystemMessage encapsulated by this exception has a long id equal to the
|
||||||
|
* argument.
|
||||||
|
* @param longMessageID the String containing the message id to test.
|
||||||
|
* @return true if the long message id of the message is equal to the supplied message id.
|
||||||
|
*/
|
||||||
|
public boolean hasLongID(String longMessageID) {
|
||||||
|
return getSystemMessage().hasLongID(longMessageID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the SystemMessage being wrapped
|
||||||
|
*/
|
||||||
|
public void setSystemMessage(SystemMessage msg)
|
||||||
|
{
|
||||||
|
this.msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,794 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.messages;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.EntityResolver;
|
||||||
|
import org.xml.sax.ErrorHandler;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import org.xml.sax.SAXParseException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this class to open, and parse, a RSE-style message file.
|
||||||
|
*/
|
||||||
|
public class SystemMessageFile implements ErrorHandler
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
private static final LinkedList msgfList=new LinkedList();
|
||||||
|
private MessageFileInfo msgFile;
|
||||||
|
private String defaultMsgFileLocation;
|
||||||
|
private InputStream dtdInputStream;
|
||||||
|
// the following is an attempt to improve response time, and reduce memory requirements, by
|
||||||
|
// caching SystemMessage objects for previously issued messages. Phil
|
||||||
|
private Hashtable messages = new Hashtable();
|
||||||
|
// XML TAG AND ELEMENT NAMES...
|
||||||
|
private static final String XML_TAG_COMPONENT = "Component";
|
||||||
|
private static final String XML_TAG_SUBCOMPONENT = "Subcomponent";
|
||||||
|
private static final String XML_TAG_MESSAGeList = "MessageList";
|
||||||
|
private static final String XML_TAG_MESSAGE = "Message";
|
||||||
|
private static final String XML_TAG_LEVELONE = "LevelOne";
|
||||||
|
private static final String XML_TAG_LEVELTWO = "LevelTwo";
|
||||||
|
private static final String XML_ATTR_ABBR = "Abbr";
|
||||||
|
private static final String XML_ATTR_ID = "ID";
|
||||||
|
private static final String XML_ATTR_INDICATOR = "Indicator";
|
||||||
|
private static final String XML_ATTR_NAME = "Name";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inner class
|
||||||
|
*/
|
||||||
|
private class MessageFileInfo
|
||||||
|
{
|
||||||
|
private String filename=null;
|
||||||
|
private String shortName=null;
|
||||||
|
private Document xmlDocument=null;
|
||||||
|
|
||||||
|
public MessageFileInfo(String ucFileName, String lcFileName, Document doc)
|
||||||
|
{
|
||||||
|
filename=ucFileName;
|
||||||
|
int idx=lcFileName.lastIndexOf('\\');
|
||||||
|
if (idx == -1)
|
||||||
|
idx = lcFileName.lastIndexOf('/');
|
||||||
|
if (idx >= 0)
|
||||||
|
shortName = lcFileName.substring(idx+1);
|
||||||
|
else
|
||||||
|
shortName = lcFileName;
|
||||||
|
xmlDocument=doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessageFullFileName()
|
||||||
|
{
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
public String getMessageShortFileName()
|
||||||
|
{
|
||||||
|
return shortName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Document getXMLDocument()
|
||||||
|
{
|
||||||
|
return xmlDocument;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param messageFileName - name of xml file which will contain the messages
|
||||||
|
*/
|
||||||
|
public SystemMessageFile (String messageFileName, String defaultMessageFileLocation)
|
||||||
|
{
|
||||||
|
this.defaultMsgFileLocation = defaultMessageFileLocation;
|
||||||
|
// have we already loaded this message file?
|
||||||
|
msgFile = getFromCache(messageFileName);
|
||||||
|
|
||||||
|
// now, we haven't. Load it now.
|
||||||
|
if (msgFile == null)
|
||||||
|
{
|
||||||
|
msgFile=new MessageFileInfo(messageFileName.toUpperCase(), messageFileName, loadAndParseXMLFile(messageFileName));
|
||||||
|
msgfList.add(msgFile);
|
||||||
|
//scanForDuplicates(); // don't keep this for production. Too expensive
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param messageFileName - name of xml file which will contain the messages
|
||||||
|
*/
|
||||||
|
public SystemMessageFile (String messageFileName, InputStream messageFile, InputStream dtdStream)
|
||||||
|
{
|
||||||
|
// have we already loaded this message file?
|
||||||
|
msgFile = getFromCache(messageFileName);
|
||||||
|
|
||||||
|
// now, we haven't. Load it now.
|
||||||
|
this.dtdInputStream = dtdStream;
|
||||||
|
if (msgFile == null)
|
||||||
|
{
|
||||||
|
msgFile=new MessageFileInfo(messageFileName.toUpperCase(), messageFileName, loadAndParseXMLFile(messageFile));
|
||||||
|
msgfList.add(msgFile);
|
||||||
|
//scanForDuplicates(); // don't keep this for production. Too expensive
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the named message file has already been loaded return its
|
||||||
|
* MessageFileInfo
|
||||||
|
* @param messageFileName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected MessageFileInfo getFromCache(String messageFileName)
|
||||||
|
{
|
||||||
|
for (int i=0; i<msgfList.size(); i++)
|
||||||
|
{
|
||||||
|
MessageFileInfo msgf=(MessageFileInfo)msgfList.get(i);
|
||||||
|
if (msgf.getMessageFullFileName().equals(messageFileName.toUpperCase()))
|
||||||
|
{
|
||||||
|
return msgf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to retrieve a message from the message file.
|
||||||
|
* @param msgId - the ID of the message to retrieve. This is the concatenation of the
|
||||||
|
* message's component abbreviation, subcomponent abbreviation, and message ID as declared
|
||||||
|
* in the message xml file.
|
||||||
|
* @return SystemMessage object
|
||||||
|
*/
|
||||||
|
public SystemMessage getMessage(String msgId)
|
||||||
|
{
|
||||||
|
boolean echoErrorsToStandardOut = true;
|
||||||
|
// DY Defect 42605
|
||||||
|
if (msgFile.getXMLDocument() == null)
|
||||||
|
{
|
||||||
|
issueErrorMessage("No XML document for message file", echoErrorsToStandardOut);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// caching added by Phil to increase performance, and not to leave a trail of SystemMessage objects for
|
||||||
|
// the garbage collector. Hopefully, the extra memory for the cache does not defeat these benefits.
|
||||||
|
SystemMessage msg = (SystemMessage)messages.get(msgFile.getMessageShortFileName()+":"+msgId);
|
||||||
|
if (msg != null)
|
||||||
|
{
|
||||||
|
//System.out.println("Reusing msg " + msgId);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
// I guess the following line of code implies we only support a single component per message file... phil.
|
||||||
|
// Code tweaked by Phil.
|
||||||
|
//String componentAbbr=msgFile.getXMLDocument().getElementsByTagName("Component").item(0).getAttributes().getNamedItem("Abbr").getFirstChild().getNodeValue();
|
||||||
|
//NodeList subComponentList=msgFile.getXMLDocument().getElementsByTagName("Subcomponent");
|
||||||
|
|
||||||
|
// parse out the Abbr attr of the first Component element
|
||||||
|
NodeList componentElementList = msgFile.getXMLDocument().getElementsByTagName(XML_TAG_COMPONENT);
|
||||||
|
if ((componentElementList == null) || (componentElementList.getLength() == 0))
|
||||||
|
{
|
||||||
|
issueErrorMessage("Unable to find any Component elements",echoErrorsToStandardOut);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Element componentElement = (Element)componentElementList.item(0);
|
||||||
|
String componentAbbr = componentElement.getAttribute(XML_ATTR_ABBR);
|
||||||
|
|
||||||
|
// get list of all Subcomponent elements...
|
||||||
|
NodeList subComponentList=msgFile.getXMLDocument().getElementsByTagName(XML_TAG_SUBCOMPONENT);
|
||||||
|
|
||||||
|
if ((subComponentList == null) || (subComponentList.getLength() == 0))
|
||||||
|
{
|
||||||
|
issueErrorMessage("Unable to find any Subcomponent elements",echoErrorsToStandardOut);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fold given msg ID to uppercase
|
||||||
|
msgId = msgId.toUpperCase();
|
||||||
|
|
||||||
|
// search for the right component/subcomponent match
|
||||||
|
for (int subComponentIdx=0; subComponentIdx<subComponentList.getLength(); subComponentIdx++)
|
||||||
|
{
|
||||||
|
//String subComponentAbbr=subComponentList.item(subComponentIdx).getAttributes().getNamedItem("Abbr").getFirstChild().getNodeValue();
|
||||||
|
Element subComponentElement = (Element)subComponentList.item(subComponentIdx);
|
||||||
|
String subComponentAbbr = subComponentElement.getAttribute(XML_ATTR_ABBR);
|
||||||
|
//String msgPrefix=componentAbbr+subComponentAbbr;
|
||||||
|
String msgPrefix = (componentAbbr + subComponentAbbr).toUpperCase();
|
||||||
|
char msgIndicator=' ';
|
||||||
|
String msgL1="";
|
||||||
|
String msgL2="";
|
||||||
|
|
||||||
|
// if the message prefix matches, then try to find the message
|
||||||
|
//if (msgPrefix.toUpperCase().equals(msgId.toUpperCase().substring(0,msgPrefix.length())) &&
|
||||||
|
//if (msgPrefix.equals(msgId.substring(0,msgPrefix.length())) &&
|
||||||
|
if (msgId.startsWith(msgPrefix) &&
|
||||||
|
Character.isDigit(msgId.charAt(msgPrefix.length())))
|
||||||
|
{
|
||||||
|
//String msgNumber=msgId.toUpperCase().substring(msgPrefix.length());
|
||||||
|
String msgNumber=msgId.substring(msgPrefix.length());
|
||||||
|
Element messageListNode=null;
|
||||||
|
|
||||||
|
// search for the message list node
|
||||||
|
/*
|
||||||
|
for (Node node=subComponentList.item(subComponentIdx).getFirstChild();
|
||||||
|
node!=null; node=node.getNextSibling())
|
||||||
|
{
|
||||||
|
if (node.getNodeName().equals("MessageList"))
|
||||||
|
{
|
||||||
|
messageListNode=node;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
NodeList msgListNodes = subComponentElement.getElementsByTagName(XML_TAG_MESSAGeList);
|
||||||
|
if ((msgListNodes!=null) && (msgListNodes.getLength()>0))
|
||||||
|
messageListNode = (Element)msgListNodes.item(0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
issueWarningMessage("unable to find MessageList nodes for subComponent " + subComponentElement.getAttribute(XML_ATTR_NAME),echoErrorsToStandardOut);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// search for the message node which has the right number
|
||||||
|
//for (Node node=messageListNode.getFirstChild();
|
||||||
|
// node!=null; node=node.getNextSibling())
|
||||||
|
NodeList msgNodes = messageListNode.getElementsByTagName(XML_TAG_MESSAGE);
|
||||||
|
if ((msgNodes==null) || (msgNodes.getLength()==0))
|
||||||
|
{
|
||||||
|
issueWarningMessage("unable to find Message nodes for subComponent " + subComponentElement.getAttribute(XML_ATTR_NAME),echoErrorsToStandardOut);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
boolean match = false; // I added this so we stop looping when we find what we are looking for!!! Phil.
|
||||||
|
for (int msgIdx = 0; !match && (msgIdx < msgNodes.getLength()); msgIdx++)
|
||||||
|
{
|
||||||
|
Element node = (Element)msgNodes.item(msgIdx);
|
||||||
|
// if the message number matches...
|
||||||
|
//if (node.getNodeName().equals("Message") && node.getAttributes().getNamedItem("ID").getFirstChild().getNodeValue().toUpperCase().equals(msgNumber))
|
||||||
|
if (node.getAttribute(XML_ATTR_ID).equals(msgNumber))
|
||||||
|
{
|
||||||
|
match = true;
|
||||||
|
// save the indicator value
|
||||||
|
//msgIndicator=(node.getAttributes().getNamedItem("Indicator").getFirstChild().getNodeValue().toUpperCase().toCharArray())[0];
|
||||||
|
msgIndicator=node.getAttribute(XML_ATTR_INDICATOR).toUpperCase().charAt(0);
|
||||||
|
// search for the l1 & l2 text
|
||||||
|
for (Node msgNode=node.getFirstChild();
|
||||||
|
msgNode!=null; msgNode=msgNode.getNextSibling())
|
||||||
|
{
|
||||||
|
// get Level One text
|
||||||
|
if (msgNode.getNodeName().equals(XML_TAG_LEVELONE))
|
||||||
|
msgL1 = getNodeText(msgNode);
|
||||||
|
// get Level Two text
|
||||||
|
else if (msgNode.getNodeName().equals(XML_TAG_LEVELTWO))
|
||||||
|
msgL2 = getNodeText(msgNode);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!match)
|
||||||
|
{
|
||||||
|
/** TODO - DKM move this somewhere else since system message now needs to be eclipse independent
|
||||||
|
SystemBasePlugin.logError("Requested Message " + msgId + " not found in message file " + msgFile.getMessageShortFileName());
|
||||||
|
*/
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
msg = loadSystemMessage(componentAbbr, subComponentAbbr, msgNumber, msgIndicator, msgL1, msgL2);
|
||||||
|
messages.put(msgFile.getMessageShortFileName()+":"+msgId, msg); // add to cache so we find it immediately next time!!
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
catch (IndicatorException e)
|
||||||
|
{
|
||||||
|
/** TODO - DKM move this somewhere else since system message now needs to be eclipse independent
|
||||||
|
SystemBasePlugin.logError("MessageFile:getMessage: "+e.toString(), e);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override this to provide different extended SystemMessage implementation
|
||||||
|
* @param componentAbbr
|
||||||
|
* @param subComponentAbbr
|
||||||
|
* @param msgNumber
|
||||||
|
* @param msgIndicator
|
||||||
|
* @param msgL1
|
||||||
|
* @param msgL2
|
||||||
|
* @return
|
||||||
|
* @throws IndicatorException
|
||||||
|
*/
|
||||||
|
protected SystemMessage loadSystemMessage(String componentAbbr, String subComponentAbbr, String msgNumber, char msgIndicator,
|
||||||
|
String msgL1, String msgL2) throws IndicatorException
|
||||||
|
{
|
||||||
|
return new SystemMessage(componentAbbr, subComponentAbbr, msgNumber, msgIndicator, msgL1, msgL2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the level one text
|
||||||
|
*/
|
||||||
|
private String getNodeText(Node msgNode)
|
||||||
|
{
|
||||||
|
String nodeText = "";
|
||||||
|
for (Node textNode=msgNode.getFirstChild();
|
||||||
|
textNode!=null; textNode=textNode.getNextSibling())
|
||||||
|
{
|
||||||
|
if ((textNode.getNodeType()==Node.TEXT_NODE) && (textNode.getNodeValue().trim().length()>0))
|
||||||
|
nodeText += textNode.getNodeValue();
|
||||||
|
}
|
||||||
|
return nodeText.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to scan message file for duplicate messages. You typically do this only during development!!
|
||||||
|
* If a duplicate is found, its message id is written to standard out, and to the systems.core
|
||||||
|
* log file.
|
||||||
|
* @return true if duplicates found.
|
||||||
|
*/
|
||||||
|
public boolean scanForDuplicates()
|
||||||
|
{
|
||||||
|
boolean echoErrorsToStandardOut = true;
|
||||||
|
if (msgFile.getXMLDocument() == null)
|
||||||
|
return issueErrorMessage("No XML document for message file", echoErrorsToStandardOut);
|
||||||
|
|
||||||
|
// parse out the Abbr attr of the first Component element
|
||||||
|
NodeList componentElementList = msgFile.getXMLDocument().getElementsByTagName(XML_TAG_COMPONENT);
|
||||||
|
if ((componentElementList == null) || (componentElementList.getLength() == 0))
|
||||||
|
return issueErrorMessage("Unable to find any Component elements",echoErrorsToStandardOut);
|
||||||
|
|
||||||
|
Element componentElement = (Element)componentElementList.item(0);
|
||||||
|
String componentAbbr = componentElement.getAttribute(XML_ATTR_ABBR);
|
||||||
|
|
||||||
|
// get list of all Subcomponent elements...
|
||||||
|
NodeList subComponentList=msgFile.getXMLDocument().getElementsByTagName(XML_TAG_SUBCOMPONENT);
|
||||||
|
|
||||||
|
if ((subComponentList == null) || (subComponentList.getLength() == 0))
|
||||||
|
return issueErrorMessage("Unable to find any Subcomponent elements",echoErrorsToStandardOut);
|
||||||
|
|
||||||
|
// scan all subcomponents...
|
||||||
|
boolean anyDupes = false;
|
||||||
|
for (int subComponentIdx=0; subComponentIdx<subComponentList.getLength(); subComponentIdx++)
|
||||||
|
{
|
||||||
|
Element subComponentElement = (Element)subComponentList.item(subComponentIdx);
|
||||||
|
String subComponentAbbr = subComponentElement.getAttribute(XML_ATTR_ABBR);
|
||||||
|
String msgPrefix = (componentAbbr + subComponentAbbr).toUpperCase();
|
||||||
|
Vector msgsById = new Vector();
|
||||||
|
|
||||||
|
// search for the message list node
|
||||||
|
Element messageListNode=null;
|
||||||
|
NodeList msgListNodes = subComponentElement.getElementsByTagName(XML_TAG_MESSAGeList);
|
||||||
|
if ((msgListNodes!=null) && (msgListNodes.getLength()>0))
|
||||||
|
messageListNode = (Element)msgListNodes.item(0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
issueWarningMessage("unable to find MessageList nodes for subComponent " + subComponentElement.getAttribute(XML_ATTR_NAME),echoErrorsToStandardOut);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeList msgNodes = messageListNode.getElementsByTagName(XML_TAG_MESSAGE);
|
||||||
|
if ((msgNodes==null) || (msgNodes.getLength()==0))
|
||||||
|
{
|
||||||
|
issueWarningMessage("unable to find Message nodes for subComponent " + subComponentElement.getAttribute(XML_ATTR_NAME),echoErrorsToStandardOut);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (int msgIdx = 0; (msgIdx < msgNodes.getLength()); msgIdx++)
|
||||||
|
{
|
||||||
|
Element node = (Element)msgNodes.item(msgIdx);
|
||||||
|
String msgId = msgPrefix + node.getAttribute(XML_ATTR_ID);
|
||||||
|
if (msgsById.contains(msgId))
|
||||||
|
{
|
||||||
|
anyDupes = true;
|
||||||
|
issueWarningMessage("Warning: duplicate message " + msgId + " found", echoErrorsToStandardOut);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
msgsById.addElement(msgId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return anyDupes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use this method to generate html documentation for the messages in the message file.
|
||||||
|
* This is useful for reference information, or to give to Level 2 for service support.
|
||||||
|
* @param htmlFile - the fully qualified name of the file to write to. Overwrites current contents.
|
||||||
|
* @return true if it went well, false if it failed for some reason, such as given a bad file name. Errors written to standard out.
|
||||||
|
*/
|
||||||
|
public boolean printHTML(String fullFileName)
|
||||||
|
{
|
||||||
|
boolean echoErrorsToStandardOut = true;
|
||||||
|
if (msgFile.getXMLDocument() == null)
|
||||||
|
return issueErrorMessage("No XML document for message file", echoErrorsToStandardOut);
|
||||||
|
|
||||||
|
// parse out the Abbr attr of the first Component element
|
||||||
|
NodeList componentElementList = msgFile.getXMLDocument().getElementsByTagName(XML_TAG_COMPONENT);
|
||||||
|
if ((componentElementList == null) || (componentElementList.getLength() == 0))
|
||||||
|
return issueErrorMessage("Unable to find any Component elements",echoErrorsToStandardOut);
|
||||||
|
|
||||||
|
Element componentElement = (Element)componentElementList.item(0);
|
||||||
|
String componentAbbr = componentElement.getAttribute(XML_ATTR_ABBR);
|
||||||
|
|
||||||
|
// get list of all Subcomponent elements...
|
||||||
|
NodeList subComponentList=msgFile.getXMLDocument().getElementsByTagName(XML_TAG_SUBCOMPONENT);
|
||||||
|
|
||||||
|
if ((subComponentList == null) || (subComponentList.getLength() == 0))
|
||||||
|
return issueErrorMessage("Unable to find any Subcomponent elements",echoErrorsToStandardOut);
|
||||||
|
|
||||||
|
File outFile = new File(fullFileName);
|
||||||
|
PrintWriter outFileStream = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
outFileStream = new PrintWriter(new FileOutputStream(outFile));
|
||||||
|
outFileStream.println("<HTML> <HEAD> <TITLE> Message File "+msgFile.getMessageShortFileName()+" </TITLE>");
|
||||||
|
outFileStream.println("<style type=\"text/css\">");
|
||||||
|
outFileStream.println("h2 { background-color: #CCCCFF }");
|
||||||
|
outFileStream.println("</style>");
|
||||||
|
outFileStream.println("</HEAD> <BODY>");
|
||||||
|
outFileStream.println("<H1>"+componentElement.getAttribute(XML_ATTR_NAME)+" Messages</H1>");
|
||||||
|
outFileStream.println("<br>");
|
||||||
|
outFileStream.println("<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\" WIDTH=\"100%\">");
|
||||||
|
outFileStream.println("<TR BGCOLOR=\"#CCCCFF\">");
|
||||||
|
outFileStream.println("<TD COLSPAN=2><FONT SIZE=\"+2\">");
|
||||||
|
outFileStream.println("<B>Sub-Component Summary</B></FONT></TD>");
|
||||||
|
outFileStream.println("</TR>");
|
||||||
|
}
|
||||||
|
catch (IOException exc)
|
||||||
|
{
|
||||||
|
return issueErrorMessage("Unable to open given html file in printHTML: " + exc.getMessage(), echoErrorsToStandardOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
// pre-scan all subcomponents...
|
||||||
|
for (int subComponentIdx=0; subComponentIdx<subComponentList.getLength(); subComponentIdx++)
|
||||||
|
{
|
||||||
|
Element subComponentElement = (Element)subComponentList.item(subComponentIdx);
|
||||||
|
String subComponentAbbr = subComponentElement.getAttribute(XML_ATTR_ABBR);
|
||||||
|
String msgPrefix = (componentAbbr + subComponentAbbr).toUpperCase();
|
||||||
|
String scName = subComponentElement.getAttribute(XML_ATTR_NAME);
|
||||||
|
|
||||||
|
outFileStream.println("<TR BGCOLOR=\"white\">");
|
||||||
|
outFileStream.println("<TD ALIGN=\"right\" VALIGN=\"top\" WIDTH=\"1%\">");
|
||||||
|
outFileStream.println("<A href=#"+scName+">"+scName+"</A></TD>");
|
||||||
|
outFileStream.println("<TD><b>Message prefix</b>="+msgPrefix+"</TD></TR>");
|
||||||
|
}
|
||||||
|
outFileStream.println("</TABLE>");
|
||||||
|
|
||||||
|
// scan all subcomponents...
|
||||||
|
for (int subComponentIdx=0; subComponentIdx<subComponentList.getLength(); subComponentIdx++)
|
||||||
|
{
|
||||||
|
Element subComponentElement = (Element)subComponentList.item(subComponentIdx);
|
||||||
|
String subComponentAbbr = subComponentElement.getAttribute(XML_ATTR_ABBR);
|
||||||
|
String msgPrefix = (componentAbbr + subComponentAbbr).toUpperCase();
|
||||||
|
|
||||||
|
// search for the message list node
|
||||||
|
Element messageListNode=null;
|
||||||
|
NodeList msgListNodes = subComponentElement.getElementsByTagName(XML_TAG_MESSAGeList);
|
||||||
|
if ((msgListNodes!=null) && (msgListNodes.getLength()>0))
|
||||||
|
messageListNode = (Element)msgListNodes.item(0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
issueWarningMessage("unable to find MessageList nodes for subComponent " + subComponentElement.getAttribute(XML_ATTR_NAME),echoErrorsToStandardOut);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeList msgNodes = messageListNode.getElementsByTagName(XML_TAG_MESSAGE);
|
||||||
|
if ((msgNodes==null) || (msgNodes.getLength()==0))
|
||||||
|
{
|
||||||
|
issueWarningMessage("unable to find Message nodes for subComponent " + subComponentElement.getAttribute(XML_ATTR_NAME),echoErrorsToStandardOut);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (subComponentIdx > 0)
|
||||||
|
outFileStream.println("<hr>");
|
||||||
|
String scName = subComponentElement.getAttribute(XML_ATTR_NAME);
|
||||||
|
outFileStream.println("<A NAME=\""+scName+"\"><!-- --></A><H2>"+scName+" Messages</H2>");
|
||||||
|
for (int msgIdx = 0; (msgIdx < msgNodes.getLength()); msgIdx++)
|
||||||
|
{
|
||||||
|
Element node = (Element)msgNodes.item(msgIdx);
|
||||||
|
String msgId = msgPrefix + node.getAttribute(XML_ATTR_ID);
|
||||||
|
char msgIndicator=node.getAttribute(XML_ATTR_INDICATOR).toUpperCase().charAt(0);
|
||||||
|
String msgSeverity = "Unknown";
|
||||||
|
if (msgIndicator == SystemMessage.ERROR)
|
||||||
|
msgSeverity = "Error";
|
||||||
|
else if (msgIndicator == SystemMessage.WARNING)
|
||||||
|
msgSeverity = "Warning";
|
||||||
|
else if (msgIndicator == SystemMessage.INQUIRY)
|
||||||
|
msgSeverity = "Question";
|
||||||
|
else if (msgIndicator == SystemMessage.INFORMATION)
|
||||||
|
msgSeverity = "Information";
|
||||||
|
else if (msgIndicator == SystemMessage.COMPLETION)
|
||||||
|
msgSeverity = "Completion";
|
||||||
|
else if (msgIndicator == SystemMessage.UNEXPECTED)
|
||||||
|
msgSeverity = "Unexpected";
|
||||||
|
|
||||||
|
String msgL1 = "";
|
||||||
|
String msgL2 = "";
|
||||||
|
// search for the l1 & l2 text
|
||||||
|
for (Node msgNode=node.getFirstChild();
|
||||||
|
msgNode!=null; msgNode=msgNode.getNextSibling())
|
||||||
|
{
|
||||||
|
// get Level One text
|
||||||
|
if (msgNode.getNodeName().equals(XML_TAG_LEVELONE))
|
||||||
|
msgL1 = getNodeText(msgNode);
|
||||||
|
// get Level Two text
|
||||||
|
else if (msgNode.getNodeName().equals(XML_TAG_LEVELTWO))
|
||||||
|
msgL2 = getNodeText(msgNode);
|
||||||
|
}
|
||||||
|
outFileStream.println("<H3>"+msgId+"</H3>");
|
||||||
|
outFileStream.println("<b>Severity: </b>"+msgSeverity+"<br>");
|
||||||
|
outFileStream.println("<b>LevelOne: </b>"+msgL1+"<br>");
|
||||||
|
outFileStream.println("<b>LevelTwo: </b>"+msgL2+"<br>");
|
||||||
|
}
|
||||||
|
outFileStream.println("<br>");
|
||||||
|
}
|
||||||
|
outFileStream.println("</BODY></HTML>");
|
||||||
|
outFileStream.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Issue an error message
|
||||||
|
*/
|
||||||
|
private boolean issueErrorMessage(String errormsg, boolean echoStandardOut)
|
||||||
|
{
|
||||||
|
|
||||||
|
/** TODO - DKM move this somewhere else since system message now needs to be eclipse independent
|
||||||
|
*
|
||||||
|
SystemBasePlugin.logError("MessageFile error for msg file " + msgFile.getMessageShortFileName() + ": " + errormsg);
|
||||||
|
**/
|
||||||
|
if (echoStandardOut)
|
||||||
|
System.out.println("MessageFile error for msg file " + msgFile.getMessageShortFileName() + ": " + errormsg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Issue a warning message
|
||||||
|
*/
|
||||||
|
private boolean issueWarningMessage(String errormsg, boolean echoStandardOut)
|
||||||
|
{
|
||||||
|
/** TODO - DKM move this somewhere else since system message now needs to be eclipse independent
|
||||||
|
SystemBasePlugin.logError("MessageFile warning for msg file " + msgFile.getMessageShortFileName() + ": " + errormsg);
|
||||||
|
*/
|
||||||
|
if (echoStandardOut)
|
||||||
|
System.out.println("MessageFile warning for msg file " + msgFile.getMessageShortFileName() + ": " + errormsg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loadAndParseXMLFile:
|
||||||
|
* tries to load and parse the specified XML file.
|
||||||
|
* @param String messageFileName: name of xml file which will contain the messages
|
||||||
|
*/
|
||||||
|
private Document loadAndParseXMLFile (String messageFileName)
|
||||||
|
{
|
||||||
|
DocumentBuilder parser = createXmlParser();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Document document = parser.parse(messageFileName);
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
catch (SAXException e)
|
||||||
|
{
|
||||||
|
// the parser was unable to parse the file.
|
||||||
|
/** TODO - DKM move this somewhere else since system message now needs to be eclipse independent
|
||||||
|
SystemBasePlugin.logError("SystemMessageFile: loadAndParseXMLFile "+e.toString(), e);
|
||||||
|
|
||||||
|
MessageBox mb = new MessageBox(SystemPlugin.getActiveWorkbenchShell());
|
||||||
|
mb.setText("Unexpected Error");
|
||||||
|
mb.setMessage("Unable to load message file " + messageFileName );
|
||||||
|
mb.open();
|
||||||
|
*/
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
/** TODO - DKM move this somewhere else since system message now needs to be eclipse independent
|
||||||
|
// there was an error reading the file
|
||||||
|
SystemBasePlugin.logError("SystemMessageFile: loadAndParseXMLFile "+e.toString(), e);
|
||||||
|
|
||||||
|
MessageBox mb = new MessageBox(SystemPlugin.getActiveWorkbenchShell());
|
||||||
|
mb.setText("Unexpected Error");
|
||||||
|
mb.setMessage("Unable to load message file " + messageFileName );
|
||||||
|
mb.open();
|
||||||
|
*/
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// the file was successfully opened and parsed
|
||||||
|
// return parser.getDocument();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the XML parser
|
||||||
|
* Set its entity resolver and error handler.
|
||||||
|
* @return DocumentBuilder
|
||||||
|
*/
|
||||||
|
private DocumentBuilder createXmlParser()
|
||||||
|
{
|
||||||
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
|
factory.setValidating(true);
|
||||||
|
DocumentBuilder parser;
|
||||||
|
try {
|
||||||
|
parser = factory.newDocumentBuilder();
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
// the configuration was not valid
|
||||||
|
/** TODO -move this elsewhere - can't depend on ui stuff
|
||||||
|
SystemBasePlugin.logError("SystemMessageFile: loadAndParseXMLFile, configuration not valid "+e.toString(), e);
|
||||||
|
*/
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// DOMParser parser=new DOMParser();
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// parser.setFeature( "http://xml.org/sax/features/validation", true);
|
||||||
|
// }
|
||||||
|
// catch (SAXNotRecognizedException e)
|
||||||
|
// {
|
||||||
|
// // the feature was not recognized
|
||||||
|
// /** TODO - DKM move this somewhere else since system message now needs to be eclipse independent
|
||||||
|
// SystemBasePlugin.logError("SystemMessageFile: loadAndParseXMLFile, feature not recognized "+e.toString(), e);
|
||||||
|
// */
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// catch (SAXNotSupportedException e)
|
||||||
|
// {
|
||||||
|
// // the feature requested was not supported
|
||||||
|
// /** TODO - DKM move this somewhere else since system message now needs to be eclipse independent
|
||||||
|
// SystemBasePlugin.logError("SystemMessageFile: loadAndParseXMLFile, feature not recognized "+e.toString(), e);
|
||||||
|
// */
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
parser.setEntityResolver(new EntityResolver() {
|
||||||
|
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, java.io.IOException
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
// This code does not work with fragments
|
||||||
|
Path path = new Path(systemId);
|
||||||
|
if (systemId.toUpperCase().endsWith("MESSAGEFILE.DTD"))
|
||||||
|
{
|
||||||
|
if (SystemPlugin.getBaseDefault().getDescriptor().find(path)==null)
|
||||||
|
{
|
||||||
|
path = new Path("messageFile.dtd");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new InputSource(SystemBasePlugin.getBaseDefault().getDescriptor().find(path).toString());
|
||||||
|
*/
|
||||||
|
// If we have the input stream of the DTD just use it
|
||||||
|
if (dtdInputStream != null)
|
||||||
|
{
|
||||||
|
return new InputSource(dtdInputStream);
|
||||||
|
}
|
||||||
|
else // if we have the directory containing the DTD use that
|
||||||
|
{
|
||||||
|
// yantzi:artemis6.2 changed to use URI instead of URL (URIs handle the spaces)
|
||||||
|
//URL url = new URL(systemId);
|
||||||
|
//File dtdFile = new File(url.getFile());
|
||||||
|
try
|
||||||
|
{
|
||||||
|
URI url = new URI(systemId);
|
||||||
|
File dtdFile = new File(url.getPath());
|
||||||
|
if (!dtdFile.exists())
|
||||||
|
{
|
||||||
|
// use default locaiton
|
||||||
|
systemId = defaultMsgFileLocation + File.separatorChar + dtdFile.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (URISyntaxException e)
|
||||||
|
{
|
||||||
|
// ignore and continue
|
||||||
|
}
|
||||||
|
|
||||||
|
return new InputSource(systemId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
parser.setErrorHandler(this);
|
||||||
|
return parser;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* loadAndParseXMLFile:
|
||||||
|
* tries to load and parse the specified XML file .
|
||||||
|
* @param String messageFile: InputStream containing the XML file
|
||||||
|
*/
|
||||||
|
private Document loadAndParseXMLFile (InputStream messageFile)
|
||||||
|
{
|
||||||
|
DocumentBuilder parser = createXmlParser();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
InputSource in = new InputSource(messageFile);
|
||||||
|
|
||||||
|
// DKM - hack!
|
||||||
|
// If systemId is null for the InputSource, then
|
||||||
|
// the current parser hits a fatal exception.
|
||||||
|
// This hack prevents that exception so that the
|
||||||
|
// specified EntityResolver will get used.
|
||||||
|
in.setSystemId("foo");
|
||||||
|
Document document = parser.parse(in);
|
||||||
|
|
||||||
|
//Document document = parser.parse(messageFile);
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
catch (SAXException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
// the parser was unable to parse the file.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
/** TODO - DKM move this somewhere else since system message now needs to be eclipse independent
|
||||||
|
*/
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XML Parser-required method: XML-parser warning.
|
||||||
|
*/
|
||||||
|
public void warning(SAXParseException ex)
|
||||||
|
{
|
||||||
|
/** TODO - DKM move this somewhere else since system message now needs to be eclipse independent
|
||||||
|
SystemBasePlugin.logError("SystemMessageFile: warning parsing message file: "+ex.toString());
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XML Parser-required method: XML-parser Error.
|
||||||
|
*/
|
||||||
|
public void error(SAXParseException ex)
|
||||||
|
{
|
||||||
|
/** TODO - DKM move this somewhere else since system message now needs to be eclipse independent
|
||||||
|
SystemBasePlugin.logError("SystemMessageFile: Error parsing message file: "+ex.toString(), ex);
|
||||||
|
Shell shell = SystemPlugin.getActiveWorkbenchShell();
|
||||||
|
if (shell.isEnabled() && !shell.isDisposed())
|
||||||
|
{
|
||||||
|
MessageBox mb = new MessageBox(shell);
|
||||||
|
mb.setText("Error loading message file: "+ex.getMessage());
|
||||||
|
mb.setMessage("Unable to load message file " + currMsgFile +". Error at line "+ex.getLineNumber()+" and column "+ex.getColumnNumber());
|
||||||
|
mb.open();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XML Parser-required method: XML-parser Fatal error.
|
||||||
|
*/
|
||||||
|
public void fatalError(SAXParseException ex) throws SAXException
|
||||||
|
{
|
||||||
|
/** TODO - DKM move this somewhere else since system message now needs to be eclipse independent
|
||||||
|
SystemBasePlugin.logError("SystemMessageFile: Fatal Error parsing message file: "+ex.toString(), ex);
|
||||||
|
*/
|
||||||
|
throw(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,443 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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.services.clientserver.processes;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
import org.eclipse.rse.services.clientserver.NamePatternMatcher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A class representing a remote process filter string. This is a name pattern
|
||||||
|
* for returning lists of remote processes when used as input to the
|
||||||
|
* UniversalProcessMiner class.
|
||||||
|
*
|
||||||
|
* Valid generic names are names with one or two asterisks
|
||||||
|
* anywhere in the name, as in:
|
||||||
|
* <sl>
|
||||||
|
* <code>ABC*</code> or <code>*ABC</code> or <code>A*C</code>
|
||||||
|
* <code>*ABC*</code> or <code>*A*C</code> or <code>A*C*</code>
|
||||||
|
* </sl>
|
||||||
|
*
|
||||||
|
* To get the actual filter string back from objects of this class, just call {@link #toString()}.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class HostProcessFilterImpl implements IHostProcessFilter, Cloneable, ISystemProcessRemoteConstants
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String ALL = "*";
|
||||||
|
|
||||||
|
protected static final char WILDCARD = '*';
|
||||||
|
|
||||||
|
protected String name, username, gid, ppid, pid;
|
||||||
|
protected long minVM, maxVM;
|
||||||
|
protected boolean anystatus;
|
||||||
|
protected String status;
|
||||||
|
protected HashMap states;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor to use when there is no existing filter string.
|
||||||
|
*/
|
||||||
|
public HostProcessFilterImpl()
|
||||||
|
{
|
||||||
|
name = ALL;
|
||||||
|
username = ALL;
|
||||||
|
gid = ALL;
|
||||||
|
ppid = ALL;
|
||||||
|
pid = ALL;
|
||||||
|
minVM = 0;
|
||||||
|
maxVM = -1;
|
||||||
|
anystatus = true;
|
||||||
|
initStates();
|
||||||
|
status = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initStates()
|
||||||
|
{
|
||||||
|
states = new HashMap();
|
||||||
|
for (int i = 0; i < ALL_STATES_STR.length; i++)
|
||||||
|
{
|
||||||
|
states.put(ALL_STATES_STR[i], new Boolean(false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor to use when filter string already exists.
|
||||||
|
*/
|
||||||
|
public HostProcessFilterImpl(String input)
|
||||||
|
{
|
||||||
|
anystatus = true;
|
||||||
|
StringTokenizer tz = new StringTokenizer(input, "|");
|
||||||
|
String strMinVM = "0";
|
||||||
|
String strMaxVM = "-1";
|
||||||
|
|
||||||
|
if (tz.hasMoreTokens())
|
||||||
|
{
|
||||||
|
name = tz.nextToken();
|
||||||
|
|
||||||
|
if (tz.hasMoreTokens())
|
||||||
|
{
|
||||||
|
username = tz.nextToken();
|
||||||
|
|
||||||
|
if (tz.hasMoreTokens())
|
||||||
|
{
|
||||||
|
gid = tz.nextToken();
|
||||||
|
if (tz.hasMoreTokens())
|
||||||
|
{
|
||||||
|
status = tz.nextToken().trim();
|
||||||
|
if (tz.hasMoreTokens())
|
||||||
|
{
|
||||||
|
ppid = tz.nextToken();
|
||||||
|
if (tz.hasMoreTokens())
|
||||||
|
{
|
||||||
|
pid = tz.nextToken();
|
||||||
|
if (tz.hasMoreTokens())
|
||||||
|
{
|
||||||
|
strMinVM = tz.nextToken();
|
||||||
|
if (tz.hasMoreTokens())
|
||||||
|
{
|
||||||
|
strMaxVM = tz.nextToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(status == null))
|
||||||
|
{
|
||||||
|
if (!status.equals(""))
|
||||||
|
{
|
||||||
|
String[] allStates = status.split(",");
|
||||||
|
if (!(allStates == null))
|
||||||
|
{
|
||||||
|
initStates();
|
||||||
|
anystatus = false;
|
||||||
|
for (int i = 0; i < allStates.length; i++)
|
||||||
|
{
|
||||||
|
states.put(allStates[i], new Boolean(true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name == null || name.equals(""))
|
||||||
|
name = ALL;
|
||||||
|
|
||||||
|
if (username == null || username.equals(""))
|
||||||
|
username = ALL;
|
||||||
|
|
||||||
|
if (gid == null || gid.equals(""))
|
||||||
|
gid = ALL;
|
||||||
|
|
||||||
|
if (ppid == null || ppid.equals(""))
|
||||||
|
ppid = ALL;
|
||||||
|
|
||||||
|
if (pid == null || pid.equals(""))
|
||||||
|
pid = ALL;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
minVM = Long.parseLong(strMinVM);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
minVM = 0;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
maxVM = Long.parseLong(strMaxVM);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
maxVM = -1;
|
||||||
|
}
|
||||||
|
if (minVM < 0)
|
||||||
|
{
|
||||||
|
minVM = 0;
|
||||||
|
}
|
||||||
|
if (maxVM < 0)
|
||||||
|
{
|
||||||
|
maxVM = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public HashMap getStates()
|
||||||
|
{
|
||||||
|
return states;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the process name part of this filter string.
|
||||||
|
*/
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the username part of this filter string.
|
||||||
|
*/
|
||||||
|
public String getUsername()
|
||||||
|
{
|
||||||
|
if (username.equals("${user.id}"))
|
||||||
|
{
|
||||||
|
return System.getProperty("user.name");
|
||||||
|
}
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the process group id (gid) part of this filter string.
|
||||||
|
*/
|
||||||
|
public String getGid()
|
||||||
|
{
|
||||||
|
return gid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the process parent id (ppid) part of this filter string.
|
||||||
|
*/
|
||||||
|
public String getPpid()
|
||||||
|
{
|
||||||
|
return ppid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the process id (pid) part of this filter string.
|
||||||
|
*/
|
||||||
|
public String getPid()
|
||||||
|
{
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true when all process states are selected. The individal state
|
||||||
|
* queries will return false in this case.
|
||||||
|
*/
|
||||||
|
public boolean getAnyStatus()
|
||||||
|
{
|
||||||
|
return anystatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the minimum VM size for processes allowed by this filter
|
||||||
|
*/
|
||||||
|
public String getMinVM()
|
||||||
|
{
|
||||||
|
return "" + minVM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the maximum VM size for processes allowed by this filter
|
||||||
|
*/
|
||||||
|
public String getMaxVM()
|
||||||
|
{
|
||||||
|
return "" + maxVM;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name part of this filter string. This can be simple or
|
||||||
|
* generic, where generic is a name containing one or two asterisks
|
||||||
|
* anywhere in the name.
|
||||||
|
*/
|
||||||
|
public void setName(String obj)
|
||||||
|
{
|
||||||
|
name = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the user id (uid) part of this filter string. This can be simple or
|
||||||
|
* generic, where generic is a uid containing one or two asterisks anywhere
|
||||||
|
* in the name.
|
||||||
|
*/
|
||||||
|
public void setUsername(String obj)
|
||||||
|
{
|
||||||
|
username = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the process group id (gid) part of this filter string.
|
||||||
|
*/
|
||||||
|
public void setGid(String obj)
|
||||||
|
{
|
||||||
|
gid = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the process parent id part of this filter string.
|
||||||
|
*/
|
||||||
|
public void setPpid(String obj)
|
||||||
|
{
|
||||||
|
ppid = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the process id part of this filter string.
|
||||||
|
*/
|
||||||
|
public void setPid(String obj)
|
||||||
|
{
|
||||||
|
pid = obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select all/any process states
|
||||||
|
*/
|
||||||
|
public void setAnyStatus()
|
||||||
|
{
|
||||||
|
anystatus = true;
|
||||||
|
initStates();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the minimum VM size for processes allowed by this filter
|
||||||
|
*/
|
||||||
|
public void setMinVM(String strMinVM)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
minVM = Long.parseLong(strMinVM);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
minVM = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the maximum VM size for processes allowed by this filter
|
||||||
|
*/
|
||||||
|
public void setMaxVM(String strMaxVM)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
maxVM = Long.parseLong(strMaxVM);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
maxVM = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert this filter into a filter string.
|
||||||
|
*/
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return name + "|" + username + "|" + gid + "|" + toStateString() + "|" + ppid + "|" + pid + "|" + minVM + "|" + maxVM;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String toStateString()
|
||||||
|
{
|
||||||
|
String s = " ";
|
||||||
|
|
||||||
|
if (!anystatus)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ALL_STATES_STR.length; i++)
|
||||||
|
{
|
||||||
|
Boolean currentState = (Boolean) states.get(ALL_STATES_STR[i]);
|
||||||
|
if (currentState.booleanValue()) s = s + ALL_STATES_STR[i];
|
||||||
|
if (currentState.booleanValue()) s = s + ",";
|
||||||
|
}
|
||||||
|
if (!s.trim().equals("")) s = s.trim();
|
||||||
|
if (s.endsWith(",")) s = s.substring(0, s.length() - 1);
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this filter allows a process with the status line
|
||||||
|
* <code>status</code> to pass through. The status line contains some of the contents of
|
||||||
|
* the <i>status</i> file contained in the processes numbered directory in
|
||||||
|
* the /proc filesystem. For example, the status line of process 12345 is
|
||||||
|
* the contents of the file <i>/proc/12345/stat</i>.
|
||||||
|
* The status line must be structured as follows:
|
||||||
|
* "pid|name|status|tgid|ppid|tracerpid|uid|username|gid|vmSize|vmRSS"
|
||||||
|
*/
|
||||||
|
public boolean allows(String status)
|
||||||
|
{
|
||||||
|
NamePatternMatcher matcher = null;
|
||||||
|
String[] tokens = status.split("\\|");
|
||||||
|
if (tokens.length < (PROCESS_ATTRIBUTES_COUNT -1)) return false;
|
||||||
|
|
||||||
|
matcher = new NamePatternMatcher(gid, true, false);
|
||||||
|
if (!matcher.matches(tokens[PROCESS_ATTRIBUTES_INDEX_GID])) return false;
|
||||||
|
|
||||||
|
matcher = new NamePatternMatcher(name, true, false);
|
||||||
|
if (!matcher.matches(tokens[PROCESS_ATTRIBUTES_INDEX_EXENAME])) return false;
|
||||||
|
|
||||||
|
String state = tokens[PROCESS_ATTRIBUTES_INDEX_STATUS].trim();
|
||||||
|
if (!satisfiesState(state)) return false;
|
||||||
|
|
||||||
|
matcher = new NamePatternMatcher(getUsername(), true, false);
|
||||||
|
if (!matcher.matches(tokens[PROCESS_ATTRIBUTES_INDEX_USERNAME])) return false;
|
||||||
|
matcher = new NamePatternMatcher(ppid, true, false);
|
||||||
|
if (!matcher.matches(tokens[PROCESS_ATTRIBUTES_INDEX_PPID])) return false;
|
||||||
|
matcher = new NamePatternMatcher(pid, true, false);
|
||||||
|
if (!matcher.matches(tokens[PROCESS_ATTRIBUTES_INDEX_PID])) return false;
|
||||||
|
long vmSize = 0;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
vmSize = Long.parseLong(tokens[PROCESS_ATTRIBUTES_INDEX_VMSIZE]);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (tokens[PROCESS_ATTRIBUTES_INDEX_VMSIZE].trim().equals("")) vmSize = 0;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
if (!(vmSize >= minVM)) return false;
|
||||||
|
if (maxVM > -1 && !(vmSize <= maxVM)) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getSpecificState(String stateCode)
|
||||||
|
{
|
||||||
|
Boolean state = (Boolean) states.get(stateCode);
|
||||||
|
if (state == null) return false;
|
||||||
|
return state.booleanValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpecificState(String stateCode)
|
||||||
|
{
|
||||||
|
anystatus = false;
|
||||||
|
states.put(stateCode, new Boolean(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean satisfiesState(String state)
|
||||||
|
{
|
||||||
|
if (!anystatus)
|
||||||
|
{
|
||||||
|
String[] allStates = state.split(",");
|
||||||
|
if (allStates == null) return false;
|
||||||
|
if (allStates.length == 0) return false;
|
||||||
|
boolean satisfied = false;
|
||||||
|
for (int i = 0; i < allStates.length; i++)
|
||||||
|
{
|
||||||
|
String nextState = allStates[i];
|
||||||
|
satisfied = getSpecificState(nextState);
|
||||||
|
if (satisfied) break;
|
||||||
|
}
|
||||||
|
if (!satisfied) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|