org.eclipse.debug.core.model.IStreamMonitor Java Examples

The following examples show how to use org.eclipse.debug.core.model.IStreamMonitor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BroadcastStreamListener.java    From tlaplus with MIT License 6 votes vote down vote up
public synchronized void streamAppended(String text, IStreamMonitor monitor)
{
    // broadcast the message
    for (int i = 0; i < listeners.length; i++)
    {
        if (listeners[i] != null)
        {
            try
            {
                listeners[i].appendText(text);
            } catch (Exception e)
            {
                TLCActivator.logError("Error broadcasting the message", e);
            }
        }
    }
}
 
Example #2
Source File: TLAPMBroadcastStreamListener.java    From tlaplus with MIT License 6 votes vote down vote up
public synchronized void streamAppended(String text, IStreamMonitor monitor)
{
    // broadcast the message
    for (int i = 0; i < listeners.length; i++)
    {
        if (listeners[i] != null)
        {
            try
            {
                listeners[i].appendText(text);
            } catch (Exception e)
            {
                ProverUIActivator.getDefault().logError("Error broadcasting the message", e);
            }
        }
    }
}
 
Example #3
Source File: GwtWtpPlugin.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: ProcessManager.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private void flushOutputStreamMonitor(IStreamMonitor streamMonitor) {
	if (streamMonitor instanceof IFlushableStreamMonitor) {
		IFlushableStreamMonitor flushableStreamMonitor = (IFlushableStreamMonitor) streamMonitor;
		flushableStreamMonitor.setBuffered(false);
		flushableStreamMonitor.flushContents(); // flush is necessary to reduce the memory footprint
	}
}
 
Example #5
Source File: TracingStreamListener.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	HybridCore.trace(text);
	if(delegate != null){
		delegate.streamAppended(text, monitor);
	}
}
 
Example #6
Source File: ScanWorkspaceOperation.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    monitor.beginTask(Messages.scanningWorkspace, IProgressMonitor.UNKNOWN);
    final ILaunchManager manager = getLaunchManager();
    final ILaunchConfigurationType ltype = manager
            .getLaunchConfigurationType(IPDELauncherConstants.ECLIPSE_APPLICATION_LAUNCH_CONFIGURATION_TYPE);
    try {
        final ILaunchConfigurationWorkingCopy workingCopy = ltype.newInstance(null, "Scan workspace");
        workingCopy.setAttribute(IPDELauncherConstants.APPLICATION,
                applicationId());
        workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "-scan");
        if (Objects.equals(Platform.getOS(), Platform.OS_MACOSX)) {
            workingCopy.setAttribute(IJavaLaunchConfigurationConstants.ATTR_USE_START_ON_FIRST_THREAD, true);
        }
        workingCopy.setAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false);
        workingCopy.setAttribute(IPDELauncherConstants.RUN_IN_UI_THREAD, true);
        workingCopy.setAttribute(IPDELauncherConstants.DOCLEAR, false);
        workingCopy.setAttribute(IPDELauncherConstants.LOCATION, tmpWorskpaceFolder());
        workingCopy.setAttribute(IPDELauncherConstants.USE_PRODUCT, false);
        final ILaunch launch = workingCopy.launch("run", Repository.NULL_PROGRESS_MONITOR);
        launch.getProcesses()[0].getStreamsProxy().getOutputStreamMonitor().addListener(new IStreamListener() {

            @Override
            public void streamAppended(String text, IStreamMonitor streamMonitor) {
                if (text.startsWith("$SCAN_PROGRESS_")) {
                    scanStatus(text);
                }
            }
        });
        while (!launch.isTerminated()) {
            Thread.sleep(1000);
        }
        if (workspaceModel.isEmpty()) {
            workspaceModel.setStatus(ValidationStatus.error(Messages.noRepositoryFoundAtLocation));
        }
        if (launch.isTerminated()) {
            monitor.done();
        }
    } catch (final CoreException | IOException e) {
        throw new InvocationTargetException(e);
    }
}
 
Example #7
Source File: ProcessManager.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public StreamAppendedListenerVisitor(AtomicBoolean isFirstRead,
		IStreamMonitor streamMonitor) {
	this.isFirstRead = isFirstRead;
	this.streamMonitor = streamMonitor;
}
 
