Java 类org.eclipse.debug.core.model.IProcess 实例源码

项目:google-cloud-eclipse    文件:FlexMavenPackagedProjectStagingDelegate.java   
/**
 * Waits until {@code launch} terminates or {@code monitor} is canceled. if the monitor is
 * canceled, attempts to terminate the launch before returning.
 *
 * @return true if the launch terminated normally; false otherwise
 */
@VisibleForTesting
static boolean waitUntilLaunchTerminates(ILaunch launch, IProgressMonitor monitor)
    throws InterruptedException, DebugException {
  while (!launch.isTerminated() && !monitor.isCanceled()) {
    Thread.sleep(100 /*ms*/);
  }

  if (monitor.isCanceled()) {
    launch.terminate();
    return false;
  }
  for (IProcess process : launch.getProcesses()) {
    if (process.getExitValue() != 0) {
      return false;
    }
  }
  return true;
}
项目:google-cloud-eclipse    文件:FlexMavenPackagedProjectStagingDelegateTest.java   
@Test
public void testWaitUntilLaunchTerminates_atLeastOneNonZeroExit()
    throws DebugException, InterruptedException {
  IProcess process = mock(IProcess.class);
  when(process.getExitValue()).thenReturn(0);
  IProcess nonZeroExitProcess = mock(IProcess.class);
  when(nonZeroExitProcess.getExitValue()).thenReturn(1);

  ILaunch launch = mock(ILaunch.class);
  when(launch.isTerminated()).thenReturn(true);
  when(launch.getProcesses()).thenReturn(new IProcess[] {process, nonZeroExitProcess});

  boolean normalExit = FlexMavenPackagedProjectStagingDelegate.waitUntilLaunchTerminates(
      launch, new NullProgressMonitor());
  assertFalse(normalExit);
}
项目:gwt-eclipse-plugin    文件:GwtWtpPlugin.java   
private void onAfterCodeServerStarted(DebugEvent event) {
  if (!(event.getSource() instanceof IProcess)) {
    return;
  }

  IProcess runtimeProcess = (IProcess) event.getSource();
  final ILaunch launch = runtimeProcess.getLaunch();
  IProcess[] processes = launch.getProcesses();
  final IProcess process = processes[0];

  // Look for the links in the sdm console output
  consoleStreamListenerCodeServer = new IStreamListener() {
    @Override
    public void streamAppended(String text, IStreamMonitor monitor) {
      displayCodeServerUrlInDevMode(launch, text);
    }
  };

  // Listen to Console output
  streamMonitorCodeServer = process.getStreamsProxy().getOutputStreamMonitor();
  streamMonitorCodeServer.addListener(consoleStreamListenerCodeServer);
}
项目:brainfuck    文件:FlushConsoleHandler.java   
private ConsoleStreamFlusher getFlusher(Object context) {
    if (context instanceof IEvaluationContext) {
        IEvaluationContext evaluationContext = (IEvaluationContext) context;
        Object o = evaluationContext.getVariable(ISources.ACTIVE_PART_NAME);
        if (!(o instanceof IWorkbenchPart)) {
            return null;
        }
        IWorkbenchPart part = (IWorkbenchPart) o;
        if (part instanceof IConsoleView && ((IConsoleView) part).getConsole() instanceof IConsole) {
            IConsole activeConsole = (IConsole) ((IConsoleView) part).getConsole();
            IProcess process = activeConsole.getProcess();
            return (ConsoleStreamFlusher) process.getAdapter(ConsoleStreamFlusher.class);
        }
    }
    return null;
}
项目:thym    文件:AndroidSDKManager.java   
/**
 * Wait for Android Emulator
 * @param emulatorProcess android emulator process
 * @param monitor progress monitor to be checked for cancellation
 * @throws CoreException
 */
