1 /* 2 * Copyright (C) 2010 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.export; 18 19 import com.android.ide.eclipse.adt.AdtPlugin; 20 import com.android.ide.eclipse.adt.AdtConstants; 21 import com.android.ide.eclipse.adt.internal.editors.AndroidTextEditor; 22 23 import org.eclipse.core.resources.IFile; 24 import org.eclipse.jface.text.DocumentEvent; 25 import org.eclipse.ui.IEditorInput; 26 import org.eclipse.ui.IEditorPart; 27 import org.eclipse.ui.PartInitException; 28 import org.eclipse.ui.part.FileEditorInput; 29 30 /** 31 * Multi-page form editor for export.properties in Export Projects. 32 */ 33 public class ExportEditor extends AndroidTextEditor { 34 35 public static final String ID = AdtConstants.EDITORS_NAMESPACE + ".text.ExportEditor"; //$NON-NLS-1$ 36 37 private ExportPropertiesPage mExportPropsPage; 38 39 /** 40 * Creates the form editor for resources XML files. 41 */ 42 public ExportEditor() { 43 super(); 44 } 45 46 // ---- Base Class Overrides ---- 47 48 /** 49 * Returns whether the "save as" operation is supported by this editor. 50 * <p/> 51 * Save-As is a valid operation for the ManifestEditor since it acts on a 52 * single source file. 53 * 54 * @see IEditorPart 55 */ 56 @Override 57 public boolean isSaveAsAllowed() { 58 return true; 59 } 60 61 /** 62 * Create the various form pages. 63 */ 64 @Override 65 protected void createFormPages() { 66 try { 67 mExportPropsPage = new ExportPropertiesPage(this); 68 addPage(mExportPropsPage); 69 } catch (PartInitException e) { 70 AdtPlugin.log(e, "Error creating nested page"); //$NON-NLS-1$ 71 } 72 73 } 74 75 /* (non-java doc) 76 * Change the tab/title name to include the project name. 77 */ 78 @Override 79 protected void setInput(IEditorInput input) { 80 super.setInput(input); 81 if (input instanceof FileEditorInput) { 82 FileEditorInput fileInput = (FileEditorInput) input; 83 IFile file = fileInput.getFile(); 84 setPartName(String.format("%1$s", file.getName())); 85 } 86 } 87 88 @Override 89 protected void postCreatePages() { 90 super.postCreatePages(); 91 mExportPropsPage.onModelInit(); 92 } 93 94 /** 95 * Indicates changes were made to the document. 96 * 97 * @param event Specification of changes applied to document. 98 */ 99 @Override 100 protected void onDocumentChanged(DocumentEvent event) { 101 super.onDocumentChanged(event); 102 mExportPropsPage.onModelChanged(event); 103 } 104 105 // ---- Local Methods ---- 106 107 } 108