org.eclipse.jface.text.source.ISourceViewer Java Examples

The following examples show how to use org.eclipse.jface.text.source.ISourceViewer. 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: JavaEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void doSetInput(IEditorInput input) throws CoreException {
	ISourceViewer sourceViewer= getSourceViewer();
	if (!(sourceViewer instanceof ISourceViewerExtension2)) {
		setPreferenceStore(createCombinedPreferenceStore(input));
		internalDoSetInput(input);
		return;
	}

	// uninstall & unregister preference store listener
	getSourceViewerDecorationSupport(sourceViewer).uninstall();
	((ISourceViewerExtension2)sourceViewer).unconfigure();

	setPreferenceStore(createCombinedPreferenceStore(input));

	// install & register preference store listener
	sourceViewer.configure(getSourceViewerConfiguration());
	getSourceViewerDecorationSupport(sourceViewer).install(getPreferenceStore());

	internalDoSetInput(input);
}
 
Example #2
Source File: CompilationUnitEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createPartControl(Composite parent) {

	super.createPartControl(parent);

	IPreferenceStore preferenceStore= getPreferenceStore();
	boolean closeBrackets= preferenceStore.getBoolean(CLOSE_BRACKETS);
	boolean closeStrings= preferenceStore.getBoolean(CLOSE_STRINGS);
	boolean closeAngularBrackets= JavaCore.VERSION_1_5.compareTo(preferenceStore.getString(JavaCore.COMPILER_SOURCE)) <= 0;

	fBracketInserter.setCloseBracketsEnabled(closeBrackets);
	fBracketInserter.setCloseStringsEnabled(closeStrings);
	fBracketInserter.setCloseAngularBracketsEnabled(closeAngularBrackets);

	ISourceViewer sourceViewer= getSourceViewer();
	if (sourceViewer instanceof ITextViewerExtension)
		((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);

	if (isMarkingOccurrences())
		installOccurrencesFinder(false);
}
 
Example #3
Source File: XtextQuickAssistProcessor.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.3
 */
protected void selectAndRevealQuickfix(IQuickAssistInvocationContext invocationContext, Set<Annotation> applicableAnnotations, List<ICompletionProposal> completionProposals) {
       if (completionProposals.isEmpty()) {
       	return;
       }
	if (!(invocationContext instanceof QuickAssistInvocationContext && ((QuickAssistInvocationContext) invocationContext).isSuppressSelection())) {
		ISourceViewer sourceViewer = invocationContext.getSourceViewer();
		IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
		Iterator<Annotation> iterator = applicableAnnotations.iterator();
		while (iterator.hasNext()) {
			Position pos = annotationModel.getPosition(iterator.next());
			if (pos != null) {
				sourceViewer.setSelectedRange(pos.getOffset(), pos.getLength());
				sourceViewer.revealRange(pos.getOffset(), pos.getLength());
				break;
			}
		}
	}
}
 
Example #4
Source File: PyEditConfiguration.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {
    // create a content assistant:
    PyCorrectionAssistant assistant = new PyCorrectionAssistant();

    // next create a content assistant processor to populate the completions window
    IQuickAssistProcessor processor = new PythonCorrectionProcessor(this.getEdit());

    // Correction assist works on all
    assistant.setQuickAssistProcessor(processor);
    assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));

    //delay and auto activate set on PyContentAssistant constructor.

    return assistant;
}
 
Example #5
Source File: EditTemplateDialog.java    From typescript.java with MIT License 6 votes vote down vote up
private void handleVerifyKeyPressed(VerifyEvent event) {
	if (!event.doit)
		return;

	if (event.stateMask != SWT.MOD1)
		return;

	switch (event.character) {
	case ' ':
		fPatternEditor.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
		event.doit = false;
		break;

	// CTRL-Z
	case 'z' - 'a' + 1:
		fPatternEditor.doOperation(ITextOperationTarget.UNDO);
		event.doit = false;
		break;
	}
}
 
