OSDN Git Service

AI 146250: am: CL 146238 ADT #1761064: Properly refresh UiTreeBlock when SDK is reloaded.
authorRaphael Moll <>
Tue, 14 Apr 2009 23:57:57 +0000 (16:57 -0700)
committerThe Android Open Source Project <initial-contribution@android.com>
Tue, 14 Apr 2009 23:57:57 +0000 (16:57 -0700)
  The fix I did last week was just refreshing the UiRootNode
  but it turns out we need to refresh the DescriptorFilters too
  (since they are null when there's no SDK.) So the old fix was
  wrong, what we need is to generate a new tree model when the
  SDK is reloaded.
  Original author: raphael
  Merged from: //branches/cupcake/...

Automated import of CL 146250

eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/editors/ui/tree/UiModelTreeContentProvider.java
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/editors/ui/tree/UiRootNodeProvider.java [deleted file]
eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/editors/ui/tree/UiTreeBlock.java

index 3091992..396b309 100644 (file)
@@ -33,12 +33,12 @@ class UiModelTreeContentProvider implements ITreeContentProvider {
     /** The descriptor of the elements to be displayed as root in this tree view. All elements
      *  of the same type in the root will be displayed. */
     private ElementDescriptor[] mDescriptorFilters;
-    /** Object which provides the uiRootNode */
-    private final UiRootNodeProvider mUiRootNodeProvider;
+    /** The uiRootNode of the model. */
+    private final UiElementNode mUiRootNode;
 
-    public UiModelTreeContentProvider(UiRootNodeProvider rootNodeProvider,
+    public UiModelTreeContentProvider(UiElementNode uiRootNode,
             ElementDescriptor[] descriptorFilters) {
-        mUiRootNodeProvider = rootNodeProvider;
+        mUiRootNode = uiRootNode;
         mDescriptorFilters = descriptorFilters;
     }
     
@@ -86,9 +86,8 @@ class UiModelTreeContentProvider implements ITreeContentProvider {
      */
     public Object[] getElements(Object inputElement) {
         ArrayList<UiElementNode> roots = new ArrayList<UiElementNode>();
-        UiElementNode uiRootNode = mUiRootNodeProvider.getRootNode();
-        if (uiRootNode != null) {
-            for (UiElementNode ui_node : uiRootNode.getUiChildren()) {
+        if (mUiRootNode != null) {
+            for (UiElementNode ui_node : mUiRootNode.getUiChildren()) {
                 if (mDescriptorFilters == null || mDescriptorFilters.length == 0) {
                     roots.add(ui_node);
                 } else {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/editors/ui/tree/UiRootNodeProvider.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/editors/ui/tree/UiRootNodeProvider.java
deleted file mode 100644 (file)
index 5121e35..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.eclipse.editors.ui.tree;
-
-import com.android.ide.eclipse.editors.uimodel.UiElementNode;
-
-/**
- * An object that can provide a uiRootNode.
- */
-public interface UiRootNodeProvider {
-    /** Returns the UiDocumentNode for the current model. */
-    public abstract UiElementNode getRootNode();
-}
index 8038a47..e1986e5 100644 (file)
@@ -83,8 +83,7 @@ import java.util.LinkedList;
  * On the left is a details part that displays all the visible UI attributes for a given
  * selected UI element node.
  */
-public final class UiTreeBlock extends MasterDetailsBlock
-    implements ICommitXml, UiRootNodeProvider {
+public final class UiTreeBlock extends MasterDetailsBlock implements ICommitXml {
 
     /** Height hint for the tree view. Helps the grid layout resize properly on smaller screens. */
     private static final int TREE_HEIGHT_HINT = 50;
@@ -251,7 +250,7 @@ public final class UiTreeBlock extends MasterDetailsBlock
         tree.setLayoutData(gd);
 
         mTreeViewer = new TreeViewer(tree);
-        mTreeViewer.setContentProvider(new UiModelTreeContentProvider(this, mDescriptorFilters));
+        mTreeViewer.setContentProvider(new UiModelTreeContentProvider(mUiRootNode, mDescriptorFilters));
         mTreeViewer.setLabelProvider(new UiModelTreeLabelProvider());
         mTreeViewer.setInput("unused"); //$NON-NLS-1$
 
@@ -380,6 +379,8 @@ public final class UiTreeBlock extends MasterDetailsBlock
         mUiRootNode = uiRootNode;
         mDescriptorFilters = descriptorFilters;
 
+        mTreeViewer.setContentProvider(new UiModelTreeContentProvider(mUiRootNode, mDescriptorFilters));
+
         // Listen on structural changes on the root node of the tree
         // If the node has a parent, listen on the parent instead.
         node = mUiRootNode.getUiParent() != null ? mUiRootNode.getUiParent() : mUiRootNode;