public void waitForEmulator(IProcess emulatorProcess, IProgressMonitor monitor) throws CoreException{
    while(!emulatorProcess.isTerminated()){ //check if process is terminated - could not start etc..
        List<AndroidDevice> devices = this.listDevices();
        if(devices != null ){
            for (AndroidDevice androidDevice : devices) {
                if(androidDevice.isEmulator() && androidDevice.getState() == AndroidDevice.STATE_DEVICE)
                    return;
            }
        }
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            throw new CoreException(new Status(IStatus.ERROR, AndroidCore.PLUGIN_ID, "Exception occured while waiting for emulator",e));
        }
        if (monitor.isCanceled()){
            throw new CoreException(new Status(IStatus.ERROR, AndroidCore.PLUGIN_ID, "Operation cancelled"));
        }
    }
    throw new CoreException(new Status(IStatus.ERROR, AndroidCore.PLUGIN_ID, "Android emulator was terminated"));
}
项目:thym    文件:ExternalProcessUtility.java   
/**
 * Executes the given command and returns a handle to the 
 * process. Should only be used if access to {@link IProcess}
 * instance is desired. 
 * 
 * @param command
 * @param workingDirectory
 * @param monitor
 * @param envp
 * @param launchConfiguration
 * @param outStreamListener
 * @param errorStreamListener
 * @return the process
 * @throws CoreException
 */
public IProcess exec(String[] command, File workingDirectory, IProgressMonitor monitor, 
        String[] envp, ILaunchConfiguration launchConfiguration, 
        IStreamListener outStreamListener, IStreamListener errorStreamListener ) throws CoreException{

    checkCommands(command);
    checkWorkingDirectory(workingDirectory);
    if(monitor == null ){
        monitor = new NullProgressMonitor();
    }
    if (envp == null && launchConfiguration != null ){
        envp = DebugPlugin.getDefault().getLaunchManager().getEnvironment(launchConfiguration);
    }
    if (monitor.isCanceled()) {
        return null;
    }
    Process process = DebugPlugin.exec(command, workingDirectory, envp);

    Map<String, String> processAttributes = generateProcessAttributes(command, launchConfiguration);
    Launch launch = new Launch(launchConfiguration, "run", null);
    IProcess prcs = DebugPlugin.newProcess(launch, process, command[0], processAttributes);
    setTracing(command, outStreamListener, errorStreamListener, prcs);
    DebugPlugin.getDefault().getLaunchManager().addLaunch(launch);
    return prcs;
}
项目:thym    文件:ExternalProcessUtility.java   
private void setTracing(String[] command, IStreamListener outStreamListener, IStreamListener errorStreamListener,
        IProcess prcs) {
    if(HybridCore.DEBUG){
        HybridCore.trace("Creating TracingStreamListeners for " + Arrays.toString(command));
        outStreamListener = new TracingStreamListener(outStreamListener);
        errorStreamListener = new TracingStreamListener(outStreamListener);
    }

    if( outStreamListener != null ){
        prcs.getStreamsProxy().getOutputStreamMonitor().addListener(outStreamListener);
        //See bug 121454. Ensure that output to fast processes is processed
        outStreamListener.streamAppended(prcs.getStreamsProxy().getOutputStreamMonitor().getContents(), null);
    }

    if( errorStreamListener != null ){
        prcs.getStreamsProxy().getErrorStreamMonitor().addListener(errorStreamListener);
        //See bug 121454. Ensure that output to fast processes is processed
        errorStreamListener.streamAppended(prcs.getStreamsProxy().getErrorStreamMonitor().getContents(), null);
    }
}
项目:thym    文件:CordovaCLI.java   
protected ILaunchConfiguration getLaunchConfiguration(String label){
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = manager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE);
    try {
        ILaunchConfiguration cfg = type.newInstance(null, "cordova");
        ILaunchConfigurationWorkingCopy wc = cfg.getWorkingCopy();
        wc.setAttribute(IProcess.ATTR_PROCESS_LABEL, label);
        if(additionalEnvProps != null && !additionalEnvProps.isEmpty()){
            wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES,additionalEnvProps);
        }
        cfg = wc.doSave();
        return cfg;
    } catch (CoreException e) {
        e.printStackTrace();
    }
    return null;
}
项目:birt    文件:StandardScriptVMRunner.java   
/**
 * Checks and forwards an error from the specified process
 * 
 * @param process
 * @throws CoreException
 */
private void checkErrorMessage( IProcess process ) throws CoreException
{
    IStreamsProxy streamsProxy = process.getStreamsProxy( );
    if ( streamsProxy != null )
    {
        String errorMessage = streamsProxy.getErrorStreamMonitor( )
                .getContents( );
        if ( errorMessage.length( ) == 0 )
        {
            errorMessage = streamsProxy.getOutputStreamMonitor( )
                    .getContents( );
        }
        if ( errorMessage.length( ) != 0 )
        {
            abort( errorMessage,
                    null,
                    IJavaLaunchConfigurationConstants.ERR_VM_LAUNCH_ERROR );
        }
    }
}
项目:Pydev    文件:InteractiveConsolePlugin.java   
/**
 * Removes a launch from a pydev console and stops the related process (may be called from a thread).
 *
 * @param launch the launch to be removed
 */
public void removeConsoleLaunch(ILaunch launch) {
    boolean removed;
    synchronized (consoleLaunchesLock) {
        removed = consoleLaunches.remove(launch);
    }
    if (removed) {
        IProcess[] processes = launch.getProcesses();
        if (processes != null) {
            for (IProcess p : processes) {
                try {
                    p.terminate();
                } catch (Exception e) {
                    Log.log(e);
                }
            }
        }
    }
}
项目:Pydev    文件:PydevIProcessFactory.java   
public static String getEncodingFromFrame(PyStackFrame selectedFrame) {
    try {
        IDebugTarget adapter = (IDebugTarget) selectedFrame.getAdapter(IDebugTarget.class);
        if (adapter == null) {
            return "UTF-8";
        }
        IProcess process = adapter.getProcess();
        if (process == null) {
            return "UTF-8";
        }
        ILaunch launch = process.getLaunch();
        if (launch == null) {
            Log.log("Unable to get launch for: " + process);
            return "UTF-8";
        }
        return getEncodingFromLaunch(launch);
    } catch (Exception e) {
        Log.log(e);
        return "UTF-8";
    }
}
项目:Pydev    文件:PyDebugTarget.java   
public PyDebugTarget(ILaunch launch, IProcess process, IPath[] file, AbstractRemoteDebugger debugger,
        IProject project, boolean isAuxiliaryDebugTarget) {
    this.launch = launch;
    this.process = process;
    this.file = file;
    this.debugger = debugger;
    this.threads = new PyThread[0];
    this.project = project;
    this.isAuxiliaryDebugTarget = isAuxiliaryDebugTarget;
    launch.addDebugTarget(this);
    debugger.addTarget(this);
    IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
    breakpointManager.addBreakpointListener(this);
    PyExceptionBreakPointManager.getInstance().addListener(this);
    PyPropertyTraceManager.getInstance().addListener(this);
    // we have to know when we get removed, so that we can shut off the debugger
    DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
}
项目:Pydev    文件:PromptOverlayConsolePageParticipant.java   
@Override
public void init(IPageBookViewPage page, IConsole console) {
    if (!(console instanceof ProcessConsole)) {
        return;
    }
    ProcessConsole processConsole = (ProcessConsole) console;
    IProcess process = processConsole.getProcess();
    if (process == null) {
        return;
    }

    String attribute = process.getAttribute(Constants.PYDEV_DEBUG_IPROCESS_ATTR);
    if (!Constants.PYDEV_DEBUG_IPROCESS_ATTR_TRUE.equals(attribute)) {
        //Only provide the console page
        return;
    }
    if (page instanceof IOConsolePage) {
        final CurrentPyStackFrameForConsole currentPyStackFrameForConsole = new CurrentPyStackFrameForConsole(
                console);
        IOConsolePage consolePage = (IOConsolePage) page;
        this.promptOverlay = new PromptOverlay(consolePage, processConsole, currentPyStackFrameForConsole);
    }

}
项目:Pydev    文件:PythonConsoleLineTracker.java   
@Override
public void init(final IConsole console) {
    IProcess process = console.getProcess();
    if (process != null) {
        ILaunch launch = process.getLaunch();
        if (launch != null) {
            initLaunchConfiguration(launch.getLaunchConfiguration());
        }
    }
    this.linkContainer = new ILinkContainer() {

        @Override
        public void addLink(IHyperlink link, int offset, int length) {
            console.addLink(link, offset, length);
        }

        @Override
        public String getContents(int offset, int length) throws BadLocationException {
            return console.getDocument().get(offset, length);
        }
    };
}
项目:Pydev    文件:RestartLaunchAction.java   
@Override
public void update() {
    IProcess process = console.getProcess();
    setEnabled(true);
    KeySequence binding = KeyBindingHelper
            .getCommandKeyBinding("org.python.pydev.debug.ui.actions.relaunchLastAction");
    String str = binding != null ? "(" + binding.format() + " with focus on editor)" : "(unbinded)";
    if (process.canTerminate()) {
        this.setImageDescriptor(SharedUiPlugin.getImageCache().getDescriptor(UIConstants.RELAUNCH));
        this.setToolTipText("Restart the current launch. " + str);

    } else {
        this.setImageDescriptor(SharedUiPlugin.getImageCache().getDescriptor(UIConstants.RELAUNCH1));
        this.setToolTipText("Relaunch with the same configuration." + str);
    }
}
项目:goclipse    文件:EclipseProcessLauncher.java   
protected IProcess launchProcess(final ILaunch launch) throws CoreException, CommonException {
    if(workingDir != null && !workingDir.toFile().exists()) {
        fail(LaunchMessages.errWorkingDirectoryDoesntExist, workingDir);
    }
    if(!programFileLocation.toFile().exists()) {
        fail(LaunchMessages.errExecutableFileDoesntExist, programFileLocation);
    }

    CommandInvocation programInvocation = unresolvedProgramInvocation.getResolvedCommandInvocation(
        new VariablesResolver(VariablesPlugin.getDefault().getStringVariableManager()));

    Indexable<String> cmdLine = programInvocation.parseCommandLineArguments();
    Process sp = newSystemProcess(programInvocation);

    return newEclipseProcessWithLabelUpdater(launch, cmdLine, sp);
}
项目:dLabPro-Plugin    文件:AbstractConsoleViewActionDelegate.java   
public void update()
{
  // Set enabled state
  m_iAction.setEnabled(getEnabled());

  // Add or removed action to/from the local console view tool bar
  if (m_iProc==null)
  {
    removeFromToolBar();
    return;
  }

  String sProcType = m_iProc.getAttribute(IProcess.ATTR_PROCESS_TYPE);
  if (sProcType.equals(LaunchUtil.PT_DLABPRO)) addToToolBar();
  else removeFromToolBar();
}
项目:dLabPro-Plugin    文件:StepConsoleViewActionDelegate.java   
public boolean getEnabled()
{
  if (getAction()==null) return false;
  getAction().setToolTipText("Step");

  IProcess iProc = getProcess();
  if (iProc==null) return false;
  String sCommand = iProc.getAttribute(IProcess.ATTR_CMDLINE);
  if (sCommand==null) return false;
  if (sCommand.indexOf("--in-IDE")<0)
  {
    getAction().setToolTipText("Step (Disabled because dLabPro was " +
        "started without option --in-IDE)");
    return false;
  }
  return iProc.canTerminate();
}
项目:dLabPro-Plugin    文件:ContConsoleViewActionDelegate.java   
public boolean getEnabled()
{
  if (getAction() == null) return false;
  getAction().setToolTipText("Cont");

  IProcess iProc = getProcess();
  if (iProc==null) return false;
  String sCommand = iProc.getAttribute(IProcess.ATTR_CMDLINE);
  if (sCommand==null) return false;
  if (sCommand.indexOf("--in-IDE")<0)
  {
    getAction().setToolTipText("Cont (Disabled because dLabPro was " +
        "started without option --in-IDE)");
    return false;
  }
  return iProc.canTerminate();
}
项目:dLabPro-Plugin    文件:BreakConsoleViewActionDelegate.java   
public boolean getEnabled()
{
  if (getAction()==null) return false;
  getAction().setToolTipText("Break");

  IProcess iProc = getProcess();
  if (iProc==null) return false;
  String sCommand = iProc.getAttribute(IProcess.ATTR_CMDLINE);
  if (sCommand==null) return false;
  if (sCommand.indexOf("--in-IDE")<0)
  {
    getAction().setToolTipText("Break (Disabled because dLabPro was " +
        "started without option --in-IDE)");
    return false;
  }
  return iProc.canTerminate();
}
项目:egradle    文件:EGradleRuntimeProcess.java   
public static EGradleRuntimeProcess create(ILaunch launch, Process process, String name,
        Map<String, String> attributes) {
    // workaround, because attribute must be set before constructor call
    // DEFINE EGRADLE AS PROCESS TYPE - so console line tracker is able to track
            attributes.put(IProcess.ATTR_PROCESS_TYPE, "EGradleRuntimeProcess");
    return new EGradleRuntimeProcess(launch, process, name, attributes);
}
项目:gemfirexd-oss    文件:DerbyServerUtils.java   
public void handleDebugEvents(DebugEvent[] events) {
    // type of event was a terminate...
    if(events.length>0){
if (events[0].getKind() == DebugEvent.TERMINATE) {
    Object source = events[0].getSource();
    if (source instanceof IProcess) {
        // check for Derby Network Servre process.
        Object proj = servers.get(source);
        if (proj != null) {
            try {
                //remove it from the hashmap, update the ui
                servers.remove(source);
                if(proj instanceof IJavaProject){
                    setRunning(((IJavaProject)proj).getProject(), null);
                }else if(proj instanceof IProject){
                    setRunning((IProject)proj,null);
                }
            }
            catch (CoreException ce) {
                Logger.log("DerbyServerTracker.handleDebugEvents: "+ce, IStatus.ERROR);
            }catch(Exception e){
                Logger.log("DerbyServerTracker.handleDebugEvents: "+e, IStatus.ERROR);
            }
        }
    }
}
    }
 }
