ListSelectionModel lsm = (ListSelectionModel) e.getSource ();
if ( lsm.isSelectionEmpty () ) {
// no rows are selected
} else {
int selectedRow = lsm.getMinSelectionIndex ();
AdminTransaction rec = (AdminTransaction) data_
.elementAt ( selectedRow );
Object id = null;
Object state = null;
id = rec.getTid ();
state = convertState ( rec.getState () );
if ( !state.equals ( TxState.IN_DOUBT ) ) {
if ( hasDetails ( rec.getState () ) ) {
Object[] options = {
messages_.getString ( "forgetNoArchiveOption" ),
messages_.getString ( "forgetAndArchiveOption" ),
messages_.getString ( "keepInLogOption" ) };
Vector descriptors = getStateDescriptors ( rec );
StateTableModel table = new StateTableModel ( descriptors );
PropertiesPanel panel = new PropertiesPanel ( table, true );
String outcome = null;
if ( rec.wasCommitted () )
outcome = messages_.getString ( "commitOutcomeMessage" );
else
outcome = messages_
.getString ( "rollbackOutcomeMessage" );
panel.addPropertyListener ( pListener_ );
int n = JOptionPane.showOptionDialog ( frame_, panel
.getPanel (), outcome + id.toString (),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE, null, options,
options[2] );
if ( n == JOptionPane.YES_OPTION
|| n == JOptionPane.NO_OPTION ) {
// System.out.println ( "Terminating transaction" );
if ( n == JOptionPane.NO_OPTION ) {
// ask user where to archive
fc_.setDialogTitle ( messages_
.getString ( "appendDialogTitle" ) );
int ret = fc_.showOpenDialog ( frame_ );
if ( ret == JFileChooser.APPROVE_OPTION ) {
try {
File file = fc_.getSelectedFile ();
FileWriter writer = new FileWriter ( file
.getPath (), true );
writer
.write ( messages_
.getString ( "rootTransactionMessage" )
+ id.toString () + " " );
writer.write ( getMessages ( data_
.elementAt ( selectedRow ) ) );
writer.write ( "\r" );
writer.flush ();
writer.close ();
forget ( data_.elementAt ( selectedRow ),
selectedRow );
} catch ( Exception err ) {
err.printStackTrace ();
}
}
}
else {
// Forget no archive
forget ( data_.elementAt ( selectedRow ),
selectedRow );
}
} else {
// CANCEL option -> just invalidate selection, to allow
// next pop-up to happen
lsm.removeSelectionInterval ( selectedRow, selectedRow );
}
} else {
//no details available -> show warning for the user
String message = messages_.getString ( "noDetailsAvailableMessage" );
String title = messages_.getString( "noDetailsAvailableTitle" );
JOptionPane.showMessageDialog (
frame_ , message , title , JOptionPane.INFORMATION_MESSAGE );
}
} else {
// indoubt instance -> present commit/rollback/keep option
Object[] options = { messages_.getString ( "commitOption" ),
messages_.getString ( "rollbackOption" ),
messages_.getString ( "keepInLogOption" ) };
AdminTransaction tx = (AdminTransaction) data_
.elementAt ( selectedRow );
JPanel panel = getMessagePanel ( tx.getHeuristicMessages () );
int n = JOptionPane
.showOptionDialog ( frame_, panel, messages_
.getString ( "selectedTransactionMessage" )
+ id.toString (),