org.eclipse.ui.texteditor.ITextEditor Java Examples

The following examples show how to use org.eclipse.ui.texteditor.ITextEditor. 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: CommandBriefKeyHandler.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see com.mulgasoft.emacsplus.minibuffer.IMinibufferExecutable#executeResult(org.eclipse.ui.texteditor.ITextEditor, java.lang.Object)
 */
public boolean executeResult(ITextEditor editor, Object minibufferResult) {
	
	String summary = EMPTY_STR;
	if (minibufferResult != null) {

		IBindingResult bindingR = (IBindingResult) minibufferResult;
		String name = bindingR.getKeyString();
		if (bindingR == null || bindingR.getKeyBinding() == null) {
			summary = String.format(CMD_NO_RESULT, name) + CMD_NO_BINDING;
		} else {
			summary = String.format(CMD_KEY_RESULT,name); 
			Binding binding = bindingR.getKeyBinding();
			try {
				Command com = getCommand(binding);
				if (com != null) {
					summary += normalizeCommandName(com.getName());
				}
			} catch (NotDefinedException e) {
				// can't happen as the Command will be null or valid
			}
		}
	}
	showResultMessage(editor, summary, false);
	return true;
}
 
Example #2
Source File: CommandDescribeHandler.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see com.mulgasoft.emacsplus.minibuffer.IMinibufferExecutable#executeResult(ITextEditor, java.lang.Object)
 */
public boolean doExecuteResult(ITextEditor editor, Object minibufferResult) {

	if (minibufferResult != null) {
		EmacsPlusConsole console = EmacsPlusConsole.getInstance();
		console.clear();
		console.activate();

		ICommandResult commandR = (ICommandResult) minibufferResult;
		String name = commandR.getName();
		Command cmd = commandR.getCommand();
		console.printBold(name + CR);
		printCmdDetails(cmd, console);
	}
	return true;
}
 
Example #3
Source File: JavaSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void showMatch(Match match, int offset, int length, boolean activate) throws PartInitException {
	IEditorPart editor= fEditorOpener.openMatch(match);

	if (editor != null && activate)
		editor.getEditorSite().getPage().activate(editor);
	Object element= match.getElement();
	if (editor instanceof ITextEditor) {
		ITextEditor textEditor= (ITextEditor) editor;
		textEditor.selectAndReveal(offset, length);
	} else if (editor != null) {
		if (element instanceof IFile) {
			IFile file= (IFile) element;
			showWithMarker(editor, file, offset, length);
		}
	} else if (getInput() instanceof JavaSearchResult) {
		JavaSearchResult result= (JavaSearchResult) getInput();
		IMatchPresentation participant= result.getSearchParticpant(element);
		if (participant != null)
			participant.showMatch(match, offset, length, activate);
	}
}
 
Example #4
Source File: TypeResourceUnloaderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testCloseEditorAndDiscardWorkingCopy() throws InterruptedException {
	waitForEvent(new Procedure0() {

		@Override
		public void apply() {
			try {
				compilationUnit.discardWorkingCopy();
				((ITextEditor) editor).close(false);
			} catch (JavaModelException e) {
				throw new RuntimeException(e);
			}
		}

	}, false);
	assertNull(event);
}
 
Example #5
Source File: ReviewMarkerContributionFactory.java    From git-appraise-eclipse with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
  ITextEditor editor = (ITextEditor)
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
  IVerticalRulerInfo rulerInfo = editor.getAdapter(IVerticalRulerInfo.class);

  try {
    List<IMarker> markers = getMarkers(editor, rulerInfo);
    additions.addContributionItem(new ReviewMarkerMenuContribution(editor, markers), null);
    if (!markers.isEmpty()) {
      additions.addContributionItem(new Separator(), null);
    }
  } catch (CoreException e) {
    AppraiseUiPlugin.logError("Error creating marker context menus", e);
  }
}
 
Example #6
Source File: UniversalHandler.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see com.mulgasoft.emacsplus.commands.EmacsPlusCmdHandler#transform(ITextEditor, IDocument, ITextSelection, ExecutionEvent)
 */
protected int transform(ITextEditor editor, IDocument document, ITextSelection currentSelection, ExecutionEvent event)
throws BadLocationException {
	prefix = INITIAL_PREFIX;	//reset in case of M-x invocation 
	UniversalMinibuffer mini = new UniversalMinibuffer(this);
	Object eTrigger = event.getTrigger();
	if (eTrigger instanceof Event) {
		Event ev = (Event)eTrigger;
		prefix = mini.getTrigger(ev.keyCode,ev.stateMask);
	}
	if (KbdMacroSupport.getInstance().isExecuting()) {
		// call without asynchronous wrapper
		// TODO: with ^U, key sequences (instead of commands) appear in kbd macro
		return bufferTransform(mini, editor, event); 		
	} else {
		return miniTransform(mini, editor, event); 		
	}
}
 
