org.eclipse.debug.core.DebugEvent Java Examples

The following examples show how to use org.eclipse.debug.core.DebugEvent. 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: VoiceXMLBrowserInputView.java    From JVoiceXML with GNU Lesser General Public License v2.1 6 votes vote down vote up
void fireInput(String text) {
    if (activeBrowser == null) {
        return;
    }
    VoiceXMLBrowserInput input = new VoiceXMLBrowserInput();
    input.setInputType(VoiceXMLBrowserInput.TYPE_VOICE);
    input.setInput(text);

    activeBrowser.getVoiceXMLBrowser().sendInput(input);
    final DebugEvent event[] = new DebugEvent[1];
    event[0] = new DebugEvent(this, DebugEvent.MODEL_SPECIFIC,
            IVoiceXMLBrowserConstants.EVENT_DIALOG_MESSAGE);

    final VoiceXMLDialogMessage utterance = new VoiceXMLDialogMessage(
            "User", text);
    event[0].setData(utterance);

    DebugPlugin.getDefault().fireDebugEventSet(event);
}
 
Example #2
Source File: ConsoleRestartLaunchPageParticipant.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void handleDebugEvents(DebugEvent[] events) {
    for (int i = 0; i < events.length; i++) {
        DebugEvent event = events[i];
        if (event.getSource().equals(getProcess())) {
            Runnable r = new Runnable() {
                @Override
                public void run() {
                    if (restartLaunchAction != null) {
                        restartLaunchAction.update();
                    }
                    if (terminateAllLaunchesAction != null) {
                        terminateAllLaunchesAction.update();
                    }
                }
            };

            DebugUIPlugin.getStandardDisplay().asyncExec(r);
        }
    }
}
 
Example #3
Source File: ContainerOfVariables.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
public void forceGetNewVariables() {
    this.onAskGetNewVars = true;
    IVariablesContainerParent p = this.parent.get();
    if (p == null) {
        return;
    }

    AbstractDebugTarget target = p.getTarget();
    if (target != null) {
        RunInUiThread.async(() -> {
            // I.e.: if we do a new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT), the selection
            // of the editor is redone (thus, if the user uses F2 it'd get back to the current breakpoint
            // location because it'd be reselected).
            target.fireEvent(new DebugEvent(p, DebugEvent.CHANGE, DebugEvent.UNSPECIFIED));
        });
    }
}
 
Example #4
Source File: ContainerOfVariables.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
PyVariable[] setVariables(PyVariable[] newVars) {
    IVariable[] oldVars = this.variables;
    if (newVars == oldVars) {
        return newVars;
    }
    IVariablesContainerParent p = this.parent.get();
    if (p == null) {
        return newVars;
    }
    this.variables = newVars;
    AbstractDebugTarget target = p.getTarget();

    if (!gettingInitialVariables && target != null) {
        RunInUiThread.async(() -> {
            target.fireEvent(new DebugEvent(p, DebugEvent.CHANGE, DebugEvent.CONTENT));
        });
    }
    return newVars;
}
 
Example #5
Source File: RuntimeSessionTracker.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void handleDebugEvents(DebugEvent[] events) {
	for (DebugEvent debugEvent : events) {
		if (debugEvent.getSource() instanceof IProcess &&
				((IProcess)debugEvent.getSource()).getLaunch() == trackedLaunch) {
			if (debugEvent.getKind() == DebugEvent.CREATE) {
				liveProcessCount++;
				assert liveProcessCount > 0;
			}
			else if (debugEvent.getKind() == DebugEvent.TERMINATE) {
				liveProcessCount--;
				assert liveProcessCount >= 0;
				if (liveProcessCount == 0) {
					dispose();
				}
			}
		}
	}
}
 
Example #6
Source File: RuntimeSessionTrackerTest.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void multipleSessionsAreTracked() {
	FakePlugin fp = new FakePlugin();
	RuntimeSessionTracker rst = new RuntimeSessionTracker(null, fp);
	assertThat("The session should be alive", fp.shutdownWasCalled, is(0));
	rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.CREATE)});
	rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.CREATE)});
	assertThat("The session should be alive", fp.shutdownWasCalled, is(0));
	rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.TERMINATE)});
	assertThat("The session should be alive", fp.shutdownWasCalled, is(0));
	rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.CREATE)});
	rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.TERMINATE)});
	assertThat("The session should be alive", fp.shutdownWasCalled, is(0));
	rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.TERMINATE)});
	assertThat("The session should be over", fp.shutdownWasCalled, is(1));
}
 
