mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
[194215] formatted code in popup example, updated tutorial from example, tested
This commit is contained in:
parent
85464385c7
commit
e8659be28e
5 changed files with 229 additions and 143 deletions
|
@ -10,34 +10,36 @@
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<h1>ShowJarContents Class After Creation</h1>
|
<h1>ShowJarContents Class After Creation</h1>
|
||||||
<p>
|
|
||||||
<pre><samp>
|
<pre><samp>
|
||||||
package samples.ui.actions;
|
package samples.ui.actions;
|
||||||
|
|
||||||
import org.eclipse.rse.files.ui.actions.SystemAbstractRemoteFilePopupMenuExtensionAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.ui.IObjectActionDelegate;
|
||||||
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
|
||||||
public class <b>ShowJarContents</b>
|
public class ShowJarContents implements IObjectActionDelegate {
|
||||||
extends SystemAbstractRemoteFilePopupMenuExtensionAction
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
public ShowJarContents() {
|
||||||
* Constructor for ShowJarContents.
|
// TODO Auto-generated constructor stub
|
||||||
*/
|
|
||||||
public <b>ShowJarContents</b>()
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
||||||
* @see org.eclipse.rse.ui.actions.SystemAbstractPopupMenuExtensionAction#run()
|
// TODO Auto-generated method stub
|
||||||
*/
|
|
||||||
public void <b>run</b>()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void run(IAction action) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectionChanged(IAction action, ISelection selection) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
</samp></pre>
|
</samp></pre>
|
||||||
</p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -4,49 +4,79 @@
|
||||||
<head>
|
<head>
|
||||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
|
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
|
||||||
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
|
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
|
||||||
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2002, 2006. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
|
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2002, 2007. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
|
||||||
<LINK REL="STYLESHEET" HREF="../../book.css" TYPE="text/css">
|
<LINK REL="STYLESHEET" HREF="../../book.css" TYPE="text/css">
|
||||||
<title>ShowJarContents Class After Editing</title>
|
<title>ShowJarContents Class After Editing</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
<body bgcolor="#ffffff">
|
||||||
<h1>ShowJarContents Class After Editing</h1>
|
<h1>ShowJarContents Class After Editing</h1>
|
||||||
<p>
|
|
||||||
<pre><samp>
|
<pre><samp>
|
||||||
package samples.ui.actions;
|
package samples.ui.actions;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.rse.core.model.IHost;
|
import org.eclipse.rse.core.model.IHost;
|
||||||
import org.eclipse.rse.files.ui.actions.SystemAbstractRemoteFilePopupMenuExtensionAction;
|
import org.eclipse.rse.core.subsystems.ISubSystem;
|
||||||
import org.eclipse.rse.shells.ui.RemoteCommandHelpers;
|
import org.eclipse.rse.shells.ui.RemoteCommandHelpers;
|
||||||
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile;
|
||||||
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem;
|
import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem;
|
||||||
|
import org.eclipse.rse.ui.SystemBasePlugin;
|
||||||
public class ShowJarContents2 extends SystemAbstractRemoteFilePopupMenuExtensionAction {
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.IObjectActionDelegate;
|
||||||
public ShowJarContents2() {
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
IRemoteFile selectedFile = getFirstSelectedRemoteFile();
|
|
||||||
String cmdToRun = "jar -tvf " + selectedFile.getAbsolutePath();
|
|
||||||
runCommand(cmdToRun);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runCommand(String command) {
|
|
||||||
IRemoteCmdSubSystem cmdss = getRemoteCmdSubSystem();
|
|
||||||
if (cmdss != null && cmdss.isConnected()) {
|
|
||||||
RemoteCommandHelpers.runUniversalCommand(getShell(), command, ".", cmdss);
|
|
||||||
} else {
|
|
||||||
MessageDialog.openError(getShell(), "No command subsystem", "Found no command subsystem");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Command subsystem associated with the current host
|
* An action that runs a command to display the contents of a Jar file.
|
||||||
|
* The plugin.xml file restricts this action so it only appears for .jar files.
|
||||||
*/
|
*/
|
||||||
private IRemoteCmdSubSystem getRemoteCmdSubSystem() {
|
public class ShowJarContents implements IObjectActionDelegate {
|
||||||
|
private List _selectedFiles;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for ShowJarContents.
|
||||||
|
*/
|
||||||
|
public ShowJarContents() {
|
||||||
|
_selectedFiles = new ArrayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Shell getShell() {
|
||||||
|
return SystemBasePlugin.getActiveWorkbenchShell();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IRemoteFile getFirstSelectedRemoteFile() {
|
||||||
|
if (_selectedFiles.size() > 0) {
|
||||||
|
return (IRemoteFile) _selectedFiles.get(0);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ISubSystem getSubSystem() {
|
||||||
|
return getFirstSelectedRemoteFile().getParentRemoteFileSubSystem();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||||
|
*/
|
||||||
|
public void run(IAction action) {
|
||||||
|
IRemoteFile selectedFile = getFirstSelectedRemoteFile();
|
||||||
|
String cmdToRun = "jar -tvf " + selectedFile.getAbsolutePath(); //$NON-NLS-1$
|
||||||
|
try {
|
||||||
|
runCommand(cmdToRun);
|
||||||
|
} catch (Exception e) {
|
||||||
|
String excType = e.getClass().getName();
|
||||||
|
MessageDialog.openError(getShell(), excType, excType + ": " + e.getLocalizedMessage()); //$NON-NLS-1$
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRemoteCmdSubSystem getRemoteCmdSubSystem() {
|
||||||
|
//get the Command subsystem associated with the current host
|
||||||
IHost myHost = getSubSystem().getHost();
|
IHost myHost = getSubSystem().getHost();
|
||||||
IRemoteCmdSubSystem[] subsys = RemoteCommandHelpers.getCmdSubSystems(myHost);
|
IRemoteCmdSubSystem[] subsys = RemoteCommandHelpers.getCmdSubSystems(myHost);
|
||||||
for (int i = 0; i < subsys.length; i++) {
|
for (int i = 0; i < subsys.length; i++) {
|
||||||
|
@ -57,8 +87,31 @@ public class ShowJarContents2 extends SystemAbstractRemoteFilePopupMenuExtension
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void runCommand(String command) throws Exception {
|
||||||
|
IRemoteCmdSubSystem cmdss = getRemoteCmdSubSystem();
|
||||||
|
if (cmdss != null && cmdss.isConnected()) {
|
||||||
|
// Run the command in a visible shell
|
||||||
|
RemoteCommandHelpers.runUniversalCommand(getShell(), command, ".", cmdss); //$NON-NLS-1$
|
||||||
|
} else {
|
||||||
|
MessageDialog.openError(getShell(), "No command subsystem", "Found no command subsystem");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectionChanged(org.eclipse.jface.action.IAction action, org.eclipse.jface.viewers.ISelection selection) {
|
||||||
|
_selectedFiles.clear();
|
||||||
|
// store the selected jars to be used when running
|
||||||
|
Iterator theSet = ((IStructuredSelection) selection).iterator();
|
||||||
|
while (theSet.hasNext()) {
|
||||||
|
Object obj = theSet.next();
|
||||||
|
if (obj instanceof IRemoteFile) {
|
||||||
|
_selectedFiles.add(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</samp></pre>
|
</samp></pre>
|
||||||
</p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -22,12 +22,6 @@ to a local temporary folder, extract the list of file names within the jar, and
|
||||||
display those names in an Eclipse table view.
|
display those names in an Eclipse table view.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p><b>Tip:</b> If you prefer your Java code to use lined-up braces, select the
|
|
||||||
first two options in the <b><A href="preferences_JavaFormatting.gif">Code
|
|
||||||
Formatter</A></b> preferences page for <b>Java</b>, via <b>Windows->Preferences</b>.
|
|
||||||
|
|
||||||
This will affect code generated by wizards. The source code shown assumes this option has been set, but this is not required.
|
|
||||||
|
|
||||||
<h2>Step-by-Step: Creating an RSE Remote Resource Pop-up Menu Action</h2>
|
<h2>Step-by-Step: Creating an RSE Remote Resource Pop-up Menu Action</h2>
|
||||||
|
|
||||||
<ol>
|
<ol>
|
||||||
|
@ -42,7 +36,7 @@ This will affect code generated by wizards. The source code shown assumes this o
|
||||||
<extension point="org.eclipse.ui.popupMenus">
|
<extension point="org.eclipse.ui.popupMenus">
|
||||||
<objectContribution
|
<objectContribution
|
||||||
objectClass="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"
|
objectClass="org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile"
|
||||||
namefilter="*.jar"´
|
nameFilter="*.jar"
|
||||||
id="actions.jar">
|
id="actions.jar">
|
||||||
<action
|
<action
|
||||||
label="Show contents"
|
label="Show contents"
|
||||||
|
@ -58,30 +52,54 @@ This will affect code generated by wizards. The source code shown assumes this o
|
||||||
Save and close the file.
|
Save and close the file.
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Create the Java package: right-click on the <B>src</B> source folder and select <B>New->Package</B> to open the <B>New
|
Right-click on the project and use the <b>New...</b> action to create a new package in this project named <b>samples.ui.actions</b>.
|
||||||
Java Package</B> wizard. Enter <B>"samples.ui.actions"</B> for the name of the package and press <B>Finish</B>.</li>
|
|
||||||
<li>
|
|
||||||
Create the Java class: right-click on the new <B>"samples.ui.actions"</B> package folder and select <B>New->Class</B> to open the <B>New
|
|
||||||
Java Class</B> wizard. Enter <B>"ShowJarContents"</B> for the <b>Name</b>
|
|
||||||
and <b>"org.eclipse.rse.files.ui.actions.SystemAbstractRemoteFilePopupMenuExtensionAction"</b>
|
|
||||||
for the <b>Superclass</b>. Select the <b>Constructors from superclass</b> check box, as shown
|
|
||||||
<A href="popup_newClass.gif">here</A>.
|
|
||||||
Press <b>Finish</b> to create the <samp><a href="ShowJarContents1.html">ShowJarContents</a></samp> class.
|
|
||||||
</li>
|
</li>
|
||||||
<li>Edit the generated <samp>ShowJarContents.java</samp> file as follows:
|
<li>
|
||||||
|
Create the Java class: right-click on the new <B>samples.ui.actions</B> package folder and select <B>New->Class</B> to open the <B>New
|
||||||
|
Java Class</B> wizard.
|
||||||
|
Enter <B>"ShowJarContents"</B> for the <b>Name</b>, add <b>IObjectActionDelegate</b>
|
||||||
|
to the <b>Interfaces</b> that are implemented, and check the <b>constructors from superclass</b> checkbox as shown
|
||||||
|
<A href="popup_newClass.gif">here</A>.
|
||||||
|
Click <b>Finish</b> to create the <samp><a href="ShowJarContents1.html">ShowJarContents</a></samp> class.
|
||||||
|
</li>
|
||||||
|
<li>Edit the generated <samp>ShowJarContents.java</samp> file as follows.
|
||||||
|
Use the "Source -> Organize Imports" context menu item to add the appropriate import statements as you edit.
|
||||||
<ol>
|
<ol>
|
||||||
<li type="i">Add the following three statements to the body of the <samp>run()</samp> method:</li>
|
<li type="i">Add an instance variable to hold a list of remote files and initialize it in the constructor.</li>
|
||||||
<pre><code>
|
<pre><code>
|
||||||
IRemoteFile selectedFile = getFirstSelectedRemoteFile();
|
private List _selectedFiles;
|
||||||
String cmdToRun = "jar -tvf " + selectedFile.getAbsolutePath();
|
|
||||||
runCommand(cmdToRun);
|
/**
|
||||||
|
* Constructor for ShowJarContents.
|
||||||
|
*/
|
||||||
|
public ShowJarContents() {
|
||||||
|
_selectedFiles = new ArrayList();
|
||||||
|
}
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<li type="i">Add the following two methods to find the subsystem and run the command:</li>
|
<li type="i">Add the following three utility methods</li>
|
||||||
<pre><code>
|
<pre><code>
|
||||||
private void runCommand(String command) {
|
protected Shell getShell() {
|
||||||
|
return SystemBasePlugin.getActiveWorkbenchShell();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IRemoteFile getFirstSelectedRemoteFile() {
|
||||||
|
if (_selectedFiles.size() > 0) {
|
||||||
|
return (IRemoteFile)_selectedFiles.get(0);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ISubSystem getSubSystem() {
|
||||||
|
return getFirstSelectedRemoteFile().getParentRemoteFileSubSystem();
|
||||||
|
}
|
||||||
|
</code></pre>
|
||||||
|
<li type="i">Add the following methods to find the subsystem and run the command:</li>
|
||||||
|
<pre><code>
|
||||||
|
public void runCommand(String command) {
|
||||||
IRemoteCmdSubSystem cmdss = getRemoteCmdSubSystem();
|
IRemoteCmdSubSystem cmdss = getRemoteCmdSubSystem();
|
||||||
if (cmdss != null && cmdss.isConnected()) {
|
if (cmdss != null && cmdss.isConnected()) {
|
||||||
RemoteCommandHelpers.runUniversalCommand(getShell(), command, ".", cmdss);
|
// Run the command in a visible shell
|
||||||
|
RemoteCommandHelpers.runUniversalCommand(getShell(), command, ".", cmdss); //$NON-NLS-1$
|
||||||
} else {
|
} else {
|
||||||
MessageDialog.openError(getShell(), "No command subsystem", "Found no command subsystem");
|
MessageDialog.openError(getShell(), "No command subsystem", "Found no command subsystem");
|
||||||
}
|
}
|
||||||
|
@ -90,7 +108,7 @@ Press <b>Finish</b> to create the <samp><a href="ShowJarContents1.html">ShowJarC
|
||||||
/**
|
/**
|
||||||
* Gets the Command subsystem associated with the current host
|
* Gets the Command subsystem associated with the current host
|
||||||
*/
|
*/
|
||||||
private IRemoteCmdSubSystem getRemoteCmdSubSystem() {
|
public IRemoteCmdSubSystem getRemoteCmdSubSystem() {
|
||||||
IHost myHost = getSubSystem().getHost();
|
IHost myHost = getSubSystem().getHost();
|
||||||
IRemoteCmdSubSystem[] subsys = RemoteCommandHelpers.getCmdSubSystems(myHost);
|
IRemoteCmdSubSystem[] subsys = RemoteCommandHelpers.getCmdSubSystems(myHost);
|
||||||
for (int i = 0; i < subsys.length; i++) {
|
for (int i = 0; i < subsys.length; i++) {
|
||||||
|
@ -101,15 +119,45 @@ Press <b>Finish</b> to create the <samp><a href="ShowJarContents1.html">ShowJarC
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<li type="i">User the "Source -> Organize Imports" context menu item to add the appropriate import statements.</li>
|
<li type="i">Finally, flesh out the methods that were created as stubs</li>
|
||||||
|
<pre><code>
|
||||||
|
public void run(IAction action) {
|
||||||
|
IRemoteFile selectedFile = getFirstSelectedRemoteFile();
|
||||||
|
String cmdToRun = "jar -tvf " + selectedFile.getAbsolutePath(); //$NON-NLS-1$
|
||||||
|
try {
|
||||||
|
runCommand(cmdToRun);
|
||||||
|
} catch (Exception e) {
|
||||||
|
String excType = e.getClass().getName();
|
||||||
|
MessageDialog.openError(getShell(), excType, excType + ": " + e.getLocalizedMessage()); //$NON-NLS-1$
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectionChanged(org.eclipse.jface.action.IAction action, org.eclipse.jface.viewers.ISelection selection) {
|
||||||
|
_selectedFiles.clear();
|
||||||
|
// store the selected jars to be used when running
|
||||||
|
Iterator theSet = ((IStructuredSelection) selection).iterator();
|
||||||
|
while (theSet.hasNext()) {
|
||||||
|
Object obj = theSet.next();
|
||||||
|
if (obj instanceof IRemoteFile) {
|
||||||
|
_selectedFiles.add(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
||||||
|
}
|
||||||
|
</code></pre>
|
||||||
</ol>
|
</ol>
|
||||||
The final result after editing is shown <a href="ShowJarContents2.html">here</a>.
|
The final result after editing is shown <a href="ShowJarContents2.html">here</a>.
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<p>Thats it! Now, you can try your new action. Use <b>Run->Run As->Run-time Workbench</b>. Drill
|
<p>
|
||||||
|
Now, you can try your new action. Use <b>Run->Run As->Eclipse Application</b>.
|
||||||
|
Drill
|
||||||
down in the RSE to a Jar file in a local or remote connection and right-click to <a href="popup_see.gif">see</a> and <a href="popup_run.gif">run</a> your new action. Notice
|
down in the RSE to a Jar file in a local or remote connection and right-click to <a href="popup_see.gif">see</a> and <a href="popup_run.gif">run</a> your new action. Notice
|
||||||
how it does not appear for files that do not end with the ".jar" extension. This is because of the "namefilter" attribute
|
how it does not appear for files that do not end with the ".jar" extension. This is because of the "nameFilter" attribute
|
||||||
in our extension point .xml file.
|
in our extension point .xml file.
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 22 KiB |
|
@ -12,6 +12,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE.
|
* Martin Oberhuber (Wind River) - Adapted original tutorial code to Open RSE.
|
||||||
|
* David Dykstal (IBM) - formatting for tutorial
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package samples.ui.actions;
|
package samples.ui.actions;
|
||||||
|
@ -47,40 +48,33 @@ import org.eclipse.ui.IWorkbenchPart;
|
||||||
* An action that runs a command to display the contents of a Jar file.
|
* An action that runs a command to display the contents of a Jar file.
|
||||||
* The plugin.xml file restricts this action so it only appears for .jar files.
|
* The plugin.xml file restricts this action so it only appears for .jar files.
|
||||||
*/
|
*/
|
||||||
public class ShowJarContents implements IObjectActionDelegate
|
public class ShowJarContents implements IObjectActionDelegate {
|
||||||
{
|
|
||||||
private List _selectedFiles;
|
private List _selectedFiles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for ShowJarContents.
|
* Constructor for ShowJarContents.
|
||||||
*/
|
*/
|
||||||
public ShowJarContents()
|
public ShowJarContents() {
|
||||||
{
|
|
||||||
_selectedFiles = new ArrayList();
|
_selectedFiles = new ArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Shell getShell()
|
protected Shell getShell() {
|
||||||
{
|
|
||||||
return SystemBasePlugin.getActiveWorkbenchShell();
|
return SystemBasePlugin.getActiveWorkbenchShell();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IRemoteFile getFirstSelectedRemoteFile()
|
protected IRemoteFile getFirstSelectedRemoteFile() {
|
||||||
{
|
if (_selectedFiles.size() > 0) {
|
||||||
if (_selectedFiles.size() > 0)
|
|
||||||
{
|
|
||||||
return (IRemoteFile) _selectedFiles.get(0);
|
return (IRemoteFile) _selectedFiles.get(0);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ISubSystem getSubSystem()
|
protected ISubSystem getSubSystem() {
|
||||||
{
|
|
||||||
return getFirstSelectedRemoteFile().getParentRemoteFileSubSystem();
|
return getFirstSelectedRemoteFile().getParentRemoteFileSubSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.rse.ui.actions.SystemAbstractPopupMenuExtensionAction#run()
|
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||||
*/
|
*/
|
||||||
public void run(IAction action) {
|
public void run(IAction action) {
|
||||||
IRemoteFile selectedFile = getFirstSelectedRemoteFile();
|
IRemoteFile selectedFile = getFirstSelectedRemoteFile();
|
||||||
|
@ -106,10 +100,7 @@ public class ShowJarContents implements IObjectActionDelegate
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void runCommand(String command) throws Exception {
|
||||||
|
|
||||||
public void runCommand(String command) throws Exception
|
|
||||||
{
|
|
||||||
IRemoteCmdSubSystem cmdss = getRemoteCmdSubSystem();
|
IRemoteCmdSubSystem cmdss = getRemoteCmdSubSystem();
|
||||||
if (cmdss != null && cmdss.isConnected()) {
|
if (cmdss != null && cmdss.isConnected()) {
|
||||||
//Option A: run the command invisibly through SubSystem API
|
//Option A: run the command invisibly through SubSystem API
|
||||||
|
@ -133,8 +124,7 @@ public class ShowJarContents implements IObjectActionDelegate
|
||||||
}
|
}
|
||||||
|
|
||||||
/** New version of running commands through IShellService / IHostShell */
|
/** New version of running commands through IShellService / IHostShell */
|
||||||
public void runCommandInvisiblyService(IRemoteCmdSubSystem cmdss, String command) throws Exception
|
public void runCommandInvisiblyService(IRemoteCmdSubSystem cmdss, String command) throws Exception {
|
||||||
{
|
|
||||||
if (cmdss instanceof IShellServiceSubSystem) {
|
if (cmdss instanceof IShellServiceSubSystem) {
|
||||||
IShellService shellService = ((IShellServiceSubSystem) cmdss).getShellService();
|
IShellService shellService = ((IShellServiceSubSystem) cmdss).getShellService();
|
||||||
String[] environment = new String[1];
|
String[] environment = new String[1];
|
||||||
|
@ -152,8 +142,7 @@ public class ShowJarContents implements IObjectActionDelegate
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Old version of running commands through the command subsystem */
|
/** Old version of running commands through the command subsystem */
|
||||||
public void runCommandInvisibly(IRemoteCmdSubSystem cmdss, String command) throws Exception
|
public void runCommandInvisibly(IRemoteCmdSubSystem cmdss, String command) throws Exception {
|
||||||
{
|
|
||||||
command = command + cmdss.getParentRemoteCmdSubSystemConfiguration().getCommandSeparator() + "exit"; //$NON-NLS-1$
|
command = command + cmdss.getParentRemoteCmdSubSystemConfiguration().getCommandSeparator() + "exit"; //$NON-NLS-1$
|
||||||
Object[] result = cmdss.runCommand(command, null, false, new NullProgressMonitor());
|
Object[] result = cmdss.runCommand(command, null, false, new NullProgressMonitor());
|
||||||
if (result.length > 0 && result[0] instanceof IRemoteCommandShell) {
|
if (result.length > 0 && result[0] instanceof IRemoteCommandShell) {
|
||||||
|
@ -173,24 +162,18 @@ public class ShowJarContents implements IObjectActionDelegate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectionChanged(org.eclipse.jface.action.IAction action,
|
public void selectionChanged(org.eclipse.jface.action.IAction action, org.eclipse.jface.viewers.ISelection selection) {
|
||||||
org.eclipse.jface.viewers.ISelection selection)
|
|
||||||
{
|
|
||||||
_selectedFiles.clear();
|
_selectedFiles.clear();
|
||||||
// store the selected jars to be used when running
|
// store the selected jars to be used when running
|
||||||
Iterator theSet = ((IStructuredSelection) selection).iterator();
|
Iterator theSet = ((IStructuredSelection) selection).iterator();
|
||||||
while (theSet.hasNext())
|
while (theSet.hasNext()) {
|
||||||
{
|
|
||||||
Object obj = theSet.next();
|
Object obj = theSet.next();
|
||||||
if (obj instanceof IRemoteFile)
|
if (obj instanceof IRemoteFile) {
|
||||||
{
|
|
||||||
_selectedFiles.add(obj);
|
_selectedFiles.add(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue