Java Code Examples for org.eclipse.jface.text.IDocument#setDocumentPartitioner()
The following examples show how to use
org.eclipse.jface.text.IDocument#setDocumentPartitioner() .
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: XtextDocumentProvider.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override protected IDocument createDocument(Object element) throws CoreException { IDocument document = null; if (isWorkspaceExternalEditorInput(element)) { document= createEmptyDocument(); if (setDocumentContent(document, (IEditorInput) element, getEncoding(element))) { setupDocument(element, document); } } else { document = super.createDocument(element); } if (document != null) { IDocumentPartitioner partitioner = documentPartitioner.get(); partitioner.connect(document); document.setDocumentPartitioner(partitioner); } return document; }
Example 2
Source File: DocumentProvider.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 6 votes |
@Override protected IDocument createDocument(Object element) throws CoreException { IDocument document = super.createDocument(element); //IDocumentPartitioner partitioner = createDocumentPartitioner(); IDocumentPartitioner partitioner = new ImpexDocumentPartitioner(); if ((document instanceof IDocumentExtension3)) { IDocumentExtension3 extension3 = (IDocumentExtension3) document; extension3.setDocumentPartitioner(Activator.IMPEX_PARTITIONING, partitioner); } else { document.setDocumentPartitioner(partitioner); } partitioner.connect(document); return document; }
Example 3
Source File: PartitionUtils.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
/** * Sets document's partitioner. * * @param document the document to be processed * @param partitioningType the partitioning for which to set the partitioner * @param partitioner the document's new partitioner * * @see org.eclipse.jface.text.IDocumentExtension3#setDocumentPartitioner(IDocument,String,IDocumentPartitioner) * @see IDocumentPartitioningListener */ public static void setDocumentPartitioning( IDocument document , String partitioningType , IDocumentPartitioner partitioner ) { // Setting the partitioner will trigger a partitionChanged listener that // will attempt to use the partitioner to initialize the document's // partitions. Therefore, need to connect first. partitioner.connect(document); if (document instanceof IDocumentExtension3) { IDocumentExtension3 extension3= (IDocumentExtension3) document; extension3.setDocumentPartitioner(partitioningType, partitioner); } else { document.setDocumentPartitioner(partitioner); } }
Example 4
Source File: DocumentUtils.java From http4e with Apache License 2.0 | 6 votes |
public static IDocument createDocument1(){ IDocument doc = new Document(){ public String getDefaultLineDelimiter(){ return String.valueOf(AssistConstants.LINE_DELIM_NL) /*super.getDefaultLineDelimiter()*/; } }; IDocumentPartitioner partitioner = new DefaultPartitioner( new HPartitionScanner(), new String[] { HPartitionScanner.COMMENT, HPartitionScanner.PROPERTY_VALUE}); partitioner.connect(doc); doc.setDocumentPartitioner(partitioner); return doc; }
Example 5
Source File: HTMLDocumentProvider.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
@Override public void connect(Object element) throws CoreException { super.connect(element); IDocument document = getDocument(element); if (document != null) { CompositePartitionScanner partitionScanner = new CompositePartitionScanner(HTMLSourceConfiguration .getDefault().createSubPartitionScanner(), new NullSubPartitionScanner(), new NullPartitionerSwitchStrategy()); IDocumentPartitioner partitioner = new ExtendedFastPartitioner(partitionScanner, HTMLSourceConfiguration .getDefault().getContentTypes()); partitionScanner.setPartitioner((IExtendedPartitioner) partitioner); partitioner.connect(document); document.setDocumentPartitioner(partitioner); CommonEditorPlugin.getDefault().getDocumentScopeManager().registerConfiguration(document, HTMLSourceConfiguration.getDefault()); } }
Example 6
Source File: AbstractFormatterPreferencePage.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * @param composite */ public SourceViewer createSourcePreview(Composite composite, IScriptFormatterFactory factory) { IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore(); // TODO - Note that we pass the factory's preferences store and not calling to this.getPrefereceStore. // In case we decide to unify the preferences into the this plugin, we might need to change this. IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { factory.getPreferenceStore(), generalTextStore }); SourceViewer fPreviewViewer = createPreviewViewer(composite, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store); if (fPreviewViewer == null) { return null; } SourceViewerConfiguration configuration = (SourceViewerConfiguration) factory .createSimpleSourceViewerConfiguration(fColorManager, store, null, false); fPreviewViewer.configure(configuration); if (fPreviewViewer.getTextWidget().getTabs() == 0) { fPreviewViewer.getTextWidget().setTabs(4); } new ScriptSourcePreviewerUpdater(fPreviewViewer, configuration, store); fPreviewViewer.setEditable(false); IDocument document = new Document(); fPreviewViewer.setDocument(document); IPartitioningConfiguration partitioningConfiguration = (IPartitioningConfiguration) factory .getPartitioningConfiguration(); CompositePartitionScanner partitionScanner = new CompositePartitionScanner( partitioningConfiguration.createSubPartitionScanner(), new NullSubPartitionScanner(), new NullPartitionerSwitchStrategy()); IDocumentPartitioner partitioner = new ExtendedFastPartitioner(partitionScanner, partitioningConfiguration.getContentTypes()); partitionScanner.setPartitioner((IExtendedPartitioner) partitioner); partitioner.connect(document); document.setDocumentPartitioner(partitioner); return fPreviewViewer; }
Example 7
Source File: XMLDocumentProvider.java From codeexamples-eclipse with Eclipse Public License 1.0 | 5 votes |
@Override protected IDocument createDocument(Object element) throws CoreException { IDocument document = super.createDocument(element); if (document != null) { IDocumentPartitioner partitioner = new FastPartitioner(new XMLPartitionScanner(), new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT }); partitioner.connect(document); document.setDocumentPartitioner(partitioner); } return document; }
Example 8
Source File: EditorConfigDocumentSetupParticipant.java From editorconfig-eclipse with Apache License 2.0 | 5 votes |
public static void setupDocument(IDocument document) { IDocumentPartitioner partitioner = createDocumentPartitioner(); if (document instanceof IDocumentExtension3) { IDocumentExtension3 extension3 = (IDocumentExtension3) document; extension3.setDocumentPartitioner(IEditorConfigPartitions.EDITOR_CONFIG_PARTITIONING, partitioner); } else { document.setDocumentPartitioner(partitioner); } partitioner.connect(document); }
Example 9
Source File: PropertiesFileDocumentSetupParticipant.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @param document the document * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument) */ public static void setupDocument(IDocument document) { IDocumentPartitioner partitioner= createDocumentPartitioner(); if (document instanceof IDocumentExtension3) { IDocumentExtension3 extension3= (IDocumentExtension3) document; extension3.setDocumentPartitioner(IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING, partitioner); } else { document.setDocumentPartitioner(partitioner); } partitioner.connect(document); }
Example 10
Source File: JavaTextTools.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Sets up the Java document partitioner for the given document for the given partitioning. * * @param document the document to be set up * @param partitioning the document partitioning * @since 3.0 */ public void setupJavaDocumentPartitioner(IDocument document, String partitioning) { IDocumentPartitioner partitioner= createDocumentPartitioner(); if (document instanceof IDocumentExtension3) { IDocumentExtension3 extension3= (IDocumentExtension3) document; extension3.setDocumentPartitioner(partitioning, partitioner); } else { document.setDocumentPartitioner(partitioner); } partitioner.connect(document); }
Example 11
Source File: SimpleDocumentProvider.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@Override public void connect(Object element) throws CoreException { super.connect(element); IDocument document = this.getDocument(element); if (document != null) { IPartitioningConfiguration configuration = this.getPartitioningConfiguration(); IDocumentPartitioner partitioner = new ExtendedFastPartitioner(this.createPartitionScanner(), configuration.getContentTypes()); partitioner.connect(document); document.setDocumentPartitioner(partitioner); CommonEditorPlugin.getDefault().getDocumentScopeManager().registerConfiguration(document, configuration); } }
Example 12
Source File: ReportDocumentProvider.java From birt with Eclipse Public License 1.0 | 5 votes |
protected IDocument createDocument( Object element ) throws CoreException { IDocument document = super.createDocument( element ); if ( document != null ) { IDocumentPartitioner partitioner = new FastPartitioner( new XMLPartitionScanner( ), new String[]{ XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT } ); partitioner.connect( document ); document.setDocumentPartitioner( partitioner ); } return document; }
Example 13
Source File: XMLDocumentProvider.java From uima-uimaj with Apache License 2.0 | 5 votes |
@Override protected IDocument createDocument(Object element) throws CoreException { IDocument document = super.createDocument(element); if (document != null) { IDocumentPartitioner partitioner = new DefaultPartitioner(new XMLPartitionScanner(), new String[] { XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_COMMENT }); partitioner.connect(document); document.setDocumentPartitioner(partitioner); } return document; }
Example 14
Source File: SVGDocumentProvider.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@Override public void connect(Object element) throws CoreException { super.connect(element); IDocument document = getDocument(element); if (document != null) { CompositePartitionScanner partitionScanner = new CompositePartitionScanner( // SVGSourceConfiguration.getDefault().createSubPartitionScanner(), // new NullSubPartitionScanner(), // new NullPartitionerSwitchStrategy() // ); IDocumentPartitioner partitioner = new ExtendedFastPartitioner( // partitionScanner, // SVGSourceConfiguration.getDefault().getContentTypes() // ); partitionScanner.setPartitioner((IExtendedPartitioner) partitioner); partitioner.connect(document); document.setDocumentPartitioner(partitioner); CommonEditorPlugin.getDefault().getDocumentScopeManager().registerConfiguration( // document, // SVGSourceConfiguration.getDefault() // ); } }
Example 15
Source File: EclipseUtils.java From goclipse with Eclipse Public License 1.0 | 5 votes |
public static void setupDocumentPartitioner(IDocument document, String partitioning, IDocumentPartitioner partitioner) { assertNotNull(document); assertNotNull(partitioning); assertNotNull(partitioner); partitioner.connect(document); if (document instanceof IDocumentExtension3) { IDocumentExtension3 extension3 = (IDocumentExtension3) document; extension3.setDocumentPartitioner(partitioning, partitioner); } else { document.setDocumentPartitioner(partitioner); } }
Example 16
Source File: JimpleDocumentProvider.java From JAADAS with GNU General Public License v3.0 | 5 votes |
protected IDocument createDocument(Object element) throws CoreException { IDocument document = super.createDocument(element); if (document != null) { IDocumentPartitioner partitioner = new DefaultPartitioner( new JimplePartitionScanner(), new String[] { JimplePartitionScanner.JIMPLE_STRING}); partitioner.connect(document); document.setDocumentPartitioner(partitioner); } return document; }
Example 17
Source File: JSDocumentProvider.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * @see DocumentProvider#createDocument(java.lang.Object) */ protected IDocument createDocument( Object element ) throws CoreException { IDocument document = super.createDocument( element ); if ( document != null ) { IDocumentPartitioner partitioner = new DefaultPartitioner( new JSPartitionScanner( ), colorTokens ); partitioner.connect( document ); document.setDocumentPartitioner( partitioner ); } return document; }
Example 18
Source File: CommonFormatterUtils.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * Format a given input string that is in the given file path (or should be injected to).<br> * This method will try to determine the content type and the project's formatter settings by the file path and run * the right formatter in order to generate a formatted output. * * @param filePath * @param input * @return The formatted output, or the given input in case the input could not be formatted. */ public static String format(IPath filePath, String input) { if (filePath == null || input == null || input.trim().length() == 0) { return input; } IContentType contentType = Platform.getContentTypeManager().findContentTypeFor(filePath.lastSegment()); if (contentType != null) { // Format the string before returning it IScriptFormatterFactory factory = ScriptFormatterManager.getSelected(contentType.getId()); if (factory != null) { IDocument document = new Document(input); IPartitioningConfiguration partitioningConfiguration = (IPartitioningConfiguration) factory .getPartitioningConfiguration(); CompositePartitionScanner partitionScanner = new CompositePartitionScanner( partitioningConfiguration.createSubPartitionScanner(), new NullSubPartitionScanner(), new NullPartitionerSwitchStrategy()); IDocumentPartitioner partitioner = new ExtendedFastPartitioner(partitionScanner, partitioningConfiguration.getContentTypes()); partitionScanner.setPartitioner((IExtendedPartitioner) partitioner); partitioner.connect(document); document.setDocumentPartitioner(partitioner); final String lineDelimiter = TextUtilities.getDefaultLineDelimiter(document); IResource parentResource = ResourcesPlugin.getWorkspace().getRoot() .findMember(filePath.removeLastSegments(1)); if (parentResource != null) { IProject project = parentResource.getProject(); Map<String, String> preferences = factory .retrievePreferences(new PreferencesLookupDelegate(project)); TextEdit formattedTextEdit = factory.createFormatter(lineDelimiter, preferences).format(input, 0, input.length(), 0, false, null, StringUtil.EMPTY); try { formattedTextEdit.apply(document); input = document.get(); } catch (Exception e) { IdeLog.logError(CommonEditorPlugin.getDefault(), "Error while formatting the file template code", e); //$NON-NLS-1$ } } } } return input; }
Example 19
Source File: PatternExpressionViewer.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
protected void addDocumentPartitioner(final IDocument document) { final IDocumentPartitioner partitioner = new GroovyExpressionPartitioner(); partitioner.connect(document); document.setDocumentPartitioner(partitioner); }
Example 20
Source File: PyPartitionScannerTest.java From Pydev with Eclipse Public License 1.0 | 4 votes |
public void testPartitioning3() throws Exception { String txt = "" + "'\\\n" + "\\\n" + "a' b '\\\n" + "c\\\n" + "e' x'g' ''' h ''' " + ""; IDocument document = new Document(txt); PyPartitioner partitioner = PyPartitionScanner.createPyPartitioner(); String scan = TestUtils.scan(partitioner.getScanner(), document); assertEquals(TestUtils.listToExpected("__python_singleline_bytes_or_unicode1:0:7", "null:7:1", "null:8:1", "null:9:1", "__python_singleline_bytes_or_unicode1:10:8", "null:18:1", "null:19:1", "__python_singleline_bytes_or_unicode1:20:3", "null:23:1", "__python_multiline_bytes_or_unicode1:24:9", "null:33:1"), scan); partitioner.connect(document); document.setDocumentPartitioner(partitioner); checkPartitions(document, "__python_singleline_bytes_or_unicode1:0:7", "__dftl_partition_content_type:7:10", "__python_singleline_bytes_or_unicode1:10:18", "__dftl_partition_content_type:18:20", "__python_singleline_bytes_or_unicode1:20:23", "__dftl_partition_content_type:23:24", "__python_multiline_bytes_or_unicode1:24:33", "__dftl_partition_content_type:33:"); document.replace(txt.length() - " ''' ".length(), 0, "i"); checkPartitions(document, "__python_singleline_bytes_or_unicode1:0:7", "__dftl_partition_content_type:7:10", "__python_singleline_bytes_or_unicode1:10:18", "__dftl_partition_content_type:18:20", "__python_singleline_bytes_or_unicode1:20:23", "__dftl_partition_content_type:23:24", "__python_multiline_bytes_or_unicode1:24:34", "__dftl_partition_content_type:34:"); document.replace(txt.length() - " ''' ".length() + 1, 0, "j"); checkPartitions(document, "__python_singleline_bytes_or_unicode1:0:7", "__dftl_partition_content_type:7:10", "__python_singleline_bytes_or_unicode1:10:18", "__dftl_partition_content_type:18:20", "__python_singleline_bytes_or_unicode1:20:23", "__dftl_partition_content_type:23:24", "__python_multiline_bytes_or_unicode1:24:35", "__dftl_partition_content_type:35:"); }