{
boolean ok = true;
if ( getSelectedValues().length == 1 && getSelectedAttributes().length == 0 )
{
IValue value = getSelectedValues()[0];
StringBuffer message = new StringBuffer();
if ( value.isEmpty() )
{
// validate single-valued attributes
if ( value.getAttribute().getValueSize() > 1
&& value.getAttribute().getAttributeTypeDescription().isSingleValued() )
{
message.append( NLS.bind( Messages.getString( "OpenBestEditorAction.ValueSingleValued" ), //$NON-NLS-1$
value.getAttribute().getDescription() ) );
message.append( BrowserCoreConstants.LINE_SEPARATOR );
message.append( BrowserCoreConstants.LINE_SEPARATOR );
}
// validate if value is allowed
IEntry entry = value.getAttribute().getEntry();
Collection<AttributeTypeDescription> allAtds = SchemaUtils.getAllAttributeTypeDescriptions( entry );
AttributeTypeDescription atd = value.getAttribute().getAttributeTypeDescription();
if ( !allAtds.contains( atd ) )
{
message.append( NLS.bind( Messages.getString( "OpenBestEditorAction.AttributeNotInSubSchema" ), //$NON-NLS-1$
value.getAttribute().getDescription() ) );
message.append( BrowserCoreConstants.LINE_SEPARATOR );
message.append( BrowserCoreConstants.LINE_SEPARATOR );
}
}
// validate non-modifiable attributes
if ( !SchemaUtils.isModifiable( value.getAttribute().getAttributeTypeDescription() ) )
{
message.append( NLS.bind( Messages.getString( "OpenBestEditorAction.ValueNotModifiable" ), //$NON-NLS-1$
value.getAttribute().getDescription() ) );
message.append( BrowserCoreConstants.LINE_SEPARATOR );
message.append( BrowserCoreConstants.LINE_SEPARATOR );
}
// validate modification of RDN
if ( value.isRdnPart() && cellEditor != valueEditorManager.getRenameValueEditor() )
{
message.append( NLS.bind( Messages.getString( "OpenBestEditorAction.ValueIsRdnPart" ), //$NON-NLS-1$
value.getAttribute().getDescription() ) );
message.append( BrowserCoreConstants.LINE_SEPARATOR );
message.append( BrowserCoreConstants.LINE_SEPARATOR );
}
if ( message.length() > 0 )
{
if ( value.isEmpty() )
{
message.append( Messages.getString( "OpenBestEditorAction.NewValueQuestion" ) ); //$NON-NLS-1$
}
else
{
message.append( Messages.getString( "OpenBestEditorAction.EditValueQuestion" ) ); //$NON-NLS-1$
}
ok = MessageDialog.openConfirm( getShell(), getText(), message.toString() );
}
if ( ok )
{
super.run();
}
else
{
if ( value.isEmpty() )
{
value.getAttribute().deleteEmptyValue();
}
}
}
}