/*
* Copyright 2005-2010 Samuel Mello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 or later of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
/*
* TemplateManagerForm.java
*
* Created on Dec 19, 2009, 10:44:46 AM
*/
package datasoul.templates;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import datasoul.DatasoulMainForm;
import datasoul.config.ConfigObj;
import datasoul.config.DisplayControlConfig;
import datasoul.render.OutputDevice;
import datasoul.util.ObjectManager;
/**
*
* @author samuel
*/
public class TemplateManagerForm extends javax.swing.JFrame implements ListSelectionListener {
/**
*
*/
private static final long serialVersionUID = -5734375915329809081L;
private TableRowSorter<TableModel> sorter;
/** Creates new form TemplateManagerForm */
public TemplateManagerForm() {
initComponents();
DatasoulMainForm.setDatasoulIcon(this);
TemplateManager manager = TemplateManager.getInstance();
jTableTemplates.setModel( manager );
jTableTemplates.getSelectionModel().addListSelectionListener(this);
cbDefaultImages.setTargetContent(DisplayTemplate.TARGET_CONTENT_IMAGES);
cbDefaultImages.setSelectedItem(DisplayControlConfig.getInstance().getDefaultTemplateImage());
cbDefaultText.setTargetContent(DisplayTemplate.TARGET_CONTENT_TEXT);
cbDefaultText.setSelectedItem(DisplayControlConfig.getInstance().getDefaultTemplateText());
cbDefaultSong.setTargetContent(DisplayTemplate.TARGET_CONTENT_SONG);
cbDefaultSong.setSelectedItem(DisplayControlConfig.getInstance().getDefaultTemplateSong());
cbMonitorImages.setTargetContent(DisplayTemplate.TARGET_CONTENT_STAGE);
cbMonitorImages.setSelectedItem(DisplayControlConfig.getInstance().getMonitorTemplateImage());
cbMonitorText.setTargetContent(DisplayTemplate.TARGET_CONTENT_STAGE);
cbMonitorText.setSelectedItem(DisplayControlConfig.getInstance().getMonitorTemplateText());
cbMonitorSong.setTargetContent(DisplayTemplate.TARGET_CONTENT_STAGE);
cbMonitorSong.setSelectedItem(DisplayControlConfig.getInstance().getMonitorTemplateSong());
cbMonitorContentless.setTargetContent(DisplayTemplate.TARGET_CONTENT_STAGE);
cbMonitorContentless.setSelectedItem(DisplayControlConfig.getInstance().getMonitorTemplateContentless());
pnlMonitor.setVisible(OutputDevice.isMonitorAllowed());
sorter = new TableRowSorter<TableModel>(jTableTemplates.getModel());
jTableTemplates.setRowSorter(sorter);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTableTemplates = new javax.swing.JTable();
jLabel2 = new javax.swing.JLabel();
lblPreview = new javax.swing.JLabel();
pnlMonitor = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
cbMonitorSong = new datasoul.templates.TemplateComboBox();
cbMonitorText = new datasoul.templates.TemplateComboBox();
cbMonitorImages = new datasoul.templates.TemplateComboBox();
jLabel9 = new javax.swing.JLabel();
cbMonitorContentless = new datasoul.templates.TemplateComboBox();
jPanel3 = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
cbDefaultSong = new datasoul.templates.TemplateComboBox();
cbDefaultText = new datasoul.templates.TemplateComboBox();
cbDefaultImages = new datasoul.templates.TemplateComboBox();
jToolBar1 = new javax.swing.JToolBar();
btnNew = new javax.swing.JButton();
btnLoad = new javax.swing.JButton();
btnDeleteTemplate = new javax.swing.JButton();
btnImport = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("datasoul/internationalize"); // NOI18N
setTitle(bundle.getString("DATASOUL TEMPLATE MANAGER")); // NOI18N
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
});
jTableTemplates.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane1.setViewportView(jTableTemplates);
jLabel2.setText(bundle.getString("PREVIEW:")); // NOI18N
lblPreview.setText(" ");
lblPreview.setMaximumSize(new java.awt.Dimension(100, 500));
lblPreview.setMinimumSize(new java.awt.Dimension(100, 15));
pnlMonitor.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("STAGE TEMPLATES"))); // NOI18N
jLabel3.setText(bundle.getString("SONG:")); // NOI18N
jLabel4.setText(bundle.getString("TEXT:")); // NOI18N
jLabel5.setText(bundle.getString("IMAGES:")); // NOI18N
cbMonitorSong.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbMonitorSong.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbMonitorSongActionPerformed(evt);
}
});
cbMonitorText.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbMonitorText.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbMonitorTextActionPerformed(evt);
}
});
cbMonitorImages.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbMonitorImages.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbMonitorImagesActionPerformed(evt);
}
});
jLabel9.setText(bundle.getString("CONTENTLESS:")); // NOI18N
cbMonitorContentless.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbMonitorContentless.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbMonitorContentlessActionPerformed(evt);
}
});
javax.swing.GroupLayout pnlMonitorLayout = new javax.swing.GroupLayout(pnlMonitor);
pnlMonitor.setLayout(pnlMonitorLayout);
pnlMonitorLayout.setHorizontalGroup(
pnlMonitorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlMonitorLayout.createSequentialGroup()
.addContainerGap()
.addGroup(pnlMonitorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4)
.addComponent(jLabel3)
.addComponent(jLabel5)
.addComponent(jLabel9))
.addGap(20, 20, 20)
.addGroup(pnlMonitorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cbMonitorContentless, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
.addComponent(cbMonitorImages, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
.addComponent(cbMonitorText, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
.addComponent(cbMonitorSong, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE))
.addContainerGap())
);
pnlMonitorLayout.setVerticalGroup(
pnlMonitorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlMonitorLayout.createSequentialGroup()
.addGroup(pnlMonitorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(cbMonitorSong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlMonitorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(cbMonitorText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlMonitorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(cbMonitorImages, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlMonitorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(cbMonitorContentless, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("DEFAULT TEMPLATES"))); // NOI18N
jLabel6.setText(bundle.getString("SONG:")); // NOI18N
jLabel7.setText(bundle.getString("TEXT:")); // NOI18N
jLabel8.setText(bundle.getString("IMAGES:")); // NOI18N
cbDefaultSong.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbDefaultSong.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbDefaultSongActionPerformed(evt);
}
});
cbDefaultText.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbDefaultText.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbDefaultTextActionPerformed(evt);
}
});
cbDefaultImages.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbDefaultImages.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbDefaultImagesActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 56, Short.MAX_VALUE)
.addComponent(cbDefaultImages, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 76, Short.MAX_VALUE)
.addComponent(cbDefaultText, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 70, Short.MAX_VALUE)
.addComponent(cbDefaultSong, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(cbDefaultSong, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(cbDefaultText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(cbDefaultImages, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jToolBar1.setFloatable(false);
jToolBar1.setRollover(true);
btnNew.setIcon(new javax.swing.ImageIcon(getClass().getResource("/datasoul/icons/v2/document-new_big.png"))); // NOI18N
btnNew.setToolTipText(bundle.getString("NEW")); // NOI18N
btnNew.setBorderPainted(false);
btnNew.setFocusPainted(false);
btnNew.setFocusable(false);
btnNew.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnNew.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnNew.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNewActionPerformed(evt);
}
});
jToolBar1.add(btnNew);
btnLoad.setIcon(new javax.swing.ImageIcon(getClass().getResource("/datasoul/icons/v2/document-open_big.png"))); // NOI18N
btnLoad.setToolTipText(bundle.getString("OPEN")); // NOI18N
btnLoad.setBorderPainted(false);
btnLoad.setFocusPainted(false);
btnLoad.setFocusable(false);
btnLoad.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnLoad.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnLoad.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnLoadActionPerformed(evt);
}
});
jToolBar1.add(btnLoad);
btnDeleteTemplate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/datasoul/icons/v2/edit-delete_big.png"))); // NOI18N
btnDeleteTemplate.setText(bundle.getString("DELETE")); // NOI18N
btnDeleteTemplate.setBorderPainted(false);
btnDeleteTemplate.setFocusPainted(false);
btnDeleteTemplate.setFocusable(false);
btnDeleteTemplate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDeleteTemplateActionPerformed(evt);
}
});
jToolBar1.add(btnDeleteTemplate);
btnImport.setIcon(new javax.swing.ImageIcon(getClass().getResource("/datasoul/icons/v2/stock_task-assigned_big.png"))); // NOI18N
btnImport.setText(bundle.getString("IMPORT")); // NOI18N
btnImport.setBorderPainted(false);
btnImport.setFocusable(false);
btnImport.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnImportActionPerformed(evt);
}
});
jToolBar1.add(btnImport);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlMonitor, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblPreview, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel2))
.addContainerGap())
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 743, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 467, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPreview, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 142, Short.MAX_VALUE)
.addComponent(pnlMonitor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void btnLoadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoadActionPerformed
try{
ObjectManager.getInstance().setBusyCursor();
if ( jTableTemplates.getSelectedRowCount() == 1){
Object x = jTableTemplates.getValueAt( jTableTemplates.getSelectedRow(), jTableTemplates.getSelectedColumn() );
if (x instanceof String){
String str = (String) x;
TemplateEditorFrame f = new TemplateEditorFrame();
f.open(str);
f.setVisible(true);
}
}
}finally{
ObjectManager.getInstance().setDefaultCursor();
}
}//GEN-LAST:event_btnLoadActionPerformed
private void btnNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewActionPerformed
TemplateEditorFrame f = new TemplateEditorFrame();
f.newTemplate();
f.setVisible(true);
}//GEN-LAST:event_btnNewActionPerformed
private void btnDeleteTemplateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteTemplateActionPerformed
if ( jTableTemplates.getSelectedRowCount() == 1){
Object x = jTableTemplates.getValueAt( jTableTemplates.getSelectedRow(), jTableTemplates.getSelectedColumn() );
if (x instanceof String){
String str = (String) x;
int confirm = JOptionPane.showConfirmDialog(this, java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("DELETE TEMPLATE ")+x+"?", java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("CONFIRM"), JOptionPane.YES_NO_OPTION);
if (confirm == JOptionPane.YES_OPTION){
try{
TemplateManager.getInstance().deleteTemplate(str);
}catch(Exception e){
JOptionPane.showMessageDialog(this,java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("UNABLE TO DELETE TEMPLATE:")+"\n"+e.getMessage(),java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("DATASOUL ERROR"),0);
}// try
}//if confirm
}// if instance of
}// if selected
}//GEN-LAST:event_btnDeleteTemplateActionPerformed
private void btnImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportActionPerformed
JFileChooser fc = new JFileChooser();
fc.addChoosableFileFilter(new FileNameExtensionFilter(java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("DATASOUL 1.X TEMPLATES (*.TEMPLATE)"), "template"));
fc.addChoosableFileFilter(new FileNameExtensionFilter(java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("DATASOUL TEMPLATES (*.TEMPLATEZ)"), "templatez"));
File dir = new File(ConfigObj.getActiveInstance().getStoragePathTemplates());
fc.setCurrentDirectory(dir);
fc.setMultiSelectionEnabled(true);
fc.setDialogTitle(java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("SELECT THE FILE TO SAVE."));
if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
for (File f : fc.getSelectedFiles()){
DisplayTemplate.importTemplate(f.getAbsolutePath());
}
}
}//GEN-LAST:event_btnImportActionPerformed
private void cbMonitorSongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbMonitorSongActionPerformed
if (cbMonitorSong.getSelectedItem() != null && ! cbMonitorSong.isUpdating()){
DisplayControlConfig.getInstance().setMonitorTemplateSong(cbMonitorSong.getSelectedItem().toString());
}
}//GEN-LAST:event_cbMonitorSongActionPerformed
private void cbMonitorTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbMonitorTextActionPerformed
if (cbMonitorText.getSelectedItem() != null && ! cbMonitorText.isUpdating()){
DisplayControlConfig.getInstance().setMonitorTemplateText(cbMonitorText.getSelectedItem().toString());
}
}//GEN-LAST:event_cbMonitorTextActionPerformed
private void cbMonitorImagesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbMonitorImagesActionPerformed
if (cbMonitorImages.getSelectedItem() != null && ! cbMonitorImages.isUpdating()){
DisplayControlConfig.getInstance().setMonitorTemplateImage(cbMonitorImages.getSelectedItem().toString());
}
}//GEN-LAST:event_cbMonitorImagesActionPerformed
private void cbDefaultSongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDefaultSongActionPerformed
if (cbDefaultSong.getSelectedItem() != null && ! cbDefaultSong.isUpdating()){
DisplayControlConfig.getInstance().setDefaultTemplateSong(cbDefaultSong.getSelectedItem().toString());
}
}//GEN-LAST:event_cbDefaultSongActionPerformed
private void cbDefaultTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDefaultTextActionPerformed
if (cbDefaultText.getSelectedItem() != null && ! cbDefaultText.isUpdating()){
DisplayControlConfig.getInstance().setDefaultTemplateText(cbDefaultText.getSelectedItem().toString());
}
}//GEN-LAST:event_cbDefaultTextActionPerformed
private void cbDefaultImagesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDefaultImagesActionPerformed
if (cbDefaultImages.getSelectedItem() != null && ! cbDefaultImages.isUpdating()){
DisplayControlConfig.getInstance().setDefaultTemplateImage(cbDefaultImages.getSelectedItem().toString());
}
}//GEN-LAST:event_cbDefaultImagesActionPerformed
private void cbMonitorContentlessActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbMonitorContentlessActionPerformed
if (cbMonitorContentless.getSelectedItem() != null && ! cbMonitorContentless.isUpdating()){
DisplayControlConfig.getInstance().setMonitorTemplateContentless(cbMonitorContentless.getSelectedItem().toString());
}
}//GEN-LAST:event_cbMonitorContentlessActionPerformed
private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
// Consistency check
DisplayControlConfig d = DisplayControlConfig.getInstance();
String defImage = cbDefaultImages.getSelectedItem()==null?"":cbDefaultImages.getSelectedItem().toString();
String defText = cbDefaultText.getSelectedItem()==null?"":cbDefaultText.getSelectedItem().toString();
String defSong = cbDefaultSong.getSelectedItem()==null?"":cbDefaultSong.getSelectedItem().toString();
String monImage = cbMonitorImages.getSelectedItem()==null?"":cbMonitorImages.getSelectedItem().toString();
String monText = cbMonitorText.getSelectedItem()==null?"":cbMonitorText.getSelectedItem().toString();
String monSong = cbMonitorSong.getSelectedItem()==null?"":cbMonitorSong.getSelectedItem().toString();
String monContentless = cbMonitorContentless.getSelectedItem()==null?"":cbMonitorContentless.getSelectedItem().toString();
if (!d.getDefaultTemplateImage().equals(defImage) ){
d.setDefaultTemplateImage(defImage);
}
if (!d.getDefaultTemplateText().equals(defText) ){
d.setDefaultTemplateText(defText);
}
if (!d.getDefaultTemplateSong().equals(defSong) ){
d.setDefaultTemplateSong(defSong);
}
if (!d.getMonitorTemplateImage().equals(monImage) ){
d.setMonitorTemplateImage(monImage);
}
if (!d.getMonitorTemplateText().equals(monText) ){
d.setMonitorTemplateText(monText);
}
if (!d.getMonitorTemplateSong().equals(monSong) ){
d.setMonitorTemplateSong(monSong);
}
if (!d.getMonitorTemplateContentless().equals(monContentless)){
d.setMonitorTemplateContentless(monContentless);
}
ObjectManager.getInstance().setTemplateManagerForm(null);
}//GEN-LAST:event_formWindowClosing
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnDeleteTemplate;
private javax.swing.JButton btnImport;
private javax.swing.JButton btnLoad;
private javax.swing.JButton btnNew;
private datasoul.templates.TemplateComboBox cbDefaultImages;
private datasoul.templates.TemplateComboBox cbDefaultSong;
private datasoul.templates.TemplateComboBox cbDefaultText;
private datasoul.templates.TemplateComboBox cbMonitorContentless;
private datasoul.templates.TemplateComboBox cbMonitorImages;
private datasoul.templates.TemplateComboBox cbMonitorSong;
private datasoul.templates.TemplateComboBox cbMonitorText;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTableTemplates;
private javax.swing.JToolBar jToolBar1;
private javax.swing.JLabel lblPreview;
private javax.swing.JPanel pnlMonitor;
// End of variables declaration//GEN-END:variables
@Override
public void valueChanged(ListSelectionEvent arg0) {
if (jTableTemplates.getSelectedRow() >= 0){
int idx = sorter.convertRowIndexToModel(jTableTemplates.getSelectedRow());
DisplayTemplateMetadata meta = TemplateManager.getInstance().getDisplayTemplateMetadata(idx);
ImageIcon icon = new ImageIcon(meta.getMiniImage());
lblPreview.setIcon(icon);
lblPreview.setText("");
}else{
lblPreview.setIcon(null);
}
}
}