Example #7
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 #8
Source File: GwtWtpPlugin.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * When a Server runtime server is started and terminated, and the project has a GWT Facet, start and stop the GWT
 * Super Dev Mode Code Server with runtime server.
 */
@Override
public void start(BundleContext context) throws Exception {
  super.start(context);

  // Observe launch events that are from the WTP server
  serverProcessListener = new IDebugEventSetListener() {
    @Override
    public void handleDebugEvents(DebugEvent[] events) {
      if (events != null) {
        onDebugEvents(events);
      }
    }
  };
  DebugPlugin.getDefault().addDebugEventListener(serverProcessListener);
}
 
Example #9
Source File: VoiceXMLBrowserInputView.java    From JVoiceXML with GNU Lesser General Public License v2.1 6 votes vote down vote up
void fireDTMF(String key) {
    if (activeBrowser == null) {
        return;
    }
    VoiceXMLBrowserInput input = new VoiceXMLBrowserInput();
    input.setInputType(VoiceXMLBrowserInput.TYPE_DTMF);
    input.setInput(key);

    activeBrowser.getVoiceXMLBrowser().sendInput(input);

    final DebugEvent event[] = new DebugEvent[1];
    event[0] = new DebugEvent(this, DebugEvent.MODEL_SPECIFIC,
            IVoiceXMLBrowserConstants.EVENT_DIALOG_MESSAGE);

    final VoiceXMLDialogMessage utterance = new VoiceXMLDialogMessage(
            "User", "#" + key);
    event[0].setData(utterance);

    DebugPlugin.getDefault().fireDebugEventSet(event);
}
 
Example #10
Source File: SimulationView.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void handleDebugEvent(DebugEvent debugEvent) {
	updateActions();
	switch (debugEvent.getKind()) {
	case DebugEvent.TERMINATE:
		setExecutionContextInput(null);
		Display.getDefault().asyncExec(() -> {
			sessionViewerInputChanged(null);
			if (clock != null && !clock.isDisposed()) {
				clock.updateTimestamp(0);
			}
		});
		raiseEventThreadGroup.interrupt();
		break;
	case DebugEvent.SUSPEND:
		Display.getDefault().asyncExec(() -> {
			simulationSessionViewer.refresh();
		});
		break;
	case DebugEvent.RESUME:
		Display.getDefault().asyncExec(() -> {
			simulationSessionViewer.refresh();
		});
		break;
	}
}
 
Example #11
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Override
public void serverChanged(ServerEvent event) {
  Preconditions.checkState(server == event.getServer());
  switch (event.getState()) {
    case IServer.STATE_STARTED:
      openBrowserPage(server);
      fireChangeEvent(DebugEvent.STATE);
      return;

    case IServer.STATE_STOPPED:
      server.removeServerListener(serverEventsListener);
      fireTerminateEvent();
      try {
        logger.fine("Server stopped; terminating launch"); //$NON-NLS-1$
        launch.terminate();
      } catch (DebugException ex) {
        logger.log(Level.WARNING, "Unable to terminate launch", ex); //$NON-NLS-1$
      }
      checkUpdatedDatastoreIndex(launch.getLaunchConfiguration());
      return;

    default:
      fireChangeEvent(DebugEvent.STATE);
      return;
  }
}
 
Example #12
Source File: DebugPluginListener.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public void handleDebugEvents(DebugEvent[] events) {
	for (DebugEvent event : events) {
		Object source = event.getSource();
		if (source instanceof IJavaThread)
			synchronized (this) {
				lastThread = (IJavaThread) source;
			}
		else if (source instanceof IStackFrame)
			synchronized (this) {
				lastFrame = (IStackFrame) source;
			}
		else if (source instanceof IDebugTarget)
			synchronized (this) {
				if (event.getKind() == DebugEvent.TERMINATE) {
					if (lastThread != null && lastThread.getDebugTarget() == source)
						lastThread = null;
					if (lastFrame != null && lastFrame.getDebugTarget() == source)
						lastFrame = null;
				}
			}
	}
}
 
Example #13
Source File: AbstractDebugTargetView.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public final void handleDebugEvents(DebugEvent[] events) {
	for (DebugEvent debugEvent : events) {
		// Only notify about events fired from the active debug target
		if ((debugEvent.getSource() instanceof SCTDebugTarget) && debugEvent.getSource() == debugTarget)
			handleDebugEvent(debugEvent);
	}
}
 
