001: package com.salmonllc.ideTools.eclipse;
002:
003: import java.util.Vector;
004:
005: import org.eclipse.jface.action.IAction;
006: import org.eclipse.jface.viewers.ISelection;
007: import org.eclipse.ui.IWorkbenchWindow;
008: import org.eclipse.ui.IWorkbenchWindowActionDelegate;
009:
010: import com.salmonllc.ideTools.IDETool;
011: import com.salmonllc.properties.Props;
012:
013: /**
014: * @author Administrator
015: *
016: * To change this generated comment edit the template variable "typecomment":
017: * Window>Preferences>Java>Templates.
018: * To enable and disable the creation of type comments go to
019: * Window>Preferences>Java>Code Generation.
020: */
021: public class StopServerAction implements IWorkbenchWindowActionDelegate {
022:
023: /**
024: * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
025: */
026: public void dispose() {
027: }
028:
029: /**
030: * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(IWorkbenchWindow)
031: */
032: public void init(IWorkbenchWindow window) {
033: }
034:
035: /**
036: * @see org.eclipse.ui.IActionDelegate#run(IAction)
037: */
038: public void run(IAction action) {
039: String serverType = SalmonPlugin.getServerType();
040: if (serverType != null)
041: stopServer(serverType);
042: }
043:
044: private void stopServer(String type) {
045: try {
046: //check for a framework project before running
047: if (!SalmonPlugin.isFrameworkFound()) {
048: SalmonPlugin
049: .displayError(
050: "Error Stopping the Server",
051: "SOFIA framework project not found in workspace. You can install the framework project by going to File->New->Project. If you have already installed the SOFIA project, make sure it's open.");
052: return;
053: }
054:
055: Props p = SalmonPlugin.getSystemProps();
056: String salmonPropsPath = SalmonPlugin.getSalmonPropsPath();
057: String classPath[] = SalmonPlugin.getClassPath(false);
058: String workingDir = p
059: .getProperty(Props.IDE_WORKING_DIRECTORY);
060:
061: Vector extraVmArgs = new Vector();
062: String classToLaunch = "";
063: String[] progArgs = null;
064:
065: if (salmonPropsPath != null)
066: extraVmArgs.addElement("-Dsalmon.props.path="
067: + salmonPropsPath);
068: String libPath = p.getProperty(Props.IDE_LIBPATH);
069: if (libPath != null)
070: extraVmArgs
071: .addElement("-Djava.library.path=" + libPath);
072:
073: if (type.equals(IDETool.SERVER_WEBLOGIC6)) {
074: classToLaunch = "weblogic.Admin";
075: String user = p
076: .getProperty(Props.IDE_SERVER_MANAGER_ID);
077: String pw = p.getProperty(Props.IDE_SERVER_MANAGER_PW);
078: String host = p.getProperty(Props.IDE_DEFAULT_HOST);
079: progArgs = new String[] { "-url", host, "SHUTDOWN",
080: "-username", user, "-password", pw };
081:
082: } else {
083: classToLaunch = "com.salmonllc.ideTools.IDETool";
084: progArgs = new String[] { "-STOP" };
085: }
086: String vmArgs[] = SalmonPlugin.getVMArgs(extraVmArgs);
087: ProgramLauncher.runProgram(classToLaunch, classPath,
088: vmArgs, progArgs, workingDir, false);
089: } catch (Exception e) {
090: e.printStackTrace();
091: }
092: }
093:
094: /**
095: * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
096: */
097: public void selectionChanged(IAction action, ISelection selection) {
098: }
099:
100: }
|