Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Maetzel2003-08-13 22:00:57 +0000
committerKai Maetzel2003-08-13 22:00:57 +0000
commita97c4d6e893127000d7d123f58015b32b145acc8 (patch)
tree5e50214498439327422c02a6ac92c081fdaf840e /org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui
parentd6ebdd824cc7f4543f987dcf5c3919ac83ea04de (diff)
downloadeclipse.platform.text-a97c4d6e893127000d7d123f58015b32b145acc8.tar.gz
eclipse.platform.text-a97c4d6e893127000d7d123f58015b32b145acc8.tar.xz
eclipse.platform.text-a97c4d6e893127000d7d123f58015b32b145acc8.zip
enabling file buffers
Diffstat (limited to 'org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui')
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaDocumentProvider.java63
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaDocumentSetupParticipant.java41
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditor.java2
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorEnvironment.java73
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorExamplePlugin.java99
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaPartitionScanner.java (renamed from org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaPartitionScanner.java)3
-rw-r--r--org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaSourceViewerConfiguration.java38
7 files changed, 172 insertions, 147 deletions
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaDocumentProvider.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaDocumentProvider.java
deleted file mode 100644
index 8ff64a983..000000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaDocumentProvider.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor;
-
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.rules.DefaultPartitioner;
-import org.eclipse.ui.editors.text.FileDocumentProvider;
-import org.eclipse.ui.examples.javaeditor.java.JavaPartitionScanner;
-
-/**
- * The JavaDocumentProvider provides the IDocuments used by java editors.
- */
-
-public class JavaDocumentProvider extends FileDocumentProvider {
-
- private final static String[] TYPES= new String[] { JavaPartitionScanner.JAVA_DOC, JavaPartitionScanner.JAVA_MULTILINE_COMMENT };
-
- private static JavaPartitionScanner fgScanner= null;
-
- public JavaDocumentProvider() {
- super();
- }
-
- /* (non-Javadoc)
- * Method declared on AbstractDocumentProvider
- */
- protected IDocument createDocument(Object element) throws CoreException {
- IDocument document= super.createDocument(element);
- if (document != null) {
- IDocumentPartitioner partitioner= createJavaPartitioner();
- document.setDocumentPartitioner(partitioner);
- partitioner.connect(document);
- }
- return document;
- }
-
- /**
- * Return a partitioner for .java files.
- */
- private IDocumentPartitioner createJavaPartitioner() {
- return new DefaultPartitioner(getJavaPartitionScanner(), TYPES);
- }
-
- /**
- * Return a scanner for creating java partitions.
- */
- private JavaPartitionScanner getJavaPartitionScanner() {
- if (fgScanner == null)
- fgScanner= new JavaPartitionScanner();
- return fgScanner;
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaDocumentSetupParticipant.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaDocumentSetupParticipant.java
new file mode 100644
index 000000000..45d4bf08a
--- /dev/null
+++ b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaDocumentSetupParticipant.java
@@ -0,0 +1,41 @@
+/**********************************************************************
+Copyright (c) 2000, 2003 IBM Corp. and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+
+Contributors:
+ IBM Corporation - Initial implementation
+**********************************************************************/
+package org.eclipse.ui.examples.javaeditor;
+
+import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.rules.DefaultPartitioner;
+
+/**
+ *
+ */
+public class JavaDocumentSetupParticipant implements IDocumentSetupParticipant {
+
+ /**
+ */
+ public JavaDocumentSetupParticipant() {
+ }
+
+ /*
+ * @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
+ */
+ public void setup(IDocument document) {
+ if (document instanceof IDocumentExtension3) {
+ IDocumentExtension3 extension3= (IDocumentExtension3) document;
+ IDocumentPartitioner partitioner= new DefaultPartitioner(JavaEditorExamplePlugin.getDefault().getJavaPartitionScanner(), JavaPartitionScanner.JAVA_PARTITION_TYPES);
+ extension3.setDocumentPartitioner(JavaEditorExamplePlugin.JAVA_PARTITIONING, partitioner);
+ partitioner.connect(document);
+ }
+ }
+}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditor.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditor.java
index 7b59f2abf..9c4f4d3f4 100644
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditor.java
+++ b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditor.java
@@ -62,7 +62,6 @@ public class JavaEditor extends TextEditor {
* disposal actions required by the java editor.
*/
public void dispose() {
- JavaEditorEnvironment.disconnect(this);
if (fOutlinePage != null)
fOutlinePage.setInput(null);
super.dispose();
@@ -140,7 +139,6 @@ public class JavaEditor extends TextEditor {
*/
protected void initializeEditor() {
super.initializeEditor();
- JavaEditorEnvironment.connect(this);
setSourceViewerConfiguration(new JavaSourceViewerConfiguration());
setEditorContextMenuId("#JavaEditorContext"); //$NON-NLS-1$
setRulerContextMenuId("#JavaRulerContext"); //$NON-NLS-1$
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorEnvironment.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorEnvironment.java
deleted file mode 100644
index 736699144..000000000
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorEnvironment.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.examples.javaeditor;
-
-
-import org.eclipse.jface.text.rules.RuleBasedScanner;
-import org.eclipse.ui.examples.javaeditor.java.JavaCodeScanner;
-import org.eclipse.ui.examples.javaeditor.javadoc.JavaDocScanner;
-import org.eclipse.ui.examples.javaeditor.util.JavaColorProvider;
-
-/** The JavaEditorEnvironment maintains singletons used by the java editor
- * examples.
- */
-public class JavaEditorEnvironment {
-
- private static JavaColorProvider fgColorProvider;
- private static JavaCodeScanner fgCodeScanner;
- private static JavaDocScanner fgDocScanner;
-
- private static int fgRefCount= 0;
-
- /**
- * A connection has occured - initialize the receiver if it is the first activation.
- */
- public static void connect(Object client) {
- if (++fgRefCount == 1) {
- fgColorProvider= new JavaColorProvider();
- fgCodeScanner= new JavaCodeScanner(fgColorProvider);
- fgDocScanner= new JavaDocScanner(fgColorProvider);
- }
- }
-
- /**
- * A disconnection has occured - clear the receiver if it is the last deactivation.
- */
- public static void disconnect(Object client) {
- if (--fgRefCount == 0) {
- fgCodeScanner= null;
- fgDocScanner= null;
- fgColorProvider.dispose();
- fgColorProvider= null;
- }
- }
-
- /**
- * Returns the singleton scanner.
- */
- public static RuleBasedScanner getJavaCodeScanner() {
- return fgCodeScanner;
- }
-
- /**
- * Returns the singleton color provider.
- */
- public static JavaColorProvider getJavaColorProvider() {
- return fgColorProvider;
- }
-
- /**
- * Returns the singleton document scanner.
- */
- public static RuleBasedScanner getJavaDocScanner() {
- return fgDocScanner;
- }
-}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorExamplePlugin.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorExamplePlugin.java
new file mode 100644
index 000000000..8eb40a038
--- /dev/null
+++ b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaEditorExamplePlugin.java
@@ -0,0 +1,99 @@
+/**********************************************************************
+Copyright (c) 2000, 2003 IBM Corp. and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+
+Contributors:
+ IBM Corporation - Initial implementation
+**********************************************************************/
+package org.eclipse.ui.examples.javaeditor;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPluginDescriptor;
+
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+
+import org.eclipse.ui.examples.javaeditor.java.JavaCodeScanner;
+import org.eclipse.ui.examples.javaeditor.javadoc.JavaDocScanner;
+import org.eclipse.ui.examples.javaeditor.util.JavaColorProvider;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * The example java editor plugin class.
+ *
+ * @since 3.0
+ */
+public class JavaEditorExamplePlugin extends AbstractUIPlugin {
+
+ public final static String JAVA_PARTITIONING= "__java_example_partitioning"; //$NON-NLS-1$
+
+ private static JavaEditorExamplePlugin fgInstance;
+ private JavaPartitionScanner fPartitionScanner;
+ private JavaColorProvider fColorProvider;
+ private JavaCodeScanner fCodeScanner;
+ private JavaDocScanner fDocScanner;
+
+ /**
+ * Creates a new plugin instance.
+ *
+ * @param descriptor
+ */
+ public JavaEditorExamplePlugin(IPluginDescriptor descriptor) {
+ super(descriptor);
+ fgInstance= this;
+ }
+
+ /**
+ * Returns the default plugin instance.
+ *
+ * @return the default plugin instance
+ */
+ public static JavaEditorExamplePlugin getDefault() {
+ return fgInstance;
+ }
+
+ /*
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#shutdown()
+ */
+ public void shutdown() throws CoreException {
+ super.shutdown();
+ }
+
+ /**
+ * Return a scanner for creating java partitions.
+ */
+ public JavaPartitionScanner getJavaPartitionScanner() {
+ if (fPartitionScanner == null)
+ fPartitionScanner= new JavaPartitionScanner();
+ return fPartitionScanner;
+ }
+
+ /**
+ * Returns the singleton scanner.
+ */
+ public RuleBasedScanner getJavaCodeScanner() {
+ if (fCodeScanner == null)
+ fCodeScanner= new JavaCodeScanner(getJavaColorProvider());
+ return fCodeScanner;
+ }
+
+ /**
+ * Returns the singleton color provider.
+ */
+ public JavaColorProvider getJavaColorProvider() {
+ if (fColorProvider == null)
+ fColorProvider= new JavaColorProvider();
+ return fColorProvider;
+ }
+
+ /**
+ * Returns the singleton document scanner.
+ */
+ public RuleBasedScanner getJavaDocScanner() {
+ if (fDocScanner == null)
+ fDocScanner= new JavaDocScanner(fColorProvider);
+ return fDocScanner;
+ }
+}
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaPartitionScanner.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaPartitionScanner.java
index 4bb57624c..54bb2edc2 100644
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/java/JavaPartitionScanner.java
+++ b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaPartitionScanner.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-package org.eclipse.ui.examples.javaeditor.java;
+package org.eclipse.ui.examples.javaeditor;
import java.util.ArrayList;
@@ -23,6 +23,7 @@ public class JavaPartitionScanner extends RuleBasedPartitionScanner {
public final static String JAVA_MULTILINE_COMMENT= "__java_multiline_comment"; //$NON-NLS-1$
public final static String JAVA_DOC= "__java_javadoc"; //$NON-NLS-1$
+ public final static String[] JAVA_PARTITION_TYPES= new String[] { JAVA_MULTILINE_COMMENT, JAVA_DOC };
/**
* Detector for empty comments.
diff --git a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaSourceViewerConfiguration.java b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaSourceViewerConfiguration.java
index 017e2a479..5df2a8737 100644
--- a/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaSourceViewerConfiguration.java
+++ b/org.eclipse.ui.examples.javaeditor/Eclipse Java Editor Example/org/eclipse/ui/examples/javaeditor/JavaSourceViewerConfiguration.java
@@ -11,15 +11,28 @@
package org.eclipse.ui.examples.javaeditor;
-import org.eclipse.jface.text.*;
+import org.eclipse.swt.graphics.RGB;
+
+import org.eclipse.jface.text.DefaultAutoIndentStrategy;
+import org.eclipse.jface.text.IAutoIndentStrategy;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextDoubleClickStrategy;
+import org.eclipse.jface.text.ITextHover;
+import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
-import org.eclipse.jface.text.rules.*;
-import org.eclipse.jface.text.source.*;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.ui.examples.javaeditor.java.*;
+import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.source.IAnnotationHover;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+
+import org.eclipse.ui.examples.javaeditor.java.JavaAutoIndentStrategy;
+import org.eclipse.ui.examples.javaeditor.java.JavaCompletionProcessor;
+import org.eclipse.ui.examples.javaeditor.java.JavaDoubleClickSelector;
import org.eclipse.ui.examples.javaeditor.javadoc.JavaDocCompletionProcessor;
import org.eclipse.ui.examples.javaeditor.util.JavaColorProvider;
@@ -59,6 +72,13 @@ public class JavaSourceViewerConfiguration extends SourceViewerConfiguration {
return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? new JavaAutoIndentStrategy() : new DefaultAutoIndentStrategy());
}
+ /*
+ * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
+ */
+ public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
+ return JavaEditorExamplePlugin.JAVA_PARTITIONING;
+ }
+
/* (non-Javadoc)
* Method declared on SourceViewerConfiguration
*/
@@ -72,6 +92,7 @@ public class JavaSourceViewerConfiguration extends SourceViewerConfiguration {
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant= new ContentAssistant();
+ assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
assistant.setContentAssistProcessor(new JavaCompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
assistant.setContentAssistProcessor(new JavaDocCompletionProcessor(), JavaPartitionScanner.JAVA_DOC);
@@ -79,7 +100,7 @@ public class JavaSourceViewerConfiguration extends SourceViewerConfiguration {
assistant.setAutoActivationDelay(500);
assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
- assistant.setContextInformationPopupBackground(JavaEditorEnvironment.getJavaColorProvider().getColor(new RGB(150, 150, 0)));
+ assistant.setContextInformationPopupBackground(JavaEditorExamplePlugin.getDefault().getJavaColorProvider().getColor(new RGB(150, 150, 0)));
return assistant;
}
@@ -110,10 +131,11 @@ public class JavaSourceViewerConfiguration extends SourceViewerConfiguration {
*/
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
- JavaColorProvider provider= JavaEditorEnvironment.getJavaColorProvider();
+ JavaColorProvider provider= JavaEditorExamplePlugin.getDefault().getJavaColorProvider();
PresentationReconciler reconciler= new PresentationReconciler();
+ reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
- DefaultDamagerRepairer dr= new DefaultDamagerRepairer(JavaEditorEnvironment.getJavaCodeScanner());
+ DefaultDamagerRepairer dr= new DefaultDamagerRepairer(JavaEditorExamplePlugin.getDefault().getJavaCodeScanner());
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);

Back to the top