Example #6
Source File: CompilationUnitEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void installTabsToSpacesConverter() {
	ISourceViewer sourceViewer= getSourceViewer();
	SourceViewerConfiguration config= getSourceViewerConfiguration();
	if (config != null && sourceViewer instanceof ITextViewerExtension7) {
		int tabWidth= config.getTabWidth(sourceViewer);
		TabsToSpacesConverter tabToSpacesConverter= new TabsToSpacesConverter();
		tabToSpacesConverter.setNumberOfSpacesPerTab(tabWidth);
		IDocumentProvider provider= getDocumentProvider();
		if (provider instanceof ICompilationUnitDocumentProvider) {
			ICompilationUnitDocumentProvider cup= (ICompilationUnitDocumentProvider) provider;
			tabToSpacesConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
		} else
			tabToSpacesConverter.setLineTracker(new DefaultLineTracker());
		((ITextViewerExtension7)sourceViewer).setTabsToSpacesConverter(tabToSpacesConverter);
		updateIndentPrefixes();
	}
}
 
Example #7
Source File: OpenDeclarationHandler.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
	if (xtextEditor != null) {
		ITextSelection selection = (ITextSelection) xtextEditor.getSelectionProvider().getSelection();

		IRegion region = new Region(selection.getOffset(), selection.getLength());

		ISourceViewer internalSourceViewer = xtextEditor.getInternalSourceViewer();

		IHyperlink[] hyperlinks = getDetector().detectHyperlinks(internalSourceViewer, region, false);
		if (hyperlinks != null && hyperlinks.length > 0) {
			IHyperlink hyperlink = hyperlinks[0];
			hyperlink.open();
		}
	}		
	return null;
}
 
Example #8
Source File: TypeScriptMergeViewer.java    From typescript.java with MIT License 6 votes vote down vote up
@Override
protected ISourceViewer createTypeScriptSourceViewer(Composite parent, IVerticalRuler verticalRuler,
		IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
	return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles,
			store) {
		@Override
		protected void handleDispose() {
			super.handleDispose();

			// dispose the compilation unit adapter
			dispose();

			fEditor.remove(this);
			if (fEditor.isEmpty()) {
				fEditor = null;
				fSite = null;
			}

			fSourceViewer.remove(this);
			if (fSourceViewer.isEmpty())
				fSourceViewer = null;

		}
	};
}
 
Example #9
Source File: FormatterPreviewUtils.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public static void updatePreview(ISourceViewer viewer, URL previewContent, String[] substitutions,
		IScriptFormatterFactory factory, Map<String, String> preferences)
{
	String content = null;
	if (previewContent != null)
	{
		try
		{
			final String c = new String(Util.getInputStreamAsCharArray(previewContent.openConnection()
					.getInputStream(), -1, ENCODING));
			content = Util.concatenate(Util.splitLines(c), LINE_SEPARATOR);
			if (content != null && substitutions != null && substitutions.length > 0)
			{
				content = substitute(content, substitutions);
			}
		}
		catch (IOException e)
		{
			IdeLog.logError(FormatterUIEplPlugin.getDefault(), e, IDebugScopes.DEBUG);
			disablePreview(viewer);
			return;
		}
	}

	updatePreview(viewer, content, substitutions, factory, preferences);
}
 
