com.josescalia.tumblr.form.TumblrRssFavList.java Source code

Java tutorial

Introduction

Here is the source code for com.josescalia.tumblr.form.TumblrRssFavList.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.josescalia.tumblr.form;

import com.josescalia.tumblr.app.BaseForm;
import com.josescalia.tumblr.model.Rss;
import com.josescalia.tumblr.service.RssService;
import com.josescalia.tumblr.util.swing.LabelValue;
import com.josescalia.tumblr.util.swing.UIFormUtil;
import com.josescalia.tumblr.util.swing.LabelValueListCellRenderer;
import org.apache.log4j.Logger;
import org.jdesktop.observablecollections.ObservableCollections;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.BeanUtils;

import javax.swing.*;

/**
 *
 * @author josescalia
 */
@Component
@Scope("prototype")
public class TumblrRssFavList extends BaseForm {
    static Logger logger = Logger.getLogger(TumblrRssFavList.class.getName());

    private static final long serialVersionUID = -304926338348199541L;

    @Autowired
    private RssService service;

    private List<Rss> dataList = ObservableCollections.observableList(new ArrayList<Rss>());
    private Rss selectedItem;
    private Rss formBean;

    private List<LabelValue> filterList = new ArrayList<LabelValue>();
    private LabelValue filter;
    private String filterText = "";

    private void initComboBox() {
        Map<String, String> filters = new HashMap<String, String>();
        filters.put("title", "Title");
        filters.put("link", "Link");
        setFilter(new LabelValue("title", "Title"));
        UIFormUtil.fillAndSetOrderLvMap(filters, filterList);
    }

    private Map<String, Object> setupFilterParam() {
        Map<String, Object> mapParams = new HashMap<String, Object>();
        if (filterText != null && !filterText.equalsIgnoreCase("")) {
            mapParams.put("searchCat", filter.getValue());
            mapParams.put("searchVal", filterText);
            return mapParams;
        } else {
            return null;
        }
    }

    private void fetchData() {
        setDataList(ObservableCollections.observableList(service.getFilteredList(setupFilterParam())));
    }

    public void showForm() {
        logger.debug("Show Form Invoked");
        initComboBox();
        //setMovieList(ObservableCollections.observableList(movieServices.getFilteredList(null)));
        initComponents();
        fetchData();
    }

    /**
     * Creates new form TumblrRssFavList
     */
    public TumblrRssFavList() {
        selectedItem = new Rss();
        formBean = new Rss();
        //initComponents();
    }

