Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJared Burns2003-02-14 21:43:43 +0000
committerJared Burns2003-02-14 21:43:43 +0000
commit247059bed04c6aa55f40c44987969f65aed26d53 (patch)
tree2fae91e606340234da4679eb44d0727e0ef6c38d /org.eclipse.ui.externaltools
parent614ce0386781238b08c0fdf84d078b2eef59103c (diff)
downloadeclipse.platform.debug-247059bed04c6aa55f40c44987969f65aed26d53.tar.gz
eclipse.platform.debug-247059bed04c6aa55f40c44987969f65aed26d53.tar.xz
eclipse.platform.debug-247059bed04c6aa55f40c44987969f65aed26d53.zip
Bug 31777 - Add reconciling to the Ant editor outline page
Diffstat (limited to 'org.eclipse.ui.externaltools')
-rw-r--r--org.eclipse.ui.externaltools/.classpath1
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/DynamicReconciling.java20
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/IOutlineCreationListener.java20
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/PlantySourceViewerConfigurationNew.java41
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/IReconcilingParticipant.java12
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/NotifyingReconciler.java90
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/OutlinePreparingHandlerNew.java35
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/PlantyContentOutlinePageNew.java64
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/XMLReconcilingStrategy.java90
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/text/PartiallySynchronizedDocument.java70
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/text/PlantyDocumentProviderNew.java46
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/PlantyEditor.java58
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/outline/OutlinePreparingHandler.java14
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/outline/PlantyContentOutlinePage.java57
-rw-r--r--org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/text/PlantyDocumentProvider.java2
-rw-r--r--org.eclipse.ui.externaltools/build.properties3
-rw-r--r--org.eclipse.ui.externaltools/scripts/exportplugin.xml1
17 files changed, 604 insertions, 20 deletions
diff --git a/org.eclipse.ui.externaltools/.classpath b/org.eclipse.ui.externaltools/.classpath
index 02214fc62..58f993d73 100644
--- a/org.eclipse.ui.externaltools/.classpath
+++ b/org.eclipse.ui.externaltools/.classpath
@@ -5,6 +5,7 @@
<classpathentry kind="src" path="Program Tools Support/"/>
<classpathentry kind="src" path="Ant Tools Support/"/>
<classpathentry kind="src" path="Ant Editor"/>
+ <classpathentry kind="src" path="Ant Editor New"/>
<classpathentry kind="src" path="/org.apache.ant"/>
<classpathentry kind="src" path="/org.apache.xerces"/>
<classpathentry kind="src" path="/org.eclipse.ant.core"/>
diff --git a/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/DynamicReconciling.java b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/DynamicReconciling.java
new file mode 100644
index 000000000..50e71f3af
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/DynamicReconciling.java
@@ -0,0 +1,20 @@
+/**********************************************************************
+Copyright (c) 2000, 2002 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.externaltools.internal.ant.editor;
+
+/**
+ * DynamicReconciling.java
+ */
+public class DynamicReconciling {
+
+ public static final boolean NEW_CODE_PATHS= true;
+
+}
diff --git a/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/IOutlineCreationListener.java b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/IOutlineCreationListener.java
new file mode 100644
index 000000000..faa161816
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/IOutlineCreationListener.java
@@ -0,0 +1,20 @@
+/**********************************************************************
+Copyright (c) 2000, 2002 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.externaltools.internal.ant.editor;
+
+/**
+ * IOutlineCreationListener.java
+ */
+public interface IOutlineCreationListener {
+
+ void outlineCreated();
+
+}
diff --git a/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/PlantySourceViewerConfigurationNew.java b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/PlantySourceViewerConfigurationNew.java
new file mode 100644
index 000000000..a5a7d3db8
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/PlantySourceViewerConfigurationNew.java
@@ -0,0 +1,41 @@
+/**********************************************************************
+Copyright (c) 2000, 2002 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.externaltools.internal.ant.editor;
+
+import org.eclipse.jface.text.reconciler.IReconciler;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.ui.externaltools.internal.ant.editor.outline.NotifyingReconciler;
+import org.eclipse.ui.externaltools.internal.ant.editor.outline.XMLReconcilingStrategy;
+
+/**
+ * PlantySourceViewerConfiguration.java
+ */
+public class PlantySourceViewerConfigurationNew extends PlantySourceViewerConfiguration {
+
+ private PlantyEditor fEditor;
+
+ public PlantySourceViewerConfigurationNew(PlantyEditor editor) {
+ super();
+ fEditor= editor;
+ }
+
+ /*
+ * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
+ */
+ public IReconciler getReconciler(ISourceViewer sourceViewer) {
+ NotifyingReconciler reconciler= new NotifyingReconciler(fEditor, new XMLReconcilingStrategy(fEditor), false);
+ reconciler.setDelay(500);
+// TODO: remove or implement?
+// reconciler.addReconcilingParticipant(fEditor);
+ return reconciler;
+ }
+
+}
diff --git a/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/IReconcilingParticipant.java b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/IReconcilingParticipant.java
new file mode 100644
index 000000000..dc6c36840
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/IReconcilingParticipant.java
@@ -0,0 +1,12 @@
+package org.eclipse.ui.externaltools.internal.ant.editor.outline;
+
+/**
+ * Interface of an object participating in reconciling.
+ */
+public interface IReconcilingParticipant {
+
+ /**
+ * Called after reconciling has been finished.
+ */
+ void reconciled();
+}
diff --git a/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/NotifyingReconciler.java b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/NotifyingReconciler.java
new file mode 100644
index 000000000..b5ae7e4cf
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/NotifyingReconciler.java
@@ -0,0 +1,90 @@
+/**********************************************************************
+Copyright (c) 2000, 2002 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.externaltools.internal.ant.editor.outline;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.reconciler.DirtyRegion;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
+import org.eclipse.jface.text.reconciler.MonoReconciler;
+import org.eclipse.ui.externaltools.internal.ant.editor.IOutlineCreationListener;
+import org.eclipse.ui.externaltools.internal.ant.editor.PlantyEditor;
+
+
+public class NotifyingReconciler extends MonoReconciler implements IOutlineCreationListener {
+
+ private ArrayList fReconcilingParticipants= new ArrayList();
+
+ private PlantyEditor fEditor;
+
+ /**
+ * Constructor for NotifyingReconciler.
+ * @param strategy
+ * @param isIncremental
+ */
+ public NotifyingReconciler(PlantyEditor editor, IReconcilingStrategy strategy, boolean isIncremental) {
+ super(strategy, isIncremental);
+ fEditor= editor;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.AbstractReconciler#process(org.eclipse.jface.text.reconciler.DirtyRegion)
+ */
+ protected void process(DirtyRegion dirtyRegion) {
+ super.process(dirtyRegion);
+ notifyReconcilingParticipants();
+ }
+
+ public void addReconcilingParticipant(IReconcilingParticipant participant) {
+ fReconcilingParticipants.add(participant);
+ }
+
+ public void removeReconcilingParticipant(IReconcilingParticipant participant) {
+ fReconcilingParticipants.remove(participant);
+ }
+
+ protected void notifyReconcilingParticipants() {
+ Iterator i= new ArrayList(fReconcilingParticipants).iterator();
+ while (i.hasNext())
+ ((IReconcilingParticipant) i.next()).reconciled();
+ }
+
+ /*
+ * @see org.eclipse.ui.externaltools.internal.ant.editor.IOutlineCreationListener#outlineCreated()
+ */
+ public void outlineCreated() {
+ IReconcilingStrategy reconcilingStrategy= getReconcilingStrategy("");
+ if (reconcilingStrategy instanceof IOutlineCreationListener)
+ ((IOutlineCreationListener) reconcilingStrategy).outlineCreated();
+ forceReconciling();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.IReconciler#install(org.eclipse.jface.text.ITextViewer)
+ */
+ public void install(ITextViewer textViewer) {
+ super.install(textViewer);
+ fEditor.addOutlineCreationListener(this);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.reconciler.IReconciler#uninstall()
+ */
+ public void uninstall() {
+ fEditor.removeOutlineCreationListener(this);
+ super.uninstall();
+ }
+
+}
diff --git a/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/OutlinePreparingHandlerNew.java b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/OutlinePreparingHandlerNew.java
new file mode 100644
index 000000000..29efd90dd
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/OutlinePreparingHandlerNew.java
@@ -0,0 +1,35 @@
+/**********************************************************************
+Copyright (c) 2000, 2002 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.externaltools.internal.ant.editor.outline;
+
+import java.io.File;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.xml.sax.SAXParseException;
+
+/**
+ * OutlinePreparingHandlerNew.java
+ */
+public class OutlinePreparingHandlerNew extends OutlinePreparingHandler {
+
+ public OutlinePreparingHandlerNew(File mainFileContainer) throws ParserConfigurationException {
+ super(mainFileContainer);
+ }
+
+ protected void generateErrorElementHierarchy(SAXParseException exception) {
+ if (getRootElement() == null)
+ setRootElement(generateErrorNode(exception));
+ else
+ super.generateErrorElementHierarchy(exception);
+ }
+
+}
diff --git a/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/PlantyContentOutlinePageNew.java b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/PlantyContentOutlinePageNew.java
new file mode 100644
index 000000000..aafeb1496
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/PlantyContentOutlinePageNew.java
@@ -0,0 +1,64 @@
+/**********************************************************************
+Copyright (c) 2000, 2002 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.externaltools.internal.ant.editor.outline;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.StringReader;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.externaltools.internal.ant.editor.xml.XmlElement;
+
+/**
+ * PlantyContentOutlinePageNew.java
+ */
+public class PlantyContentOutlinePageNew extends PlantyContentOutlinePage {
+
+ public PlantyContentOutlinePageNew() {
+ super();
+ }
+
+ public synchronized void reconcile() {
+ final XmlElement contentOutline= getInput() == null ? new XmlElement("") : getContentOutline(getInput());
+
+ if (!getControl().isDisposed()) {
+ getControl().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ update(contentOutline);
+ }
+ });
+ }
+ }
+
+ public synchronized void setInput(Object input) {
+ super.setInput(input);
+ }
+
+ public synchronized void dispose() {
+ super.dispose();
+ }
+
+ protected String getContentAsString(Object input) {
+ return getReaderContentAsString(new BufferedReader(new StringReader(((IDocument) input).get())));
+ }
+
+ protected IPath getLocation(Object input) {
+ return null;
+ }
+
+ protected OutlinePreparingHandler createOutlinePreparingHandler(File tempParentFile) throws ParserConfigurationException {
+ return new OutlinePreparingHandlerNew(tempParentFile);
+ }
+
+}
diff --git a/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/XMLReconcilingStrategy.java b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/XMLReconcilingStrategy.java
new file mode 100644
index 000000000..6688d7e15
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/outline/XMLReconcilingStrategy.java
@@ -0,0 +1,90 @@
+/**********************************************************************
+Copyright (c) 2000, 2002 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.externaltools.internal.ant.editor.outline;
+
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.reconciler.DirtyRegion;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
+
+import org.eclipse.ui.externaltools.internal.ant.editor.IOutlineCreationListener;
+import org.eclipse.ui.externaltools.internal.ant.editor.PlantyEditor;
+
+
+public class XMLReconcilingStrategy implements IReconcilingStrategy, IOutlineCreationListener {
+
+ private PlantyEditor fEditor;
+ private boolean fIsDocumentSetOnModel;
+ private IDocument fDocument;
+
+ public XMLReconcilingStrategy(PlantyEditor editor) {
+ fEditor= editor;
+ }
+
+ private void internalReconcile() {
+ PlantyContentOutlinePage model= fEditor.getOutlinePage();
+ if (model != null && model instanceof PlantyContentOutlinePageNew) {
+ PlantyContentOutlinePageNew modelNew= (PlantyContentOutlinePageNew) model;
+
+ synchronized (this) {
+ if (!isDocumentSetOnModel())
+ setDocumentOnModel(modelNew);
+ }
+
+ modelNew.reconcile();
+ }
+ }
+
+ /*
+ * @see IReconcilingStrategy#reconcile(IRegion)
+ */
+ public void reconcile(IRegion partition) {
+ internalReconcile();
+ }
+
+ /*
+ * @see IReconcilingStrategy#reconcile(DirtyRegion, IRegion)
+ */
+ public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
+ internalReconcile();
+ }
+
+ /*
+ * @see IReconcilingStrategy#setDocument(IDocument)
+ */
+ public synchronized void setDocument(IDocument document) {
+ fDocument= document;
+ unsetDocumentOnModel();
+ }
+
+ /*
+ * @see org.eclipse.ui.externaltools.internal.ant.editor.IOutlineCreationListener#outlineCreated()
+ */
+ public synchronized void outlineCreated() {
+ unsetDocumentOnModel();
+ }
+
+ private void setDocumentOnModel(PlantyContentOutlinePageNew model) {
+ model.setInput(fDocument);
+ fIsDocumentSetOnModel= true;
+ }
+
+ private void unsetDocumentOnModel() {
+ fIsDocumentSetOnModel= false;
+ }
+
+ private boolean isDocumentSetOnModel() {
+ return fIsDocumentSetOnModel;
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/text/PartiallySynchronizedDocument.java b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/text/PartiallySynchronizedDocument.java
new file mode 100644
index 000000000..9f6bced3d
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/text/PartiallySynchronizedDocument.java
@@ -0,0 +1,70 @@
+/**********************************************************************
+Copyright (c) 2000, 2002 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.externaltools.internal.ant.editor.text;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+
+/**
+ * Document that can also be used by a background reconciler.
+ */
+public class PartiallySynchronizedDocument extends Document {
+
+ /*
+ * @see IDocumentExtension#startSequentialRewrite(boolean)
+ */
+ synchronized public void startSequentialRewrite(boolean normalized) {
+ super.startSequentialRewrite(normalized);
+ }
+
+ /*
+ * @see IDocumentExtension#stopSequentialRewrite()
+ */
+ synchronized public void stopSequentialRewrite() {
+ super.stopSequentialRewrite();
+ }
+
+ /*
+ * @see IDocument#get()
+ */
+ synchronized public String get() {
+ return super.get();
+ }
+
+ /*
+ * @see IDocument#get(int, int)
+ */
+ synchronized public String get(int offset, int length) throws BadLocationException {
+ return super.get(offset, length);
+ }
+
+ /*
+ * @see IDocument#getChar(int)
+ */
+ synchronized public char getChar(int offset) throws BadLocationException {
+ return super.getChar(offset);
+ }
+
+ /*
+ * @see IDocument#replace(int, int, String)
+ */
+ synchronized public void replace(int offset, int length, String text) throws BadLocationException {
+ super.replace(offset, length, text);
+ }
+
+ /*
+ * @see IDocument#set(String)
+ */
+ synchronized public void set(String text) {
+ super.set(text);
+ }
+};
diff --git a/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/text/PlantyDocumentProviderNew.java b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/text/PlantyDocumentProviderNew.java
new file mode 100644
index 000000000..b28f86464
--- /dev/null
+++ b/org.eclipse.ui.externaltools/Ant Editor New/org/eclipse/ui/externaltools/internal/ant/editor/text/PlantyDocumentProviderNew.java
@@ -0,0 +1,46 @@
+/**********************************************************************
+Copyright (c) 2000, 2002 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.externaltools.internal.ant.editor.text;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.ui.IEditorInput;
+
+/**
+ * PlantyDocumentProvider.java
+ */
+public class PlantyDocumentProviderNew extends PlantyDocumentProvider {
+
+ public PlantyDocumentProviderNew() {
+ super();
+ }
+
+ public IDocument createDocument(Object element) throws CoreException {
+ IDocument document;
+ if (element instanceof IEditorInput) {
+ document= new PartiallySynchronizedDocument();
+ if (setDocumentContent(document, (IEditorInput) element, getEncoding(element))) {
+ initializeDocument(document);
+ }
+ } else {
+ document= null;
+ }
+ return document;
+ }
+
+ protected void initializeDocument(IDocument document) {
+ IDocumentPartitioner partitioner= createDocumentPartitioner();
+ document.setDocumentPartitioner(partitioner);
+ partitioner.connect(document);
+ }
+
+}
diff --git a/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/PlantyEditor.java b/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/PlantyEditor.java
index 4df5ee88f..0edf4380a 100644
--- a/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/PlantyEditor.java
+++ b/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/PlantyEditor.java
@@ -13,6 +13,9 @@ http://www.eclipse.org/legal/cpl-v10.html
// Berlin, Duesseldorf, Frankfurt (Germany) 2002
// All rights reserved.
//
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import java.util.ResourceBundle;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -29,8 +32,10 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.externaltools.internal.ant.editor.outline.PlantyContentOutlinePage;
+import org.eclipse.ui.externaltools.internal.ant.editor.outline.PlantyContentOutlinePageNew;
import org.eclipse.ui.externaltools.internal.ant.editor.text.IAntEditorColorConstants;
import org.eclipse.ui.externaltools.internal.ant.editor.text.PlantyDocumentProvider;
+import org.eclipse.ui.externaltools.internal.ant.editor.text.PlantyDocumentProviderNew;
import org.eclipse.ui.externaltools.internal.ant.editor.xml.XmlElement;
import org.eclipse.ui.externaltools.internal.model.ExternalToolsPlugin;
import org.eclipse.ui.texteditor.ContentAssistAction;
@@ -65,6 +70,8 @@ public class PlantyEditor extends TextEditor {
* The page that shows the outline.
*/
protected PlantyContentOutlinePage page;
+ private List fOutlineCreationListeners;
+ private Object fPageLock;
/**
@@ -72,7 +79,13 @@ public class PlantyEditor extends TextEditor {
*/
public PlantyEditor() {
super();
- setDocumentProvider(new PlantyDocumentProvider());
+ if (DynamicReconciling.NEW_CODE_PATHS) {
+ fOutlineCreationListeners= new ArrayList();
+ fPageLock= new Object();
+ setDocumentProvider(new PlantyDocumentProviderNew());
+ } else {
+ setDocumentProvider(new PlantyDocumentProvider());
+ }
setPreferenceStore(ExternalToolsPlugin.getDefault().getPreferenceStore());
}
@@ -93,7 +106,11 @@ public class PlantyEditor extends TextEditor {
public void initializeEditor() {
// That is where the assistant and its processor is defined
- setSourceViewerConfiguration(new PlantySourceViewerConfiguration());
+ if (DynamicReconciling.NEW_CODE_PATHS) {
+ setSourceViewerConfiguration(new PlantySourceViewerConfigurationNew(this));
+ } else {
+ setSourceViewerConfiguration(new PlantySourceViewerConfiguration());
+ }
}
/* (non-Javadoc)
@@ -105,8 +122,16 @@ public class PlantyEditor extends TextEditor {
if (key.equals(IContentOutlinePage.class)) {
IEditorInput input = getEditorInput();
if (input instanceof IFileEditorInput) {
- page = new PlantyContentOutlinePage(((IFileEditorInput)input).getFile());
- page.addSelectionChangedListener(selectionChangedListener);
+ if (DynamicReconciling.NEW_CODE_PATHS) {
+ synchronized (fPageLock) {
+ page= new PlantyContentOutlinePageNew();
+ page.addSelectionChangedListener(selectionChangedListener);
+ notifyOutlineCreationListeners();
+ }
+ } else {
+ page= new PlantyContentOutlinePage(((IFileEditorInput) input).getFile());
+ page.addSelectionChangedListener(selectionChangedListener);
+ }
return page;
}
}
@@ -215,11 +240,17 @@ public class PlantyEditor extends TextEditor {
*/
public void doSave(IProgressMonitor monitor) {
super.doSave(monitor);
- if (page != null) {
+ if (!DynamicReconciling.NEW_CODE_PATHS && page != null) {
page.update();
}
}
+ public PlantyContentOutlinePage getOutlinePage() {
+ synchronized (fPageLock) {
+ return page;
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.AbstractTextEditor#affectsTextPresentation(org.eclipse.jface.util.PropertyChangeEvent)
*/
@@ -241,4 +272,21 @@ public class PlantyEditor extends TextEditor {
}
super.handlePreferenceStoreChanged(event);
}
+
+ public void addOutlineCreationListener(IOutlineCreationListener listener) {
+ fOutlineCreationListeners.add(listener);
+ }
+
+
+ public void removeOutlineCreationListener(IOutlineCreationListener listener) {
+ fOutlineCreationListeners.remove(listener);
+ }
+
+ public void notifyOutlineCreationListeners() {
+ Iterator i= new ArrayList(fOutlineCreationListeners).iterator();
+ while (i.hasNext()) {
+ ((IOutlineCreationListener) i.next()).outlineCreated();
+ }
+ }
+
}
diff --git a/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/outline/OutlinePreparingHandler.java b/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/outline/OutlinePreparingHandler.java
index e608a7536..38bd13a66 100644
--- a/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/outline/OutlinePreparingHandler.java
+++ b/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/outline/OutlinePreparingHandler.java
@@ -405,7 +405,7 @@ public class OutlinePreparingHandler extends DefaultHandler implements LexicalHa
generateErrorElementHierarchy(anException);
}
- private void generateErrorElementHierarchy(SAXParseException exception) {
+ protected void generateErrorElementHierarchy(SAXParseException exception) {
if (rootElement == null) {
rootElement= new XmlElement(exception.getSystemId());
}
@@ -419,6 +419,11 @@ public class OutlinePreparingHandler extends DefaultHandler implements LexicalHa
}
}
+ XmlElement errorNode= generateErrorNode(exception);
+ rootElement.addChildNode(errorNode);
+ }
+
+ protected XmlElement generateErrorNode(SAXParseException exception) {
int lineNumber= exception.getLineNumber();
StringBuffer message= new StringBuffer(exception.getMessage());
if (lineNumber != -1){
@@ -431,7 +436,7 @@ public class OutlinePreparingHandler extends DefaultHandler implements LexicalHa
errorNode.setStartingColumn(locator.getColumnNumber());
errorNode.setStartingRow(locator.getLineNumber());
}
- rootElement.addChildNode(errorNode);
+ return errorNode;
}
/**
@@ -519,4 +524,9 @@ public class OutlinePreparingHandler extends DefaultHandler implements LexicalHa
external.getAttributes().removeAll(external.getAttributes());
external.addAttribute(new XmlAttribute(IAntEditorConstants.ATTR_TYPE, IAntEditorConstants.TYPE_EXTERNAL));
}
+
+ protected void setRootElement(XmlElement rootElement) {
+ this.rootElement= rootElement;
+ }
+
} \ No newline at end of file
diff --git a/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/outline/PlantyContentOutlinePage.java b/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/outline/PlantyContentOutlinePage.java
index 779331604..0f18d06a5 100644
--- a/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/outline/PlantyContentOutlinePage.java
+++ b/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/outline/PlantyContentOutlinePage.java
@@ -54,6 +54,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.externaltools.internal.ant.editor.DynamicReconciling;
import org.eclipse.ui.externaltools.internal.ant.editor.PlantyException;
import org.eclipse.ui.externaltools.internal.ant.editor.xml.IAntEditorConstants;
import org.eclipse.ui.externaltools.internal.ant.editor.xml.XmlAttribute;
@@ -76,7 +77,7 @@ import org.xml.sax.SAXParseException;
*/
public class PlantyContentOutlinePage extends ContentOutlinePage implements IShowInSource, IAdaptable {
- private IFile file;
+ private Object fInput;
private Menu menu;
private IAction openEditorAction;
@@ -259,9 +260,13 @@ public class PlantyContentOutlinePage extends ContentOutlinePage implements ISho
*/
public PlantyContentOutlinePage(IFile aFile) {
super();
- this.file = aFile;
+ setInput(aFile);
}
+ PlantyContentOutlinePage() {
+ super();
+ }
+
/**
* Creates the control (outline view) for this page
*/
@@ -281,8 +286,9 @@ public class PlantyContentOutlinePage extends ContentOutlinePage implements ISho
* We probably also need our own label provider.
*/
viewer.setLabelProvider(new PlantyLabelProvider());
- viewer.setInput(getContentOutline(file));
- viewer.expandToLevel(2);
+
+ if (!DynamicReconciling.NEW_CODE_PATHS)
+ update();
MenuManager manager= new MenuManager("#PopUp"); //$NON-NLS-1$
manager.setRemoveAllWhenShown(true);
@@ -322,16 +328,15 @@ public class PlantyContentOutlinePage extends ContentOutlinePage implements ISho
* Returns the root XmlElement, or null if the
* outline could not be generated.
*/
- protected XmlElement getContentOutline(IAdaptable input) {
+ protected XmlElement getContentOutline(Object input) {
/*
* What happens here:
* The file is parsed by the SAX Parser.
* The Parser then creates the DOM Tree of the file.
* The root element is returned here.
*/
- IFile tempFile = (IFile)input;
- String tempWholeDocumentString = getFileContentAsString(tempFile);
+ String tempWholeDocumentString = getContentAsString(input);
// Create the parser
SAXParser tempParser;
@@ -352,13 +357,13 @@ public class PlantyContentOutlinePage extends ContentOutlinePage implements ISho
// Create the handler
OutlinePreparingHandler tempHandler = null;
- IPath location = tempFile.getLocation();
+ IPath location= getLocation(input);
try {
File tempParentFile = null;
if(location != null) {
tempParentFile = location.toFile().getParentFile();
}
- tempHandler = new OutlinePreparingHandler(tempParentFile);
+ tempHandler= createOutlinePreparingHandler(tempParentFile);
} catch (ParserConfigurationException e) {
ExternalToolsPlugin.getDefault().log(e);
@@ -400,6 +405,18 @@ public class PlantyContentOutlinePage extends ContentOutlinePage implements ISho
return tempElement;
}
+ protected OutlinePreparingHandler createOutlinePreparingHandler(File tempParentFile) throws ParserConfigurationException {
+ return new OutlinePreparingHandler(tempParentFile);
+ }
+
+ protected IPath getLocation(Object input) {
+ return ((IFile) input).getLocation();
+ }
+
+ protected String getContentAsString(Object input) {
+ return getFileContentAsString((IFile) input);
+ }
+
private XmlElement generateExceptionOutline(String wholeDocumentString, Exception e, XmlElement rootElement) {
rootElement.setIsErrorNode(true);
XmlElement inputElement = new XmlElement(""); //$NON-NLS-1$
@@ -580,6 +597,10 @@ public class PlantyContentOutlinePage extends ContentOutlinePage implements ISho
}
BufferedReader tempBufferedReader = new BufferedReader(tempReader);
+ return getReaderContentAsString(tempBufferedReader);
+ }
+
+ protected String getReaderContentAsString(BufferedReader tempBufferedReader) {
StringBuffer tempResult = new StringBuffer();
try {
String tempLine;
@@ -619,8 +640,13 @@ public class PlantyContentOutlinePage extends ContentOutlinePage implements ISho
* Forces the page to update its contents.
*/
public void update() {
+ if (!DynamicReconciling.NEW_CODE_PATHS)
+ update(getContentOutline((IFile) getInput()));
+ }
+
+ protected void update(XmlElement contentOutline) {
getControl().setRedraw(false);
- getTreeViewer().setInput(getContentOutline(file));
+ getTreeViewer().setInput(contentOutline);
getTreeViewer().expandToLevel(2);
updateColor();
getControl().setRedraw(true);
@@ -658,7 +684,7 @@ public class PlantyContentOutlinePage extends ContentOutlinePage implements ISho
* @see org.eclipse.ui.part.IShowInSource#getShowInContext()
*/
public ShowInContext getShowInContext() {
- ISelection selection= new StructuredSelection(file);
+ ISelection selection= new StructuredSelection(getInput());
return new ShowInContext(null, selection);
}
@@ -671,4 +697,13 @@ public class PlantyContentOutlinePage extends ContentOutlinePage implements ISho
}
return null;
}
+
+ public Object getInput() {
+ return fInput;
+ }
+
+ public void setInput(Object input) {
+ fInput= input;
+ }
+
}
diff --git a/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/text/PlantyDocumentProvider.java b/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/text/PlantyDocumentProvider.java
index f9435452e..2ed19d901 100644
--- a/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/text/PlantyDocumentProvider.java
+++ b/org.eclipse.ui.externaltools/Ant Editor/org/eclipse/ui/externaltools/internal/ant/editor/text/PlantyDocumentProvider.java
@@ -34,7 +34,7 @@ import org.eclipse.ui.editors.text.FileDocumentProvider;
*/
public class PlantyDocumentProvider extends FileDocumentProvider {
- private IDocumentPartitioner createDocumentPartitioner() {
+ protected IDocumentPartitioner createDocumentPartitioner() {
DefaultPartitioner partitioner =
new DefaultPartitioner(
new PlantyPartitionScanner(),
diff --git a/org.eclipse.ui.externaltools/build.properties b/org.eclipse.ui.externaltools/build.properties
index 9135a0b34..f330bccf3 100644
--- a/org.eclipse.ui.externaltools/build.properties
+++ b/org.eclipse.ui.externaltools/build.properties
@@ -1,7 +1,8 @@
source.externaltools.jar = External Tools Base/,\
Program Tools Support/,\
Ant Tools Support/,\
- Ant Editor
+ Ant Editor/,\
+ Ant Editor New/
source.lib/antrunner.jar = Ant Runner Support/
diff --git a/org.eclipse.ui.externaltools/scripts/exportplugin.xml b/org.eclipse.ui.externaltools/scripts/exportplugin.xml
index 93ab98a9b..5b3d068e4 100644
--- a/org.eclipse.ui.externaltools/scripts/exportplugin.xml
+++ b/org.eclipse.ui.externaltools/scripts/exportplugin.xml
@@ -28,6 +28,7 @@
<fileset dir="External Tools Base"/>
<fileset dir="Program Tools Support"/>
<fileset dir="Ant Editor"/>
+ <fileset dir="Ant Editor New"/>
</zip>
<copy file="plugin.xml" todir="${dest}"/>
<copy file="plugin.properties" todir="${dest}"/>

Back to the top