2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.eclipse.org/org/documents/epl-v10.php
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.
17 package com.android.ide.eclipse.adt.internal.editors.resources;
19 import com.android.ide.eclipse.adt.AdtPlugin;
20 import com.android.ide.eclipse.adt.internal.editors.ui.tree.UiTreeBlock;
21 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
22 import com.android.ide.eclipse.adt.internal.resources.manager.ResourceFolder;
23 import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager;
25 import org.eclipse.core.resources.IFile;
26 import org.eclipse.ui.IEditorInput;
27 import org.eclipse.ui.forms.IManagedForm;
28 import org.eclipse.ui.forms.editor.FormPage;
29 import org.eclipse.ui.forms.widgets.ScrolledForm;
30 import org.eclipse.ui.part.FileEditorInput;
33 * Page for instrumentation settings, part of the AndroidManifest form editor.
35 public final class ResourcesTreePage extends FormPage {
36 /** Page id used for switching tabs programmatically */
37 public final static String PAGE_ID = "res_tree_page"; //$NON-NLS-1$
39 /** Container editor */
40 ResourcesEditor mEditor;
42 public ResourcesTreePage(ResourcesEditor editor) {
43 super(editor, PAGE_ID, "Resources"); // tab's label, keep it short
48 * Creates the content in the form hosted in this page.
50 * @param managedForm the form hosted in this page.
53 protected void createFormContent(IManagedForm managedForm) {
54 super.createFormContent(managedForm);
55 ScrolledForm form = managedForm.getForm();
57 String configText = null;
58 IEditorInput input = mEditor.getEditorInput();
59 if (input instanceof FileEditorInput) {
60 FileEditorInput fileInput = (FileEditorInput)input;
61 IFile iFile = fileInput.getFile();
63 ResourceFolder resFolder = ResourceManager.getInstance().getResourceFolder(iFile);
64 if (resFolder != null) {
65 configText = resFolder.getConfiguration().toDisplayString();
69 if (configText != null) {
70 form.setText(String.format("Android Resources (%1$s)", configText));
72 form.setText("Android Resources");
75 form.setImage(AdtPlugin.getAndroidLogo());
77 UiElementNode resources = mEditor.getUiRootNode();
78 UiTreeBlock block = new UiTreeBlock(mEditor, resources,
79 true /* autoCreateRoot */,
80 null /* no element filters */,
82 "List of all resources elements in this XML file.");
83 block.createContent(managedForm);