    /**
     * 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() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        labelValueListCellRenderer1 = new com.josescalia.tumblr.util.swing.LabelValueListCellRenderer();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jComboBox1 = new javax.swing.JComboBox();
        txtSearchVal = new javax.swing.JTextField();
        btnFind = new javax.swing.JButton();
        panelForm = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtRssTitle = new javax.swing.JTextField();
        txtRssLink = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        pnlButton = new javax.swing.JPanel();
        btnNew2 = new javax.swing.JButton();
        btnSave = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();
        btnEdit = new javax.swing.JButton();
        btnDelete = new javax.swing.JButton();

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty
                .create("${dataList}");
        org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings
                .createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this,
                        eLProperty, jTable1);
        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding
                .addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${title}"));
        columnBinding.setColumnName("Title");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${link}"));
        columnBinding.setColumnName("Link");
        columnBinding.setColumnClass(String.class);
        columnBinding.setEditable(false);
        bindingGroup.addBinding(jTableBinding);
        jTableBinding.bind();
        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
                org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this,
                org.jdesktop.beansbinding.ELProperty.create("${selectedItem}"), jTable1,
                org.jdesktop.beansbinding.BeanProperty.create("selectedElement"));
        bindingGroup.addBinding(binding);

        jScrollPane1.setViewportView(jTable1);
        if (jTable1.getColumnModel().getColumnCount() > 0) {
            jTable1.getColumnModel().getColumn(0).setResizable(false);
            jTable1.getColumnModel().getColumn(0).setPreferredWidth(100);
            jTable1.getColumnModel().getColumn(1).setResizable(false);
            jTable1.getColumnModel().getColumn(1).setPreferredWidth(300);
        }

        jComboBox1.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox1.setRenderer(labelValueListCellRenderer1);

        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${filterList}");
        org.jdesktop.swingbinding.JComboBoxBinding jComboBoxBinding = org.jdesktop.swingbinding.SwingBindings
                .createJComboBoxBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this,
                        eLProperty, jComboBox1);
        bindingGroup.addBinding(jComboBoxBinding);
        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
                org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this,
                org.jdesktop.beansbinding.ELProperty.create("${filter}"), jComboBox1,
                org.jdesktop.beansbinding.BeanProperty.create("selectedItem"));
        bindingGroup.addBinding(binding);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
                org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this,
                org.jdesktop.beansbinding.ELProperty.create("${filterText}"), txtSearchVal,
                org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        btnFind.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/magnifier.png"))); // NOI18N
        btnFind.setText("Find");
        btnFind.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFindActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(jPanel1Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                jPanel1Layout.createSequentialGroup()
                                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 99,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtSearchVal, javax.swing.GroupLayout.PREFERRED_SIZE, 274,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(btnFind, javax.swing.GroupLayout.PREFERRED_SIZE, 96,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(txtSearchVal, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btnFind))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 379, Short.MAX_VALUE)
                        .addContainerGap()));

        panelForm.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setText("Title");

        txtRssTitle.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
                org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this,
                org.jdesktop.beansbinding.ELProperty.create("${formBean.title}"), txtRssTitle,
                org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        txtRssLink.setEnabled(false);

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
                org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this,
                org.jdesktop.beansbinding.ELProperty.create("${formBean.link}"), txtRssLink,
                org.jdesktop.beansbinding.BeanProperty.create("text"));
        bindingGroup.addBinding(binding);

        jLabel2.setText("Link");

        javax.swing.GroupLayout panelFormLayout = new javax.swing.GroupLayout(panelForm);
        panelForm.setLayout(panelFormLayout);
        panelFormLayout.setHorizontalGroup(panelFormLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelFormLayout.createSequentialGroup().addContainerGap()
                        .addGroup(panelFormLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(panelFormLayout.createSequentialGroup()
                                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 39,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtRssTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 243,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(191, 191, 191))
                                .addGroup(panelFormLayout.createSequentialGroup()
                                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 39,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(txtRssLink, javax.swing.GroupLayout.PREFERRED_SIZE, 434,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(39, Short.MAX_VALUE)));
        panelFormLayout.setVerticalGroup(panelFormLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panelFormLayout.createSequentialGroup().addContainerGap().addGroup(panelFormLayout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel1)
                        .addComponent(txtRssTitle, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelFormLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel2).addComponent(txtRssLink,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap()));

        pnlButton.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        btnNew2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/add.png"))); // NOI18N
        btnNew2.setText("New");
        btnNew2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnNew2.setName("btnNew"); // NOI18N
        btnNew2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnNew2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNew2ActionPerformed(evt);
            }
        });

        btnSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/save.png"))); // NOI18N
        btnSave.setText("Save");
        btnSave.setEnabled(false);
        btnSave.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnSave.setName("btnSave"); // NOI18N
        btnSave.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        btnCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/cancel.png"))); // NOI18N
        btnCancel.setText("Cancel");
        btnCancel.setEnabled(false);
        btnCancel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCancel.setName("btnCancel"); // NOI18N
        btnCancel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });

        btnEdit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/edit.png"))); // NOI18N
        btnEdit.setText("Edit");
        btnEdit.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnEdit.setName("btnEdit"); // NOI18N
        btnEdit.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnEdit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditActionPerformed(evt);
            }
        });

        btnDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/delete.png"))); // NOI18N
        btnDelete.setText("Delete");
        btnDelete.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnDelete.setName("btnDelete"); // NOI18N
        btnDelete.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlButtonLayout = new javax.swing.GroupLayout(pnlButton);
        pnlButton.setLayout(pnlButtonLayout);
        pnlButtonLayout
                .setHorizontalGroup(pnlButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(pnlButtonLayout.createSequentialGroup().addContainerGap()
                                .addComponent(btnNew2, javax.swing.GroupLayout.PREFERRED_SIZE, 93,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 93,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnDelete, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 93,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btnSave, javax.swing.GroupLayout.PREFERRED_SIZE, 93,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap()));
        pnlButtonLayout.setVerticalGroup(pnlButtonLayout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(pnlButtonLayout.createSequentialGroup().addContainerGap()
                        .addGroup(pnlButtonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(btnEdit).addComponent(btnNew2).addComponent(btnSave)
                                .addComponent(btnCancel).addComponent(btnDelete))
                        .addContainerGap()));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap()
                        .addComponent(jPanel1, 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(pnlButton, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(panelForm, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap()));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                        .addComponent(panelForm, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(pnlButton, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGroup(layout.createSequentialGroup()
                                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGap(20, 20, 20)))));

        bindingGroup.bind();
    }// </editor-fold>//GEN-END:initComponents

    private void btnFindActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFindActionPerformed
        fetchData();
    }//GEN-LAST:event_btnFindActionPerformed

    private void btnNew2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNew2ActionPerformed
        //must deselect selected item
        setSelectedItem(null);
        BeanUtils.copyProperties(new Rss(), formBean);
        System.out.println(formBean);
        UIFormUtil.btnSetupConfig(UIFormUtil.ADD_MODE, pnlButton);
        UIFormUtil.isEnabledAndClearComp(true, true, panelForm);
    }//GEN-LAST:event_btnNew2ActionPerformed

    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
        //logger.info("obj to save :" + selectedItem);
        //saveAction
        if (formBean != null) {
            try {
                Rss temp = new Rss();
                BeanUtils.copyProperties(formBean, temp);
                service.save(temp);
                if (temp.getId() != null) {
                    JOptionPane.showMessageDialog(this, "Save Succeed");
                } else {
                    JOptionPane.showMessageDialog(this, "Save Failed");
                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(this, "Save Failed\n" + e.getMessage(), "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        }

        UIFormUtil.btnSetupConfig(UIFormUtil.CANCEL_MODE, pnlButton);
        UIFormUtil.isEnabledAndClearComp(false, true, panelForm);
        fetchData();
    }//GEN-LAST:event_btnSaveActionPerformed

    private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
        UIFormUtil.isEnabledAndClearComp(false, false, panelForm);
        UIFormUtil.btnSetupConfig(UIFormUtil.CANCEL_MODE, pnlButton);
    }//GEN-LAST:event_btnCancelActionPerformed

    private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditActionPerformed
        if (selectedItem != null) {
            UIFormUtil.btnSetupConfig(UIFormUtil.EDIT_MODE, pnlButton);
            UIFormUtil.isEnabledAndClearComp(true, false, panelForm);
        } else {
            JOptionPane.showMessageDialog(this, "Please select item first");
        }
    }//GEN-LAST:event_btnEditActionPerformed

    private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed
        if (JOptionPane.showConfirmDialog(this, "Are you sure to delete this data ? ") == JOptionPane.OK_OPTION) {
            try {
                if (service.delete(selectedItem.getId())) {
                    JOptionPane.showMessageDialog(this, "Delete Succeed");
                } else {
                    JOptionPane.showMessageDialog(this, "Delete Failed");
                }
            } catch (Exception e) {
                logger.error(e.getMessage());
                JOptionPane.showMessageDialog(this, "Delete Failed " + e.getMessage());
            }
            btnFindActionPerformed(evt);
            setFormBean(new Rss());
        }
    }//GEN-LAST:event_btnDeleteActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnDelete;
    private javax.swing.JButton btnEdit;
    private javax.swing.JButton btnFind;
    private javax.swing.JButton btnNew2;
    private javax.swing.JButton btnSave;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private com.josescalia.tumblr.util.swing.LabelValueListCellRenderer labelValueListCellRenderer1;
    private javax.swing.JPanel panelForm;
    private javax.swing.JPanel pnlButton;
    private javax.swing.JTextField txtRssLink;
    private javax.swing.JTextField txtRssTitle;
    private javax.swing.JTextField txtSearchVal;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

    public List<Rss> getDataList() {
        return dataList;
    }

    public void setDataList(List<Rss> dataList) {
        List<Rss> old = this.dataList;
        this.dataList = dataList;
        firePropertyChange("dataList", old, dataList);
    }

    public Rss getSelectedItem() {
        return selectedItem;
    }

    public void setSelectedItem(Rss selectedItem) {
        Rss old = this.selectedItem;
        this.selectedItem = selectedItem;
        firePropertyChange("selectedItem", old, selectedItem);
        if (selectedItem != null) {
            setFormBean(selectedItem);
        }
    }

    public Rss getFormBean() {
        return formBean;
    }

    public void setFormBean(Rss formBean) {
        Rss old = this.formBean;
        this.formBean = formBean;
        firePropertyChange("formBean", old, formBean);
    }

    public List<LabelValue> getFilterList() {
        return filterList;
    }

    public void setFilterList(List<LabelValue> filterList) {
        List<LabelValue> old = this.filterList;
        this.filterList = filterList;
        firePropertyChange("filterList", old, filterList);
    }

    public LabelValue getFilter() {
        return filter;
    }

    public void setFilter(LabelValue filter) {
        LabelValue old = this.filter;
        this.filter = filter;
        firePropertyChange("filter", old, filter);
    }

    public String getFilterText() {
        return filterText;
    }

    public void setFilterText(String filterText) {
        String old = this.filterText;
        this.filterText = filterText;
        firePropertyChange("filterText", old, filterText);
    }
}