FileDocCategorySizeDatePackage
ApplicationToggle.javaAPI DocAndroid 1.5 API13103Wed May 06 22:41:10 BST 2009com.android.ide.eclipse.editors.manifest.pages

ApplicationToggle

public final class ApplicationToggle extends com.android.ide.eclipse.editors.ui.UiElementPart
Appllication Toogle section part for application page.

Fields Summary
private org.eclipse.swt.widgets.Button
mCheckbox
Checkbox indicating whether an application node is present
private AppNodeUpdateListener
mAppNodeUpdateListener
Listen to changes to the UI node for and updates the checkbox
public boolean
mInternalModification
Internal flag to know where we're programmatically modifying the checkbox and we want to avoid triggering the checkbox's callback.
private org.eclipse.ui.forms.widgets.FormText
mTooltipFormText
Constructors Summary
public ApplicationToggle(org.eclipse.swt.widgets.Composite body, org.eclipse.ui.forms.widgets.FormToolkit toolkit, com.android.ide.eclipse.editors.manifest.ManifestEditor editor, com.android.ide.eclipse.editors.uimodel.UiElementNode applicationUiNode)

        super(body, toolkit, editor, applicationUiNode,
                "Application Toggle",
                null, /* description */
                Section.TWISTIE | Section.EXPANDED);
    
Methods Summary
protected voidcreateFormControls(org.eclipse.ui.forms.IManagedForm managedForm)
Create the controls to edit the attributes for the given ElementDescriptor.

This MUST not be called by the constructor. Instead it must be called from initialize (i.e. right after the form part is added to the managed form.)

param
managedForm The owner managed form

        FormToolkit toolkit = managedForm.getToolkit();
        Composite table = createTableLayout(toolkit, 1 /* numColumns */);

        mTooltipFormText = createFormText(table, toolkit, true, "<form></form>",
                false /* setupLayoutData */);
        updateTooltip();

        mCheckbox = toolkit.createButton(table,
                "Define an <application> tag in the AndroidManifest.xml",
                SWT.CHECK);
        mCheckbox.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP));
        mCheckbox.setSelection(false);
        mCheckbox.addSelectionListener(new CheckboxSelectionListener());

        mAppNodeUpdateListener = new AppNodeUpdateListener();
        getUiElementNode().addUpdateListener(mAppNodeUpdateListener);

        // Initialize the state of the checkbox
        mAppNodeUpdateListener.uiElementNodeUpdated(getUiElementNode(),
                UiUpdateState.CHILDREN_CHANGED);
        
        // Tell the section that the layout has changed.
        layoutChanged();
    
public voiddispose()

        super.dispose();
        if (getUiElementNode() != null && mAppNodeUpdateListener != null) {
            getUiElementNode().removeUpdateListener(mAppNodeUpdateListener);
            mAppNodeUpdateListener = null;
        }
    
public voidsetUiElementNode(com.android.ide.eclipse.editors.uimodel.UiElementNode uiElementNode)
Changes and refreshes the Application UI node handle by the this part.

        super.setUiElementNode(uiElementNode);

        updateTooltip();

        // Set the state of the checkbox
        mAppNodeUpdateListener.uiElementNodeUpdated(getUiElementNode(),
                UiUpdateState.CHILDREN_CHANGED);
    
private voidupdateTooltip()
Updates the application tooltip in the form text. If there is no tooltip, the form text is hidden.

        boolean isVisible = false;

        String tooltip = getUiElementNode().getDescriptor().getTooltip();
        if (tooltip != null) {
            tooltip = DescriptorsUtils.formatFormText(tooltip,
                    getUiElementNode().getDescriptor(),
                    Sdk.getCurrent().getDocumentationBaseUrl());
    
            mTooltipFormText.setText(tooltip, true /* parseTags */, true /* expandURLs */);
            mTooltipFormText.setImage(DescriptorsUtils.IMAGE_KEY, AdtPlugin.getAndroidLogo());
            mTooltipFormText.addHyperlinkListener(getEditor().createHyperlinkListener());
            isVisible = true;
        }
        
        mTooltipFormText.setVisible(isVisible);