Example #7
Source File: AlignMinibuffer.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
public boolean executeResult(ITextEditor editor, Object minibufferResult, ExecutingMinibuffer mini) {
			boolean result = false;
			AlignMinibuffer am = (AlignMinibuffer)mini;
			String number = (String)minibufferResult;
			if (number != null && number.length() > 0) {
				try {
					AlignControl ac = am.getAlignControl();
					ac.group = EmacsPlusUtils.emacsParseInt(number);
//					am.addToHistory(Integer.toString(ac.group)); // add to command history
					am.addToHistory(ac.group); // add to command history
					am.setExecuteState(sSpaces);	// next state
				} catch (NumberFormatException e) {
					am.setResultMessage(String.format(BAD_NUMBER,number), true, true);	
					am.setAlignControl(null); // clear and 
					result = true;  		  // flag for exit
				}
			}
			return result;
		}
 
Example #8
Source File: TestXML.java    From wildwebdeveloper with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testDTDFile() throws Exception {
	final IFile file = project.getFile("blah.dtd");
	file.create(new ByteArrayInputStream("FAIL".getBytes()), true, null);
	ITextEditor editor = (ITextEditor) IDE
			.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file);
	editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("<!--<!-- -->");
	assertTrue("Diagnostic not published", new DisplayHelper() {
		@Override
		protected boolean condition() {
			try {
				return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0;
			} catch (CoreException e) {
				return false;
			}
		}
	}.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000));
}
 
Example #9
Source File: EditorAPITextPositionTest.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Builds the ITextEditor mock.
 *
 * @return the ITextEditor mock
 * @see #withLineOffsetLookupAnswer(int, int)
 */
private ITextEditor build() {
  IDocument document = documentBuilder.build();

  IEditorInput editorInput = EasyMock.createNiceMock(IEditorInput.class);
  EasyMock.replay(editorInput);

  IDocumentProvider documentProvider = EasyMock.createNiceMock(IDocumentProvider.class);
  EasyMock.expect(documentProvider.getDocument(editorInput)).andReturn(document).anyTimes();
  EasyMock.replay(documentProvider);

  editor = EasyMock.createNiceMock(ITextEditor.class);
  EasyMock.expect(editor.getDocumentProvider()).andReturn(documentProvider).anyTimes();
  EasyMock.expect(editor.getEditorInput()).andReturn(editorInput).anyTimes();
  EasyMock.replay(editor);

  return editor;
}
 
Example #10
Source File: TextChangeCombinerTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testMultipleDocumentChanges() throws Exception {
	ITextEditor editor = openInEditor(file0);
	CompositeChange compositeChange = new CompositeChange("test");
	compositeChange.add(createEditorDocumentChange(editor, 1, 1, "foo"));
	compositeChange.add(createEditorDocumentChange(editor, 2, 1, "bar"));
	CompositeChange compositeChange1 = new CompositeChange("test");
	compositeChange.add(compositeChange1);
	compositeChange1.add(createEditorDocumentChange(editor, 3, 1, "baz"));
	compositeChange1.add(createEditorDocumentChange(editor, 2, 1, "bar"));
	compositeChange1.add(createMultiEditorDocumentChange(editor, 1, 1, "foo", 4, 1, "foo"));
	Change combined = combiner.combineChanges(compositeChange);
	assertTrue(combined instanceof CompositeChange);
	assertEquals(1, ((CompositeChange) combined).getChildren().length);
	assertTrue(((CompositeChange)combined).getChildren()[0] instanceof EditorDocumentChange);
	Change undo = combined.perform(new NullProgressMonitor());
	IDocument document = getDocument(editor);
	assertEquals(MODEL.replace("1234", "foobarbazfoo"), document.get());
	undo.perform(new NullProgressMonitor());
	assertEquals(MODEL, document.get());
}
 
Example #11
Source File: SelectionListenerWithASTManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public PartListenerGroup(ITextEditor editorPart) {
	fPart= editorPart;
	fCurrentJob= null;
	fAstListeners= new ListenerList(ListenerList.IDENTITY);

	fSelectionListener= new ISelectionChangedListener() {
		public void selectionChanged(SelectionChangedEvent event) {
			ISelection selection= event.getSelection();
			if (selection instanceof ITextSelection) {
				fireSelectionChanged((ITextSelection) selection);
			}
		}
	};

	fPostSelectionListener= new ISelectionListener() {
		public void selectionChanged(IWorkbenchPart part, ISelection selection) {
			if (part == fPart && selection instanceof ITextSelection)
				firePostSelectionChanged((ITextSelection) selection);
		}
	};
}
 