Example #14
Source File: XpectConfigurationDelegate.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void handleDebugEvents(DebugEvent[] events) {
	for (DebugEvent e : events) {
		switch (e.getKind()) {
		case DebugEvent.TERMINATE:
			DebugPlugin.getDefault().removeDebugEventListener(this);
			terminateProcess();
			break;
		default:
			break;
		}
	}
}
 
Example #15
Source File: PyDebugTargetConsole.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void setSuspended(boolean suspended) {
    if (suspended != virtualConsoleThread.isSuspended()) {
        final int state;
        if (suspended) {
            state = DebugEvent.SUSPEND;
            virtualConsoleThread.setSuspended(true, createFrames());
        } else {
            state = DebugEvent.RESUME;
            virtualConsoleThread.setSuspended(false, null);
        }
        fireEvent(new DebugEvent(virtualConsoleThread, state, DebugEvent.CLIENT_REQUEST));
    }
}
 
Example #16
Source File: PyVariable.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This method is called when some value has to be changed to some other expression.
 *
 * Note that it will (currently) only work for changing local values that are in the topmost frame.
 * -- python has no way of making it work right now (see: pydevd_vars.changeAttrExpression)
 */
@Override
public void setValue(String expression) throws DebugException {
    ChangeVariableCommand changeVariableCommand = getChangeVariableCommand(target, expression);
    if (changeVariableCommand != null) {
        target.postCommand(changeVariableCommand);
        this.value = expression;
        target.fireEvent(new DebugEvent(this, DebugEvent.CONTENT | DebugEvent.CHANGE));
    }
}
 
Example #17
Source File: DerbyServerUtils.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
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);
			}
		}
	}
}
 	}
 }
 
Example #18
Source File: AbstractDebugTarget.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private void processThreadKilled(String thread_id) {
    PyThread threadToDelete = findThreadByID(thread_id);
    if (threadToDelete != null) {
        int j = 0;
        PyThread[] newThreads = new PyThread[threads.length - 1];
        for (int i = 0; i < threads.length; i++) {
            if (threads[i] != threadToDelete) {
                newThreads[j++] = threads[i];
            }
        }
        threads = newThreads;
        fireEvent(new DebugEvent(threadToDelete, DebugEvent.TERMINATE));
    }
}
 
Example #19
Source File: ScriptDebugTarget.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void handleEvent( int eventCode, VMContextData context )
{
	if ( eventCode == VMConstants.VM_SUSPENDED_STEP_OVER )
	{
		suspended( DebugEvent.STEP_END );
		thread.setStepping( false );
	}
	else if ( eventCode == VMConstants.VM_SUSPENDED_STEP_INTO )
	{
		suspended( DebugEvent.STEP_END );
		thread.setStepping( false );
	}
	else if ( eventCode == VMConstants.VM_SUSPENDED_STEP_OUT )
	{
		suspended( DebugEvent.STEP_END );
		thread.setStepping( false );
	}
	else if ( eventCode == VMConstants.VM_STARTED )
	{
		started( );
	}
	else if ( eventCode == VMConstants.VM_SUSPENDED_BREAKPOINT )
	{
		suspended( DebugEvent.BREAKPOINT );
	}
	else if ( eventCode == VMConstants.VM_SUSPENDED_CLIENT )
	{
		suspended( DebugEvent.CLIENT_REQUEST );
	}
	else if ( eventCode == VMConstants.VM_TERMINATED )
	{
		terminated( );
	}
	else if ( eventCode == VMConstants.VM_RESUMED )
	{
		resumed( DebugEvent.RESUME );
	}
}
 
Example #20
Source File: ScriptDebugElement.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Fires a debug event
 * 
 * @param event
 *            the event to be fired
 */
protected void fireEvent( DebugEvent event )
{
	DebugPlugin.getDefault( ).fireDebugEventSet( new DebugEvent[]{
		event
	} );
}
 
Example #21
Source File: GenerateUml2Solidity.java    From uml2solidity with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Fires the given debug event.
 *
 * @param event debug event to fire
 */
protected void fireEvent(DebugEvent event) {
	DebugPlugin manager= DebugPlugin.getDefault();
	if (manager != null) {
		manager.fireDebugEventSet(new DebugEvent[]{event});
	}
}
 
