Methods Summary |
---|
public void | commit(boolean onSave)If part is displaying information loaded from a model, this method
instructs it to commit the new (modified) data back into the model.
if (mUiElementNode != null) {
mEditor.editXmlModel(new Runnable() {
public void run() {
for (UiAttributeNode ui_attr : mUiElementNode.getUiAttributes()) {
ui_attr.commit();
}
}
});
}
// We need to call super's commit after we synchronized the nodes to make sure we
// reset the dirty flag after all the side effects from committing have occurred.
super.commit(onSave);
|
protected void | createFormControls(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.)
Derived classes can override this if necessary.
setTable(createTableLayout(managedForm.getToolkit(), 2 /* numColumns */));
createUiAttributes(managedForm);
|
protected void | createUiAttributes(org.eclipse.ui.forms.IManagedForm managedForm)Add all the attribute UI widgets into the underlying table layout.
Composite table = getTable();
if (table == null || managedForm == null) {
return;
}
// Remove any old UI controls
for (Control c : table.getChildren()) {
c.dispose();
}
fillTable(table, managedForm);
// Tell the section that the layout has changed.
layoutChanged();
|
protected void | fillTable(org.eclipse.swt.widgets.Composite table, org.eclipse.ui.forms.IManagedForm managedForm)Actually fills the table.
This is called by {@link #createUiAttributes(IManagedForm)} to populate the new
table. The default implementation is to use
{@link #insertUiAttributes(UiElementNode, Composite, IManagedForm)} to actually
place the attributes of the default {@link UiElementNode} in the table.
Derived classes can override this to add controls in the table before or after.
int inserted = insertUiAttributes(mUiElementNode, table, managedForm);
if (inserted == 0) {
createLabel(table, managedForm.getToolkit(),
"No attributes to display, waiting for SDK to finish loading...",
null /* tooltip */ );
}
|
public com.android.ide.eclipse.editors.manifest.ManifestEditor | getEditor()Returns the Editor associated with this part.
return mEditor;
|
protected org.eclipse.swt.widgets.Composite | getTable()Returns the table where the attribute UI needs to be created.
return mTable;
|
public com.android.ide.eclipse.editors.uimodel.UiElementNode | getUiElementNode()Returns the {@link UiElementNode} associated with this part.
return mUiElementNode;
|
public void | initialize(org.eclipse.ui.forms.IManagedForm form)Initializes the form part.
This is called by the owning managed form as soon as the part is added to the form,
which happens right after the part is actually created.
super.initialize(form);
createFormControls(form);
|
protected int | insertUiAttributes(com.android.ide.eclipse.editors.uimodel.UiElementNode uiNode, org.eclipse.swt.widgets.Composite table, org.eclipse.ui.forms.IManagedForm managedForm)Insert the UI attributes of the given {@link UiElementNode} in the given table.
if (uiNode == null || table == null || managedForm == null) {
return 0;
}
// To iterate over all attributes, we use the {@link ElementDescriptor} instead
// of the {@link UiElementNode} because the attributes' order is guaranteed in the
// descriptor but not in the node itself.
AttributeDescriptor[] attr_desc_list = uiNode.getAttributeDescriptors();
for (AttributeDescriptor attr_desc : attr_desc_list) {
if (attr_desc instanceof XmlnsAttributeDescriptor) {
// Do not show hidden attributes
continue;
}
UiAttributeNode ui_attr = uiNode.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(),
uiNode.getDescriptor().getXmlName());
}
}
return attr_desc_list.length;
|
public boolean | isDirty()Tests whether the part is dirty i.e. its widgets have state that is
newer than the data in the model.
This is done by iterating over all attributes and updating the super's
internal dirty flag. Stop once at least one attribute is dirty.
if (mUiElementNode != null && !super.isDirty()) {
for (UiAttributeNode ui_attr : mUiElementNode.getUiAttributes()) {
if (ui_attr.isDirty()) {
markDirty();
break;
}
}
}
return super.isDirty();
|
protected void | setTable(org.eclipse.swt.widgets.Composite table)Sets the table where the attribute UI needs to be created.
mTable = table;
|
public void | setUiElementNode(com.android.ide.eclipse.editors.uimodel.UiElementNode uiElementNode)Changes the element node handled by this part.
mUiElementNode = uiElementNode;
|
protected void | setupSection(java.lang.String sectionTitle, java.lang.String sectionDescription)Setup the section that contains this part.
This is called by the constructor to set the section's title and description
with parameters given in the constructor.
Derived class override this if needed, however in most cases the default
implementation should be enough.
Section section = getSection();
section.setText(sectionTitle);
section.setDescription(sectionDescription);
|