Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 87647 Details for
Bug 208881
[api] enable document setup participants to customize behaviour based on resource being opened
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
reworked patch
208881_Jan23_1.txt (text/plain), 33.25 KB, created by
Andrew Ferguson
on 2008-01-23 09:06:09 EST
(
hide
)
Description:
reworked patch
Filename:
MIME Type:
Creator:
Andrew Ferguson
Created:
2008-01-23 09:06:09 EST
Size:
33.25 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.filebuffers.tests >Index: src/org/eclipse/core/filebuffers/tests/FileBuffersTestSuite.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.filebuffers.tests/src/org/eclipse/core/filebuffers/tests/FileBuffersTestSuite.java,v >retrieving revision 1.7 >diff -u -r1.7 FileBuffersTestSuite.java >--- src/org/eclipse/core/filebuffers/tests/FileBuffersTestSuite.java 29 May 2007 16:38:49 -0000 1.7 >+++ src/org/eclipse/core/filebuffers/tests/FileBuffersTestSuite.java 23 Jan 2008 13:59:50 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Andrew Ferguson (Symbian) > *******************************************************************************/ > > package org.eclipse.core.filebuffers.tests; >@@ -38,6 +39,9 @@ > suite.addTestSuite(FileStoreFileBuffersForExternalFiles.class); > suite.addTestSuite(FileStoreFileBuffersForNonExistingExternalFiles.class); > suite.addTestSuite(FileStoreFileBuffersForNonExistingWorkspaceFiles.class); >+ >+ suite.addTestSuite(TextFileManagerDocCreationTests.class); >+ suite.addTestSuite(ResourceTextFileManagerDocCreationTests.class); > //$JUnit-END$ > return suite; > } >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.filebuffers.tests/META-INF/MANIFEST.MF,v >retrieving revision 1.3 >diff -u -r1.3 MANIFEST.MF >--- META-INF/MANIFEST.MF 23 Jan 2008 08:47:31 -0000 1.3 >+++ META-INF/MANIFEST.MF 23 Jan 2008 13:59:50 -0000 >@@ -1,7 +1,7 @@ > Manifest-Version: 1.0 > Bundle-ManifestVersion: 2 > Bundle-Name: %Plugin.name >-Bundle-SymbolicName: org.eclipse.core.filebuffers.tests >+Bundle-SymbolicName: org.eclipse.core.filebuffers.tests;singleton:=true > Bundle-Version: 3.4.0.qualifier > Bundle-ClassPath: filebufferstests.jar > Bundle-Activator: org.eclipse.core.filebuffers.tests.FileBuffersTestPlugin >Index: build.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.filebuffers.tests/build.properties,v >retrieving revision 1.5 >diff -u -r1.5 build.properties >--- build.properties 29 Jun 2007 15:29:33 -0000 1.5 >+++ build.properties 23 Jan 2008 13:59:50 -0000 >@@ -13,7 +13,8 @@ > about.html,\ > testResources/,\ > *.jar,\ >- META-INF/ >+ META-INF/,\ >+ plugin.xml > > src.includes = about.html > >Index: plugin.xml >=================================================================== >RCS file: plugin.xml >diff -N plugin.xml >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ plugin.xml 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,75 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<?eclipse version="3.2"?> >+<!-- >+ - >+ - Register IDocumentSetupParticipants against names and extensions that won't interfere with >+ - normal operation. >+ - >+ --> >+<plugin> >+<!-- IDocumentSetupParticipant --> >+ <extension point="org.eclipse.core.filebuffers.documentSetup"> >+ <participant >+ class="org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants$TestDSP1" >+ extensions="111foo"> >+ </participant> >+ </extension> >+ <extension point="org.eclipse.core.filebuffers.documentSetup"> >+ <participant >+ class="org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants$TestDSP2" >+ fileNames="111fooname,111fooname.111foo"> >+ </participant> >+ </extension> >+ <extension point="org.eclipse.core.filebuffers.documentSetup"> >+ <participant >+ class="org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants$TestDSP3" >+ extensions="111foo" >+ fileNames="111fooname,111fooname.111foo"> >+ </participant> >+ </extension> >+ >+ <!-- IDocumentSetupParticipantExtension ignoring hint --> >+ <extension point="org.eclipse.core.filebuffers.documentSetup"> >+ <participant >+ class="org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants$TestDSP4" >+ extensions="222foo"> >+ </participant> >+ </extension> >+ <extension point="org.eclipse.core.filebuffers.documentSetup"> >+ <participant >+ class="org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants$TestDSP5" >+ fileNames="222fooname,222fooname.222foo"> >+ </participant> >+ </extension> >+ <extension point="org.eclipse.core.filebuffers.documentSetup"> >+ <participant >+ class="org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants$TestDSP6" >+ extensions="222foo" >+ fileNames="222fooname,222fooname.222foo"> >+ </participant> >+ </extension> >+ >+ <!-- IDocumentSetupPartcipantExtension selectively picking up hint --> >+ <extension point="org.eclipse.core.filebuffers.documentSetup"> >+ <participant >+ class="org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants$TestDSP7" >+ extensions="333foo" >+ fileNames="333fooname,333fooname.333foo"> >+ </participant> >+ </extension> >+ <extension point="org.eclipse.core.filebuffers.documentSetup"> >+ <participant >+ class="org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants$TestDSP8" >+ extensions="444foo" >+ fileNames="444fooname,444fooname.444foo"> >+ </participant> >+ </extension> >+ <extension point="org.eclipse.core.filebuffers.documentSetup"> >+ <participant >+ class="org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants$TestDSP9" >+ extensions="555foo" >+ fileNames="555fooname,555fooname.555foo"> >+ </participant> >+ </extension> >+</plugin> >+ >Index: src/org/eclipse/core/filebuffers/tests/ResourceTextFileManagerDocCreationTests.java >=================================================================== >RCS file: src/org/eclipse/core/filebuffers/tests/ResourceTextFileManagerDocCreationTests.java >diff -N src/org/eclipse/core/filebuffers/tests/ResourceTextFileManagerDocCreationTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/filebuffers/tests/ResourceTextFileManagerDocCreationTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Symbian Software Systems and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Ferguson (Symbian) - Initial implementation >+ *******************************************************************************/ >+package org.eclipse.core.filebuffers.tests; >+ >+import org.eclipse.core.filebuffers.LocationKind; >+import org.eclipse.core.internal.filebuffers.ResourceTextFileBufferManager; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.ResourcesPlugin; >+import org.eclipse.core.runtime.Path; >+ >+public class ResourceTextFileManagerDocCreationTests extends AbstractFileBufferDocCreationTests { >+ protected void setUp() throws Exception { >+ fManager= new ResourceTextFileBufferManager(); >+ } >+ >+ protected void assertDocumentContent(String expectedContent, String fullPath, LocationKind locKind) { >+ assertEquals(expectedContent, fManager.createEmptyDocument(new Path(fullPath), locKind).get()); >+ if(locKind.equals(LocationKind.IFILE)) { >+ IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fullPath)); >+ assertEquals(expectedContent, ((ResourceTextFileBufferManager)fManager).createEmptyDocument(file).get()); >+ } >+ } >+ >+ protected LocationKind[] getSupportLocationKinds() { >+ return new LocationKind[] {LocationKind.IFILE, LocationKind.LOCATION, LocationKind.NORMALIZE}; >+ } >+} >Index: src/org/eclipse/core/filebuffers/tests/TextFileManagerDocCreationTests.java >=================================================================== >RCS file: src/org/eclipse/core/filebuffers/tests/TextFileManagerDocCreationTests.java >diff -N src/org/eclipse/core/filebuffers/tests/TextFileManagerDocCreationTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/filebuffers/tests/TextFileManagerDocCreationTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Symbian Software Systems and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Ferguson (Symbian) - Initial implementation >+ *******************************************************************************/ >+package org.eclipse.core.filebuffers.tests; >+ >+import org.eclipse.core.filebuffers.LocationKind; >+import org.eclipse.core.internal.filebuffers.TextFileBufferManager; >+ >+public class TextFileManagerDocCreationTests extends AbstractFileBufferDocCreationTests { >+ protected void setUp() throws Exception { >+ fManager= new TextFileBufferManager(); >+ } >+ >+ protected void assertDocumentContent(String expectedContent, String path, >+ LocationKind locKind) { >+ if(!locKind.equals(LocationKind.IFILE)) { >+ /** {@link TextFileBufferManager} does not deal with {@link LocationKind#IFILE} */ >+ super.assertDocumentContent(expectedContent, path, locKind); >+ } >+ } >+ >+ protected LocationKind[] getSupportLocationKinds() { >+ return new LocationKind[] {LocationKind.LOCATION, LocationKind.NORMALIZE}; >+ } >+} >Index: src/org/eclipse/core/filebuffers/tests/MockDocumentSetupParticipants.java >=================================================================== >RCS file: src/org/eclipse/core/filebuffers/tests/MockDocumentSetupParticipants.java >diff -N src/org/eclipse/core/filebuffers/tests/MockDocumentSetupParticipants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/filebuffers/tests/MockDocumentSetupParticipants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,87 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Symbian Software Systems and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Ferguson (Symbian) - Initial implementation >+ *******************************************************************************/ >+package org.eclipse.core.filebuffers.tests; >+ >+import org.eclipse.core.filebuffers.IDocumentSetupParticipant; >+import org.eclipse.core.filebuffers.IDocumentSetupParticipantExtension; >+import org.eclipse.core.filebuffers.LocationKind; >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.jface.text.BadLocationException; >+import org.eclipse.jface.text.IDocument; >+ >+/** >+ * Holds {@link IDocumentSetupParticipant}'s for registering against fictional >+ * document extensions for test purposes. >+ */ >+public class MockDocumentSetupParticipants { >+ /** >+ * An {@link IDocumentSetupParticipant} which stamps its name >+ * into the document being setup for integration test purposes. >+ */ >+ static abstract class AbstractTestDSP implements IDocumentSetupParticipant { >+ /* >+ * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument) >+ */ >+ public void setup(IDocument document) { >+ append(document, getClass()+"\n"); >+ } >+ } >+ >+ static abstract class AbstractTestDSPExtension extends AbstractTestDSP implements IDocumentSetupParticipant, IDocumentSetupParticipantExtension { >+ /* >+ * @see org.eclipse.core.filebuffers.IDocumentSetupParticipantExtension#setup(org.eclipse.jface.text.IDocument, org.eclipse.core.runtime.IPath, org.eclipse.core.filebuffers.LocationKind) >+ */ >+ public void setup(IDocument document, IPath location, LocationKind locationKind) { >+ append(document, getClass()+"%%EXTENSION\n"); >+ } >+ } >+ >+ public static class TestDSP1 extends AbstractTestDSP {} >+ public static class TestDSP2 extends AbstractTestDSP {} >+ public static class TestDSP3 extends AbstractTestDSP {} >+ >+ public static class TestDSP4 extends AbstractTestDSPExtension {} >+ public static class TestDSP5 extends AbstractTestDSPExtension {} >+ public static class TestDSP6 extends AbstractTestDSPExtension {} >+ >+ public static class TestDSP7 extends AbstractTestDSPExtension { >+ public void setup(IDocument document, IPath location, LocationKind locationKind) { >+ if(location!=null && LocationKind.IFILE.equals(locationKind)) { >+ append(document, new StringBuffer(location.toPortableString()).reverse().toString()); >+ } >+ } >+ } >+ >+ public static class TestDSP8 extends AbstractTestDSPExtension { >+ public void setup(IDocument document, IPath location, LocationKind locationKind) { >+ if(location!=null && LocationKind.LOCATION.equals(locationKind)) { >+ append(document, new StringBuffer(location.toPortableString()).reverse().toString()); >+ } >+ } >+ } >+ >+ public static class TestDSP9 extends AbstractTestDSPExtension { >+ public void setup(IDocument document, IPath location, LocationKind locationKind) { >+ if(location!=null && LocationKind.NORMALIZE.equals(locationKind)) { >+ append(document, new StringBuffer(location.toPortableString()).reverse().toString()); >+ } >+ } >+ } >+ >+ private static void append(IDocument document, String string) { >+ try { >+ document.replace(document.getLength(), 0, string); >+ } catch(BadLocationException ble) { >+ Assert.isTrue(false); >+ } >+ } >+} >Index: src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java >=================================================================== >RCS file: src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java >diff -N src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/filebuffers/tests/AbstractFileBufferDocCreationTests.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,134 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Symbian Software Systems and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Ferguson (Symbian) - Initial implementation >+ *******************************************************************************/ >+package org.eclipse.core.filebuffers.tests; >+ >+import java.util.Arrays; >+import java.util.HashSet; >+import java.util.Set; >+ >+import junit.framework.TestCase; >+ >+import org.eclipse.core.filebuffers.IDocumentSetupParticipantExtension; >+import org.eclipse.core.filebuffers.ITextFileBufferManager; >+import org.eclipse.core.filebuffers.LocationKind; >+import org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants.TestDSP1; >+import org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants.TestDSP2; >+import org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants.TestDSP3; >+import org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants.TestDSP4; >+import org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants.TestDSP5; >+import org.eclipse.core.filebuffers.tests.MockDocumentSetupParticipants.TestDSP6; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.jface.text.IDocument; >+ >+public abstract class AbstractFileBufferDocCreationTests extends TestCase { >+ protected ITextFileBufferManager fManager; >+ >+ >+ public void testCreateDocumentPartipants_FileExt() { >+ assertParticipantsInvoked("anything.111foo", new Class[] {TestDSP1.class, TestDSP3.class}); >+ } >+ >+ public void testCreateDocumentPartipants_Name() { >+ assertParticipantsInvoked("111fooname", new Class[] {TestDSP2.class, TestDSP3.class}); >+ } >+ >+ public void testCreateDocumentPartipants_FileExt_Name() { >+ assertParticipantsInvoked("111fooname.111foo", new Class[] {TestDSP1.class, TestDSP2.class, TestDSP3.class}); >+ } >+ >+ public void testCreateDocumentPartipants_FileExt_Extension() { >+ assertParticipantsInvoked("anything.222foo", new Class[] {TestDSP4.class, TestDSP6.class}); >+ } >+ >+ public void testCreateDocumentPartipants_Name_Extension() { >+ assertParticipantsInvoked("222fooname", new Class[] {TestDSP5.class, TestDSP6.class}); >+ } >+ >+ public void testCreateDocumentPartipants_FileExt_Name_Extension() { >+ assertParticipantsInvoked("222fooname.222foo", new Class[] {TestDSP4.class, TestDSP5.class, TestDSP6.class}); >+ } >+ >+ public void testDocumentSetupParticipantExtension_1() { >+ assertDocumentContent("emanoof333/p/", "/p/333fooname", LocationKind.IFILE); >+ assertDocumentContent("oof333.emanoof333/p/", "/p/333fooname.333foo", LocationKind.IFILE); >+ assertDocumentContent("oof333.gnihtyna/p/", "/p/anything.333foo", LocationKind.IFILE); >+ >+ assertDocumentContent("", "333fooname", LocationKind.LOCATION); >+ assertDocumentContent("", "333fooname.333foo", LocationKind.LOCATION); >+ assertDocumentContent("", "anything.333foo", LocationKind.LOCATION); >+ >+ assertDocumentContent("", "333fooname", LocationKind.NORMALIZE); >+ assertDocumentContent("", "333fooname.333foo", LocationKind.NORMALIZE); >+ assertDocumentContent("", "anything.333foo", LocationKind.NORMALIZE); >+ } >+ >+ public void testDocumentSetupParticipantExtension_2() { >+ assertDocumentContent("", "/p/444fooname", LocationKind.IFILE); >+ assertDocumentContent("", "/p/444fooname.444foo", LocationKind.IFILE); >+ assertDocumentContent("", "/p/anything.444foo", LocationKind.IFILE); >+ >+ assertDocumentContent("emanoof444", "444fooname", LocationKind.LOCATION); >+ assertDocumentContent("oof444.emanoof444", "444fooname.444foo", LocationKind.LOCATION); >+ assertDocumentContent("oof444.gnihtyna", "anything.444foo", LocationKind.LOCATION); >+ >+ assertDocumentContent("", "444fooname", LocationKind.NORMALIZE); >+ assertDocumentContent("", "444fooname.444foo", LocationKind.NORMALIZE); >+ assertDocumentContent("", "anything.444foo", LocationKind.NORMALIZE); >+ } >+ >+ public void testDocumentSetupParticipantExtension_3() { >+ assertDocumentContent("", "/p/555fooname", LocationKind.IFILE); >+ assertDocumentContent("", "/p/555fooname.555foo", LocationKind.IFILE); >+ assertDocumentContent("", "/p/anything.555foo", LocationKind.IFILE); >+ >+ assertDocumentContent("", "555fooname", LocationKind.LOCATION); >+ assertDocumentContent("", "555fooname.555foo", LocationKind.LOCATION); >+ assertDocumentContent("", "anything.555foo", LocationKind.LOCATION); >+ >+ assertDocumentContent("emanoof555", "555fooname", LocationKind.NORMALIZE); >+ assertDocumentContent("oof555.emanoof555", "555fooname.555foo", LocationKind.NORMALIZE); >+ assertDocumentContent("oof555.gnihtyna", "anything.555foo", LocationKind.NORMALIZE); >+ } >+ >+ /* Utilities */ >+ >+ private void assertParticipantsInvoked(String path, Class[] expectedDSPsArray) { >+ LocationKind[] lks= getSupportLocationKinds(); >+ for(int i=0; i<lks.length; i++) { >+ IDocument document= fManager.createEmptyDocument(new Path(path), lks[i]); >+ String content= document.get(); >+ Set expectedDSPs= new HashSet(Arrays.asList(toString(expectedDSPsArray))); >+ Set actualDSPs= new HashSet(Arrays.asList(content.split("\n"))); >+ assertEquals(expectedDSPs, actualDSPs); >+ } >+ } >+ >+ abstract protected LocationKind[] getSupportLocationKinds(); >+ >+ protected void assertDocumentContent(String expectedContent, String path, LocationKind locKind) { >+ assertEquals(expectedContent, fManager.createEmptyDocument(new Path(path), locKind).get()); >+ } >+ >+ private static String[] toString(Class[] clss) { >+ String[] result= new String[clss.length]; >+ for(int i=0; i<result.length; i++) { >+ String s= null; >+ if(clss[i]!=null) { >+ s= clss[i].toString(); >+ if(IDocumentSetupParticipantExtension.class.isAssignableFrom(clss[i])) { >+ s+= "%%EXTENSION"; >+ } >+ } >+ result[i]= s; >+ } >+ return result; >+ } >+} >#P org.eclipse.core.filebuffers >Index: src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java,v >retrieving revision 1.45 >diff -u -r1.45 TextFileBufferManager.java >--- src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java 22 Feb 2007 15:25:10 -0000 1.45 >+++ src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java 23 Jan 2008 13:59:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Andrew Ferguson (Symbian) > *******************************************************************************/ > package org.eclipse.core.internal.filebuffers; > >@@ -18,11 +19,21 @@ > import java.util.List; > import java.util.Map; > >+import org.eclipse.core.filebuffers.IAnnotationModelFactory; >+import org.eclipse.core.filebuffers.IDocumentFactory; >+import org.eclipse.core.filebuffers.IDocumentSetupParticipant; >+import org.eclipse.core.filebuffers.IDocumentSetupParticipantExtension; >+import org.eclipse.core.filebuffers.IFileBuffer; >+import org.eclipse.core.filebuffers.IFileBufferListener; >+import org.eclipse.core.filebuffers.IFileBufferStatusCodes; >+import org.eclipse.core.filebuffers.ISynchronizationContext; >+import org.eclipse.core.filebuffers.ITextFileBuffer; >+import org.eclipse.core.filebuffers.ITextFileBufferManager; >+import org.eclipse.core.filebuffers.LocationKind; > import org.eclipse.core.filesystem.EFS; > import org.eclipse.core.filesystem.IFileInfo; > import org.eclipse.core.filesystem.IFileStore; > import org.eclipse.core.filesystem.URIUtil; >- > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; >@@ -35,18 +46,6 @@ > import org.eclipse.core.runtime.content.IContentDescription; > import org.eclipse.core.runtime.content.IContentType; > import org.eclipse.core.runtime.content.IContentTypeManager; >- >-import org.eclipse.core.filebuffers.IAnnotationModelFactory; >-import org.eclipse.core.filebuffers.IDocumentFactory; >-import org.eclipse.core.filebuffers.IDocumentSetupParticipant; >-import org.eclipse.core.filebuffers.IFileBuffer; >-import org.eclipse.core.filebuffers.IFileBufferListener; >-import org.eclipse.core.filebuffers.IFileBufferStatusCodes; >-import org.eclipse.core.filebuffers.ISynchronizationContext; >-import org.eclipse.core.filebuffers.ITextFileBuffer; >-import org.eclipse.core.filebuffers.ITextFileBufferManager; >-import org.eclipse.core.filebuffers.LocationKind; >- > import org.eclipse.jface.text.IDocument; > import org.eclipse.jface.text.IDocumentExtension4; > import org.eclipse.jface.text.source.IAnnotationModel; >@@ -432,7 +431,7 @@ > * @see org.eclipse.core.filebuffers.ITextFileBufferManager#createEmptyDocument(org.eclipse.core.runtime.IPath, org.eclipse.core.filebuffers.LocationKind) > * @since 3.3 > */ >- public IDocument createEmptyDocument(IPath location, LocationKind locationKind) { >+ public IDocument createEmptyDocument(final IPath location, final LocationKind locationKind) { > final IDocument[] runnableResult= new IDocument[1]; > if (location != null) { > final IDocumentFactory factory= fRegistry.getDocumentFactory(location, locationKind); >@@ -473,7 +472,12 @@ > final IDocumentSetupParticipant participant= participants[i]; > ISafeRunnable runnable= new ISafeRunnable() { > public void run() throws Exception { >- participant.setup(document); >+ if(participant instanceof IDocumentSetupParticipantExtension) { >+ IDocumentSetupParticipantExtension extParticipant= (IDocumentSetupParticipantExtension) participant; >+ extParticipant.setup(document, location, locationKind); >+ } else { >+ participant.setup(document); >+ } > if (document.getDocumentPartitioner() != null) { > String message= NLSUtility.format(FileBuffersMessages.TextFileBufferManager_warning_documentSetupInstallsDefaultPartitioner, participant.getClass()); > IStatus status= new Status(IStatus.WARNING, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, message, null); >Index: src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java,v >retrieving revision 1.2 >diff -u -r1.2 ResourceTextFileBufferManager.java >--- src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java 20 Feb 2007 12:40:25 -0000 1.2 >+++ src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java 23 Jan 2008 13:59:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007 IBM Corporation and others. >+ * Copyright (c) 2007, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,11 +7,27 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Andrew Ferguson (Symbian) > *******************************************************************************/ > package org.eclipse.core.internal.filebuffers; > > import java.util.ArrayList; > >+import org.eclipse.core.filebuffers.FileBuffers; >+import org.eclipse.core.filebuffers.IAnnotationModelFactory; >+import org.eclipse.core.filebuffers.IDocumentFactory; >+import org.eclipse.core.filebuffers.IDocumentSetupParticipant; >+import org.eclipse.core.filebuffers.IDocumentSetupParticipantExtension; >+import org.eclipse.core.filebuffers.IFileBuffer; >+import org.eclipse.core.filebuffers.IStateValidationSupport; >+import org.eclipse.core.filebuffers.LocationKind; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.resources.IResourceRuleFactory; >+import org.eclipse.core.resources.IWorkspace; >+import org.eclipse.core.resources.IWorkspaceRunnable; >+import org.eclipse.core.resources.ProjectScope; >+import org.eclipse.core.resources.ResourcesPlugin; > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IPath; >@@ -27,23 +43,6 @@ > import org.eclipse.core.runtime.jobs.ISchedulingRule; > import org.eclipse.core.runtime.preferences.IScopeContext; > import org.eclipse.core.runtime.preferences.InstanceScope; >- >-import org.eclipse.core.resources.IFile; >-import org.eclipse.core.resources.IResource; >-import org.eclipse.core.resources.IResourceRuleFactory; >-import org.eclipse.core.resources.IWorkspace; >-import org.eclipse.core.resources.IWorkspaceRunnable; >-import org.eclipse.core.resources.ProjectScope; >-import org.eclipse.core.resources.ResourcesPlugin; >- >-import org.eclipse.core.filebuffers.FileBuffers; >-import org.eclipse.core.filebuffers.IAnnotationModelFactory; >-import org.eclipse.core.filebuffers.IDocumentFactory; >-import org.eclipse.core.filebuffers.IDocumentSetupParticipant; >-import org.eclipse.core.filebuffers.IFileBuffer; >-import org.eclipse.core.filebuffers.IStateValidationSupport; >-import org.eclipse.core.filebuffers.LocationKind; >- > import org.eclipse.jface.text.IDocument; > import org.eclipse.jface.text.IDocumentExtension4; > import org.eclipse.jface.text.source.IAnnotationModel; >@@ -125,7 +124,7 @@ > return null; > } > >- IDocument createEmptyDocument(IFile file) { >+ public IDocument createEmptyDocument(final IFile file) { > final IDocument[] runnableResult= new IDocument[1]; > final IDocumentFactory factory= ((ResourceExtensionRegistry)fRegistry).getDocumentFactory(file); > if (factory != null) { >@@ -162,7 +161,13 @@ > final IDocumentSetupParticipant participant= participants[i]; > ISafeRunnable runnable= new ISafeRunnable() { > public void run() throws Exception { >- participant.setup(document); >+ if(participant instanceof IDocumentSetupParticipantExtension) { >+ IDocumentSetupParticipantExtension ext= (IDocumentSetupParticipantExtension) participant; >+ IPath path= file == null ? null : file.getFullPath(); >+ ext.setup(document, path, LocationKind.IFILE); >+ } else { >+ participant.setup(document); >+ } > if (document.getDocumentPartitioner() != null) { > String message= NLSUtility.format(FileBuffersMessages.TextFileBufferManager_warning_documentSetupInstallsDefaultPartitioner, participant.getClass()); > IStatus status= new Status(IStatus.WARNING, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, message, null); >Index: src/org/eclipse/core/filebuffers/IDocumentSetupParticipant.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentSetupParticipant.java,v >retrieving revision 1.12 >diff -u -r1.12 IDocumentSetupParticipant.java >--- src/org/eclipse/core/filebuffers/IDocumentSetupParticipant.java 28 Mar 2006 16:28:56 -0000 1.12 >+++ src/org/eclipse/core/filebuffers/IDocumentSetupParticipant.java 23 Jan 2008 13:59:50 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -29,6 +29,7 @@ > * > * @since 3.0 > * @see org.eclipse.jface.text.IDocumentExtension3 >+ * @see org.eclipse.core.filebuffers.IDocumentSetupParticipantExtension > */ > public interface IDocumentSetupParticipant { > >Index: src/org/eclipse/core/filebuffers/IDocumentSetupParticipantExtension.java >=================================================================== >RCS file: src/org/eclipse/core/filebuffers/IDocumentSetupParticipantExtension.java >diff -N src/org/eclipse/core/filebuffers/IDocumentSetupParticipantExtension.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/core/filebuffers/IDocumentSetupParticipantExtension.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Symbian Software Systems and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Andrew Ferguson (Symbian) - Initial implementation >+ *******************************************************************************/ >+package org.eclipse.core.filebuffers; >+ >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.jface.text.IDocument; >+ >+/** >+ * Extension interface for {@link org.eclipse.core.filebuffers.IDocumentSetupParticipant}.<p> >+ * >+ * This interface is additionally implemented by {@link IDocumentSetupParticipant}'s which >+ * would like to alter their behavior based on the location of the file being opened.<p> >+ * >+ * Note that when participants implement this interface, the original method from >+ * {@link IDocumentSetupParticipant} will never be called. >+ * >+ * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant >+ * @since 3.4 >+ */ >+public interface IDocumentSetupParticipantExtension { >+ >+ /** >+ * Sets up the document to be ready for use by a text file buffer. >+ * >+ * @param document the document to be set up >+ * @param location a path of the resource backing the new document. May be null. >+ * @param locationKind the LocationKind of the location specified. May be null. >+ */ >+ void setup(IDocument document, IPath location, LocationKind locationKind); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 208881
:
84301
| 87647 |
87659