Example #10
Source File: XMLConfiguration.java    From http4e with Apache License 2.0 6 votes vote down vote up
public IContentFormatter getContentFormatter( ISourceViewer sourceViewer){
    ContentFormatter formatter = new ContentFormatter();
    XMLFormattingStrategy formattingStrategy = new XMLFormattingStrategy();
    DefaultFormattingStrategy defaultStrategy = new DefaultFormattingStrategy();
    TextFormattingStrategy textStrategy = new TextFormattingStrategy();
    DocTypeFormattingStrategy doctypeStrategy = new DocTypeFormattingStrategy();
    PIFormattingStrategy piStrategy = new PIFormattingStrategy();
    formatter.setFormattingStrategy(defaultStrategy,
            IDocument.DEFAULT_CONTENT_TYPE);
    formatter.setFormattingStrategy(textStrategy,
            XMLPartitionScanner.XML_TEXT);
    formatter.setFormattingStrategy(doctypeStrategy,
            XMLPartitionScanner.XML_DOCTYPE);
    formatter.setFormattingStrategy(piStrategy, XMLPartitionScanner.XML_PI);
    formatter.setFormattingStrategy(textStrategy,
            XMLPartitionScanner.XML_CDATA);
    formatter.setFormattingStrategy(formattingStrategy,
            XMLPartitionScanner.XML_START_TAG);
    formatter.setFormattingStrategy(formattingStrategy,
            XMLPartitionScanner.XML_END_TAG);
    
    return formatter;
}
 
Example #11
Source File: PyEditConfigurationWithoutEditor.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
    if (fPreferenceStore == null || !fPreferenceStore.getBoolean(SpellingService.PREFERENCE_SPELLING_ENABLED)) {
        return null;
    }

    SpellingService spellingService = EditorsUI.getSpellingService();
    if (spellingService.getActiveSpellingEngineDescriptor(fPreferenceStore) == null) {
        return null;
    }

    //Overridden (just) to return a PyReconciler!
    IReconcilingStrategy strategy = new PyReconciler(sourceViewer, spellingService);

    MonoReconciler reconciler = new MonoReconciler(strategy, false);
    reconciler.setIsIncrementalReconciler(false);
    reconciler.setProgressMonitor(new NullProgressMonitor());
    reconciler.setDelay(500);
    return reconciler;
}
 
Example #12
Source File: JavaEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void setCaretPosition(final int position) {
	final ISourceViewer viewer= getSourceViewer();

	final StyledText text= viewer.getTextWidget();
	if (text != null && !text.isDisposed()) {

		final Point selection= text.getSelection();
		final int caret= text.getCaretOffset();
		final int offset= modelOffset2WidgetOffset(viewer, position);

		if (caret == selection.x)
			text.setSelectionRange(selection.y, offset - selection.y);
		else
			text.setSelectionRange(selection.x, offset - selection.x);
	}
}
 
Example #13
Source File: JsonSourceViewerConfiguration.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
    ContentAssistant ca = new ContentAssistant();
    JsonContentAssistProcessor processor = createContentAssistProcessor(ca);

    ca.setContentAssistProcessor(processor, IDocument.DEFAULT_CONTENT_TYPE);
    ca.setInformationControlCreator(getInformationControlCreator(sourceViewer));

    ca.enableAutoInsert(false);
    ca.enablePrefixCompletion(false);
    ca.enableAutoActivation(true);
    ca.setAutoActivationDelay(100);
    ca.enableColoredLabels(true);
    ca.setShowEmptyList(true);
    ca.setRepeatedInvocationMode(true);
    ca.addCompletionListener(processor);
    ca.setStatusLineVisible(true);

    return ca;
}
 
Example #14
Source File: JavaSourceViewerConfiguration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {

	if (getEditor() != null) {

		ContentAssistant assistant= new ContentAssistant();
		assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));

		assistant.setRestoreCompletionProposalSize(getSettings("completion_proposal_size")); //$NON-NLS-1$

		IContentAssistProcessor javaProcessor= new JavaCompletionProcessor(getEditor(), assistant, IDocument.DEFAULT_CONTENT_TYPE);
		assistant.setContentAssistProcessor(javaProcessor, IDocument.DEFAULT_CONTENT_TYPE);

		ContentAssistProcessor singleLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);
		assistant.setContentAssistProcessor(singleLineProcessor, IJavaPartitions.JAVA_SINGLE_LINE_COMMENT);

		ContentAssistProcessor stringProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_STRING);
		assistant.setContentAssistProcessor(stringProcessor, IJavaPartitions.JAVA_STRING);

		ContentAssistProcessor multiLineProcessor= new JavaCompletionProcessor(getEditor(), assistant, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);
		assistant.setContentAssistProcessor(multiLineProcessor, IJavaPartitions.JAVA_MULTI_LINE_COMMENT);

		ContentAssistProcessor javadocProcessor= new JavadocCompletionProcessor(getEditor(), assistant);
		assistant.setContentAssistProcessor(javadocProcessor, IJavaPartitions.JAVA_DOC);

		ContentAssistPreference.configure(assistant, fPreferenceStore);

		assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
		assistant.setInformationControlCreator(new IInformationControlCreator() {
			public IInformationControl createInformationControl(Shell parent) {
				return new DefaultInformationControl(parent, JavaPlugin.getAdditionalInfoAffordanceString());
			}
		});

		return assistant;
	}

	return null;
}
 
