Java Code Examples for org.eclipse.debug.ui.DebugUITools#getDebugContext()

The following examples show how to use org.eclipse.debug.ui.DebugUITools#getDebugContext() . 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: ProcessServerOutputStream.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Checks if the last thing entered was a new line, and if it was, notifies clients about it.
 */
private void checkFinishedLine() {
    String s = this.toString();
    this.reset();
    char c;
    if (s.length() > 0 && ((c = s.charAt(s.length() - 1)) == '\n' || c == '\r')) {
        IAdaptable context = DebugUITools.getDebugContext();
        if (context != null) {
            s = StringUtils.rightTrim(s);
            Object adapter = context.getAdapter(IDebugTarget.class);
            if (adapter instanceof AbstractDebugTarget) {
                AbstractDebugTarget target = (AbstractDebugTarget) adapter;

                for (IConsoleInputListener listener : participants) {
                    listener.newLineReceived(s, target);
                }
            }
        }
    }
}
 
Example 2
Source File: AbstractDebugTargetView.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void setActiveSession() {
	// if a simulation session is running, we should initialize with its
	// content
	IAdaptable debugContext = DebugUITools.getDebugContext();
	if (debugContext != null) {
		IDebugTarget debugTarget = (IDebugTarget) debugContext.getAdapter(IDebugTarget.class);
		if (debugTarget != null) {
			if (!debugTarget.isTerminated()) {
				this.debugTarget = (IDebugTarget) debugTarget;
				activeTargetChanged(this.debugTarget);
			}
		}
	}
}
 
Example 3
Source File: ScriptDebugHover.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private ScriptStackFrame getFrame( )
{
	IAdaptable adaptable = DebugUITools.getDebugContext( );
	if ( adaptable != null )
	{
		return (ScriptStackFrame) adaptable.getAdapter( ScriptStackFrame.class );
	}
	return null;
}
 
Example 4
Source File: EvaluationConsoleInputListener.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void newLineReceived(String lineReceived, AbstractDebugTarget target) {
    boolean evaluateNow = !lineReceived.startsWith(" ") && !lineReceived.startsWith("\t")
            && !lineReceived.endsWith(":") && !lineReceived.endsWith("\\");

    if (DEBUG) {
        System.out.println("line: '" + lineReceived + "'");
    }
    buf.append(lineReceived);
    if (lineReceived.length() > 0) {
        buf.append("@LINE@");
    }

    if (evaluateNow) {
        final String toEval = buf.toString();
        if (toEval.trim().length() > 0) {
            IAdaptable context = DebugUITools.getDebugContext();
            if (DEBUG) {
                System.out.println("Evaluating:\n" + toEval);
            }
            if (context instanceof PyStackFrame) {
                final PyStackFrame frame = (PyStackFrame) context;
                target.postCommand(new EvaluateExpressionCommand(target, toEval, frame
                        .getLocalsLocator().getPyDBLocation(), true) {
                    @Override
                    public void processOKResponse(int cmdCode, String payload) {
                        frame.forceGetNewVariables();
                        super.processOKResponse(cmdCode, payload);
                    }
                });
            }
        }
        buf = new StringBuffer();
    }

}
 
Example 5
Source File: ChooseProcessTypeDialog.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Determine if any frame is selected in the Launch view
 * 
 * @return
 */
private PyStackFrame getSuspendedFrame() {
    IAdaptable context = DebugUITools.getDebugContext();
    if (context instanceof PyStackFrame) {
        if (context instanceof PyStackFrameConsole) {
            // We already have a real console opened on the Interactive Console, we don't support
            // opening a special debug console on it
            return null;
        }
        return (PyStackFrame) context;
    }
    return null;
}
 
Example 6
Source File: WatchExpressionAction.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
private void createExpression(String variable) {
    IWatchExpression expression = DebugPlugin.getDefault().getExpressionManager().newWatchExpression(variable);

    DebugPlugin.getDefault().getExpressionManager().addExpression(expression);
    IAdaptable object = DebugUITools.getDebugContext();
    IDebugElement context = null;
    if (object instanceof IDebugElement) {
        context = (IDebugElement) object;
    } else if (object instanceof ILaunch) {
        context = ((ILaunch) object).getDebugTarget();
    }
    expression.setExpressionContext(context);
    showExpressionsView();
}
 
Example 7
Source File: EvalExpressionAction.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a watch expression to be evaluated with the current debug context.
 * 
 * @param expr the expression that should be evaluated in the current context
 * @return the created expression.
 */
public static IWatchExpression createWatchExpression(final String expr) {
    final IWatchExpression expression = DebugPlugin.getDefault().getExpressionManager().newWatchExpression(expr);
    IAdaptable object = DebugUITools.getDebugContext();
    IDebugElement context = null;
    if (object instanceof IDebugElement) {
        context = (IDebugElement) object;
    } else if (object instanceof ILaunch) {
        context = ((ILaunch) object).getDebugTarget();
    }

    expression.setExpressionContext(context);
    return expression;
}
 
Example 8
Source File: DelegatingDebugTextHover.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
private ICEditorTextHover getDelegate() {
    IAdaptable context = DebugUITools.getDebugContext();
    if (context != null) {
        ICEditorTextHover hover = context.getAdapter(ICEditorTextHover.class);
        if (hover != null) {
            hover.setEditor(fEditor);
        }
        return hover;
    }
    return null;
}