Example #12
Source File: TLAMultiPageEditorActionBarContributor.java    From tlaplus with MIT License 6 votes vote down vote up
public void contributeToStatusLine(IStatusLineManager statusLineManager)
{
    if (this.activeEditor instanceof ITextEditor)
    {
        if (statusLineManager.find(cursorPositionStatusField.getId()) == null)
        {
            // add the cursor position if not already there
            statusLineManager.add(cursorPositionStatusField);
        }
    } else
    {
        // remove cursor position if the active editor is not a text editor
        statusLineManager.remove(cursorPositionStatusField);
    }
    // must update to show changes in UI
    statusLineManager.update(true);
}
 
Example #13
Source File: MarkUtils.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Wrap selection provider setSelection within a block disabling highlight
 * range to protect against the JavaEditor from changing the narrow focus in
 * - org.eclipse.jdt.internal.ui.javaeditor.TogglePresentationAction -
 * 
 * @param editor
 * @param selection
 *            in model coords
 */
public static ITextSelection setSelection(ITextEditor editor, ITextSelection selection) {
	boolean isNarrow = editor.showsHighlightRangeOnly();
	// Use the text widget, as the IRewriteTarget has unpleasant scrolling side effects 
	Control text = getTextWidget(editor);
	try {
		text.setRedraw(false);
		if (isNarrow) {
			editor.showHighlightRangeOnly(false);
		}
		editor.getSelectionProvider().setSelection(selection);
	} finally {
		if (isNarrow) {
			editor.showHighlightRangeOnly(isNarrow);
		}
		text.setRedraw(true);
	}
	return selection;
}
 
Example #14
Source File: BufferLocal.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/************ For testing ****************/

public void handleActivate(IEditorPart epart) {
	if (epart instanceof ITextEditor) {
		handleNarrowActivate((ITextEditor)epart);
	}
}
 
Example #15
Source File: MultiPageEditor.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the source page editor.
 *
 * @return the source page editor
 */
public ITextEditor getSourcePageEditor() {
  if (getCurrentPage() == sourceIndex) {
    return sourceTextEditor;
  } else
    return null;
}
 
Example #16
Source File: TextEditorContextContributionFactory.java    From git-appraise-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
  ITextEditor editor = (ITextEditor)
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();

  additions.addContributionItem(new TextEditorContextMenuContribution(editor), null);
}
 
Example #17
Source File: RemoveBlockCommentHandler.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
protected boolean validateEditorInputState(ITextEditor editor) {
    if (editor instanceof ITextEditorExtension2)
        return ((ITextEditorExtension2) editor).validateEditorInputState();
    else if (editor instanceof ITextEditorExtension)
        return !((ITextEditorExtension) editor).isEditorInputReadOnly();
    else if (editor != null)
        return editor.isEditable();
    else
        return false;
}
 
Example #18
Source File: MarkRing.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Verify that the editor in the location is still in use
 * 
 * @param location
 * @return true if editor is valid
 */
private boolean checkEditor(IBufferLocation location) {
	boolean result = false;
	if (location != null) {
		ITextEditor editor = location.getEditor(); 
		if (editor != null) {
			IEditorInput input = editor.getEditorInput();
			// check all the editor references that match the input for a match
			IEditorReference[] refs = EmacsPlusUtils.getWorkbenchPage().findEditors(input,null, IWorkbenchPage.MATCH_INPUT); 
			for (int i=0; i< refs.length; i++) {
				IEditorPart ed = refs[i].getEditor(false);
				// multi page annoyance
				if (ed instanceof MultiPageEditorPart) {
					IEditorPart[] eds = ((MultiPageEditorPart)ed).findEditors(input);
					for (int j=0; j < eds.length; j++) {
						if (eds[i] == editor) {
							result = true;
							break;
						}
					}
					if (result) {
						break;
					}
				} else {
					if (ed == editor) {
						result = true;
						break;
					}
				}
			}
		}
	}
	return result;
}
 
Example #19
Source File: ToggleTextHoverAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void run() {
	ITextEditor editor= getTextEditor();
	if (editor == null)
		return;

	boolean showHover= !fStore.getBoolean(PreferenceConstants.EDITOR_SHOW_HOVER);
	setChecked(showHover);

	fStore.removePropertyChangeListener(this);
	fStore.setValue(PreferenceConstants.EDITOR_SHOW_HOVER, showHover);
	fStore.addPropertyChangeListener(this);
}
 