Example #15
Source File: DefaultCompletionProposalFactory.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public ICompletionProposalHandle createAssistAssignCompletionProposal(String replacementString,
        int replacementOffset, int replacementLength, int cursorPosition, IImageHandle image, String displayString,
        Object contextInformation, String additionalProposalInfo, int priority,
        Object sourceViewer, ICompareContext compareContext) {
    return new AssistAssignCompletionProposal(replacementString, replacementOffset, replacementLength,
            cursorPosition, image, displayString, (IContextInformation) contextInformation, additionalProposalInfo,
            priority,
            (ISourceViewer) sourceViewer, compareContext);
}
 
Example #16
Source File: RenameInformationPopup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void releaseWidgetToken() {
	ISourceViewer viewer= fEditor.getViewer();
	if (viewer instanceof IWidgetTokenOwner) {
		IWidgetTokenOwner widgetTokenOwner= (IWidgetTokenOwner) viewer;
		widgetTokenOwner.releaseWidgetToken(this);
	}
}
 
Example #17
Source File: JsonSourceViewerConfiguration.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IQuickAssistAssistant getQuickAssistAssistant(ISourceViewer sourceViewer) {
    QuickAssistAssistant assistant = new QuickAssistAssistant();
    assistant.setQuickAssistProcessor(new JsonQuickAssistProcessor());
    assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
    return assistant;
}
 
Example #18
Source File: EditorManager.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
/** Called when the local user opened an editor part. (called by EditorPartListener) */
void partOpened(IEditorPart editorPart) {

  log.trace(".partOpened invoked");

  if (!isSharedEditor(editorPart)) return;

  /*
   * If the resource is not accessible it might have been deleted without
   * the editor having been closed (for instance outside of Eclipse).
   * Others might be confused about if they receive this editor from us.
   */
  final IResource resource = EditorAPI.getEditorResource(editorPart);

  if (!resource.isAccessible()) {
    log.warn(".partOpened resource: " + resource + " is not accessible");
    return;
  }

  /*
   * side effect: this method call also locks the editor part if the user
   * has no write access or if the session is currently locked
   */
  editorPool.add(editorPart);

  final ITextViewer viewer = EditorAPI.getViewer(editorPart);

  if (viewer instanceof ISourceViewer)
    customAnnotationManager.installPainter((ISourceViewer) viewer);

  refreshAnnotations(editorPart);

  // HACK 6 Why does this not work via partActivated? Causes duplicate
  // activate events
  partActivated(editorPart);
}
 
Example #19
Source File: ContentAssistProcessorTestBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected ICompletionProposal[] computeCompletionProposals(final IXtextDocument xtextDocument, int cursorPosition,
		XtextSourceViewerConfiguration configuration, ISourceViewer sourceViewer) throws BadLocationException {
	IContentAssistant contentAssistant = configuration.getContentAssistant(sourceViewer);
	String contentType = xtextDocument.getContentType(cursorPosition);
	IContentAssistProcessor processor = contentAssistant.getContentAssistProcessor(contentType);
	if (processor != null) {
		return processor.computeCompletionProposals(sourceViewer, cursorPosition);
	}
	return new ICompletionProposal[0];
}
 