Example #8
Source File: WPEmulator.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	buffer.append(text);
}
 
Example #9
Source File: WindowsRegistry.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	buffer.append(text);
}
 
Example #10
Source File: WindowsRegistry.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	buffer.append(text);
}
 
Example #11
Source File: CordovaCLIStreamListener.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	message.append(text);
}
 
Example #12
Source File: TextDetectingStreamListener.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	if(text.contains(theText)){
		detected = true;
	}
}
 
Example #13
Source File: IOSSimulator.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	buffer.append(text);
}
 
Example #14
Source File: XCodeBuild.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	buffer.append(text);
}
 
Example #15
Source File: XCodeBuild.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	buffer.append(text);
	
}
 
Example #16
Source File: AndroidSDKManager.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	buffer.append(text);
	
}
 
Example #17
Source File: AndroidSDKManager.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	buffer.append(text);
}
 
Example #18
Source File: AndroidSDKManager.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	buffer.append(text);
}
 
Example #19
Source File: AndroidSDKManager.java    From thym with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	buffer.append(text);
}
 
Example #20
Source File: TscStreamListener.java    From typescript.java with MIT License 4 votes vote down vote up
@Override
public void streamAppended(String text, IStreamMonitor monitor) {
	TypeScriptCompilerHelper.processMessage(text, this);
}
 
Example #21
Source File: ProverJob.java    From tlaplus with MIT License 4 votes vote down vote up
/**
 * This method sets up the mechanism for listening to the error and output streams
 * of the prover. It also sets the value of the field proverProcess.
 * 
 * @param process
 * @param monitor
 */
private void setUpStreamListening(Process process, IProgressMonitor monitor)
{
    /*
     * This code proceeds as follows. First, we wrap the java.lang.Process in an IProcess by calling
     * DebugPlugin.newProcess(). An IProcess is an eclipse object with some
     * convenience methods. Then we create a TLAPMBroadcastStreamListener and add it as
     * a listener to the output and error streams of the IProcess.
     * 
     * The code is wrapped in two synchronized blocks to avoid a race condition on the
     * prover's output. The race condition can occur as follows. Calling DebugPlugin.newProcess()
     * creates instances of IStreamMonitor to monitor the output and error streams
     * of the prover. These monitors immediately start monitoring the streams and passing the
     * text from the streams to registered listeners. This means that they can potentially read
     * text from the prover's streams before the TLAPMBroadcastStreamListener is added as a listener.
     * This text would be lost. To solve this, this thread locks access to the prover's output and error
     * streams until after the TLAPMBroadcastStreamListener has been added as a listener.
     */
    if (process != null)
    {
        synchronized (process.getInputStream())
        {
            synchronized (process.getErrorStream())
            {
                /* 
                 * Calling DebugPlugin.newProcess()
                 * wraps the java.lang.Process in an IProcess with some
                 * convenience methods.
                 */
                proverProcess = DebugPlugin.newProcess(launch, process, getName());
                /*
                 * Setup the broadcasting of the prover output stream.
                 * We pass in the progress monitor to allow listeners
                 * to report progress.
                 */
                listener = new TLAPMBroadcastStreamListener(module, this, monitor);

                /*
                 * Send a string to the listener indicating
                 * that a new prover job is starting. This makes
                 * it easier to read the console.
                 */
                listener.streamAppended("---------------- New Prover Launch --------------\n", null);

                IStreamMonitor esMonitor = proverProcess.getStreamsProxy().getErrorStreamMonitor();
                IStreamMonitor osMonitor = proverProcess.getStreamsProxy().getOutputStreamMonitor();

                esMonitor.addListener(listener);
                osMonitor.addListener(listener);

                /*
                 * The output from the prover can be long, so buffering it can lead to an
                 * OutOfMemoryError. The following code turns off buffering.
                 */
                if (esMonitor instanceof IFlushableStreamMonitor && osMonitor instanceof IFlushableStreamMonitor)
                {
                    ((IFlushableStreamMonitor) esMonitor).setBuffered(false);
                    ((IFlushableStreamMonitor) osMonitor).setBuffered(false);
                }
            }
        }
    }
}