Java Code Examples for org.eclipse.jdt.ui.text.IJavaPartitions#JAVA_PARTITIONING
The following examples show how to use
org.eclipse.jdt.ui.text.IJavaPartitions#JAVA_PARTITIONING .
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: JavaTemplatesPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected SourceViewer createPatternViewer(Composite parent) { IDocument document= new Document(); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); JavaSourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store); SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(viewer, configuration, store); Control control= viewer.getControl(); GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); control.setLayoutData(data); viewer.setEditable(false); return viewer; }
Example 2
Source File: AbstractJavaCompletionProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void handleSmartTrigger(IDocument document, char trigger, int referenceOffset) throws BadLocationException { DocumentCommand cmd= new DocumentCommand() { }; cmd.offset= referenceOffset; cmd.length= 0; cmd.text= Character.toString(trigger); cmd.doit= true; cmd.shiftsCaret= true; cmd.caretOffset= getReplacementOffset() + getCursorPosition(); SmartSemicolonAutoEditStrategy strategy= new SmartSemicolonAutoEditStrategy(IJavaPartitions.JAVA_PARTITIONING); strategy.customizeDocumentCommand(document, cmd); replace(document, cmd.offset, cmd.length, cmd.text); setCursorPosition(cmd.caretOffset - getReplacementOffset() + cmd.text.length()); }
Example 3
Source File: JavaTemplatePreferencePage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected SourceViewer createViewer(Composite parent) { IDocument document= new Document(); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store); SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false); viewer.configure(configuration); viewer.setEditable(false); viewer.setDocument(document); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); viewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(viewer, configuration, store); Control control= viewer.getControl(); GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); control.setLayoutData(data); return viewer; }
Example 4
Source File: GWTJavaEditor.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
@Override protected void doSetInput(IEditorInput input) throws CoreException { IJavaProject javaProject = EditorUtility.getJavaProject(input); if (javaProject != null && GWTNature.isGWTProject(javaProject.getProject())) { // Use GWT partitioning if the compilation unit is in a GWT project inputPartitioning = GWTPartitions.GWT_PARTITIONING; } else { // Otherwise, use Java partitioning to emulate the Java editor inputPartitioning = IJavaPartitions.JAVA_PARTITIONING; } super.doSetInput(input); }
Example 5
Source File: GWTSourceViewerConfiguration.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
@Override public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) { try { ITextEditor editor = getEditor(); return ((GWTJavaEditor) editor).getInputPartitioning(); } catch (Exception e) { GWTPluginLog.logError(e); return IJavaPartitions.JAVA_PARTITIONING; } }
Example 6
Source File: SourceView.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected void internalCreatePartControl(Composite parent) { IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); fViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store); fViewerConfiguration= new SimpleJavaSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false); fViewer.configure(fViewerConfiguration); fViewer.setEditable(false); setViewerFont(); JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener); store.addPropertyChangeListener(fPropertyChangeListener); getViewSite().setSelectionProvider(fViewer); }
Example 7
Source File: JavaEditorColoringConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private Control createPreviewer(Composite parent) { IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore(); IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore }); fPreviewViewer= new JavaSourceViewer(parent, null, null, false, SWT.H_SCROLL | SWT.BORDER, store); SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(fColorManager, store, null, IJavaPartitions.JAVA_PARTITIONING, false); fPreviewViewer.configure(configuration); // fake 1.5 source to get 1.5 features right. configuration.handlePropertyChangeEvent(new PropertyChangeEvent(this, JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4, JavaCore.VERSION_1_5)); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store); fPreviewViewer.setEditable(false); Cursor arrowCursor= fPreviewViewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW); fPreviewViewer.getTextWidget().setCursor(arrowCursor); // Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263 // fPreviewViewer.getTextWidget().setCaret(null); String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$ IDocument document= new Document(content); JavaPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); fPreviewViewer.setDocument(document); installSemanticHighlighting(); return fPreviewViewer.getControl(); }
Example 8
Source File: JavaPairMatcher.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns <code>true</code> if the character at the specified offset is a less-than sign, rather than * the opening angle bracket of a type parameter list. * * @param document a document * @param offset an offset within the document * @return <code>true</code> if the character at the specified offset is a less-than sign * @throws BadLocationException if offset is invalid in the document */ private boolean isLessThanOperator(IDocument document, int offset) throws BadLocationException { if (offset < 0) return false; String contentType= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, offset, false); if (!IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)) { return false; } JavaHeuristicScanner scanner= new JavaHeuristicScanner(document, IJavaPartitions.JAVA_PARTITIONING, contentType); return !isTypeParameterOpeningBracket(offset, document, scanner); }
Example 9
Source File: JavaPairMatcher.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns true if the character at the specified offset is a greater-than sign, rather than an * type parameter list close angle bracket. * * @param document a document * @param offset an offset within the document * @return true if the character at the specified offset is a greater-than sign * @throws BadLocationException if offset is invalid in the document */ private boolean isGreaterThanOperator(IDocument document, int offset) throws BadLocationException { if (offset < 0) return false; String contentType= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, offset, false); if (!IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)) { return false; } JavaHeuristicScanner scanner= new JavaHeuristicScanner(document, IJavaPartitions.JAVA_PARTITIONING, contentType); return !isTypeParameterClosingBracket(offset, document, scanner); }
Example 10
Source File: JavaPreview.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public JavaPreview(Map<String, String> workingValues, Composite parent) { JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); fPreviewDocument= new Document(); fWorkingValues= workingValues; tools.setupJavaDocumentPartitioner( fPreviewDocument, IJavaPartitions.JAVA_PARTITIONING); PreferenceStore prioritizedSettings= new PreferenceStore(); HashMap<String, String> complianceOptions= new HashMap<String, String>(); JavaModelUtil.setComplianceOptions(complianceOptions, JavaModelUtil.VERSION_LATEST); for (Entry<String, String> complianceOption : complianceOptions.entrySet()) { prioritizedSettings.setValue(complianceOption.getKey(), complianceOption.getValue()); } IPreferenceStore[] chain= { prioritizedSettings, JavaPlugin.getDefault().getCombinedPreferenceStore() }; fPreferenceStore= new ChainedPreferenceStore(chain); fSourceViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, fPreferenceStore); fSourceViewer.setEditable(false); Cursor arrowCursor= fSourceViewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW); fSourceViewer.getTextWidget().setCursor(arrowCursor); // Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263 // fSourceViewer.getTextWidget().setCaret(null); fViewerConfiguration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null, IJavaPartitions.JAVA_PARTITIONING, true); fSourceViewer.configure(fViewerConfiguration); fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); fMarginPainter= new MarginPainter(fSourceViewer); final RGB rgb= PreferenceConverter.getColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR); fMarginPainter.setMarginRulerColor(tools.getColorManager().getColor(rgb)); fSourceViewer.addPainter(fMarginPainter); new JavaSourcePreviewerUpdater(); fSourceViewer.setDocument(fPreviewDocument); }
Example 11
Source File: JavaMergeViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected String getDocumentPartitioning() { return IJavaPartitions.JAVA_PARTITIONING; }
Example 12
Source File: EditorAction.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
public void run(IAction action) { if (targetEditor == null) { GWTPluginLog.logWarning("targetEditor is null"); return; } IEditorInput editorInput = targetEditor.getEditorInput(); IResource resource = (IResource) editorInput.getAdapter(IResource.class); ITextEditor javaEditor = (ITextEditor) targetEditor; ITextSelection sel = (ITextSelection) javaEditor.getSelectionProvider().getSelection(); IDocument document = javaEditor.getDocumentProvider().getDocument( javaEditor.getEditorInput()); IDocumentExtension3 document3 = (IDocumentExtension3) document; IDocumentPartitioner gwtPartitioner = document3.getDocumentPartitioner(GWTPartitions.GWT_PARTITIONING); String[] partitionings = document3.getPartitionings(); String partitioning = (gwtPartitioner != null ? GWTPartitions.GWT_PARTITIONING : IJavaPartitions.JAVA_PARTITIONING); ITypedRegion[] types; try { types = TextUtilities.computePartitioning(document, partitioning, sel.getOffset(), sel.getLength(), false); } catch (BadLocationException e) { GWTPluginLog.logError(e); return; } String msg = "File: " + resource.getName(); msg += "\nPartitionings: "; for (String part : partitionings) { msg += "\n" + part; } msg += "\n\nContent types: "; for (ITypedRegion type : types) { msg += "\n" + type.getType(); } msg += "\n\nSelection range: (offset = " + sel.getOffset() + ", length = " + sel.getLength() + ")"; MessageDialog.openInformation(targetEditor.getSite().getShell(), "Selection Info", msg); }
Example 13
Source File: JavaStructureCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected String getDocumentPartitioning() { return IJavaPartitions.JAVA_PARTITIONING; }
Example 14
Source File: CodeTemplateSourceViewerConfiguration.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public CodeTemplateSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore store, ITextEditor editor, TemplateVariableProcessor processor) { super(colorManager, store, editor, IJavaPartitions.JAVA_PARTITIONING, false); fProcessor= processor; }
Example 15
Source File: JavaPairMatcher.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public JavaPairMatcher(char[] pairs) { super(pairs, IJavaPartitions.JAVA_PARTITIONING, true); }
Example 16
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override protected LineChangeHover createChangeHover() { return new JavaChangeHover(IJavaPartitions.JAVA_PARTITIONING, getOrientation()); }
Example 17
Source File: JavaHeuristicScanner.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Calls <code>this(document, IJavaPartitions.JAVA_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE)</code>. * * @param document the document to scan. */ public JavaHeuristicScanner(IDocument document) { this(document, IJavaPartitions.JAVA_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE); }
Example 18
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * Returns a new Java source viewer configuration. * * @return a new <code>JavaSourceViewerConfiguration</code> * @since 3.3 */ protected JavaSourceViewerConfiguration createJavaSourceViewerConfiguration() { JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools(); return new JavaSourceViewerConfiguration(textTools.getColorManager(), getPreferenceStore(), this, IJavaPartitions.JAVA_PARTITIONING); }