[211826] Support a configurable outline view
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ADTMultiPageEditor.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ADTMultiPageEditor.java
index 3270c78..3f46c13 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ADTMultiPageEditor.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ADTMultiPageEditor.java
@@ -38,6 +38,7 @@
import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel;
import org.eclipse.wst.xsd.ui.internal.adt.outline.ADTContentOutlinePage;
import org.eclipse.wst.xsd.ui.internal.adt.outline.ADTLabelProvider;
+import org.eclipse.wst.xsd.ui.internal.adt.outline.ExtensibleContentOutlinePage;
import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin;
public abstract class ADTMultiPageEditor extends CommonMultiPageEditor
@@ -125,14 +126,23 @@
{
if (fOutlinePage == null || fOutlinePage.getControl() == null || fOutlinePage.getControl().isDisposed())
{
- ADTContentOutlinePage outlinePage = new ADTContentOutlinePage(this);
- //outlinePage.getTreeViewer().removeF(filter);
+ final ProductCustomizationProvider productCustomizationProvider = (ProductCustomizationProvider)getAdapter(ProductCustomizationProvider.class);
+ ExtensibleContentOutlinePage outlinePage = null;
+ if (productCustomizationProvider != null)
+ {
+ outlinePage = productCustomizationProvider.getProductContentOutlinePage();
+ }
+
+ if (outlinePage == null)
+ {
+ outlinePage = new ADTContentOutlinePage();
+ }
+ outlinePage.setEditor(this);
ITreeContentProvider provider = (ITreeContentProvider)getEditorModeManager().getCurrentMode().getOutlineProvider();
outlinePage.setContentProvider(provider);
ADTLabelProvider adtLabelProvider = new ADTLabelProvider();
outlinePage.setLabelProvider(adtLabelProvider);
outlinePage.setModel(getModel());
-
fOutlinePage = outlinePage;
}
return fOutlinePage;
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ProductCustomizationProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ProductCustomizationProvider.java
index be3d429..9703e50 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ProductCustomizationProvider.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/editor/ProductCustomizationProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 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
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.wst.xsd.ui.internal.adt.editor;
+import org.eclipse.wst.xsd.ui.internal.adt.outline.ExtensibleContentOutlinePage;
+
public abstract class ProductCustomizationProvider
{
public abstract boolean isEditorModeApplicable(String id);
@@ -28,4 +30,9 @@
public void handleAction(String actionId)
{
}
+
+ public ExtensibleContentOutlinePage getProductContentOutlinePage()
+ {
+ return null;
+ }
}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/outline/ADTContentOutlinePage.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/outline/ADTContentOutlinePage.java
index 12ee02c..322c931 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/outline/ADTContentOutlinePage.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/outline/ADTContentOutlinePage.java
@@ -16,7 +16,6 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
@@ -27,54 +26,22 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.part.MultiPageSelectionProvider;
-import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeLabelProvider;
import org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewContextMenuProvider;
import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.model.IModelProxy;
-import org.eclipse.wst.xsd.ui.internal.adt.editor.ADTMultiPageEditor;
import org.eclipse.wst.xsd.ui.internal.adt.facade.IModel;
import org.eclipse.xsd.XSDConcreteComponent;
import org.eclipse.xsd.XSDSchema;
-public class ADTContentOutlinePage extends ContentOutlinePage
+public class ADTContentOutlinePage extends ExtensibleContentOutlinePage
{
- protected ADTMultiPageEditor editor;
protected int level = 0;
- protected Object model;
- protected ITreeContentProvider contentProvider;
- protected ILabelProvider labelProvider;
protected MultiPageSelectionProvider selectionManager;
protected SelectionManagerSelectionChangeListener selectionManagerSelectionChangeListener = new SelectionManagerSelectionChangeListener();
-// protected TreeSelectionChangeListener treeSelectionChangeListener = new TreeSelectionChangeListener();
- /**
- *
- */
- public ADTContentOutlinePage(ADTMultiPageEditor editor)
+ public ADTContentOutlinePage()
{
super();
- this.editor = editor;
- }
-
- public void setModel(Object newModel)
- {
- model = newModel;
- }
-
- public void setContentProvider(ITreeContentProvider contentProvider)
- {
- this.contentProvider = contentProvider;
- }
-
- public void setLabelProvider(ILabelProvider labelProvider)
- {
- this.labelProvider = labelProvider;
- }
-
- // expose
- public TreeViewer getTreeViewer()
- {
- return super.getTreeViewer();
}
public void createControl(Composite parent)
@@ -172,7 +139,7 @@
}
}
- class SelectionManagerSelectionChangeListener implements ISelectionChangedListener
+ protected class SelectionManagerSelectionChangeListener implements ISelectionChangedListener
{
public void selectionChanged(SelectionChangedEvent event)
{
@@ -221,7 +188,7 @@
// }
- void updateStatusLine(IStatusLineManager mgr, ISelection selection)
+ protected void updateStatusLine(IStatusLineManager mgr, ISelection selection)
{
String text = null;
Image image = null;
@@ -242,7 +209,7 @@
}
}
- private class StatusLineLabelProvider extends JFaceNodeLabelProvider
+ protected class StatusLineLabelProvider extends JFaceNodeLabelProvider
{
TreeViewer treeViewer = null;
diff --git a/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/outline/ExtensibleContentOutlinePage.java b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/outline/ExtensibleContentOutlinePage.java
new file mode 100644
index 0000000..1c668a4
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src-adt/org/eclipse/wst/xsd/ui/internal/adt/outline/ExtensibleContentOutlinePage.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.adt.outline;
+
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.util.SafeRunnable;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.part.IPageSite;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+import org.eclipse.wst.xsd.ui.internal.adt.editor.ADTMultiPageEditor;
+
+public class ExtensibleContentOutlinePage extends Page implements IContentOutlinePage, ISelectionChangedListener
+{
+ protected ListenerList selectionChangedListeners = new ListenerList();
+ protected TreeViewer treeViewer;
+ protected Object model;
+ protected ITreeContentProvider contentProvider;
+ protected ILabelProvider labelProvider;
+ protected ADTMultiPageEditor editor;
+
+ protected ExtensibleContentOutlinePage()
+ {
+ super();
+ }
+
+ public void createControl(Composite parent)
+ {
+ treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ treeViewer.addSelectionChangedListener(this);
+ }
+
+ public void setEditor(ADTMultiPageEditor editor)
+ {
+ this.editor = editor;
+ }
+
+ public void setModel(Object newModel)
+ {
+ model = newModel;
+ }
+
+ public void setContentProvider(ITreeContentProvider contentProvider)
+ {
+ this.contentProvider = contentProvider;
+ }
+
+ public void setLabelProvider(ILabelProvider labelProvider)
+ {
+ this.labelProvider = labelProvider;
+ }
+
+ public void setFocus()
+ {
+ treeViewer.getControl().setFocus();
+ }
+
+ public void setSelection(ISelection selection)
+ {
+ if (treeViewer != null)
+ {
+ treeViewer.setSelection(selection);
+ }
+ }
+
+ public void addSelectionChangedListener(ISelectionChangedListener listener)
+ {
+ selectionChangedListeners.add(listener);
+ }
+
+ protected void fireSelectionChanged(ISelection selection)
+ {
+ // create an event
+ final SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
+
+ // fire the event
+ Object[] listeners = selectionChangedListeners.getListeners();
+ for (int i = 0; i < listeners.length; ++i)
+ {
+ final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i];
+ Platform.run(new SafeRunnable()
+ {
+ public void run()
+ {
+ l.selectionChanged(event);
+ }
+ });
+ }
+ }
+
+ public Control getControl()
+ {
+ if (treeViewer == null)
+ {
+ return null;
+ }
+ return treeViewer.getControl();
+ }
+
+ public ISelection getSelection()
+ {
+ if (treeViewer == null)
+ {
+ return StructuredSelection.EMPTY;
+ }
+ return treeViewer.getSelection();
+ }
+
+ public TreeViewer getTreeViewer()
+ {
+ return treeViewer;
+ }
+
+ public void init(IPageSite pageSite)
+ {
+ super.init(pageSite);
+ pageSite.setSelectionProvider(this);
+ }
+
+ public void removeSelectionChangedListener(ISelectionChangedListener listener)
+ {
+ selectionChangedListeners.remove(listener);
+ }
+
+ public void selectionChanged(SelectionChangedEvent event)
+ {
+ fireSelectionChanged(event.getSelection());
+ }
+}