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 StartServerAction implements
022: IWorkbenchWindowActionDelegate {
023:
024: /**
025: * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
026: */
027: public void dispose() {
028: }
029:
030: /**
031: * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(IWorkbenchWindow)
032: */
033: public void init(IWorkbenchWindow window) {
034: }
035:
036: /**
037: * @see org.eclipse.ui.IActionDelegate#run(IAction)
038: */
039: public void run(IAction action) {
040: String serverType = SalmonPlugin.getServerType();
041: if (serverType != null)
042: startServer(serverType, null);
043: }
044:
045: public static void startServer(String type, String[] extraArgs) {
046: try {
047: //check for a framework project before running
048: if (!SalmonPlugin.isFrameworkFound()) {
049: SalmonPlugin
050: .displayError(
051: "Error Starting the Server",
052: "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.");
053: return;
054: }
055:
056: String classPath[] = SalmonPlugin.getClassPath(false);
057: String salmonPropsPath = SalmonPlugin.getSalmonPropsPath();
058: Props p = SalmonPlugin.getSystemProps();
059:
060: String workingDir = p
061: .getProperty(Props.IDE_WORKING_DIRECTORY);
062:
063: Vector extraVmArgs = new Vector();
064: String classToLaunch = "";
065: String[] progArgs = new String[0];
066:
067: if (salmonPropsPath != null)
068: extraVmArgs.addElement("-Dsalmon.props.path="
069: + salmonPropsPath);
070: String libPath = p.getProperty(Props.IDE_LIBPATH);
071: if (libPath != null && !libPath.equals(""))
072: extraVmArgs
073: .addElement("-Djava.library.path=" + libPath);
074:
075: if (type.equals(IDETool.SERVER_WEBLOGIC6)) {
076: classToLaunch = "weblogic.Server";
077: String wlPw = p
078: .getProperty(Props.IDE_SERVER_MANAGER_PW);
079: if (wlPw != null)
080: extraVmArgs
081: .addElement("-Dweblogic.management.password="
082: + wlPw);
083: } else {
084: classToLaunch = "com.salmonllc.ideTools.IDETool";
085: if (extraArgs == null)
086: progArgs = new String[] { "-RESTART" };
087: else {
088: progArgs = new String[1 + extraArgs.length];
089: for (int i = 0; i < extraArgs.length; i++)
090: progArgs[i] = extraArgs[i];
091: progArgs[extraArgs.length] = "-RESTART";
092: }
093: }
094: String vmArgs[] = SalmonPlugin.getVMArgs(extraVmArgs);
095: ProgramLauncher.runProgram(classToLaunch, classPath,
096: vmArgs, progArgs, workingDir, true);
097: } catch (Exception e) {
098: e.printStackTrace();
099: }
100: }
101:
102: /**
103: * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
104: */
105: public void selectionChanged(IAction action, ISelection selection) {
106: }
107:
108: }
|