项目:gemfirexd-oss    文件:DerbyServerUtils.java   
public void startDerbyServer( IProject proj) throws CoreException {
    String args = CommonNames.START_DERBY_SERVER;
    String vmargs="";
    DerbyProperties dprop=new DerbyProperties(proj);
    //Starts the server as a Java app
    args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort();

    //Set Derby System Home from the Derby Properties
    if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
        vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
    }
    String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.START_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")";
    ILaunch launch = DerbyUtils.launch(proj, procName ,     
    CommonNames.DERBY_SERVER_CLASS, args, vmargs, CommonNames.START_DERBY_SERVER);
    IProcess ip=launch.getProcesses()[0];
    //set a name to be seen in the Console list
    ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);

    // saves the mapping between (server) process and project
    //servers.put(launch.getProcesses()[0], proj);
    servers.put(ip, proj);
    // register a listener to listen, when this process is finished
    DebugPlugin.getDefault().addDebugEventListener(listener);
    //Add resource listener
    IWorkspace workspace = ResourcesPlugin.getWorkspace();

    workspace.addResourceChangeListener(rlistener);
    setRunning(proj, Boolean.TRUE);
    Shell shell = new Shell();
    MessageDialog.openInformation(
        shell,
        CommonNames.PLUGIN_NAME,
        Messages.D_NS_ATTEMPT_STARTED+dprop.getPort()+".");

}
项目:gemfirexd-oss    文件:DerbyServerUtils.java   
public void stopDerbyServer( IProject proj) throws CoreException, ClassNotFoundException, SQLException {
    String args = CommonNames.SHUTDOWN_DERBY_SERVER;
    String vmargs="";
    DerbyProperties dprop=new DerbyProperties(proj);
    args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort();

    //  Set Derby System Home from the Derby Properties
    if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
        vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
    }
    String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.SHUTDOWN_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")";

    // starts the server as a Java app
    ILaunch launch = DerbyUtils.launch(proj, procName,
    CommonNames.DERBY_SERVER_CLASS, args, vmargs,CommonNames.SHUTDOWN_DERBY_SERVER);
    IProcess ip=launch.getProcesses()[0];

    //set a name to be seen in the Console list
    ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);

    //update the objectState
    setRunning(proj, Boolean.FALSE);
    if(proj.isOpen()){
        Shell shell = new Shell();
        MessageDialog.openInformation(
        shell,
        CommonNames.PLUGIN_NAME,
        Messages.D_NS_ATTEMPT_STOPPED+dprop.getPort()+"." );
    }
}
项目:gemfirexd-oss    文件:DerbyUtils.java   
public static void runIJ(IFile currentScript, IProject currentProject) throws CoreException {   

        String launchType="";
        String args="";

        //the above some times throws wrong 'create=true|false' errors
        String vmargs="";
        DerbyProperties dprop=new DerbyProperties(currentProject);
        if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
            vmargs+=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
        }

        if(currentScript!=null){
            launchType=CommonNames.SQL_SCRIPT;

            //Preferable to use the full String with quotes to take care of spaces 
            //in file names
            args="\""+currentScript.getLocation().toOSString()+"\"";
        }else{
            launchType=CommonNames.IJ;
            args="";    
        }

        ILaunch launch=launch(currentProject,launchType,CommonNames.IJ_CLASS,args, vmargs, CommonNames.IJ);
        IProcess ip=launch.getProcesses()[0];
        String procName="["+currentProject.getName()+"] - "+CommonNames.IJ+" "+args;
        ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
    }