Example #20
Source File: XtextEditor.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Finds the next position after the given position.
 * 
 * @param position
 *            the current position
 * @return the next position
 */
protected int findNextPosition(int position) {
	ISourceViewer viewer = getSourceViewer();
	int widget = -1;
	int next = position;
	while (next != BreakIterator.DONE && widget == -1) {
		next = fIterator.following(next);
		if (next != BreakIterator.DONE)
			widget = modelOffset2WidgetOffset(viewer, next);
	}

	IDocument document = viewer.getDocument();
	LinkedModeModel model = LinkedModeModel.getModel(document, position);
	if (model != null) {
		LinkedPosition linkedPosition = model.findPosition(new LinkedPosition(document, position, 0));
		if (linkedPosition != null) {
			int linkedPositionEnd = linkedPosition.getOffset() + linkedPosition.getLength();
			if (position != linkedPositionEnd && linkedPositionEnd < next)
				next = linkedPositionEnd;
		} else {
			LinkedPosition nextLinkedPosition = model.findPosition(new LinkedPosition(document, next, 0));
			if (nextLinkedPosition != null) {
				int nextLinkedPositionOffset = nextLinkedPosition.getOffset();
				if (position != nextLinkedPositionOffset && nextLinkedPositionOffset < next)
					next = nextLinkedPositionOffset;
			}
		}
	}

	return next;
}
 
Example #21
Source File: SourceCodeTextEditor.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
    final ISourceViewer viewer = super.createSourceViewer(parent, ruler, styles);
    if (isIndenGuidesSupported()) {
        IndentGuidesPainter.installToViewer(viewer, new IndentGuidesModel(this));
    }
    

    viewer.addTextInputListener(new TextInputListener());
    
    return viewer;
}
 
Example #22
Source File: SubWordActions.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Finds the previous position before the given position.
 *
 * @param position the current position
 * @return the previous position
 */
protected int findPreviousPosition(int position) {
    ISourceViewer viewer = getSourceViewer();
    int widget = -1;
    int previous = position;
    while (previous != BreakIterator.DONE && widget == -1) { // XXX: optimize
        previous = fIterator.preceding(previous);
        if (previous != BreakIterator.DONE) {
            widget = modelOffset2WidgetOffset(viewer, previous);
        }
    }

    IDocument document = viewer.getDocument();
    LinkedModeModel model = LinkedModeModel.getModel(document, position);
    if (model != null && previous != BreakIterator.DONE) {
        LinkedPosition linkedPosition = model.findPosition(new LinkedPosition(document, position, 0));
        if (linkedPosition != null) {
            int linkedPositionOffset = linkedPosition.getOffset();
            if (position != linkedPositionOffset && previous < linkedPositionOffset) {
                previous = linkedPositionOffset;
            }
        } else {
            LinkedPosition previousLinkedPosition = model
                    .findPosition(new LinkedPosition(document, previous, 0));
            if (previousLinkedPosition != null) {
                int previousLinkedPositionEnd = previousLinkedPosition.getOffset()
                        + previousLinkedPosition.getLength();
                if (position != previousLinkedPositionEnd && previous < previousLinkedPositionEnd) {
                    previous = previousLinkedPositionEnd;
                }
            }
        }
    }

    return previous;
}
 
Example #23
Source File: TexSourceViewerConfiguration.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
    //return super.getAutoEditStrategies(sourceViewer, contentType);
    if (autoIndentStrategy == null) {
        autoIndentStrategy = new TexAutoIndentStrategy();
    }
    return new IAutoEditStrategy[] {autoIndentStrategy};
}
 
Example #24
Source File: AbstractLangSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) {
	return new HTMLAnnotationHover(true) {
		@Override
		protected boolean isIncluded(Annotation annotation) {
			return isShowInOverviewRuler(annotation);
		}
	};
}
 
