aboutsummaryrefslogtreecommitdiff
path: root/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/export/ExportPropertiesPage.java
blob: f3db5eea63c25447f7a4bb96ec6b5e7324ac707d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
 * 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);
        }
    }
}