presets.addItem(profile); // TODO insert at
} else { // profile already exists
profile = (Preset) item;
profile.setConfig(createCurrentConfig());
}
Config config = client.getConfig();
config.getPresets().put(profile.getName(), profile.getConfig());
client.saveConfig();
updatePresetButtons(presets.getSelectedItem());
}
});
presetPanel.add(presetSave, "width 80, gapright 10, west");
presetDelete = new JButton(_("Delete"));
presetDelete.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Object item = presets.getSelectedItem();
if (item instanceof String) {
item = getPresetFor((String) item);
}
if (item instanceof Preset) {
Preset preset = (Preset) item;
presets.removeItem(preset);
Config config = client.getConfig();
config.getPresets().remove(preset.getName());
client.saveConfig();
presets.setSelectedItem("");
updatePresetButtons("");
}
}