ApplicationAttributesPartpublic final class ApplicationAttributesPart extends com.android.ide.eclipse.editors.ui.UiElementPart Application's attributes section part for Application page.
This part is displayed at the top of the application page and displays all the possible
attributes of an application node in the AndroidManifest (icon, class name, label, etc.) |
Fields Summary |
---|
private AppNodeUpdateListener | mAppNodeUpdateListenerListen to changes to the UI node for and updates the UI | private org.eclipse.ui.forms.IManagedForm | mManagedFormManagedForm needed to create the UI controls |
Methods Summary |
---|
protected void | createFormControls(org.eclipse.ui.forms.IManagedForm managedForm)
mManagedForm = managedForm;
setTable(createTableLayout(managedForm.getToolkit(), 4 /* numColumns */));
mAppNodeUpdateListener = new AppNodeUpdateListener();
getUiElementNode().addUpdateListener(mAppNodeUpdateListener);
createUiAttributes(mManagedForm);
| protected void | createUiAttributes(org.eclipse.ui.forms.IManagedForm managedForm)
Composite table = getTable();
if (table == null || managedForm == null) {
return;
}
// Remove any old UI controls
for (Control c : table.getChildren()) {
c.dispose();
}
UiElementNode uiElementNode = getUiElementNode();
AttributeDescriptor[] attr_desc_list = uiElementNode.getAttributeDescriptors();
// Display the attributes in 2 columns:
// attr 0 | attr 4
// attr 1 | attr 5
// attr 2 | attr 6
// attr 3 | attr 7
// that is we have to fill the grid in order 0, 4, 1, 5, 2, 6, 3, 7
// thus index = i/2 + (i is odd * n/2)
int n = attr_desc_list.length;
int n2 = (int) Math.ceil(n / 2.0);
for (int i = 0; i < n; i++) {
AttributeDescriptor attr_desc = attr_desc_list[i / 2 + (i & 1) * n2];
if (attr_desc instanceof XmlnsAttributeDescriptor) {
// Do not show hidden attributes
continue;
}
UiAttributeNode ui_attr = uiElementNode.findUiAttribute(attr_desc);
if (ui_attr != null) {
ui_attr.createUiControl(table, managedForm);
} else {
// The XML has an extra attribute which wasn't declared in
// AndroidManifestDescriptors. This is not a problem, we just ignore it.
AdtPlugin.log(IStatus.WARNING,
"Attribute %1$s not declared in node %2$s, ignored.", //$NON-NLS-1$
attr_desc.getXmlLocalName(),
uiElementNode.getDescriptor().getXmlName());
}
}
if (n == 0) {
createLabel(table, managedForm.getToolkit(),
"No attributes to display, waiting for SDK to finish loading...",
null /* tooltip */ );
}
// Initialize the enabled/disabled state
if (mAppNodeUpdateListener != null) {
mAppNodeUpdateListener.uiElementNodeUpdated(uiElementNode, null /* state, not used */);
}
// Tell the section that the layout has changed.
layoutChanged();
| public void | dispose()
super.dispose();
if (getUiElementNode() != null && mAppNodeUpdateListener != null) {
getUiElementNode().removeUpdateListener(mAppNodeUpdateListener);
mAppNodeUpdateListener = null;
}
| public void | setUiElementNode(com.android.ide.eclipse.editors.uimodel.UiElementNode uiElementNode)Changes and refreshes the Application UI node handle by the this part.
super.setUiElementNode(uiElementNode);
createUiAttributes(mManagedForm);
|
|