Fixed outline view
diff --git a/bundles/org.eclipse.rap.themeeditor/build.properties b/bundles/org.eclipse.rap.themeeditor/build.properties
index c8a64b4..54102bb 100644
--- a/bundles/org.eclipse.rap.themeeditor/build.properties
+++ b/bundles/org.eclipse.rap.themeeditor/build.properties
@@ -3,5 +3,7 @@
 output.. = bin/
 bin.includes = .,\
                META-INF/,\
-               plugin.xml
+               plugin.xml,\
+               icons/
+src.includes = icons/
 
diff --git a/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/ThemeEditorPlugin.java b/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/ThemeEditorPlugin.java
index 9ff7443..dacf334 100644
--- a/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/ThemeEditorPlugin.java
+++ b/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/ThemeEditorPlugin.java
@@ -14,7 +14,7 @@
   public static final String IMG_FIELD_PRIVATE = "field_private_obj.gif";
   public static final String IMG_PUBLIC = "public_co.gif";
 
-  public static final String PLUGIN_ID = "org.eclipse.rap.themeeditor.csseditor"; //$NON-NLS-1$
+  public static final String PLUGIN_ID = "org.eclipse.rap.themeeditor";
 
   private static ThemeEditorPlugin sharedInstance;
 
@@ -45,7 +45,6 @@
     return getImageRegistry().get( key );
   }
 
-
   public static ImageDescriptor getImageDescriptor( final String path ) {
     return imageDescriptorFromPlugin( PLUGIN_ID, path );
   }
diff --git a/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/CSSContentOutlinePage.java b/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/CSSContentOutlinePage.java
index eab813d..c2c067c 100644
--- a/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/CSSContentOutlinePage.java
+++ b/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/CSSContentOutlinePage.java
@@ -10,20 +10,16 @@
  *******************************************************************************/
 package org.eclipse.rap.themeeditor.editor;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.rap.themeeditor.editor.rule.DefaultContentProvider;
+import org.eclipse.rap.themeeditor.editor.source.CSSSourceEditor;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Tree;
 import org.eclipse.swt.widgets.TreeItem;
 import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
 import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
 
 /**
@@ -35,14 +31,11 @@
 
   protected Object[] input;
   protected IDocumentProvider documentProvider;
-  protected ITextEditor textEditor;
+  protected CSSSourceEditor textEditor;
   private boolean isSetSelectionEnabled = true;
-  private int tabIndex = -1;
-  private Map listenerMap;
 
-  public CSSContentOutlinePage() {
-    super();
-    listenerMap = new HashMap();
+  public CSSContentOutlinePage( CSSSourceEditor cssSourceEditor ) {
+    textEditor = cssSourceEditor;
   }
 
   public void createControl( final Composite parent ) {
@@ -50,15 +43,11 @@
     TreeViewer viewer = getTreeViewer();
     viewer.setContentProvider( new DefaultContentProvider() );
     viewer.setLabelProvider( new ContentOutlineLabelProvider() );
-    viewer.addSelectionChangedListener( this );
-    if( input != null )
+    if( input != null ) {
       viewer.setInput( input );
+    }
   }
 
-  /**
-   * Handles the SelectionChangedEvent if the Outline selection has been changed
-   * by the user, and so it calls a possibly registered listener.
-   */
   public void selectionChanged( final SelectionChangedEvent event ) {
     isSetSelectionEnabled = false;
     super.selectionChanged( event );
@@ -72,17 +61,10 @@
       TreeItem treeItem = getTreeViewer().getTree().getSelection()[ 0 ];
       newIndex = getTreeViewer().getTree().indexOf( treeItem );
     }
-    IOutlineSelectionChangedListener listener = ( IOutlineSelectionChangedListener )listenerMap.get( new Integer( tabIndex ) );
-    if( listener != null ) {
-      listener.outlineSelectionChanged( newIndex, item );
-    }
+    textEditor.outlineSelectionChanged( newIndex, item );
     isSetSelectionEnabled = true;
   }
 
-  /**
-   * Forces a SelectionChangedEvent, and so it calls a possibly registered
-   * listener.
-   */
   public void forceSelectionChanged( final int newIndex ) {
     if( getTreeViewer() != null ) {
       isSetSelectionEnabled = false;
@@ -91,42 +73,16 @@
       if( !selection.isEmpty() ) {
         item = ( ( IStructuredSelection )selection ).getFirstElement();
       }
-      IOutlineSelectionChangedListener listener = ( IOutlineSelectionChangedListener )listenerMap.get( new Integer( tabIndex ) );
-      if( listener != null ) {
-        listener.outlineSelectionChanged( newIndex, item );
-      }
+      textEditor.outlineSelectionChanged( newIndex, item );
       isSetSelectionEnabled = true;
     }
   }
 