项目:gemfirexd-oss    文件:DerbyUtils.java   
public static void runSysInfo(IProject currentProject) throws CoreException {   
    String args="";
    ILaunch launch=launch(currentProject,CommonNames.SYSINFO,CommonNames.SYSINFO_CLASS,args, null, CommonNames.SYSINFO);
    IProcess ip=launch.getProcesses()[0];
    String procName="["+currentProject.getName()+"] - "+CommonNames.SYSINFO;
    ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
}
项目:eclemma    文件:DumpExecutionDataHandler.java   
public void handleDebugEvents(DebugEvent[] events) {
  for (final DebugEvent e : events) {
    if (e.getSource() instanceof IProcess
        && e.getKind() == DebugEvent.TERMINATE) {
      fireEnablementChanged();
    }
  }
}
项目:eclemma    文件:EclEmmaCorePlugin.java   
public void handleDebugEvents(DebugEvent[] events) {
  for (final DebugEvent e : events) {
    if (e.getSource() instanceof IProcess
        && e.getKind() == DebugEvent.TERMINATE) {
      final IProcess proc = (IProcess) e.getSource();
      final ILaunch launch = proc.getLaunch();
      if (launch instanceof CoverageLaunch) {
        final CoverageLaunch coverageLaunch = (CoverageLaunch) launch;
        coverageLaunch.getAgentServer().stop();
        checkExecutionData(coverageLaunch);
      }
    }
  }
}
项目:google-cloud-eclipse    文件:DevAppServerProcessFactory.java   
@Override
public IProcess newProcess(ILaunch launch,
                           Process process,
                           String label,
                           Map<String, String> attributes) {
  return new DevAppServerRuntimeProcess(launch, process, label, attributes);
}
项目:google-cloud-eclipse    文件:FlexMavenPackagedProjectStagingDelegateTest.java   
@Test
public void testWaitUntilLaunchTerminates_normalExit()
    throws DebugException, InterruptedException {
  IProcess process = mock(IProcess.class);
  when(process.getExitValue()).thenReturn(0);

  ILaunch launch = mock(ILaunch.class);
  when(launch.isTerminated()).thenReturn(true);
  when(launch.getProcesses()).thenReturn(new IProcess[] {process, process});

  boolean normalExit = FlexMavenPackagedProjectStagingDelegate.waitUntilLaunchTerminates(
      launch, new NullProgressMonitor());
  assertTrue(normalExit);
}
项目:google-cloud-eclipse    文件:MockLaunch.java   
@Override
public boolean canTerminate() {
    for (IProcess p : processes) {
        if (p.canTerminate()) {
            return true;
        }
    }
    for (IDebugTarget t : targets) {
        if (t.canTerminate()) {
            return true;
        }
    }
    return false;
}
项目:google-cloud-eclipse    文件:MockLaunch.java   
@Override
public boolean isTerminated() {
    for (IProcess p : processes) {
        if (!p.isTerminated()) {
            return false;
        }
    }
    for (IDebugTarget t : targets) {
        if (!t.isTerminated()) {
            return false;
        }
    }
    return true;
}
项目:google-cloud-eclipse    文件:MockLaunch.java   
@Override
public void terminate() throws DebugException {
    for (Iterator<IProcess> iter = processes.iterator(); iter.hasNext(); iter.remove()) {
        IProcess p = iter.next();
        if (p.canTerminate()) {
            p.terminate();
        }
    }
    for (Iterator<IDebugTarget> iter = targets.iterator(); iter.hasNext(); iter.remove()) {
        IDebugTarget t = iter.next();
        if (t.canTerminate()) {
            t.terminate();
        }
    }
}
项目:tlaplus    文件:TLCProcessJob.java   
/**
 * Retrieves a process to a given ILaunch
 * @param launch
 * @return
 */
