newSchemeBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
String newSchemeName = JOptionPane.showInputDialog(parent, mLocalizer.msg("enterNewSchemeName","Enter new name for scheme:"), mLocalizer.msg("newScheme","New scheme"), JOptionPane.PLAIN_MESSAGE);
if (newSchemeName != null) {
if (newSchemeName.trim().length() > 0) {
Scheme newScheme = mDialogContent.createNewScheme(newSchemeName);
newScheme.setSettings(mDialogContent.getSettings());
mSchemeCBModel.addElement(newScheme);
mSchemeCB.setSelectedItem(newScheme);
mDialogContent.setSettings(newScheme.getSettings());
}
else {
JOptionPane.showMessageDialog(parent, mLocalizer.msg("invalidSchemeMsg","Invalid scheme name"), mLocalizer.msg("invalidInput","Invalid input"), JOptionPane.INFORMATION_MESSAGE);
}
}
}
});
mSaveSchemeBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
Scheme scheme = (Scheme)mSchemeCB.getSelectedItem();
scheme.setSettings(mDialogContent.getSettings());
}
});
mEditSchemeBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
Scheme scheme = (Scheme)mSchemeCB.getSelectedItem();
Object newSchemeName = JOptionPane.showInputDialog(parent, mLocalizer.msg("enterNewSchemeName","Enter new name for scheme:"), mLocalizer.msg("editScheme","Edit scheme"), JOptionPane.PLAIN_MESSAGE, null, null, scheme.getName());
if (newSchemeName != null) {
if (newSchemeName.toString().trim().length()>0) {
scheme.setName(newSchemeName.toString());
mSchemeCB.repaint();
}
else {
JOptionPane.showMessageDialog(parent, mLocalizer.msg("invalidSchemeMsg","Invalid scheme name"), mLocalizer.msg("invalidInput","Invalid input"), JOptionPane.INFORMATION_MESSAGE);
}
}
}
});
mDeleteSchemeBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event) {
Scheme scheme = (Scheme)mSchemeCB.getSelectedItem();
if (scheme != null) {
if (JOptionPane.showConfirmDialog(parent, mLocalizer.msg("deleteSchemeMsg","Do you want to delete the selected scheme?"), mLocalizer.msg("deleteScheme","Delete Scheme"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
mSchemeCBModel.removeElement(scheme);
mSchemeCB.setSelectedIndex(0);
}
}
}
});
mSchemeCBModel = new DefaultComboBoxModel(schemes);
mSchemeCB = new JComboBox(mSchemeCBModel);
JPanel schemePanel = new JPanel();
schemePanel.add(mSchemeCB);
schemePanel.add(newSchemeBtn);
schemePanel.add(mEditSchemeBtn);
schemePanel.add(mSaveSchemeBtn);
schemePanel.add(mDeleteSchemeBtn);
southPanel.add(schemePanel, BorderLayout.WEST);
mSchemeCB.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e) {
mDeleteSchemeBtn.setEnabled(mSchemeCB.getSelectedIndex()!=0);
mEditSchemeBtn.setEnabled(mSchemeCB.getSelectedIndex()!=0);
Scheme scheme = (Scheme)mSchemeCB.getSelectedItem();
mDialogContent.setSettings(scheme.getSettings());
}
});
contentPane.add(eastPanel, BorderLayout.EAST);