155a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project/* 255a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * Copyright (C) 2007 The Android Open Source Project 355a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * 455a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * Licensed under the Eclipse Public License, Version 1.0 (the "License"); 555a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * you may not use this file except in compliance with the License. 655a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * You may obtain a copy of the License at 755a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * 855a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * http://www.eclipse.org/org/documents/epl-v10.php 955a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * 1055a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software 1155a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 1255a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1355a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * See the License for the specific language governing permissions and 1455a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * limitations under the License. 1555a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project */ 1655a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project 1769425d803b34589309a69eddc53a338e1409b30cXavier Ducrohetpackage com.android.ide.eclipse.adt.internal.editors.manifest.pages; 1855a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project 1955a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Projectimport com.android.ide.eclipse.adt.AdtPlugin; 2058fbcbc338dcea62816a0fdb6c21b707ecdf06a8Raphael Mollimport com.android.ide.eclipse.adt.internal.editors.IPageImageProvider; 2158fbcbc338dcea62816a0fdb6c21b707ecdf06a8Raphael Mollimport com.android.ide.eclipse.adt.internal.editors.IconFactory; 2269425d803b34589309a69eddc53a338e1409b30cXavier Ducrohetimport com.android.ide.eclipse.adt.internal.editors.descriptors.ElementDescriptor; 2369425d803b34589309a69eddc53a338e1409b30cXavier Ducrohetimport com.android.ide.eclipse.adt.internal.editors.manifest.ManifestEditor; 2469425d803b34589309a69eddc53a338e1409b30cXavier Ducrohetimport com.android.ide.eclipse.adt.internal.editors.manifest.descriptors.AndroidManifestDescriptors; 2569425d803b34589309a69eddc53a338e1409b30cXavier Ducrohetimport com.android.ide.eclipse.adt.internal.editors.ui.tree.UiTreeBlock; 2669425d803b34589309a69eddc53a338e1409b30cXavier Ducrohetimport com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode; 2755a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project 2858fbcbc338dcea62816a0fdb6c21b707ecdf06a8Raphael Mollimport org.eclipse.swt.graphics.Image; 2955a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Projectimport org.eclipse.ui.forms.IManagedForm; 3055a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Projectimport org.eclipse.ui.forms.editor.FormPage; 3155a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Projectimport org.eclipse.ui.forms.widgets.ScrolledForm; 3255a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project 3355a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project/** 3455a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * Page for permissions settings, part of the AndroidManifest form editor. 3555a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * <p/> 3655a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * Useful reference: 3755a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * <a href="http://www.eclipse.org/articles/Article-Forms/article.html"> 3855a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * http://www.eclipse.org/articles/Article-Forms/article.html</a> 3955a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project */ 4058fbcbc338dcea62816a0fdb6c21b707ecdf06a8Raphael Mollpublic final class PermissionPage extends FormPage implements IPageImageProvider { 4155a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project /** Page id used for switching tabs programmatically */ 4255a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project public final static String PAGE_ID = "permission_page"; //$NON-NLS-1$ 4355a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project 4455a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project /** Container editor */ 4555a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project ManifestEditor mEditor; 4655a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project 4755a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project private UiTreeBlock mTreeBlock; 4855a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project 4955a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project public PermissionPage(ManifestEditor editor) { 5055a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project super(editor, PAGE_ID, "Permissions"); // tab label, keep it short 5155a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project mEditor = editor; 5255a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project } 5355a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project 54ab36f4e7488358dea4ab6b54ee2b7bef3da0232bTor Norbye @Override 5558fbcbc338dcea62816a0fdb6c21b707ecdf06a8Raphael Moll public Image getPageImage() { 5658fbcbc338dcea62816a0fdb6c21b707ecdf06a8Raphael Moll return IconFactory.getInstance().getIcon(getTitle(), 5758fbcbc338dcea62816a0fdb6c21b707ecdf06a8Raphael Moll IconFactory.COLOR_RED, 5858fbcbc338dcea62816a0fdb6c21b707ecdf06a8Raphael Moll IconFactory.SHAPE_RECT); 5958fbcbc338dcea62816a0fdb6c21b707ecdf06a8Raphael Moll } 6058fbcbc338dcea62816a0fdb6c21b707ecdf06a8Raphael Moll 6155a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project /** 6255a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * Creates the content in the form hosted in this page. 6358fbcbc338dcea62816a0fdb6c21b707ecdf06a8Raphael Moll * 6455a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * @param managedForm the form hosted in this page. 6555a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project */ 6655a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project @Override 6755a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project protected void createFormContent(IManagedForm managedForm) { 6855a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project super.createFormContent(managedForm); 6955a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project ScrolledForm form = managedForm.getForm(); 7055a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project form.setText("Android Manifest Permissions"); 7155a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project form.setImage(AdtPlugin.getAndroidLogo()); 7255a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project 7355a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project UiElementNode manifest = mEditor.getUiRootNode(); 7455a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project AndroidManifestDescriptors manifestDescriptor = mEditor.getManifestDescriptors(); 7558fbcbc338dcea62816a0fdb6c21b707ecdf06a8Raphael Moll 7655a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project ElementDescriptor[] descriptorFilters = null; 7755a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project if (manifestDescriptor != null) { 7855a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project descriptorFilters = new ElementDescriptor[] { 7955a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project manifestDescriptor.getPermissionElement(), 8055a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project manifestDescriptor.getUsesPermissionElement(), 8155a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project manifestDescriptor.getPermissionGroupElement(), 8255a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project manifestDescriptor.getPermissionTreeElement() 8355a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project }; 8455a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project } 8555a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project mTreeBlock = new UiTreeBlock(mEditor, manifest, 8655a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project true /* autoCreateRoot */, 8755a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project descriptorFilters, 8855a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project "Permissions", 8955a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project "List of permissions defined and used by the manifest"); 9055a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project mTreeBlock.createContent(managedForm); 9155a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project } 9255a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project 9355a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project /** 9455a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project * Changes and refreshes the Application UI node handled by the sub parts. 9555a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project */ 9655a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project public void refreshUiNode() { 9755a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project if (mTreeBlock != null) { 9855a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project UiElementNode manifest = mEditor.getUiRootNode(); 9955a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project AndroidManifestDescriptors manifestDescriptor = mEditor.getManifestDescriptors(); 10055a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project 10155a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project mTreeBlock.changeRootAndDescriptors(manifest, 10255a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project new ElementDescriptor[] { 10355a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project manifestDescriptor.getPermissionElement(), 10455a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project manifestDescriptor.getUsesPermissionElement(), 10555a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project manifestDescriptor.getPermissionGroupElement(), 10655a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project manifestDescriptor.getPermissionTreeElement() 10755a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project }, 10855a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project true /* refresh */); 10955a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project } 11055a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project } 11155a2c71f27d3e0b8344597c7f281e687cb7aeb1bThe Android Open Source Project} 112