simple folding
diff --git a/eclipsecon08/org.eclipse.dltk.examples.python.part3/src/org/eclipse/dltk/examples/python/internal/ui/editor/ExamplePythonEditor.java b/eclipsecon08/org.eclipse.dltk.examples.python.part3/src/org/eclipse/dltk/examples/python/internal/ui/editor/ExamplePythonEditor.java
index 41c3bbb..b372668 100644
--- a/eclipsecon08/org.eclipse.dltk.examples.python.part3/src/org/eclipse/dltk/examples/python/internal/ui/editor/ExamplePythonEditor.java
+++ b/eclipsecon08/org.eclipse.dltk.examples.python.part3/src/org/eclipse/dltk/examples/python/internal/ui/editor/ExamplePythonEditor.java
@@ -5,6 +5,7 @@
import org.eclipse.dltk.examples.python.internal.ExamplePythonUI;
import org.eclipse.dltk.internal.ui.editor.ScriptEditor;
import org.eclipse.dltk.ui.text.ScriptTextTools;
+import org.eclipse.dltk.ui.text.folding.IFoldingStructureProvider;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension3;
@@ -48,4 +49,14 @@
}
}
}
+
+ private IFoldingStructureProvider foldingStructureProvider = null;
+
+ @Override
+ protected IFoldingStructureProvider getFoldingStructureProvider() {
+ if (foldingStructureProvider == null) {
+ foldingStructureProvider = new ExamplePythonFoldingStructureProvider();
+ }
+ return foldingStructureProvider;
+ }
}
diff --git a/eclipsecon08/org.eclipse.dltk.examples.python.part3/src/org/eclipse/dltk/examples/python/internal/ui/editor/ExamplePythonFoldingStructureProvider.java b/eclipsecon08/org.eclipse.dltk.examples.python.part3/src/org/eclipse/dltk/examples/python/internal/ui/editor/ExamplePythonFoldingStructureProvider.java
new file mode 100644
index 0000000..ce85e5c
--- /dev/null
+++ b/eclipsecon08/org.eclipse.dltk.examples.python.part3/src/org/eclipse/dltk/examples/python/internal/ui/editor/ExamplePythonFoldingStructureProvider.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 2007 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ ******************************************************************************/
+package org.eclipse.dltk.examples.python.internal.ui.editor;
+
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.dltk.examples.internal.python.core.ExamplePythonNature;
+import org.eclipse.dltk.examples.python.internal.ExamplePythonUI;
+import org.eclipse.dltk.ui.text.folding.AbstractASTFoldingStructureProvider;
+import org.eclipse.jface.text.rules.IPartitionTokenScanner;
+
+public class ExamplePythonFoldingStructureProvider extends
+ AbstractASTFoldingStructureProvider {
+
+ public String getCommentPartition() {
+ return IExamplePythonPartitions.PYTHON_COMMENT;
+ }
+
+ protected ILog getLog() {
+ return ExamplePythonUI.getDefault().getLog();
+ }
+
+ protected String getPartition() {
+ return IExamplePythonPartitions.PYTHON_PARTITIONING;
+ }
+
+ protected IPartitionTokenScanner getPartitionScanner() {
+ return ExamplePythonUI.getDefault().getTextTools()
+ .getPartitionScanner();
+ }
+
+ protected String[] getPartitionTypes() {
+ return IExamplePythonPartitions.PYTHON_PARITION_TYPES;
+ }
+
+ protected String getNatureId() {
+ return ExamplePythonNature.PYTHON_NATURE;
+ }
+}