addName.setOptionSelected(previousFieldID);
Composite addComposite = addForm.addItem().addComposite("value");
addComposite.setLabel(T_value_label);
TextArea addValue = addComposite.addTextArea("value");
Text addLang = addComposite.addText("language");
addValue.setSize(4, 35);
addLang.setLabel(T_lang_label);
addLang.setSize(6);
addForm.addItem().addButton("submit_add").setValue(T_submit_add);
// PARA: Disclaimer
main.addPara(T_para1);
Para actions = main.addPara(null,"edit-metadata-actions top" );
actions.addButton("submit_update").setValue(T_submit_update);
actions.addButton("submit_return").setValue(T_submit_return);
// TABLE: Metadata
main.addHidden("scope").setValue("*");
int index = 1;
Table table = main.addTable("editItemMetadata",1,1);
table.setHead(T_head2);
Row header = table.addRow(Row.ROLE_HEADER);
header.addCell().addContent(T_column1);
header.addCell().addContent(T_column2);
header.addCell().addContent(T_column3);
header.addCell().addContent(T_column4);
ChoiceAuthorityManager cmgr = ChoiceAuthorityManager.getManager();
for(DCValue value : values)
{
String name = value.schema + "_" + value.element;
if (value.qualifier != null)
name += "_" + value.qualifier;
Row row = table.addRow(name,Row.ROLE_DATA,"metadata-value");
CheckBox remove = row.addCell().addCheckBox("remove_"+index);
remove.setLabel("remove");
remove.addOption(index);
Cell cell = row.addCell();
cell.addContent(name.replaceAll("_", ". "));
cell.addHidden("name_"+index).setValue(name);
// value entry cell:
Cell mdCell = row.addCell();
String fieldKey = MetadataAuthorityManager.makeFieldKey(value.schema, value.element, value.qualifier);
// put up just a selector when preferred choice presentation is select:
if (cmgr.isChoicesConfigured(fieldKey) &&
Params.PRESENTATION_SELECT.equals(cmgr.getPresentation(fieldKey)))
{
Select mdSelect = mdCell.addSelect("value_"+index);
mdSelect.setSize(1);
Choices cs = cmgr.getMatches(fieldKey, value.value, collectionID, 0, 0, null);
if (cs.defaultSelected < 0)
mdSelect.addOption(true, value.value, value.value);
for (int i = 0; i < cs.values.length; ++i)
{
mdSelect.addOption(i == cs.defaultSelected, cs.values[i].value, cs.values[i].label);
}
}
else
{
TextArea mdValue = mdCell.addTextArea("value_"+index);
mdValue.setSize(4,35);
mdValue.setValue(value.value);
boolean isAuth = MetadataAuthorityManager.getManager().isAuthorityControlled(fieldKey);
if (isAuth)
{
mdValue.setAuthorityControlled();
mdValue.setAuthorityRequired(MetadataAuthorityManager.getManager().isAuthorityRequired(fieldKey));
Value authValue = mdValue.setAuthorityValue((value.authority == null)?"":value.authority, Choices.getConfidenceText(value.confidence));
// add the "unlock" button to auth field
Button unlock = authValue.addButton("authority_unlock_"+index,"ds-authority-lock");
unlock.setHelp(T_unlock);
}
if (ChoiceAuthorityManager.getManager().isChoicesConfigured(fieldKey))
{
mdValue.setChoices(fieldKey);
mdValue.setChoicesPresentation(Params.PRESENTATION_LOOKUP);
mdValue.setChoicesClosed(ChoiceAuthorityManager.getManager().isClosed(fieldKey));
}
}
Text mdLang = row.addCell().addText("language_"+index);
mdLang.setSize(6);
mdLang.setValue(value.language);