private Widget createValuePairItem( final Annotation annotation, final AnnotationValuePairDefinition valuePairDefinition, final AnnotationSource annotationSource) { final Row valuePairRow = new Row(); final FormGroup formGroup = new FormGroup(); valuePairRow.add(formGroup); final FormLabel formLabel = new FormLabel(); formLabel.addStyleName(ColumnSize.MD_3.getCssName()); formLabel.setText(valuePairDefinition.getName()); formGroup.add(formLabel); final Column column = new Column(ColumnSize.MD_9); formGroup.add(column); final TextBox content = new TextBox(); column.add(content); final String valuePairString = getValuePairStringValue(annotation, valuePairDefinition, annotationSource); content.setText(valuePairString); content.setReadOnly(true); content.setTitle(valuePairString); final Button editButton = new Button( Constants.INSTANCE.advanced_domain_annotation_list_editor_action_edit(), new ClickHandler() { @Override public void onClick(ClickEvent event) { presenter.onEditValuePair(annotation, valuePairDefinition.getName()); } }); editButton.setEnabled(!readonly); editButton.setIcon(IconType.EDIT); final Button clearButton = new Button( Constants.INSTANCE.advanced_domain_annotation_list_editor_action_clear(), new ClickHandler() { @Override public void onClick(ClickEvent event) { presenter.onClearValuePair(annotation, valuePairDefinition.getName()); } }); clearButton.setEnabled(!readonly); clearButton.setIcon(IconType.ERASER); final FormGroup formGroupButton = new FormGroup(); formGroupButton.add(editButton); formGroupButton.add(clearButton); final Column columnButton = new Column(ColumnSize.MD_9); columnButton.setOffset(ColumnOffset.MD_3); columnButton.add(formGroupButton); valuePairRow.add(columnButton); return valuePairRow; }
private String getValuePairStringValue( Annotation annotation, AnnotationValuePairDefinition valuePairDefinition, AnnotationSource annotationSource) { Object value = annotation.getValue(valuePairDefinition.getName()); String strValue; if (value == null) { strValue = Constants.INSTANCE.advanced_domain_annotation_list_editor_message_value_not_set(); } else { strValue = annotationSource != null ? annotationSource.getValuePairSource(valuePairDefinition.getName()) : null; if (strValue == null) { strValue = Constants.INSTANCE .advanced_domain_annotation_list_editor_message_source_code_not_available(); } } return strValue; }