diff options
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export')
5 files changed, 0 insertions, 800 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/AbstractPropertiesFieldsPart.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/AbstractPropertiesFieldsPart.java deleted file mode 100755 index bc3051e88..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/AbstractPropertiesFieldsPart.java +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Copyright (C) 2010 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.adt.internal.editors.export; - -import com.android.SdkConstants; -import com.android.ide.eclipse.adt.AdtPlugin; -import com.android.ide.eclipse.adt.internal.editors.ui.SectionHelper.ManifestSectionPart; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.DocumentEvent; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Section; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; - -/** - * Section part for editing fields of a properties file in an Export editor. - * <p/> - * This base class is intended to be derived and customized. - */ -abstract class AbstractPropertiesFieldsPart extends ManifestSectionPart { - - private final HashMap<String, Control> mNameToField = new HashMap<String, Control>(); - - private ExportEditor mEditor; - - private boolean mInternalTextUpdate = false; - - public AbstractPropertiesFieldsPart(Composite body, FormToolkit toolkit, ExportEditor editor) { - super(body, toolkit, Section.TWISTIE | Section.EXPANDED, true /* description */); - mEditor = editor; - } - - protected HashMap<String, Control> getNameToField() { - return mNameToField; - } - - protected ExportEditor getEditor() { - return mEditor; - } - - protected void setInternalTextUpdate(boolean internalTextUpdate) { - mInternalTextUpdate = internalTextUpdate; - } - - protected boolean isInternalTextUpdate() { - return mInternalTextUpdate; - } - - /** - * Adds a modify listener to every text field that will mark the part as dirty. - * - * CONTRACT: Derived classes MUST call this at the end of their constructor. - * - * @see #setFieldModifyListener(Control, ModifyListener) - */ - protected void addModifyListenerToFields() { - ModifyListener markDirtyListener = new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - // Mark the part as dirty if a field has been changed. - // This will force a commit() operation to store the data in the model. - if (!mInternalTextUpdate) { - markDirty(); - } - } - }; - - for (Control field : mNameToField.values()) { - setFieldModifyListener(field, markDirtyListener); - } - } - - /** - * Sets a listener that will mark the part as dirty when the control is modified. - * The base method only handles {@link Text} fields. - * - * CONTRACT: Derived classes CAN use this to add a listener to their own controls. - * The listener must call {@link #markDirty()} when the control is modified by the user. - * - * @param field A control previously registered with {@link #getNameToField()}. - * @param markDirtyListener A {@link ModifyListener} that invokes {@link #markDirty()}. - * - * @see #isInternalTextUpdate() - */ - protected void setFieldModifyListener(Control field, ModifyListener markDirtyListener) { - if (field instanceof Text) { - ((Text) field).addModifyListener(markDirtyListener); - } - } - - /** - * Updates the model based on the content of fields. This is invoked when a field - * has marked the document as dirty. - * - * CONTRACT: Derived classes do not need to override this. - */ - @Override - public void commit(boolean onSave) { - - // We didn't store any information indicating which field was dirty (we could). - // Since there are not many fields, just update all the document lines that - // match our field keywords. - - if (isDirty()) { - mEditor.wrapRewriteSession(new Runnable() { - @Override - public void run() { - saveFieldsToModel(); - } - }); - } - - super.commit(onSave); - } - - private void saveFieldsToModel() { - // Get a list of all keywords to process. Go thru the document, replacing in-place - // the ones we can find and remove them from this set. This will leave the list - // of new keywords to add at the end of the document. - HashSet<String> allKeywords = new HashSet<String>(mNameToField.keySet()); - - IDocument doc = mEditor.getDocument(); - int numLines = doc.getNumberOfLines(); - - String delim = null; - try { - delim = numLines > 0 ? doc.getLineDelimiter(0) : null; - } catch (BadLocationException e1) { - // ignore - } - if (delim == null || delim.length() == 0) { - delim = SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_WINDOWS ? - "\r\n" : "\n"; //$NON-NLS-1$ //$NON-NLS-2# - } - - for (int i = 0; i < numLines; i++) { - try { - IRegion info = doc.getLineInformation(i); - String line = doc.get(info.getOffset(), info.getLength()); - line = line.trim(); - if (line.startsWith("#")) { //$NON-NLS-1$ - continue; - } - - int pos = line.indexOf('='); - if (pos > 0 && pos < line.length() - 1) { - String key = line.substring(0, pos).trim(); - - Control field = mNameToField.get(key); - if (field != null) { - - // This is the new line to inject - line = key + "=" + getFieldText(field); - - try { - // replace old line by new one. This doesn't change the - // line delimiter. - mInternalTextUpdate = true; - doc.replace(info.getOffset(), info.getLength(), line); - allKeywords.remove(key); - } finally { - mInternalTextUpdate = false; - } - } - } - - } catch (BadLocationException e) { - // TODO log it - AdtPlugin.log(e, "Failed to replace in export.properties"); - } - } - - for (String key : allKeywords) { - Control field = mNameToField.get(key); - if (field != null) { - // This is the new line to inject - String line = key + "=" + getFieldText(field); - - try { - // replace old line by new one - mInternalTextUpdate = true; - - numLines = doc.getNumberOfLines(); - - IRegion info = numLines > 0 ? doc.getLineInformation(numLines - 1) : null; - if (info != null && info.getLength() == 0) { - // last line is empty. Insert right before there. - doc.replace(info.getOffset(), info.getLength(), line); - } else { - if (numLines > 0) { - String eofDelim = doc.getLineDelimiter(numLines - 1); - if (eofDelim == null || eofDelim.length() == 0) { - // The document doesn't end with a line delimiter, so add - // one to the line to be written. - line = delim + line; - } - } - - int len = doc.getLength(); - doc.replace(len, 0, line); - } - - allKeywords.remove(key); - } catch (BadLocationException e) { - // TODO log it - AdtPlugin.log(e, "Failed to append to export.properties: %s", line); - } finally { - mInternalTextUpdate = false; - } - } - } - } - - /** - * Used when committing fields values to the model to retrieve the text - * associated with a field. - * <p/> - * The base method only handles {@link Text} controls. - * - * CONTRACT: Derived classes CAN use this to support their own controls. - * - * @param field A control previously registered with {@link #getNameToField()}. - * @return A non-null string to write to the properties files. - */ - protected String getFieldText(Control field) { - if (field instanceof Text) { - return ((Text) field).getText(); - } - return ""; - } - - /** - * Called after all pages have been created, to let the parts initialize their - * content based on the document's model. - * <p/> - * The model should be acceded via the {@link ExportEditor}. - * - * @param editor The {@link ExportEditor} instance. - */ - public void onModelInit(ExportEditor editor) { - - // Start with a set of all the possible keywords and remove those we - // found in the document as we read the lines. - HashSet<String> allKeywords = new HashSet<String>(mNameToField.keySet()); - - // Parse the lines in the document for patterns "keyword=value", - // trimming all whitespace and discarding lines that start with # (comments) - // then affect to the internal fields as appropriate. - IDocument doc = editor.getDocument(); - int numLines = doc.getNumberOfLines(); - for (int i = 0; i < numLines; i++) { - try { - IRegion info = doc.getLineInformation(i); - String line = doc.get(info.getOffset(), info.getLength()); - line = line.trim(); - if (line.startsWith("#")) { //$NON-NLS-1$ - continue; - } - - int pos = line.indexOf('='); - if (pos > 0 && pos < line.length() - 1) { - String key = line.substring(0, pos).trim(); - - Control field = mNameToField.get(key); - if (field != null) { - String value = line.substring(pos + 1).trim(); - try { - mInternalTextUpdate = true; - setFieldText(field, value); - allKeywords.remove(key); - } finally { - mInternalTextUpdate = false; - } - } - } - - } catch (BadLocationException e) { - // TODO log it - AdtPlugin.log(e, "Failed to set field to export.properties value"); - } - } - - // Clear the text of any keyword we didn't find in the document - Iterator<String> iterator = allKeywords.iterator(); - while (iterator.hasNext()) { - String key = iterator.next(); - Control field = mNameToField.get(key); - if (field != null) { - try { - mInternalTextUpdate = true; - setFieldText(field, ""); - iterator.remove(); - } finally { - mInternalTextUpdate = false; - } - } - } - } - - /** - * Used when reading the model to set the field values. - * <p/> - * The base method only handles {@link Text} controls. - * - * CONTRACT: Derived classes CAN use this to support their own controls. - * - * @param field A control previously registered with {@link #getNameToField()}. - * @param value A non-null string to that was read from the properties files. - * The value is an empty string if the property line is missing. - */ - protected void setFieldText(Control field, String value) { - if (field instanceof Text) { - ((Text) field).setText(value); - } - } - - /** - * Called after the document model has been changed. The model should be acceded via - * the {@link ExportEditor} (e.g. getDocument, wrapRewriteSession) - * - * @param editor The {@link ExportEditor} instance. - * @param event Specification of changes applied to document. - */ - public void onModelChanged(ExportEditor editor, DocumentEvent event) { - // To simplify and since we don't have many fields, just reload all the values. - // A better way would to be to look at DocumentEvent which gives us the offset/length - // and text that has changed. - if (!mInternalTextUpdate) { - onModelInit(editor); - } - } -} diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/ExportEditor.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/ExportEditor.java deleted file mode 100755 index 769f74e27..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/ExportEditor.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2010 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.adt.internal.editors.export; - -import com.android.ide.eclipse.adt.AdtPlugin; -import com.android.ide.eclipse.adt.AdtConstants; -import com.android.ide.eclipse.adt.internal.editors.AndroidTextEditor; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.text.DocumentEvent; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.FileEditorInput; - -/** - * Multi-page form editor for export.properties in Export Projects. - */ -public class ExportEditor extends AndroidTextEditor { - - public static final String ID = AdtConstants.EDITORS_NAMESPACE + ".text.ExportEditor"; //$NON-NLS-1$ - - private ExportPropertiesPage mExportPropsPage; - - /** - * Creates the form editor for resources XML files. - */ - public ExportEditor() { - super(); - } - - // ---- Base Class Overrides ---- - - /** - * Returns whether the "save as" operation is supported by this editor. - * <p/> - * Save-As is a valid operation for the ManifestEditor since it acts on a - * single source file. - * - * @see IEditorPart - */ - @Override - public boolean isSaveAsAllowed() { - return true; - } - - /** - * Create the various form pages. - */ - @Override - protected void createFormPages() { - try { - mExportPropsPage = new ExportPropertiesPage(this); - addPage(mExportPropsPage); - } catch (PartInitException e) { - AdtPlugin.log(e, "Error creating nested page"); //$NON-NLS-1$ - } - - } - - /* (non-java doc) - * Change the tab/title name to include the project name. - */ - @Override - protected void setInput(IEditorInput input) { - super.setInput(input); - if (input instanceof FileEditorInput) { - FileEditorInput fileInput = (FileEditorInput) input; - IFile file = fileInput.getFile(); - setPartName(String.format("%1$s", file.getName())); - } - } - - @Override - protected void postCreatePages() { - super.postCreatePages(); - mExportPropsPage.onModelInit(); - } - - /** - * Indicates changes were made to the document. - * - * @param event Specification of changes applied to document. - */ - @Override - protected void onDocumentChanged(DocumentEvent event) { - super.onDocumentChanged(event); - mExportPropsPage.onModelChanged(event); - } - - // ---- Local Methods ---- - -} diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/ExportFieldsPart.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/ExportFieldsPart.java deleted file mode 100755 index eff3e4806..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/ExportFieldsPart.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2010 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.adt.internal.editors.export; - -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Section; - -import java.util.HashMap; - -/** - * Section part for editing the properties in an Export editor. - */ -final class ExportFieldsPart extends AbstractPropertiesFieldsPart { - - public ExportFieldsPart(Composite body, FormToolkit toolkit, ExportEditor editor) { - super(body, toolkit, editor); - Section section = getSection(); - - section.setText("Export Properties"); - section.setDescription("Properties of export.properties:"); - - Composite table = createTableLayout(toolkit, 2 /* numColumns */); - - createLabel(table, toolkit, - "Available Properties", //label - "List of properties you can edit in export.properties"); //tooltip - - Text packageField = createLabelAndText(table, toolkit, - "Package", //label, - "", //$NON-NLS-1$ value, - "TODO tooltip for Package"); //tooltip - - Text projectsField = createLabelAndText(table, toolkit, - "Projects", //label, - "", //$NON-NLS-1$ value, - "TODO tooltip for Projects"); //tooltip - - Text versionCodeField = createLabelAndText(table, toolkit, - "Version Code", //label, - "", //$NON-NLS-1$ value, - "TODO tooltip for Version Code"); //tooltip - - Text keyStoreField = createLabelAndText(table, toolkit, - "Key Store", //label, - "", //$NON-NLS-1$ value, - "TODO tooltip for Key Store"); //tooltip - - Text keyAliasField = createLabelAndText(table, toolkit, - "Key Alias", //label, - "", //$NON-NLS-1$ value, - "TODO tooltip for Key Alias"); //tooltip - - // Associate each field with the keyword in the properties files. - // TODO there's probably some constant to reuse here. - HashMap<String, Control> map = getNameToField(); - map.put("package", packageField); //$NON-NLS-1$ - map.put("projects", projectsField); //$NON-NLS-1$ - map.put("versionCode", versionCodeField); //$NON-NLS-1$ - map.put("_key.store", keyStoreField); //$NON-NLS-1$ - map.put("_key.alias", keyAliasField); //$NON-NLS-1$ - - addModifyListenerToFields(); - } - - @Override - protected void setFieldModifyListener(Control field, ModifyListener markDirtyListener) { - super.setFieldModifyListener(field, markDirtyListener); - // TODO override for custom controls - } - - @Override - protected String getFieldText(Control field) { - // TODO override for custom controls - return super.getFieldText(field); - } - - @Override - protected void setFieldText(Control field, String value) { - // TODO override for custom controls - super.setFieldText(field, value); - } -} diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/ExportLinksPart.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/ExportLinksPart.java deleted file mode 100644 index 85a2165cc..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/ExportLinksPart.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2010 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.adt.internal.editors.export; - -import com.android.ide.eclipse.adt.AdtPlugin; -import com.android.ide.eclipse.adt.internal.editors.ui.SectionHelper.ManifestSectionPart; - -import org.eclipse.jface.text.DocumentEvent; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.MessageBox; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.events.IHyperlinkListener; -import org.eclipse.ui.forms.widgets.FormText; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Section; - -/** - * Links section part for export properties page. - * Displays some help and some links/actions for the user to use. - */ -final class ExportLinksPart extends ManifestSectionPart { - - private FormText mFormText; - - public ExportLinksPart(Composite body, FormToolkit toolkit, ExportEditor editor) { - super(body, toolkit, Section.TWISTIE | Section.EXPANDED, true /* description */); - Section section = getSection(); - section.setText("Links"); - section.setDescription("TODO SOME TEXT HERE. You can also edit the XML directly."); - - final Composite table = createTableLayout(toolkit, 2 /* numColumns */); - - StringBuffer buf = new StringBuffer(); - buf.append("<form>"); //$NON-NLS-1$ - - buf.append("<li style=\"image\" value=\"android_img\"><a href=\"action_dosomething\">"); - buf.append("TODO Custom Action"); - buf.append("</a>"); //$NON-NLS-1$ - buf.append(": blah blah do something (like build/export)."); - buf.append("</li>"); //$NON-NLS-1$ - - buf.append(String.format("<li style=\"image\" value=\"android_img\"><a href=\"page:%1$s\">", //$NON-NLS-1$ - ExportEditor.TEXT_EDITOR_ID)); - buf.append("XML Source"); - buf.append("</a>"); //$NON-NLS-1$ - buf.append(": Directly edit the AndroidManifest.xml file."); - buf.append("</li>"); //$NON-NLS-1$ - - buf.append("<li style=\"image\" value=\"android_img\">"); //$NON-NLS-1$ - buf.append("<a href=\"http://code.google.com/android/devel/bblocks-manifest.html\">Documentation</a>: Documentation from the Android SDK for AndroidManifest.xml."); //$NON-NLS-1$ - buf.append("</li>"); //$NON-NLS-1$ - buf.append("</form>"); //$NON-NLS-1$ - - mFormText = createFormText(table, toolkit, true, buf.toString(), - false /* setupLayoutData */); - - Image androidLogo = AdtPlugin.getAndroidLogo(); - mFormText.setImage("android_img", androidLogo); //$NON-NLS-1$ - - // Listener for default actions (page change, URL web browser) - mFormText.addHyperlinkListener(editor.createHyperlinkListener()); - - mFormText.addHyperlinkListener(new IHyperlinkListener() { - @Override - public void linkExited(HyperlinkEvent e) { - // pass - } - - @Override - public void linkEntered(HyperlinkEvent e) { - // pass - } - - @Override - public void linkActivated(HyperlinkEvent e) { - String link = e.data.toString(); - if ("action_dosomething".equals(link)) { - MessageBox mb = new MessageBox(table.getShell(), SWT.OK); - mb.setText("Custom Action Invoked"); - mb.open(); - } - } - }); - } - - /** - * Called after all pages have been created, to let the parts initialize their - * content based on the document's model. - * <p/> - * The model should be acceded via the {@link ExportEditor}. - * - * @param editor The {@link ExportEditor} instance. - */ - public void onModelInit(ExportEditor editor) { - // pass - } - - /** - * Called after the document model has been changed. The model should be acceded via - * the {@link ExportEditor} (e.g. getDocument, wrapRewriteSession) - * - * @param editor The {@link ExportEditor} instance. - * @param event Specification of changes applied to document. - */ - public void onModelChanged(ExportEditor editor, DocumentEvent event) { - // pass - } -} diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/ExportPropertiesPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/ExportPropertiesPage.java deleted file mode 100755 index f3db5eea6..000000000 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/ExportPropertiesPage.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (C) 2010 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.adt.internal.editors.export; - -import com.android.ide.eclipse.adt.AdtPlugin; - -import org.eclipse.jface.text.DocumentEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.editor.FormPage; -import org.eclipse.ui.forms.widgets.ColumnLayout; -import org.eclipse.ui.forms.widgets.ColumnLayoutData; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.ScrolledForm; - - -/** - * Page for export properties, used by {@link ExportEditor}. - * It displays a part to edit the properties and another part - * to provide some links and actions. - */ -public final class ExportPropertiesPage extends FormPage { - - /** Page id used for switching tabs programmatically */ - final static String PAGE_ID = "export_prop_page"; //$NON-NLS-1$ - - /** Container editor */ - ExportEditor mEditor; - /** Export fields part */ - private ExportFieldsPart mFieldsPart; - /** Export links part */ - private ExportLinksPart mLinksPart; - - public ExportPropertiesPage(ExportEditor editor) { - super(editor, PAGE_ID, "Export Properties"); // tab's label, user visible, keep it short - mEditor = editor; - } - - /** - * Creates the content in the form hosted in this page. - * - * @param managedForm the form hosted in this page. - */ - @Override - protected void createFormContent(IManagedForm managedForm) { - super.createFormContent(managedForm); - ScrolledForm form = managedForm.getForm(); - form.setText("Android Export Properties"); - form.setImage(AdtPlugin.getAndroidLogo()); - - Composite body = form.getBody(); - FormToolkit toolkit = managedForm.getToolkit(); - - body.setLayout(new ColumnLayout()); - - mFieldsPart = new ExportFieldsPart(body, toolkit, mEditor); - mFieldsPart.getSection().setLayoutData(new ColumnLayoutData()); - managedForm.addPart(mFieldsPart); - - mLinksPart = new ExportLinksPart(body, toolkit, mEditor); - mLinksPart.getSection().setLayoutData(new ColumnLayoutData()); - managedForm.addPart(mLinksPart); - - mFieldsPart.onModelInit(mEditor); - mLinksPart.onModelInit(mEditor); - } - - /** - * Called after all pages have been created, to let the parts initialize their - * content based on the document's model. - * <p/> - * The model should be acceded via the {@link ExportEditor}. - */ - public void onModelInit() { - if (mFieldsPart != null) { - mFieldsPart.onModelInit(mEditor); - } - - if (mLinksPart != null) { - mLinksPart.onModelInit(mEditor); - } - } - - /** - * Called after the document model has been changed. The model should be acceded via - * the {@link ExportEditor}. - * - * @param event Specification of changes applied to document. - */ - public void onModelChanged(DocumentEvent event) { - if (mFieldsPart != null) { - mFieldsPart.onModelChanged(mEditor, event); - } - - if (mLinksPart != null) { - mLinksPart.onModelChanged(mEditor, event); - } - } -} |