-  /**
-   * Sets a new input array for the Outline.
-   */
-  public void setInput( final Object[] input, final int tabIndex ) {
+  public void setInput( final Object[] input ) {
     this.input = input;
-    this.tabIndex = tabIndex;
     update();
   }
 
-  /**
-   * Updates the Outline. Called after the Outline input has changed.
-   */
-  private void update() {
-    TreeViewer viewer = getTreeViewer();
-    if( viewer != null ) {
-      Control control = viewer.getControl();
-      if( control != null && !control.isDisposed() ) {
-        control.setRedraw( false );
-        viewer.setInput( input );
-        viewer.expandAll();
-        control.setRedraw( true );
-      }
-    }
-  }
-
-  /**
-   * Sets the selected item in the Outline programmatically to the given index.
-   */
   public void setSelection( final int index ) {
     if( isSetSelectionEnabled && getTreeViewer() != null ) {
       Tree tree = getTreeViewer().getTree();
@@ -139,13 +95,16 @@
     }
   }
 
-  /**
-   * Sets a listener that will be notified of the selected item in the Outline
-   * changes.
-   */
-  public void setSelectionChangedListener( final IOutlineSelectionChangedListener listener,
-                                           final int tabIndex )
-  {
-    listenerMap.put( new Integer( tabIndex ), listener );
+  private void update() {
+    TreeViewer viewer = getTreeViewer();
+    if( viewer != null ) {
+      Control control = viewer.getControl();
+      if( control != null && !control.isDisposed() ) {
+        control.setRedraw( false );
+        viewer.setInput( input );
+        viewer.expandAll();
+        control.setRedraw( true );
+      }
+    }
   }
 }
diff --git a/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/rule/DefaultContentProvider.java b/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/DefaultContentProvider.java
similarity index 92%
rename from bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/rule/DefaultContentProvider.java
rename to bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/DefaultContentProvider.java
index b2aa13c..b797a23 100644
--- a/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/rule/DefaultContentProvider.java
+++ b/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/DefaultContentProvider.java
@@ -1,4 +1,3 @@
-package org.eclipse.rap.themeeditor.editor.rule;
 /*******************************************************************************
  * Copyright (c) 2008 Mathias Schaeffner and others.
  * All rights reserved. This program and the accompanying materials
@@ -9,7 +8,7 @@
  * Contributors:
  *    Mathias Schaeffner - initial API and implementation
  *******************************************************************************/
-
+package org.eclipse.rap.themeeditor.editor;
 
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.ITreeContentProvider;
@@ -22,9 +21,6 @@
   implements ITreeContentProvider
 {
 
-  public DefaultContentProvider() {
-  }
-
   public Object[] getChildren( final Object parentElement ) {
     return new Object[ 0 ];
   }
diff --git a/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/source/CSSSourceEditor.java b/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/source/CSSSourceEditor.java
index 920f0a7..37e7be1 100644
--- a/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/source/CSSSourceEditor.java
+++ b/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/source/CSSSourceEditor.java
@@ -24,11 +24,13 @@
 import org.eclipse.jface.text.source.ISourceViewer;
 import org.eclipse.jface.text.source.IVerticalRuler;
 import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.rap.themeeditor.editor.CSSContentOutlinePage;
 import org.eclipse.rap.themeeditor.editor.IOutlineSelectionChangedListener;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.ui.editors.text.TextEditor;
 import org.eclipse.ui.texteditor.ContentAssistAction;
 import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
 
 /**
  * The general editor in the Source Tab. Providing content assists, syntax
@@ -39,16 +41,14 @@
 {
 
   private CSSTokenScanner tokenScanner;
-
-  public CSSSourceEditor() {
-    super();
-//    getCSSTokenScanner().setTokenChangedListener( editor );
-//    outline.setSelectionChangedListener( this, ThemeEditor.SOURCE_TAB );
-  }
+  private CSSContentOutlinePage outlinePage;
 
   protected void initializeEditor() {
     super.initializeEditor();
-    setSourceViewerConfiguration( new CSSSourceViewerConfiguration( getCSSTokenScanner() ) );
+    tokenScanner = new CSSTokenScanner( this );
+    CSSSourceViewerConfiguration configuration
+      = new CSSSourceViewerConfiguration( tokenScanner );
+    setSourceViewerConfiguration( configuration );
   }
 
   public void createPartControl( Composite parent ) {
@@ -63,7 +63,8 @@
       }
 
       public void documentChanged( DocumentEvent event ) {
-        getCSSTokenScanner().setRange( doc, 0, doc.getLength() );
+        tokenScanner.setRange( doc, 0, doc.getLength() );
+        outlinePage.setInput( getSelectorTokens() );
       }
     } );
   }
@@ -76,26 +77,7 @@
   }
 
   public Object[] getSelectorTokens() {
-    return getCSSTokenScanner().getOutlineRegionsArray();
-  }
-
-  /**
-   * Returns the index of a rule in the StyleSheet at a given offset position
-   * within the document.
-   */
-  private int getRuleNumber( final int offset ) {
-    int result = -1;
-    Iterator it = getCSSTokenScanner().getOutlineRegionsList().iterator();
-    while( it.hasNext() ) {
-      IRegion regionExt = ( IRegion )it.next();
-      if( regionExt.getOffset() <= offset ) {
-        result++;
-      }
-    }
-    if( result < 0 ) {
-      result = 0;
-    }
-    return result;
+    return tokenScanner.getOutlineRegionsArray();
   }
 
   protected void handleCursorPositionChanged() {
@@ -104,7 +86,9 @@
     if( selection instanceof ITextSelection ) {
       int offset = ( ( ITextSelection )selection ).getOffset();
       int index = getRuleNumber( offset );
-//      editor.updateOutlineSelection( index );
+      if( outlinePage != null ) {
+        outlinePage.setSelection( index );
+      }
     }
   }
 
@@ -112,18 +96,6 @@
     handleCursorPositionChanged();
   }
 
-  private CSSTokenScanner getCSSTokenScanner() {
-    if( tokenScanner == null ) {
-      tokenScanner = new CSSTokenScanner( this );
-    }
-    return tokenScanner;
-  }
-
-  public void dispose() {
-    tokenScanner.setTokenChangedListener( null );
-    super.dispose();
-  }
-
   protected void createActions() {
     super.createActions();
     IAction action = new ContentAssistAction( getResourceBundle(),
@@ -170,16 +142,47 @@
     return getDocumentProvider().getDocument( getEditorInput() );
   }
 
+  public Object getAdapter( Class adapter ) {
+    Object result;
+    if( IContentOutlinePage.class.equals( adapter ) ) {
+      if( outlinePage == null ) {
+        outlinePage = new CSSContentOutlinePage( this );
+        outlinePage.setInput( getSelectorTokens() );
+      }
+      result = outlinePage;
+    } else {
+      result = super.getAdapter( adapter );
+    }
+    return result;
+  }
+
+  /**
+   * Returns the index of a rule in the StyleSheet at a given offset position
+   * within the document.
+   */
+  private int getRuleNumber( final int offset ) {
+    int result = -1;
+    Iterator it = tokenScanner.getOutlineRegionsList().iterator();
+    while( it.hasNext() ) {
+      IRegion regionExt = ( IRegion )it.next();
+      if( regionExt.getOffset() <= offset ) {
+        result++;
+      }
+    }
+    if( result < 0 ) {
+      result = 0;
+    }
+    return result;
+  }
+
   private ResourceBundle getResourceBundle() {
     return new ResourceBundle() {
       
       protected Object handleGetObject( String key ) {
-        // TODO Auto-generated method stub
         return null;
       }
       
       public Enumeration getKeys() {
-        // TODO Auto-generated method stub
         return null;
       }
     };
diff --git a/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/source/CSSTokenScanner.java b/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/source/CSSTokenScanner.java
index 7bb294f..7eeb3fe 100644
--- a/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/source/CSSTokenScanner.java
+++ b/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/source/CSSTokenScanner.java
@@ -36,7 +36,6 @@
   private IRegionExt lastState;
   private int currentListPosition;
   private int lastListPosition;
-  private ITokenChangedListener listener = null;
   private String oldContent;
   private int oldListPosition;
   private SelectorRegion lastSelector;
@@ -121,10 +120,6 @@
         lastListPosition++;
       }
       oldListPosition = currentListPosition;
-      // notify token changed listener if one is registered
-      if( listener != null ) {
-        listener.tokensChanged();
-      }
     }
   }
 
@@ -147,10 +142,6 @@
     return tokenList;
   }
 
-  public void setTokenChangedListener( final ITokenChangedListener listener ) {
-    this.listener = listener;
-  }
-
   /**
    * Returns the array of Outline regions that are directly used as the input
    * items for the Outline.
diff --git a/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/source/ITokenChangedListener.java b/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/source/ITokenChangedListener.java
deleted file mode 100644
index a337a91..0000000
--- a/bundles/org.eclipse.rap.themeeditor/src/org/eclipse/rap/themeeditor/editor/source/ITokenChangedListener.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Mathias Schaeffner 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:
- *    Mathias Schaeffner - initial API and implementation
- *******************************************************************************/
-package org.eclipse.rap.themeeditor.editor.source;
-
-/**
- * Listener interface that is called whenever the token scanner was requested to
- * split the document again into tokens.
- */
-public interface ITokenChangedListener {
-
-  public void tokensChanged();
-}