package samples.ui.actions; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.files.ui.actions.SystemAbstractRemoteFilePopupMenuExtensionAction; import org.eclipse.rse.shells.ui.RemoteCommandHelpers; import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; import org.eclipse.rse.subsystems.shells.core.subsystems.IRemoteCmdSubSystem; public class ShowJarContents2 extends SystemAbstractRemoteFilePopupMenuExtensionAction { public ShowJarContents2() { 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 */ private IRemoteCmdSubSystem getRemoteCmdSubSystem() { IHost myHost = getSubSystem().getHost(); IRemoteCmdSubSystem[] subsys = RemoteCommandHelpers.getCmdSubSystems(myHost); for (int i = 0; i < subsys.length; i++) { if (subsys[i].getSubSystemConfiguration().supportsCommands()) { return subsys[i]; } } return null; } }