Example #25
Source File: DoubleClickStrategyProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public ITextDoubleClickStrategy getStrategy(ISourceViewer sourceViewer, String contentType, String documentPartitioning) {
	if (TerminalsTokenTypeToPartitionMapper.COMMENT_PARTITION.equals(contentType))
		return new FixedCharCountPartitionDoubleClickSelector(documentPartitioning, 0, 0);
	if (TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION.equals(contentType))
		return new FixedCharCountPartitionDoubleClickSelector(documentPartitioning, 0, 0);
	if (TerminalsTokenTypeToPartitionMapper.STRING_LITERAL_PARTITION.equals(contentType))
		return new FixedCharCountPartitionDoubleClickSelector(documentPartitioning, 1, 1);
	return defaultDoubleClickStrategy;
}
 
Example #26
Source File: DotDoubleClickStrategyProvider.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ITextDoubleClickStrategy getStrategy(ISourceViewer sourceViewer,
		String contentType, String documentPartitioning) {
	if (DotTerminalsTokenTypeToPartitionMapper.HTML_STRING_PARTITION
			.equals(contentType)) {
		return new DotHtmlLabelDoubleClickStrategy();
	}
	return super.getStrategy(sourceViewer, contentType,
			documentPartitioning);
}
 
Example #27
Source File: ImpexSourceViewerConfig.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
	
	return new String[] { 
			IDocument.DEFAULT_CONTENT_TYPE,
			ImpexDocumentPartitioner.IMPEX_COMMENT,
			ImpexDocumentPartitioner.IMPEX_DATA,
			ImpexDocumentPartitioner.IMPEX_HEADER,
			ImpexDocumentPartitioner.IMPEX_INSTRUCTION };
}
 
Example #28
Source File: KbdMacroSupport.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
private void setRedraw(ISourceViewer view, boolean value) {
	if (view != null) {
		try {
			// some viewers may not have a text widget
			view.getTextWidget().setRedraw(value);
		} catch (Exception e) {}
	}
}
 
Example #29
Source File: RenameInformationPopup.java    From typescript.java with MIT License 5 votes vote down vote up
private void updateVisibility() {
	if (fPopup != null && !fPopup.isDisposed() && fDelayJobFinished) {
		boolean visible= false;
		//TODO: Check for visibility of linked position, not whether popup is outside of editor?
		if (fRenameLinkedMode.isCaretInLinkedPosition()) {
			StyledText textWidget= fEditor.getViewer().getTextWidget();
			Rectangle eArea= Geometry.toDisplay(textWidget, textWidget.getClientArea());
			Rectangle pBounds= fPopup.getBounds();
			pBounds.x-= GAP;
			pBounds.y-= GAP;
			pBounds.width+= 2 * GAP;
			pBounds.height+= 2 * GAP;
			if (eArea.intersects(pBounds)) {
				visible= true;
			}
		}
		if (visible && ! fPopup.isVisible()) {
			ISourceViewer viewer= fEditor.getViewer();
			if (viewer instanceof IWidgetTokenOwnerExtension) {
				IWidgetTokenOwnerExtension widgetTokenOwnerExtension= (IWidgetTokenOwnerExtension) viewer;
				visible= widgetTokenOwnerExtension.requestWidgetToken(this, WIDGET_PRIORITY);
			}
		} else if (! visible && fPopup.isVisible()) {
			releaseWidgetToken();
		}
		fPopup.setVisible(visible);
	}
}
 
Example #30
Source File: SpecificContentAssistAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean computeEnablement(ITextEditor editor) {
	if (editor == null)
		return false;
	
	ITextOperationTarget target= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
	if (target == null || ! target.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS))
		return false;
	
	IJavaProject javaProject = EditorUtility.getJavaProject(editor.getEditorInput());
	if (! fCategory.matches(javaProject))
		return false;
	
	ISelection selection= editor.getSelectionProvider().getSelection();
	return isValidSelection(selection);
}