{
String name;
boolean b1;
int result;
List collSO;
SessionGroup group;
AbstractCompoundEdit ce;
try {
doc.bird.waitShared( Session.DOOR_TRNS | Session.DOOR_RCV );
b1 = doc.getSelectedReceivers().isEmpty() && doc.getSelectedTransmitters().isEmpty();
} finally {
doc.bird.releaseShared( Session.DOOR_TRNS | Session.DOOR_RCV );
}
if( b1 ) { // ask if we should create an empty group
result = JOptionPane.showConfirmDialog( null,
AbstractApplication.getApplication().getResourceString( "warnNoObjectsSelected" ),
getValue( Action.NAME ).toString(), JOptionPane.YES_NO_OPTION );
if( result != JOptionPane.YES_OPTION ) return;
}
try {
doc.bird.waitShared( Session.DOOR_GRP );
name = BasicSessionCollection.createUniqueName( Session.SO_NAME_PTRN,
new Object[] { new Integer( 1 ), Session.GRP_NAME_PREFIX, Session.GRP_NAME_SUFFIX },
doc.getGroups().getAll() );
} finally {
doc.bird.releaseShared( Session.DOOR_GRP );
}
name = JOptionPane.showInputDialog( null, AbstractApplication.getApplication().getResourceString(
"inputDlgNewGroup" ), name );
if( name == null ) return;
ce = new BasicCompoundEdit( getValue( NAME ).toString() );
try {
doc.bird.waitExclusive( Session.DOOR_GRP );
group = (SessionGroup) doc.getGroups().findByName( name );
b1 = group == null;
if( !b1 ) {
result = JOptionPane.showConfirmDialog( null,
AbstractApplication.getApplication().getResourceString(
"optionDlgOverwriteGroup" ), getValue( Action.NAME ).toString(),
JOptionPane.YES_NO_OPTION );
if( result != JOptionPane.YES_OPTION ) return;
} else {
group = new BasicSessionGroup( doc );
group.setName( name );
doc.getGroups().getMap().copyContexts( this, MapManager.Context.FLAG_DYNAMIC,
MapManager.Context.NONE_EXCLUSIVE, group.getMap() );
}
if( !doc.bird.attemptShared( Session.DOOR_TRNS | Session.DOOR_RCV, 250 )) return;
try {
collSO = doc.getSelectedReceivers().getAll();
final List collGroup = Collections.singletonList( group );