@Override
public void contribute( final PropertyEditorAssistContext context )
{
SapphirePart part = context.getPart();
Property property0 = null;
boolean propertyReadOnly = false;
if (part instanceof PropertyEditorPart)
{
property0 = ((PropertyEditorPart)part).property();
propertyReadOnly = ( (PropertyEditorPart) part ).isReadOnly();
}
else if (part instanceof WithPart)
{
property0 = ((WithPart)part).property();
propertyReadOnly = property0.definition().isReadOnly();
}
if( property0 == null || property0.empty() || propertyReadOnly )
{
return;
}
final Property property = property0;
if( property instanceof Value<?> )
{
final DefaultValueService defaultValueService = property.service( DefaultValueService.class );
final boolean hasDefaultValue = ( defaultValueService == null ? false : defaultValueService.value() != null );
final boolean isBooleanType = property.definition().getTypeClass().equals( Boolean.class );
final String actionText
= ( hasDefaultValue || isBooleanType ? restoreDefaultValue.text() : clear.text() );
final PropertyEditorAssistContribution.Factory contribution = PropertyEditorAssistContribution.factory();
contribution.text( "<p><a href=\"action\" nowrap=\"true\">" + escapeForXml( actionText ) + "</a></p>" );
contribution.link
(
"action",
new Runnable()
{
public void run()
{
property.clear();
}
}
);
final PropertyEditorAssistSection section = context.getSection( SECTION_ID_ACTIONS );
section.addContribution( contribution.create() );
}
else if( property.definition() instanceof ListProperty )
{
final PropertyEditorAssistContribution.Factory contribution = PropertyEditorAssistContribution.factory();
contribution.text( "<p><a href=\"action\" nowrap=\"true\">" + escapeForXml( clear.text() ) + "</a></p>" );
contribution.link
(
"action",
new Runnable()
{
public void run()
{
property.clear();
}
}
);
final PropertyEditorAssistSection section = context.getSection( SECTION_ID_ACTIONS );
section.addContribution( contribution.create() );
}
else if( property instanceof ElementHandle<?> )
{
final PropertyEditorAssistContribution.Factory contribution = PropertyEditorAssistContribution.factory();
contribution.text( "<p><a href=\"action\" nowrap=\"true\">" + escapeForXml( clear.text() ) + "</a></p>" );
contribution.link
(
"action",
new Runnable()
{
public void run()
{
property.clear();
}
}
);
final PropertyEditorAssistSection section = context.getSection( SECTION_ID_ACTIONS );