Java Code Examples for org.eclipse.ui.handlers.HandlerUtil#getActiveEditorChecked()

The following examples show how to use org.eclipse.ui.handlers.HandlerUtil#getActiveEditorChecked() . 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: RefreshTraceContentHandler.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    IEditorPart activeEditor = HandlerUtil.getActiveEditorChecked(event);
    if (activeEditor instanceof ITmfTraceEditor) {
        ITmfTrace trace = ((ITmfTraceEditor) activeEditor).getTrace();
        refreshTrace(trace);
    }

    return null;
}
 
Example 2
Source File: EmacsPlusCmdHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Get the current active editor
 * @param event
 * @return the current active editor, else null if some other part is active
 * 
 * @throws ExecutionException
 */
protected IEditorPart getEditor(ExecutionEvent event) throws ExecutionException {

	IEditorPart epart = HandlerUtil.getActiveEditorChecked(event);
	if (HandlerUtil.getActivePart(event) != epart) {
		// When something other than the editor is active (e.g. the JavaStackTraceConsole)
		// Then don't return the editor
		return null;
	}
	return epart;
}
 
Example 3
Source File: SelectAllOccurrencesHandler.java    From eclipse-multicursor with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditorChecked(event);

	ISourceViewer viewer = ISourceViewerFinder.fromEditorPart(editor);
	if (viewer != null) {
		startEditing(viewer);
	}

	return null;
}
 
Example 4
Source File: SelectNextOccurrenceHandler.java    From eclipse-multicursor with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditorChecked(event);

	ISourceViewer viewer = ISourceViewerFinder.fromEditorPart(editor);
	if (viewer != null) {
		startEditing(viewer);
	}

	return null;
}
 
Example 5
Source File: AbstractEditorHandler.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	ITextEditor editor = (ITextEditor) HandlerUtil.getActiveEditorChecked(event);
	assertNotNull(editor);
	
	createOperation(editor).executeAndHandle();
	
	return null;
}