Example #20
Source File: AddBlockCommentHandler.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
protected boolean validateEditorInputState(ITextEditor editor) {
    if (editor instanceof ITextEditorExtension2)
        return ((ITextEditorExtension2) editor).validateEditorInputState();
    else if (editor instanceof ITextEditorExtension)
        return !((ITextEditorExtension) editor).isEditorInputReadOnly();
    else if (editor != null)
        return editor.isEditable();
    else
        return false;
}
 
Example #21
Source File: MarkerHandler.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds a fatal error to the problem log.
 * 
 * @param editor The editor to add the errors to
 * @param error The error message 
 */
public void addFatalError(ITextEditor editor, String error) {
    IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
    if (resource == null) return;
    //IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
    try {
        Map<String, ? super Object> map = new HashMap<String, Object>();
        map.put(IMarker.MESSAGE, error);
        map.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR));
        
        MarkerUtilities.createMarker(resource, map, IMarker.PROBLEM);
    } catch (CoreException ce) {
        TexlipsePlugin.log("Creating marker", ce);
    }
}
 
Example #22
Source File: EmacsPlusCmdHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
void executeUniversal(ITextEditor editor, String id, Event event, int count, boolean isNumeric) 
throws NotDefinedException,	ExecutionException, CommandException {
	String did = null;
	if ((did = getInternalCmd(id)) != null) {
		// Emacs+ internal commands should support +- universal-argument
		EmacsPlusUtils.executeCommand(did, count, event, editor);
	} else if (count != 1 && (isUniversalCmd(id) || (alwaysUniversal && !id.startsWith(EmacsPlusUtils.MULGASOFT)))) {
		// only non-Emacs+ commands should be invoked here
		executeWithDispatch(editor, getUniversalCmd(id), count);
	} else {
		executeCommand(id, event, editor);
	}
}
 
Example #23
Source File: RectangleMinibuffer.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Store text in history and invoke the executable command
 * 
 * @see com.mulgasoft.emacsplus.minibuffer.ExecutingMinibuffer#executeResult(org.eclipse.ui.texteditor.ITextEditor, java.lang.Object)
 */
@Override
protected boolean executeResult(ITextEditor editor, Object commandResult) {
	boolean result = true;
	String text = (String)commandResult;
	if (text != null) {
		// skip history on erase replace
		if (text.length() > 0) {
			addToHistory(text); // add to command history
		}
		result = super.executeResult(editor, commandResult);
	}
	return result;
}
 
