String destName = nameTF.getText();
destName = destName.trim();
int intValue;
long longValue;
BrokerAdminEvent bae = new BrokerAdminEvent(this, BrokerAdminEvent.ADD_DEST);
// Destination name is a must.
if (!isValidString(destName)) {
JOptionPane.showOptionDialog(this,
acr.getString(acr.E_NO_BROKER_DEST_NAME),
acr.getString(acr.I_ADD_BROKER_DEST),
JOptionPane.YES_NO_OPTION,
JOptionPane.ERROR_MESSAGE, null, close, close[0]);
return;
} else
bae.setDestinationName(destName);
/*
* QUEUE-specifics.
*/
if (queueRB.isSelected()) {
bae.setDestinationTypeMask(DestType.DEST_TYPE_QUEUE);
if (activeConsumerUnlimitedRB.isSelected()) {
bae.setActiveConsumers(UNLIMITED_VALUE_NEG1);
} else {
intValue = Integer.parseInt(activeConsumerIF.getText());
bae.setActiveConsumers(intValue);
}
if (failoverConsumerUnlimitedRB.isSelected()) {
bae.setFailoverConsumers(UNLIMITED_VALUE_NEG1);
} else {
intValue = Integer.parseInt(failoverConsumerIF.getText());
bae.setFailoverConsumers(intValue);
}
/*
* TOPIC-specifics.
*/
} else if (topicRB.isSelected()) {
bae.setDestinationTypeMask(DestType.DEST_TYPE_TOPIC);
}
/*
* From here on applies to both queues and topics.
*/
if (maxProducerUnlimitedRB.isSelected()) {
bae.setMaxProducers(UNLIMITED_VALUE_NEG1);
} else {
intValue = Integer.parseInt(maxProducerIF.getText());
bae.setMaxProducers(intValue);
}
// Set default value unlimited anyway in case if the broker
// decides to change its default value...
if (queueSizeLimitUnlimitedRB.isSelected())
bae.setMaxMesgBytes(UNLIMITED_VALUE_NEG1);
else {
longValue = queueSizeLimitBF.getValue();
bae.setMaxMesgBytes(longValue);
}
if (queueMessageLimitUnlimitedRB.isSelected())
bae.setMaxMesg(UNLIMITED_VALUE_NEG1);
else {
String s = queueMessageLimitTF.getText();
try {
intValue = Integer.parseInt(s);
} catch (NumberFormatException nfe) {
/*
* Should never happen since queueMessageLimitTF
* is an IntegerField.
*/
intValue = -1;
}
if (intValue != -1) {
bae.setMaxMesg(intValue);
}
}
if (destMaxSizePerMsgUnlimitedRB.isSelected())
bae.setMaxPerMesgSize(UNLIMITED_VALUE_NEG1);
else {
longValue = destMaxSizePerMsgBF.getValue();
bae.setMaxPerMesgSize(longValue);
}
bae.setOKAction(true);
fireAdminEventDispatched(bae);
}