Home | History | Annotate | Download | only in otherxml
      1 /*
      2  * Copyright (C) 2008 The Android Open Source Project
      3  *
      4  * Licensed under the Eclipse Public License, Version 1.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.eclipse.org/org/documents/epl-v10.php
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package com.android.ide.eclipse.adt.internal.editors.otherxml;
     18 
     19 import com.android.ide.eclipse.adt.AdtPlugin;
     20 import com.android.ide.eclipse.adt.internal.editors.IPageImageProvider;
     21 import com.android.ide.eclipse.adt.internal.editors.IconFactory;
     22 import com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor;
     23 import com.android.ide.eclipse.adt.internal.editors.ui.tree.UiTreeBlock;
     24 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
     25 
     26 import org.eclipse.swt.graphics.Image;
     27 import org.eclipse.ui.forms.IManagedForm;
     28 import org.eclipse.ui.forms.editor.FormPage;
     29 import org.eclipse.ui.forms.widgets.ScrolledForm;
     30 
     31 /**
     32  * Page for the xml form editor.
     33  */
     34 public final class OtherXmlTreePage extends FormPage implements IPageImageProvider {
     35     /** Page id used for switching tabs programmatically */
     36     public final static String PAGE_ID = "xml_tree_page"; //$NON-NLS-1$
     37 
     38     /** Container editor */
     39     CommonXmlEditor mEditor;
     40 
     41     public OtherXmlTreePage(CommonXmlEditor editor) {
     42         super(editor, PAGE_ID, "Structure");  // tab's label, keep it short
     43         mEditor = editor;
     44     }
     45 
     46     @Override
     47     public Image getPageImage() {
     48         return IconFactory.getInstance().getIcon("editor_page_design");  //$NON-NLS-1$
     49     }
     50 
     51     /**
     52      * Creates the content in the form hosted in this page.
     53      *
     54      * @param managedForm the form hosted in this page.
     55      */
     56     @Override
     57     protected void createFormContent(IManagedForm managedForm) {
     58         super.createFormContent(managedForm);
     59         ScrolledForm form = managedForm.getForm();
     60         form.setText("Android Xml");
     61         form.setImage(AdtPlugin.getAndroidLogo());
     62 
     63         UiElementNode rootNode = mEditor.getUiRootNode();
     64         UiTreeBlock block = new UiTreeBlock(mEditor, rootNode,
     65                 true /* autoCreateRoot */,
     66                 null /* no element filters */,
     67                 "Xml Elements",
     68                 "List of all xml elements in this XML file.");
     69         block.createContent(managedForm);
     70     }
     71 }
     72