private static IProcess findProcessForLaunch(ILaunch launch)
{
    // find the process
    IProcess[] processes = DebugPlugin.getDefault().getLaunchManager().getProcesses();
    for (int i = 0; i < processes.length; i++)
    {
        if (processes[i].getLaunch().equals(launch))
        {
            return processes[i];
        }
    }
    return null;
}
项目:gemfirexd-oss    文件:DerbyServerUtils.java   
public void handleDebugEvents(DebugEvent[] events) {
    // type of event was a terminate...
    if(events.length>0){
if (events[0].getKind() == DebugEvent.TERMINATE) {
    Object source = events[0].getSource();
    if (source instanceof IProcess) {
        // check for Derby Network Servre process.
        Object proj = servers.get(source);
        if (proj != null) {
            try {
                //remove it from the hashmap, update the ui
                servers.remove(source);
                if(proj instanceof IJavaProject){
                    setRunning(((IJavaProject)proj).getProject(), null);
                }else if(proj instanceof IProject){
                    setRunning((IProject)proj,null);
                }
            }
            catch (CoreException ce) {
                Logger.log("DerbyServerTracker.handleDebugEvents: "+ce, IStatus.ERROR);
            }catch(Exception e){
                Logger.log("DerbyServerTracker.handleDebugEvents: "+e, IStatus.ERROR);
            }
        }
    }
}
    }
 }
