Skip to content

Commit

Permalink
Adding code so that newly created servers are immediately selected.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelker committed Oct 21, 2014
1 parent 82e79b7 commit f9408b7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 46 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,3 +1,4 @@
target/
.idea/
*.iml
*.iml
.DS_Store
Expand Up @@ -42,12 +42,14 @@ public class AddEditServerDialog extends javax.swing.JDialog {

public enum Mode {ADD, EDIT};
private Mode mode = null;
private final ChangeNdexServerDialog parent;

/**
* Creates new form AddNDExServer
*/
public AddEditServerDialog(Frame parent) {
public AddEditServerDialog(ChangeNdexServerDialog parent) {
super(parent, true);
this.parent = parent;
initComponents();
prepComponents();
}
Expand Down Expand Up @@ -262,6 +264,8 @@ private void saveActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:even
{
servers.add(server);
servers.save();
ServerManager.INSTANCE.setSelectedServer(server);
parent.setSelectedServer(server);
setVisible(false);
}
catch (Exception ex)
Expand Down Expand Up @@ -310,48 +314,6 @@ private void cancelActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:ev
setVisible(false);
}//GEN-LAST:event_cancelActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(AddEditServerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(AddEditServerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(AddEditServerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(AddEditServerDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
AddEditServerDialog dialog = new AddEditServerDialog(new javax.swing.JFrame());
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancel;
private javax.swing.JLabel jLabel1;
Expand Down
Expand Up @@ -122,6 +122,11 @@ public void intervalRemoved(ListDataEvent e)
});
guiServerList.setSelectedIndex(0);
}

public void setSelectedServer(Server server)
{
guiServerList.setSelectedValue(server, true);
}

/**
* This method is called from within the constructor to initialize the form.
Expand Down Expand Up @@ -334,15 +339,15 @@ private void connectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST
}//GEN-LAST:event_connectActionPerformed

private void addActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addActionPerformed
AddEditServerDialog dialog = new AddEditServerDialog(parent);
AddEditServerDialog dialog = new AddEditServerDialog(this);
dialog.setMode(AddEditServerDialog.Mode.ADD);
dialog.setLocationRelativeTo(this);
dialog.setVisible(true);
}//GEN-LAST:event_addActionPerformed

private void editActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_editActionPerformed
{//GEN-HEADEREND:event_editActionPerformed
AddEditServerDialog dialog = new AddEditServerDialog(parent);
AddEditServerDialog dialog = new AddEditServerDialog(this);
dialog.setMode(AddEditServerDialog.Mode.EDIT);
dialog.setLocationRelativeTo(this);
dialog.setVisible(true);
Expand Down

0 comments on commit f9408b7

Please sign in to comment.