Example #24
Source File: EditorAPI.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the line base selection values for the given editor part.
 *
 * <p>The given editor part must not be <code>null</code>.
 *
 * @param editorPart the editorPart for which to get the text selection
 * @return the line base selection values for the given editor part or {@link
 *     TextSelection#EMPTY_SELECTION} if the given editor part is is <code>null</code> or not a
 *     text editor, the editor does not have a valid selection provider or document provider, a
 *     valid IDocument could not be obtained form the document provider, or the correct line
 *     numbers or in-lin offsets could not be calculated
 */
public static TextSelection getSelection(IEditorPart editorPart) {
  if (!(editorPart instanceof ITextEditor)) {
    return TextSelection.EMPTY_SELECTION;
  }

  ITextEditor textEditor = (ITextEditor) editorPart;
  ISelectionProvider selectionProvider = textEditor.getSelectionProvider();

  if (selectionProvider == null) {
    return TextSelection.EMPTY_SELECTION;
  }

  IDocumentProvider documentProvider = textEditor.getDocumentProvider();

  if (documentProvider == null) {
    return TextSelection.EMPTY_SELECTION;
  }

  IDocument document = documentProvider.getDocument(editorPart.getEditorInput());

  if (document == null) {
    return TextSelection.EMPTY_SELECTION;
  }

  ITextSelection textSelection = (ITextSelection) selectionProvider.getSelection();
  int offset = textSelection.getOffset();
  int length = textSelection.getLength();

  return calculateSelection(document, offset, length);
}
 
Example #25
Source File: ZapToCharHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see com.mulgasoft.emacsplus.commands.EmacsPlusCmdHandler#transform(org.eclipse.ui.texteditor.ITextEditor, org.eclipse.jface.text.IDocument, org.eclipse.jface.text.ITextSelection, org.eclipse.core.commands.ExecutionEvent)
 */
@Override
protected int transform(ITextEditor editor, IDocument document,
		ITextSelection currentSelection, ExecutionEvent event)
		throws BadLocationException {
	return bufferTransform(new ZapMinibuffer(this), editor, event);
}
 
Example #26
Source File: TagsSetHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Set up working set scope, if present, else workspace
 * 
 * @see com.mulgasoft.emacsplus.commands.TagsSearchHandler#getInputObject(org.eclipse.ui.texteditor.ITextEditor)
 */
protected FileTextSearchScope getInputObject(ITextEditor editor) {
	IWorkingSet set = (wset != null ? wset : getWorkingSet(editor));
	if (set != null) {
		return FileTextSearchScope.newSearchScope(new IWorkingSet[] { set }, new String[0], false);			
	} else {
		return super.getInputObject(editor);
	}
}
 
Example #27
Source File: EditorUtils.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public static ITextEditor openTextEditor(ITextEditor currentEditor, String editorId, IEditorInput newInput,
		OpenNewEditorMode openNewEditor) throws PartInitException, CoreException {
	IWorkbenchPage page;
	if(currentEditor == null) {
		page = WorkbenchUtils.getActivePage();
		openNewEditor = OpenNewEditorMode.ALWAYS;
	} else {
		page = currentEditor.getEditorSite().getWorkbenchWindow().getActivePage();
	}
	
	if(openNewEditor == OpenNewEditorMode.NEVER) {
		if(currentEditor.getEditorInput().equals(newInput)) {
			return currentEditor;
		} else if(currentEditor instanceof IReusableEditor) {
			IReusableEditor reusableEditor = (IReusableEditor) currentEditor;
			reusableEditor.setInput(newInput);
			return currentEditor;
		} else {
			openNewEditor = OpenNewEditorMode.ALWAYS;
		}
	}
	
	int matchFlags = openNewEditor == OpenNewEditorMode.ALWAYS ? 
		IWorkbenchPage.MATCH_NONE : IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID;
	IEditorPart editor = page.openEditor(newInput, editorId, true, matchFlags);
	ITextEditor targetEditor = tryCast(editor, ITextEditor.class);
	if(targetEditor == null) {
		throw EclipseCore.createCoreException("Not a text editor", null);
	}
	return targetEditor;
}
 
Example #28
Source File: KbdMacroBindHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Check for C-x C-k <key> binding conflict
 * 
 * @param editor
 * @param c
 * @return IBindingResult with C-x C-k <key> information
 */
private IBindingResult getBinding(ITextEditor editor, char c) {
	IBindingResult result = null;
	try {
		final KeySequence sequence = KeySequence.getInstance(KeySequence.getInstance(STD_KBD_PREFIX), KeyStroke.getInstance(c));
		final Binding binding = checkForBinding(editor, sequence);
		result = new IBindingResult() {
			public Binding getKeyBinding() { return binding; }
			public String getKeyString() { return sequence.format(); }
			public KeySequence getTrigger() { return sequence; }
		};
	} catch (ParseException e) { }
	return result;
}
 
Example #29
Source File: ToggleBreakpointsTargetFactory.java    From corrosion with Eclipse Public License 2.0 5 votes vote down vote up
private static boolean isRustPart(IWorkbenchPart part) {
	if (part instanceof ITextEditor) {
		IEditorInput editorInput = ((ITextEditor) part).getEditorInput();
		return editorInput instanceof FileEditorInput
				&& "rs".equals(((FileEditorInput) editorInput).getPath().getFileExtension()); //$NON-NLS-1$
	}
	return false;
}
 
Example #30
Source File: KbdMacroSupport.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
public void setExecuting(boolean is, ITextEditor editor, VerifyKeyListener vkf) {
	boolean wasExecuting = isExecuting();
	// keep track of nested macro executions
	if (is) {
		++executeCount;
	} else {
		--executeCount;
	}
	if (!wasExecuting && is) {
		whileExecuting = vkf;
		setViewer(findSourceViewer(editor));
		if (viewer != null) {
			setRedraw(viewer,false);
			if (whileExecuting != null
					&& viewer instanceof ITextViewerExtension) {
				((ITextViewerExtension) viewer)
						.prependVerifyKeyListener(whileExecuting);
			}
		}
		setEditor(editor); 
	} else if (!isExecuting() && viewer != null) {
		setRedraw(viewer,true);
		if (whileExecuting != null && viewer instanceof ITextViewerExtension){
			((ITextViewerExtension) viewer).removeVerifyKeyListener(whileExecuting);
			whileExecuting = null;
		}
		setEditor(null); 
	} 
}