private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshButtonActionPerformed
Lookup.getDefault().lookup(PreviewUIController.class).refreshPreview();
}//GEN-LAST:event_refreshButtonActionPerformed
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
PreviewUIController previewController = Lookup.getDefault().lookup(PreviewUIController.class);
PreviewPreset preset = previewController.getModel().getCurrentPreset();
boolean saved = false;
if (isDefaultPreset(preset)) {
NotifyDescriptor.InputLine question = new NotifyDescriptor.InputLine(
NbBundle.getMessage(PreviewSettingsTopComponent.class, "PreviewSettingsTopComponent.savePreset.input"),
NbBundle.getMessage(PreviewSettingsTopComponent.class, "PreviewSettingsTopComponent.savePreset.input.title"));
if (DialogDisplayer.getDefault().notify(question) == NotifyDescriptor.OK_OPTION) {
String input = question.getInputText();
if (input != null && !input.isEmpty()) {
previewController.savePreset(input);
saved = true;
StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(PreviewSettingsTopComponent.class, "PreviewSettingsTopComponent.savePreset.status", input));
}
}
} else {
previewController.savePreset(preset.getName());
saved = true;
StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(PreviewSettingsTopComponent.class, "PreviewSettingsTopComponent.savePreset.status", preset.getName()));
}
if (saved) {
//refresh combo
DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
defaultPresetLimit = 0;
for (PreviewPreset p : previewController.getDefaultPresets()) {
comboBoxModel.addElement(p);
defaultPresetLimit++;
}
PreviewPreset[] userPresets = previewController.getUserPresets();
if (userPresets.length > 0) {
comboBoxModel.addElement(NO_SELECTION);
for (PreviewPreset p : userPresets) {
comboBoxModel.addElement(p);
}
}
comboBoxModel.setSelectedItem(previewController.getModel().getCurrentPreset());
presetComboBox.setModel(comboBoxModel);
}
}//GEN-LAST:event_saveButtonActionPerformed