Example #22
Source File: RuntimeSessionTrackerTest.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void singleSessionIsTracked() {
	FakePlugin fp = new FakePlugin();
	RuntimeSessionTracker rst = new RuntimeSessionTracker(null, fp);
	assertThat("The session should be alive", fp.shutdownWasCalled, is(0));
	rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.CREATE)});
	assertThat("The session should be alive", fp.shutdownWasCalled, is(0));
	rst.handleDebugEvents(new DebugEvent[] {new DebugEvent(new FakeProcess(), DebugEvent.TERMINATE)});
	assertThat("The session should be over", fp.shutdownWasCalled, is(1));
}
 
Example #23
Source File: GwtWtpPlugin.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private void onAfterWebServerStarted(DebugEvent event) {
  if (!(event.getSource() instanceof IProcess)) {
    return;
  }

  // nothing at the moment
}
 
Example #24
Source File: GwtWtpPlugin.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
protected void onDebugEvents(DebugEvent[] events) {
  for (int i = 0; i < events.length; i++) {
    try {
      onDebugEvent(events[i]);
    } catch (CoreException e) {
      logError("Error processing debug events " + e.getMessage());
      e.printStackTrace();
    }
  }
}
 
Example #25
Source File: ModulaEditor.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isSourceCorrespondsToSameDebugSession(DebugEvent e) {
  	if (e.getSource() instanceof IAdaptable) {
  		IAdaptable adaptable = (IAdaptable) e.getSource();
  		ILaunch launch = (ILaunch)adaptable.getAdapter(ILaunch.class);
  		if (launch != null){
  			try {
			IProject iProjectOfLaunch = LaunchConfigurationUtils.getProject(launch.getLaunchConfiguration());
			return Objects.equals(getProject(), iProjectOfLaunch);
		} catch (CoreException err) {
			LogHelper.logError(err);
		}
  		}
}
  	return false;
  }
 
Example #26
Source File: RemoteLaunchConfigDelegate.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public static void addDebugEventListener(final ILaunch launch) {
	// Add the debug listener
	DebugPlugin.getDefault().addDebugEventListener(new IDebugEventSetListener() {
		@Override
		public void handleDebugEvents(DebugEvent[] events) {
			for (DebugEvent event : events) {
				if (event.getKind() == DebugEvent.TERMINATE && event.getSource() instanceof IDebugTarget
						&& ((IDebugTarget) event.getSource()).getLaunch() == launch) {
					// Remove this listener
					DebugPlugin.getDefault().removeDebugEventListener(this);

					// Make sure the port forward is terminated
					Arrays.stream(launch.getProcesses()).filter(process -> !process.isTerminated()).forEach(process -> {
						try {
							process.terminate();
						} catch (DebugException e) {
							Logger.logError("An error occurred trying to terminate the process: " + process.getLabel(), e);
						}
					});

					// No need to process the rest of the events
					break;
				}
			}
		}
	});
}
 
Example #27
Source File: TextServerListener.java    From JVoiceXML with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void outputSsml(TextMessageEvent message, final SsmlDocument document) {
    browser.logMessage(document.toString());

    final DebugEvent event[] = new DebugEvent[1];
    event[0] = new DebugEvent(this, DebugEvent.MODEL_SPECIFIC,
            IVoiceXMLBrowserConstants.EVENT_DIALOG_MESSAGE);

    final Speak speak = document.getSpeak();
    final VoiceXMLDialogMessage utterance = new VoiceXMLDialogMessage(
            "System", speak.getTextContent());
    event[0].setData(utterance);

    DebugPlugin.getDefault().fireDebugEventSet(event);
}
 
Example #28
Source File: DerbyServerUtils.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
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);
			}
		}
	}
}
 	}
 }
 
Example #29
Source File: SCTDebugTarget.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public void terminate() throws DebugException {
	fireEvent(new DebugEvent(getDebugTarget(), DebugEvent.TERMINATE));
	terminated = true;
	executionControl.terminate();
	if (engine.getExecutionContext() != null)
		engine.getExecutionContext().eAdapters().remove(updater);
}
 
Example #30
Source File: SCTSourceDisplay.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void handleDebugTargetTerminated(DebugEvent debugEvent) {
	Object source = debugEvent.getSource();
	if (source instanceof IDebugTarget) {
		IDebugTarget target = (IDebugTarget) source;
		if (activeLaunch == target.getLaunch()) {
			activeLaunch = null;
			for (IDynamicNotationHandler current : handler.values()) {
				current.terminate();
			}
			handler.clear();
		}
	}
}