项目:gemfirexd-oss    文件:DerbyServerUtils.java   
public void startDerbyServer( IProject proj) throws CoreException {
    String args = CommonNames.START_DERBY_SERVER;
    String vmargs="";
    DerbyProperties dprop=new DerbyProperties(proj);
    //Starts the server as a Java app
    args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort();

    //Set Derby System Home from the Derby Properties
    if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
        vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
    }
    String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.START_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")";
    ILaunch launch = DerbyUtils.launch(proj, procName ,     
    CommonNames.DERBY_SERVER_CLASS, args, vmargs, CommonNames.START_DERBY_SERVER);
    IProcess ip=launch.getProcesses()[0];
    //set a name to be seen in the Console list
    ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);

    // saves the mapping between (server) process and project
    //servers.put(launch.getProcesses()[0], proj);
    servers.put(ip, proj);
    // register a listener to listen, when this process is finished
    DebugPlugin.getDefault().addDebugEventListener(listener);
    //Add resource listener
    IWorkspace workspace = ResourcesPlugin.getWorkspace();

    workspace.addResourceChangeListener(rlistener);
    setRunning(proj, Boolean.TRUE);
    Shell shell = new Shell();
    MessageDialog.openInformation(
        shell,
        CommonNames.PLUGIN_NAME,
        Messages.D_NS_ATTEMPT_STARTED+dprop.getPort()+".");

}
项目:gemfirexd-oss    文件:DerbyServerUtils.java   
public void stopDerbyServer( IProject proj) throws CoreException, ClassNotFoundException, SQLException {
    String args = CommonNames.SHUTDOWN_DERBY_SERVER;
    String vmargs="";
    DerbyProperties dprop=new DerbyProperties(proj);
    args+=" -h "+dprop.getHost()+ " -p "+dprop.getPort();

    //  Set Derby System Home from the Derby Properties
    if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
        vmargs=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
    }
    String procName="["+proj.getName()+"] - "+CommonNames.DERBY_SERVER+" "+CommonNames.SHUTDOWN_DERBY_SERVER+" ("+dprop.getHost()+ ", "+dprop.getPort()+")";

    // starts the server as a Java app
    ILaunch launch = DerbyUtils.launch(proj, procName,
    CommonNames.DERBY_SERVER_CLASS, args, vmargs,CommonNames.SHUTDOWN_DERBY_SERVER);
    IProcess ip=launch.getProcesses()[0];

    //set a name to be seen in the Console list
    ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);

    //update the objectState
    setRunning(proj, Boolean.FALSE);
    if(proj.isOpen()){
        Shell shell = new Shell();
        MessageDialog.openInformation(
        shell,
        CommonNames.PLUGIN_NAME,
        Messages.D_NS_ATTEMPT_STOPPED+dprop.getPort()+"." );
    }
}
项目:gemfirexd-oss    文件:DerbyUtils.java   
public static void runIJ(IFile currentScript, IProject currentProject) throws CoreException {   

        String launchType="";
        String args="";

        //the above some times throws wrong 'create=true|false' errors
        String vmargs="";
        DerbyProperties dprop=new DerbyProperties(currentProject);
        if((dprop.getSystemHome()!=null)&& !(dprop.getSystemHome().equals(""))){
            vmargs+=CommonNames.D_SYSTEM_HOME+dprop.getSystemHome();
        }

        if(currentScript!=null){
            launchType=CommonNames.SQL_SCRIPT;

            //Preferable to use the full String with quotes to take care of spaces 
            //in file names
            args="\""+currentScript.getLocation().toOSString()+"\"";
        }else{
            launchType=CommonNames.IJ;
            args="";    
        }

        ILaunch launch=launch(currentProject,launchType,CommonNames.IJ_CLASS,args, vmargs, CommonNames.IJ);
        IProcess ip=launch.getProcesses()[0];
        String procName="["+currentProject.getName()+"] - "+CommonNames.IJ+" "+args;
        ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
    }
项目:gemfirexd-oss    文件:DerbyUtils.java   
public static void runSysInfo(IProject currentProject) throws CoreException {   
    String args="";
    ILaunch launch=launch(currentProject,CommonNames.SYSINFO,CommonNames.SYSINFO_CLASS,args, null, CommonNames.SYSINFO);
    IProcess ip=launch.getProcesses()[0];
    String procName="["+currentProject.getName()+"] - "+CommonNames.SYSINFO;
    ip.setAttribute(IProcess.ATTR_PROCESS_LABEL,procName);
}
项目:gwt-eclipse-plugin    文件:GwtWtpPlugin.java   
private void onAfterWebServerStarted(DebugEvent event) {
  if (!(event.getSource() instanceof IProcess)) {
    return;
  }

  // nothing at the moment
}