org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingPresenter Java Examples

The following examples show how to use org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingPresenter. 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: FixedHighlightingReconciler.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Install this reconciler on the given editor and presenter.
 *
 * @param editor
 *          the editor
 * @param sourceViewer
 *          the source viewer
 * @param presenter
 *          the highlighting presenter
 */
@Override
public void install(final XtextEditor editor, final XtextSourceViewer sourceViewer, final HighlightingPresenter presenter) {
  synchronized (fReconcileLock) {
    cleanUpAfterReconciliation = false; // prevents a potentially already running reconciliation process to clean up after itself
  }
  this.presenter = presenter;
  this.editor = editor;
  this.sourceViewer = sourceViewer;
  if (oldCalculator != null || newCalculator != null) {
    if (editor == null) {
      ((IXtextDocument) sourceViewer.getDocument()).addModelListener(this);
    } else if (editor.getDocument() != null) {
      editor.getDocument().addModelListener(this);
    }

    sourceViewer.addTextInputListener(this);
  }
  refresh();
}
 
Example #2
Source File: XtextStyledTextHighlightingReconciler.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Install this reconciler on the given editor and presenter.
 * 
 * @param editor
 *            the editor
 * @param sourceViewer
 *            the source viewer
 * @param presenter
 *            the highlighting presenter
 */
public void install(StyledTextXtextAdapter xtextStyledText, XtextSourceViewer sourceViewer,
		HighlightingPresenter presenter) {
	this.presenter = presenter;
	this.styledTextXtextAdapter = xtextStyledText;
	this.sourceViewer = sourceViewer;
	if (calculator != null) {
		if (styledTextXtextAdapter.getXtextDocument() != null)
			styledTextXtextAdapter.getXtextDocument().addModelListener(this);

		sourceViewer.addTextInputListener(this);
	}
	refresh();
}
 
Example #3
Source File: XtextStyledTextHighlightingReconciler.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public void modelChanged(XtextResource resource) {
	// ensure at most one thread can be reconciling at any time
	synchronized (fReconcileLock) {
		if (reconciling)
			return;
		reconciling = true;
	}
	final HighlightingPresenter highlightingPresenter = presenter;
	try {
		if (highlightingPresenter == null)
			return;

		highlightingPresenter.setCanceled(false);

		if (highlightingPresenter.isCanceled())
			return;

		startReconcilingPositions();

		if (!highlightingPresenter.isCanceled()) {
			reconcilePositions(resource);
		}

		final TextPresentation[] textPresentation = new TextPresentation[1];
		if (!highlightingPresenter.isCanceled()) {
			textPresentation[0] = highlightingPresenter.createPresentation(
					addedPositions, removedPositions);
		}

		if (!highlightingPresenter.isCanceled())
			updatePresentation(textPresentation[0], addedPositions,
					removedPositions);

		stopReconcilingPositions();
	} finally {
		synchronized (fReconcileLock) {
			reconciling = false;
		}
	}
}
 
Example #4
Source File: FixedHighlightingReconciler.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @since 2.7
 */
@Override
public void modelChanged(final XtextResource resource, final CancelIndicator cancelIndicator) {
  if (resource == null) {
    return;
  }

  // ensure at most one thread can be reconciling at any time
  synchronized (fReconcileLock) {
    if (reconciling) {
      return;
    }
    reconciling = true;
  }
  final HighlightingPresenter highlightingPresenter = presenter;
  try {
    if (highlightingPresenter == null) {
      return;
    }

    highlightingPresenter.setCanceled(cancelIndicator.isCanceled());

    if (highlightingPresenter.isCanceled()) {
      return;
    }
    checkCanceled(cancelIndicator);

    startReconcilingPositions();

    if (highlightingPresenter.isCanceled()) {
      return;
    }
    checkCanceled(cancelIndicator);
    reconcilePositions(resource, cancelIndicator);

    if (highlightingPresenter.isCanceled()) {
      return;
    }
    checkCanceled(cancelIndicator);
    final TextPresentation textPresentation = highlightingPresenter.createPresentation(addedPositions, removedPositions);

    if (highlightingPresenter.isCanceled()) {
      return;
    }
    checkCanceled(cancelIndicator);
    updatePresentation(textPresentation, addedPositions, removedPositions, resource);

  } finally {
    if (highlightingPresenter != null) {
      highlightingPresenter.setCanceled(false);
    }
    stopReconcilingPositions();
    synchronized (fReconcileLock) {
      reconciling = false;
      if (cleanUpAfterReconciliation) {
        editor = null;
        sourceViewer = null;
        presenter = null;
        cleanUpAfterReconciliation = false;
      }
    }
  }
}
 
Example #5
Source File: XtextStyledTextHighlightingHelper.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
public void setPresenterProvider(
		Provider<HighlightingPresenter> presenterProvider) {
	this.presenterProvider = presenterProvider;
}
 
Example #6
Source File: XtextStyledTextHighlightingHelper.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
public Provider<HighlightingPresenter> getPresenterProvider() {
	return presenterProvider;
}