Example usage for javax.swing ListSelectionModel isSelectionEmpty

List of usage examples for javax.swing ListSelectionModel isSelectionEmpty

Introduction

In this page you can find the example usage for javax.swing ListSelectionModel isSelectionEmpty.

Prototype

boolean isSelectionEmpty();

Source Link

Document

Returns true if no indices are selected.

Usage

From source file:org.freeplane.view.swing.features.time.mindmapmode.NodeList.java

public void startup() {
    if (dialog != null) {
        dialog.toFront();/*w  w w . j  a va 2s .c  o m*/
        return;
    }
    NodeList.COLUMN_MODIFIED = TextUtils.getText(PLUGINS_TIME_LIST_XML_MODIFIED);
    NodeList.COLUMN_CREATED = TextUtils.getText(PLUGINS_TIME_LIST_XML_CREATED);
    NodeList.COLUMN_ICONS = TextUtils.getText(PLUGINS_TIME_LIST_XML_ICONS);
    NodeList.COLUMN_TEXT = TextUtils.getText(PLUGINS_TIME_LIST_XML_TEXT);
    NodeList.COLUMN_DATE = TextUtils.getText(PLUGINS_TIME_LIST_XML_DATE);
    NodeList.COLUMN_NOTES = TextUtils.getText(PLUGINS_TIME_LIST_XML_NOTES);
    dialog = new JDialog(Controller.getCurrentController().getViewController().getFrame(), modal /* modal */);
    String windowTitle;
    if (showAllNodes) {
        windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE_ALL_NODES;
    } else {
        windowTitle = PLUGINS_TIME_MANAGEMENT_XML_WINDOW_TITLE;
    }
    dialog.setTitle(TextUtils.getText(windowTitle));
    dialog.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    final WindowAdapter windowListener = new WindowAdapter() {

        @Override
        public void windowGainedFocus(WindowEvent e) {
            mFilterTextSearchField.getEditor().selectAll();
        }

        @Override
        public void windowClosing(final WindowEvent event) {
            disposeDialog();
        }
    };
    dialog.addWindowListener(windowListener);
    dialog.addWindowFocusListener(windowListener);
    UITools.addEscapeActionToDialog(dialog, new AbstractAction() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(final ActionEvent arg0) {
            disposeDialog();
        }
    });
    final Container contentPane = dialog.getContentPane();
    final GridBagLayout gbl = new GridBagLayout();
    contentPane.setLayout(gbl);
    final GridBagConstraints layoutConstraints = new GridBagConstraints();
    layoutConstraints.gridx = 0;
    layoutConstraints.gridy = 0;
    layoutConstraints.gridwidth = 1;
    layoutConstraints.gridheight = 1;
    layoutConstraints.weightx = 0.0;
    layoutConstraints.weighty = 0.0;
    layoutConstraints.anchor = GridBagConstraints.WEST;
    layoutConstraints.fill = GridBagConstraints.HORIZONTAL;
    contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_FIND)), layoutConstraints);
    layoutConstraints.gridwidth = 1;
    layoutConstraints.gridx++;
    contentPane.add(Box.createHorizontalStrut(40), layoutConstraints);
    layoutConstraints.gridx++;
    contentPane.add(new JLabel(TextUtils.getText("filter_match_case")), layoutConstraints);
    layoutConstraints.gridx++;
    contentPane.add(matchCase, layoutConstraints);
    layoutConstraints.gridx++;
    contentPane.add(Box.createHorizontalStrut(40), layoutConstraints);
    layoutConstraints.gridx++;
    contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints);
    layoutConstraints.gridx++;
    contentPane.add(useRegexInFind, layoutConstraints);
    layoutConstraints.gridx = 0;
    layoutConstraints.weightx = 1.0;
    layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
    layoutConstraints.gridy++;
    contentPane.add(/* new JScrollPane */(mFilterTextSearchField), layoutConstraints);
    layoutConstraints.gridy++;
    layoutConstraints.weightx = 0.0;
    layoutConstraints.gridwidth = 1;
    contentPane.add(new JLabel(TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_REPLACE)), layoutConstraints);
    layoutConstraints.gridx = 5;
    contentPane.add(new JLabel(TextUtils.getText("regular_expressions")), layoutConstraints);
    layoutConstraints.gridx++;
    contentPane.add(useRegexInReplace, layoutConstraints);
    layoutConstraints.gridx = 0;
    layoutConstraints.weightx = 1.0;
    layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
    layoutConstraints.gridy++;
    contentPane.add(/* new JScrollPane */(mFilterTextReplaceField), layoutConstraints);
    dateRenderer = new DateRenderer();
    nodeRenderer = new NodeRenderer();
    notesRenderer = new NotesRenderer();
    iconsRenderer = new IconsRenderer();
    timeTable = new FlatNodeTable();
    timeTable.addKeyListener(new FlatNodeTableKeyListener());
    timeTable.addMouseListener(new FlatNodeTableMouseAdapter());
    timeTable.getTableHeader().setReorderingAllowed(false);
    timeTableModel = updateModel();
    mFlatNodeTableFilterModel = new FlatNodeTableFilterModel(timeTableModel, NodeList.NODE_TEXT_COLUMN);
    sorter = new TableSorter(mFlatNodeTableFilterModel);
    timeTable.setModel(sorter);
    sorter.setTableHeader(timeTable.getTableHeader());
    sorter.setColumnComparator(Date.class, TableSorter.COMPARABLE_COMPARATOR);
    sorter.setColumnComparator(NodeModel.class, TableSorter.LEXICAL_COMPARATOR);
    sorter.setColumnComparator(IconsHolder.class, TableSorter.COMPARABLE_COMPARATOR);
    sorter.setSortingStatus(NodeList.DATE_COLUMN, TableSorter.ASCENDING);
    final JScrollPane pane = new JScrollPane(timeTable);
    UITools.setScrollbarIncrement(pane);
    layoutConstraints.gridy++;
    GridBagConstraints tableConstraints = (GridBagConstraints) layoutConstraints.clone();
    tableConstraints.weightx = 1;
    tableConstraints.weighty = 10;
    tableConstraints.fill = GridBagConstraints.BOTH;
    contentPane.add(pane, tableConstraints);
    mTreeLabel = new JLabel();
    layoutConstraints.gridy++;
    GridBagConstraints treeConstraints = (GridBagConstraints) layoutConstraints.clone();
    treeConstraints.fill = GridBagConstraints.BOTH;
    @SuppressWarnings("serial")
    JScrollPane scrollPane = new JScrollPane(mTreeLabel) {
        @Override
        public boolean isValidateRoot() {
            return false;
        }
    };
    contentPane.add(scrollPane, treeConstraints);
    final AbstractAction exportAction = new AbstractAction(
            TextUtils.getText("plugins/TimeManagement.xml_Export")) {
        /**
             * 
             */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(final ActionEvent arg0) {
            exportSelectedRowsAndClose();
        }
    };
    final JButton exportButton = new JButton(exportAction);
    final AbstractAction replaceAllAction = new AbstractAction(
            TextUtils.getText("plugins/TimeManagement.xml_Replace_All")) {
        /**
             * 
             */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(final ActionEvent arg0) {
            replace(new ReplaceAllInfo());
        }
    };
    final JButton replaceAllButton = new JButton(replaceAllAction);
    final AbstractAction replaceSelectedAction = new AbstractAction(
            TextUtils.getText("plugins/TimeManagement.xml_Replace_Selected")) {
        /**
             * 
             */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(final ActionEvent arg0) {
            replace(new ReplaceSelectedInfo());
        }
    };
    final JButton replaceSelectedButton = new JButton(replaceSelectedAction);
    final AbstractAction gotoAction = new AbstractAction(TextUtils.getText("plugins/TimeManagement.xml_Goto")) {
        /**
             * 
             */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(final ActionEvent arg0) {
            selectSelectedRows();
        }
    };
    final JButton gotoButton = new JButton(gotoAction);
    final AbstractAction disposeAction = new AbstractAction(
            TextUtils.getText(PLUGINS_TIME_MANAGEMENT_XML_CLOSE)) {
        /**
             * 
             */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(final ActionEvent arg0) {
            disposeDialog();
        }
    };
    final JButton cancelButton = new JButton(disposeAction);
    /* Initial State */
    gotoAction.setEnabled(false);
    exportAction.setEnabled(false);
    replaceSelectedAction.setEnabled(false);
    final Box bar = Box.createHorizontalBox();
    bar.add(Box.createHorizontalGlue());
    bar.add(cancelButton);
    bar.add(exportButton);
    bar.add(replaceAllButton);
    bar.add(replaceSelectedButton);
    bar.add(gotoButton);
    bar.add(Box.createHorizontalGlue());
    layoutConstraints.gridy++;
    contentPane.add(/* new JScrollPane */(bar), layoutConstraints);
    final JMenuBar menuBar = new JMenuBar();
    final JMenu menu = new JMenu(TextUtils.getText("plugins/TimeManagement.xml_menu_actions"));
    final AbstractAction[] actionList = new AbstractAction[] { gotoAction, replaceSelectedAction,
            replaceAllAction, exportAction, disposeAction };
    for (int i = 0; i < actionList.length; i++) {
        final AbstractAction action = actionList[i];
        final JMenuItem item = menu.add(action);
        item.setIcon(new BlindIcon(UIBuilder.ICON_SIZE));
    }
    menuBar.add(menu);
    dialog.setJMenuBar(menuBar);
    final ListSelectionModel rowSM = timeTable.getSelectionModel();
    rowSM.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(final ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            final ListSelectionModel lsm = (ListSelectionModel) e.getSource();
            final boolean enable = !(lsm.isSelectionEmpty());
            replaceSelectedAction.setEnabled(enable);
            gotoAction.setEnabled(enable);
            exportAction.setEnabled(enable);
        }
    });
    rowSM.addListSelectionListener(new ListSelectionListener() {
        String getNodeText(final NodeModel node) {
            return TextController.getController().getShortText(node)
                    + ((node.isRoot()) ? "" : (" <- " + getNodeText(node.getParentNode())));
        }

        public void valueChanged(final ListSelectionEvent e) {
            if (e.getValueIsAdjusting()) {
                return;
            }
            final ListSelectionModel lsm = (ListSelectionModel) e.getSource();
            if (lsm.isSelectionEmpty()) {
                mTreeLabel.setText("");
                return;
            }
            final int selectedRow = lsm.getLeadSelectionIndex();
            final NodeModel mindMapNode = getMindMapNode(selectedRow);
            mTreeLabel.setText(getNodeText(mindMapNode));
        }
    });
    final String marshalled = ResourceController.getResourceController()
            .getProperty(NodeList.WINDOW_PREFERENCE_STORAGE_PROPERTY);
    final WindowConfigurationStorage result = TimeWindowConfigurationStorage.decorateDialog(marshalled, dialog);
    final WindowConfigurationStorage storage = result;
    if (storage != null) {
        timeTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        int column = 0;
        for (final TimeWindowColumnSetting setting : ((TimeWindowConfigurationStorage) storage)
                .getListTimeWindowColumnSettingList()) {
            timeTable.getColumnModel().getColumn(column).setPreferredWidth(setting.getColumnWidth());
            sorter.setSortingStatus(column, setting.getColumnSorting());
            column++;
        }
    }
    mFlatNodeTableFilterModel.setFilter((String) mFilterTextSearchField.getSelectedItem(),
            matchCase.isSelected(), useRegexInFind.isSelected());
    dialog.setVisible(true);
}

From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow.java

/**
 * Set up the GUI/* w w  w.  j  a v  a2  s  .  c  om*/
 * 
 * @param void
 * @return void
 */
private void initComponents() {
    frame = new JFrame("geWorkbench - Component Configuration Manager");

    topPanel = new JPanel();
    displayLabel = new JLabel();
    String[] displayChoices = { DISPLAY_FILTER_ALL, DISPLAY_ONLY_LOADED, DISPLAY_ONLY_UNLOADED };
    displayComboBox = new JComboBox(displayChoices);
    showByTypeLabel = new JLabel();
    String[] showByTypeChoices = new String[PluginComponent.categoryList.size() + 2];
    showByTypeChoices[0] = SHOW_BY_TYPE_ALL;
    int index = 1;
    for (String s : PluginComponent.categoryList) {
        showByTypeChoices[index] = s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
        index++;
    }
    ;
    showByTypeChoices[index] = SHOW_BY_TYPE_OTHERS;
    Arrays.sort(showByTypeChoices);
    showByTypeComboBox = new JComboBox(showByTypeChoices);
    showByTypeComboBox.setMaximumRowCount(showByTypeChoices.length);
    keywordSearchLabel = new JLabel("Keyword search:");
    keywordSearchField = new JTextField("Enter Text");
    splitPane = new JSplitPane();
    scrollPaneForTextPane = new JScrollPane();
    textPane = new JTextPane();
    bottompanel = new JPanel();
    CellConstraints cc = new CellConstraints();

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            ccmWindow = null;
        }
    });

    viewLicenseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            viewLicense_actionPerformed(e);
        }
    });

    applyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            applyCcmSelections_actionPerformed(e);
        }
    });
    resetButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            resetCcmSelections_actionPerformed(e);
        }

    });
    closeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeCcmSelections_actionPerformed(e);
        }

    });

    //======== frame ========
    {
        Container frameContentPane = frame.getContentPane();
        frameContentPane.setLayout(new BorderLayout());

        //======== outerPanel ========
        {

            frameContentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
                public void propertyChange(java.beans.PropertyChangeEvent e) {
                    if ("border".equals(e.getPropertyName()))
                        throw new RuntimeException();
                }
            });

            //======== topPanel ========
            {
                FormLayout topPanelLayout = new FormLayout(
                        " 32dlu, default,  4dlu, default,  32dlu, default,  4dlu, default, 32dlu, default,  4dlu, 64dlu, 32dlu",
                        "center:25dlu");
                topPanel.setLayout(topPanelLayout);

                //---- displayLabel ----
                displayLabel.setText("Display:");
                topPanel.add(displayLabel, cc.xy(2, 1));
                //======== scrollPaneForTopList1 ========
                {
                    //---- displayComboBox ----
                    ActionListener actionListener = new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            ItemSelectable is = (ItemSelectable) actionEvent.getSource();
                            Object[] selections = is.getSelectedObjects();
                            String selection = (String) selections[0];
                            ccmTableModel.setLoadedFilterValue(selection);
                            sorter.setRowFilter(combinedFilter);
                            ccmTableModel.fireTableDataChanged();
                        }
                    };

                    displayComboBox.addActionListener(actionListener);
                }
                topPanel.add(displayComboBox, cc.xy(4, 1));

                //---- showByTypeLabel ----
                showByTypeLabel.setText("Show by type:");
                topPanel.add(showByTypeLabel, cc.xy(6, 1));
                //======== scrollPaneForTopList2 ========
                {
                    //---- showByTypeComboBox ----
                    ActionListener actionListener2 = new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            ItemSelectable is = (ItemSelectable) actionEvent.getSource();
                            Object[] selections = is.getSelectedObjects();
                            String selection = (String) selections[0];
                            ccmTableModel.setTypeFilterValue(selection);
                            sorter.setRowFilter(combinedFilter);
                            ccmTableModel.fireTableDataChanged();
                        }
                    };

                    showByTypeComboBox.addActionListener(actionListener2);
                }
                topPanel.add(showByTypeComboBox, cc.xy(8, 1));

                //---- topLabel3 ----               
                topPanel.add(keywordSearchLabel, cc.xy(10, 1));

                //======== scrollPaneForTopList3 ========
                {
                    // ---- keywordSearchField ----
                    KeyListener actionListener3 = new KeyListener() {

                        public void keyPressed(KeyEvent e) {
                        }

                        public void keyReleased(KeyEvent e) {
                            String text = keywordSearchField.getText();
                            ccmTableModel.setKeywordFilterValue(text);
                            sorter.setRowFilter(combinedFilter);
                            ccmTableModel.fireTableDataChanged();
                        }

                        public void keyTyped(KeyEvent e) {
                        }
                    };

                    keywordSearchField.setText("Enter Text");
                    keywordSearchField.addKeyListener(actionListener3);
                }
                topPanel.add(keywordSearchField, cc.xy(12, 1));
            } // Top Panel
            frameContentPane.add(topPanel, BorderLayout.NORTH);

            //======== splitPane ========
            {
                splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
                splitPane.setResizeWeight(0.5);

                //======== scrollPaneForTable ========
                {
                    //---- table ----
                    ccmTableModel = new CCMTableModel(manager);
                    setOriginalChoices();
                    table = new JTable(ccmTableModel);
                    sorter = new TableRowSorter<CCMTableModel>(ccmTableModel);
                    table.setRowSorter(sorter);

                    table.setDefaultRenderer(Object.class, new CellRenderer());
                    table.setDefaultRenderer(CCMTableModel.ImageLink.class, new ImageLinkRenderer());
                    table.setDefaultRenderer(CCMTableModel.HyperLink.class, new HyperLinkRenderer());
                    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

                    ListSelectionModel cellSM = table.getSelectionModel();
                    cellSM.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                    cellSM.addListSelectionListener(new ListSelectionListener() {
                        public void valueChanged(ListSelectionEvent e) {
                            boolean adjusting = e.getValueIsAdjusting();
                            if (adjusting) {
                                return;
                            }
                            int selectedRow = table.getSelectedRow();
                            ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                            if (lsm.isSelectionEmpty()) {
                                textPane.setText(" ");
                            } else {
                                String description = (String) ccmTableModel.getValueAt(
                                        table.convertRowIndexToModel(selectedRow),
                                        CCMTableModel.DESCRIPTION_INDEX);
                                textPane.setText(description);

                                if (textPane.getCaretPosition() > 1) {
                                    textPane.setCaretPosition(1);
                                }
                            }
                        }
                    });

                    table.addMouseListener(new MouseAdapter() {

                        @Override
                        public void mouseClicked(java.awt.event.MouseEvent event) {
                            launchBrowser();
                        }
                    });

                    TableColumn column = table.getColumnModel().getColumn(CCMTableModel.SELECTION_INDEX);
                    column.setMaxWidth(50);
                    column = table.getColumnModel().getColumn(CCMTableModel.VERSION_INDEX);
                    column.setMaxWidth(60);
                    column = table.getColumnModel().getColumn(CCMTableModel.TUTORIAL_URL_INDEX);
                    column.setMaxWidth(70);
                    column = table.getColumnModel().getColumn(CCMTableModel.TOOL_URL_INDEX);
                    column.setMaxWidth(70);

                    scrollPaneForTable = new JScrollPane(table);
                }
                splitPane.setTopComponent(scrollPaneForTable);

                //======== scrollPaneForTextPane ========
                {
                    //---- textPane ----
                    textPane.setEditable(false);
                    scrollPaneForTextPane.setViewportView(textPane);
                }
                splitPane.setBottomComponent(scrollPaneForTextPane);
            } //======== splitPane ========.
            frameContentPane.add(splitPane, BorderLayout.CENTER);

            //======== bottompanel ========
            {
                bottompanel.setLayout(new FormLayout("20dlu," + "default,  4dlu, " + // view License
                        "default,200dlu, " + // Apply
                        "default,  4dlu, " + // Reset
                        "default,  4dlu, " + // Cancel
                        "default " // Close
                        , "center:25dlu"));

                viewLicenseButton.setText("View License");
                bottompanel.add(viewLicenseButton, cc.xy(2, 1));

                //---- applyButton ----
                applyButton.setText("Apply");
                bottompanel.add(applyButton, cc.xy(6, 1));

                //---- resetButton ----
                resetButton.setText("Reset");
                bottompanel.add(resetButton, cc.xy(8, 1));

                //---- closeButton ----
                closeButton.setText("Close");
                bottompanel.add(closeButton, cc.xy(10, 1));

            } //======== bottompanel ========.
            frameContentPane.add(bottompanel, BorderLayout.SOUTH);
        } //======== outerPanel ========
        frame.pack();
        frame.setLocationRelativeTo(frame.getOwner());
    } // ============ frame ============

    topPanel.setVisible(true);
    splitPane.setVisible(true);
    scrollPaneForTable.setVisible(true);
    table.setVisible(true);
    scrollPaneForTextPane.setVisible(true);
    textPane.setVisible(true);
    bottompanel.setVisible(true);
    sorter.setRowFilter(combinedFilter);
    frame.setVisible(true);
    splitPane.setDividerLocation(.7d);
}

From source file:org.geworkbench.engine.ccm.ComponentConfigurationManagerWindow2.java

/**
 * Set up the GUI//from  ww w.  ja  va  2 s.  c o m
 * 
 * @param void
 * @return void
 */
private void initComponents() {
    frame = new JFrame("geWorkbench - Component Configuration Manager");

    topPanel = new JPanel();
    displayLabel = new JLabel();
    String[] displayChoices = { DISPLAY_FILTER_ALL, DISPLAY_ONLY_LOADED, DISPLAY_ONLY_UNLOADED };
    displayComboBox = new JComboBox(displayChoices);
    showByTypeLabel = new JLabel();
    String[] showByTypeChoices = new String[PluginComponent.categoryList.size() + 2];
    showByTypeChoices[0] = SHOW_BY_TYPE_ALL;
    int index = 1;
    for (String s : PluginComponent.categoryList) {
        showByTypeChoices[index] = s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
        index++;
    }
    ;
    showByTypeChoices[index] = SHOW_BY_TYPE_OTHERS;
    Arrays.sort(showByTypeChoices);
    showByTypeComboBox = new JComboBox(showByTypeChoices);
    showByTypeComboBox.setMaximumRowCount(showByTypeChoices.length);
    keywordSearchLabel = new JLabel("Keyword search:");
    keywordSearchField = new JTextField("Enter Text");
    splitPane = new JSplitPane();
    scrollPaneForTextPane = new JScrollPane();
    textPane = new JTextPane();
    bottompanel = new JPanel();
    CellConstraints cc = new CellConstraints();

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            ccmWindow = null;
        }
    });

    viewLicenseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            viewLicense_actionPerformed(e);
        }
    });

    applyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            applyCcmSelections_actionPerformed(e);
        }
    });
    resetButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            resetCcmSelections_actionPerformed(e);
        }

    });
    closeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeCcmSelections_actionPerformed(e);
        }

    });
    componentUpdateButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            componentRemoteUpdate_actionPerformed(e);
        }

    });

    //======== frame ========
    {
        Container frameContentPane = frame.getContentPane();
        frameContentPane.setLayout(new BorderLayout());

        //======== outerPanel ========
        {

            frameContentPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
                public void propertyChange(java.beans.PropertyChangeEvent e) {
                    if ("border".equals(e.getPropertyName()))
                        throw new RuntimeException();
                }
            });

            //======== topPanel ========
            {
                FormLayout topPanelLayout = new FormLayout(
                        " 32dlu, default,  4dlu, default,  32dlu, default,  4dlu, default, 32dlu, default,  4dlu, 64dlu, 32dlu",
                        "center:25dlu");
                topPanel.setLayout(topPanelLayout);

                //---- displayLabel ----
                displayLabel.setText("Display:");
                topPanel.add(displayLabel, cc.xy(2, 1));
                //======== scrollPaneForTopList1 ========
                {
                    //---- displayComboBox ----
                    ActionListener actionListener = new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            ItemSelectable is = (ItemSelectable) actionEvent.getSource();
                            Object[] selections = is.getSelectedObjects();
                            String selection = (String) selections[0];
                            ccmTableModel.setLoadedFilterValue(selection);
                            sorter.setRowFilter(combinedFilter);
                            ccmTableModel.fireTableDataChanged();
                        }
                    };

                    displayComboBox.addActionListener(actionListener);
                }
                topPanel.add(displayComboBox, cc.xy(4, 1));

                //---- showByTypeLabel ----
                showByTypeLabel.setText("Show by type:");
                topPanel.add(showByTypeLabel, cc.xy(6, 1));
                //======== scrollPaneForTopList2 ========
                {
                    //---- showByTypeComboBox ----
                    ActionListener actionListener2 = new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            ItemSelectable is = (ItemSelectable) actionEvent.getSource();
                            Object[] selections = is.getSelectedObjects();
                            String selection = (String) selections[0];
                            ccmTableModel.setTypeFilterValue(selection);
                            sorter.setRowFilter(combinedFilter);
                            ccmTableModel.fireTableDataChanged();
                        }
                    };

                    showByTypeComboBox.addActionListener(actionListener2);
                }
                topPanel.add(showByTypeComboBox, cc.xy(8, 1));

                //---- topLabel3 ----               
                topPanel.add(keywordSearchLabel, cc.xy(10, 1));

                //======== scrollPaneForTopList3 ========
                {
                    // ---- keywordSearchField ----
                    KeyListener actionListener3 = new KeyListener() {

                        public void keyPressed(KeyEvent e) {
                        }

                        public void keyReleased(KeyEvent e) {
                            String text = keywordSearchField.getText();
                            ccmTableModel.setKeywordFilterValue(text);
                            sorter.setRowFilter(combinedFilter);
                            ccmTableModel.fireTableDataChanged();
                        }

                        public void keyTyped(KeyEvent e) {
                        }
                    };

                    keywordSearchField.setText("Enter Text");
                    keywordSearchField.addKeyListener(actionListener3);
                }
                topPanel.add(keywordSearchField, cc.xy(12, 1));
            } // Top Panel
            frameContentPane.add(topPanel, BorderLayout.NORTH);

            //======== splitPane ========
            {
                splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
                splitPane.setResizeWeight(0.5);

                //======== scrollPaneForTable ========
                {
                    //---- table ----
                    ccmTableModel = new CCMTableModel2(manager.componentConfigurationManager);
                    setOriginalChoices();
                    table = new JTable(ccmTableModel);
                    sorter = new TableRowSorter<CCMTableModel2>(ccmTableModel);
                    table.setRowSorter(sorter);

                    table.setDefaultRenderer(Object.class, new CellRenderer());
                    table.setDefaultRenderer(CCMTableModel2.ImageLink.class, new ImageLinkRenderer());
                    table.setDefaultRenderer(CCMTableModel2.HyperLink.class, new HyperLinkRenderer());
                    table.setDefaultRenderer(CCMTableModel2.DownloadLink.class, new DownloadLinkRenderer());
                    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

                    ListSelectionModel cellSM = table.getSelectionModel();
                    cellSM.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                    cellSM.addListSelectionListener(new ListSelectionListener() {
                        public void valueChanged(ListSelectionEvent e) {
                            boolean adjusting = e.getValueIsAdjusting();
                            if (adjusting) {
                                return;
                            }
                            int[] selectedRow = table.getSelectedRows();
                            ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                            if (lsm.isSelectionEmpty()) {
                                textPane.setText(" ");
                            } else {
                                String description = (String) ccmTableModel.getValueAt(
                                        table.convertRowIndexToModel(selectedRow[0]),
                                        CCMTableModel2.DESCRIPTION_INDEX);
                                textPane.setText(description);

                                if (textPane.getCaretPosition() > 1) {
                                    textPane.setCaretPosition(1);
                                }
                            }

                            if (table.getSelectedRow() >= 0) {
                                int modelColumn = table.convertColumnIndexToModel(table.getSelectedColumn());
                                if (modelColumn == CCMTableModel2.AVAILABLE_UPDATE_INDEX)
                                    installRemoteComponent();
                                else
                                    launchBrowser();
                            }
                        }
                    });

                    TableColumn column = table.getColumnModel().getColumn(CCMTableModel2.SELECTION_INDEX);
                    column.setMaxWidth(50);
                    column = table.getColumnModel().getColumn(CCMTableModel2.VERSION_INDEX);
                    column.setMaxWidth(60);
                    column = table.getColumnModel().getColumn(CCMTableModel2.AVAILABLE_UPDATE_INDEX);
                    column.setMaxWidth(60);
                    column = table.getColumnModel().getColumn(CCMTableModel2.TUTORIAL_URL_INDEX_2);
                    column.setMaxWidth(70);
                    column = table.getColumnModel().getColumn(CCMTableModel2.TOOL_URL_INDEX_2);
                    column.setMaxWidth(70);

                    scrollPaneForTable = new JScrollPane(table);
                }
                splitPane.setTopComponent(scrollPaneForTable);

                //======== scrollPaneForTextPane ========
                {
                    //---- textPane ----
                    textPane.setEditable(false);
                    scrollPaneForTextPane.setViewportView(textPane);
                }
                splitPane.setBottomComponent(scrollPaneForTextPane);
            } //======== splitPane ========.
            frameContentPane.add(splitPane, BorderLayout.CENTER);

            //======== bottompanel ========
            {
                bottompanel.setLayout(new FormLayout("20dlu," + "default,  4dlu, " + // view License
                        "default,100dlu, " + // Component Update
                        "default,  4dlu, " + // Apply
                        "default,  4dlu, " + // Reset
                        "default,  4dlu, " + // Cancel
                        "default " // Close
                        , "center:25dlu"));

                viewLicenseButton.setText("View License");
                bottompanel.add(viewLicenseButton, cc.xy(2, 1));

                //---- componentUpdateButton ----
                bottompanel.add(componentUpdateButton, cc.xy(6, 1));

                //---- applyButton ----
                applyButton.setText("Apply");
                bottompanel.add(applyButton, cc.xy(8, 1));

                //---- resetButton ----
                resetButton.setText("Reset");
                bottompanel.add(resetButton, cc.xy(10, 1));

                //---- closeButton ----
                closeButton.setText("Close");
                bottompanel.add(closeButton, cc.xy(12, 1));

            } //======== bottompanel ========.
            frameContentPane.add(bottompanel, BorderLayout.SOUTH);
        } //======== outerPanel ========
        frame.pack();
        frame.setLocationRelativeTo(frame.getOwner());
    } // ============ frame ============

    topPanel.setVisible(true);
    splitPane.setVisible(true);
    scrollPaneForTable.setVisible(true);
    table.setVisible(true);
    scrollPaneForTextPane.setVisible(true);
    textPane.setVisible(true);
    bottompanel.setVisible(true);
    sorter.setRowFilter(combinedFilter);
    frame.setVisible(true);
    splitPane.setDividerLocation(.7d);
}

From source file:org.nuclos.client.ui.collect.result.ResultController.java

private ListSelectionListener newListSelectionListener(final JTable tblResult) {
    return new ListSelectionListener() {
        @Override/*from   w ww .  j a v  a 2s.  c om*/
        public void valueChanged(ListSelectionEvent ev) {
            try {
                final ListSelectionModel lsm = (ListSelectionModel) ev.getSource();

                final CollectStateModel<?> clctstatemodel = clctctl.getCollectStateModel();
                if (clctstatemodel.getOuterState() == CollectState.OUTERSTATE_RESULT) {
                    final int iResultMode = CollectStateModel.getResultModeFromSelectionModel(lsm);
                    if (iResultMode != clctctl.getCollectStateModel().getResultMode()) {
                        clctctl.setCollectState(CollectState.OUTERSTATE_RESULT, iResultMode);
                    }
                }

                if (!ev.getValueIsAdjusting()) {
                    // Autoscroll selection. It's okay to do that here rather than in the CollectStateListener.
                    if (!lsm.isSelectionEmpty() && tblResult.getAutoscrolls()) {
                        // ensure that the last selected row is visible:
                        final int iRowIndex = lsm.getLeadSelectionIndex();
                        final int iColIndex = tblResult.getSelectedColumn();
                        final Rectangle rectCell = tblResult.getCellRect(iRowIndex,
                                iColIndex != -1 ? iColIndex : 0, true);
                        if (rectCell != null) {
                            tblResult.scrollRectToVisible(rectCell);
                        }
                    }
                }
            } catch (CommonBusinessException ex) {
                Errors.getInstance().showExceptionDialog(clctctl.getTab(), ex);
            }
        } // valueChanged
    };
}

From source file:org.ow2.aspirerfid.demos.warehouse.management.UI.WarehouseManagement.java

/**
 * Initialize the contents of the frame/*from w w w  .ja  va  2 s  .  c  o  m*/
 */
private void initialize() {

    final JTabbedPane tabbedPane;
    final JPanel deliveryPanel;
    final JLabel entryDateLabel;
    final JLabel entryDateLabel_1;
    final JLabel entryDateLabel_2;
    final JLabel entryDateLabel_3;
    final JLabel entryDateLabel_3_1;
    final JLabel entryDateLabel_3_2;
    final JPanel shipmentPanel;
    final JLabel entryDateLabel_3_1_1;
    final JLabel entryDateLabel_3_1_2;
    final JScrollPane scrollPane;
    final JButton printReportButton;
    final JButton saveReportButton;
    final JButton activateDoorButton;
    final JButton deactivateDoorButton;
    final JButton clearReportButton;
    final JPanel panel;
    final JLabel entryDateLabel_3_3;
    final JLabel entryDateLabel_2_1;
    frame = new JFrame();
    frame.getContentPane().setLayout(new BorderLayout());
    frame.setTitle("Warehouse Management");
    frame.setBounds(100, 100, 1011, 625);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    tabbedPane = new JTabbedPane();
    frame.getContentPane().add(tabbedPane);

    deliveryPanel = new JPanel();
    deliveryPanel.setLayout(null);
    tabbedPane.addTab("Delivery Counter", null, deliveryPanel, null);

    entryDateLabel = new JLabel();
    entryDateLabel.setText("Entry Date .........");
    entryDateLabel.setBounds(533, 23, 117, 16);
    deliveryPanel.add(entryDateLabel);

    entryDateLabel_1 = new JLabel();
    entryDateLabel_1.setText("User ID ................");
    entryDateLabel_1.setBounds(10, 94, 117, 16);
    deliveryPanel.add(entryDateLabel_1);

    entryDateLabel_2 = new JLabel();
    entryDateLabel_2.setText("Invoice ID ............");
    entryDateLabel_2.setBounds(10, 23, 117, 16);
    deliveryPanel.add(entryDateLabel_2);

    entryDateLabel_3 = new JLabel();
    entryDateLabel_3.setText("Warehouse ID....");
    entryDateLabel_3.setBounds(10, 45, 117, 16);
    deliveryPanel.add(entryDateLabel_3);

    entryDateLabel_3_1 = new JLabel();
    entryDateLabel_3_1.setText("Zone ID ................");
    entryDateLabel_3_1.setBounds(10, 67, 117, 16);
    deliveryPanel.add(entryDateLabel_3_1);

    entryDateLabel_3_2 = new JLabel();
    entryDateLabel_3_2.setText("Entry Hour .........");
    entryDateLabel_3_2.setBounds(533, 45, 117, 16);
    deliveryPanel.add(entryDateLabel_3_2);

    entryDateLabel_3_1_1 = new JLabel();
    entryDateLabel_3_1_1.setText("Offering Date ....");
    entryDateLabel_3_1_1.setBounds(533, 70, 117, 16);
    deliveryPanel.add(entryDateLabel_3_1_1);

    entryDateLabel_3_1_2 = new JLabel();
    entryDateLabel_3_1_2.setText("Offering Hour ....");
    entryDateLabel_3_1_2.setBounds(533, 94, 117, 16);
    deliveryPanel.add(entryDateLabel_3_1_2);

    invoiceIDTextField = new JTextField();
    invoiceIDTextField.setBounds(105, 19, 365, 20);
    deliveryPanel.add(invoiceIDTextField);

    warehouseIDTextField = new JTextField();
    warehouseIDTextField.setBounds(105, 43, 365, 20);
    deliveryPanel.add(warehouseIDTextField);

    zoneIDTextField = new JTextField();
    zoneIDTextField.setBounds(105, 66, 365, 20);
    deliveryPanel.add(zoneIDTextField);

    userIDTextField = new JTextField();
    userIDTextField.setBounds(105, 90, 365, 20);
    deliveryPanel.add(userIDTextField);

    entryDateTextField = new JTextField();
    entryDateTextField.setBounds(623, 19, 365, 20);
    deliveryPanel.add(entryDateTextField);

    entryHourTextField = new JTextField();
    entryHourTextField.setBounds(623, 41, 365, 20);
    deliveryPanel.add(entryHourTextField);

    offeringDateTextField = new JTextField();
    offeringDateTextField.setBounds(623, 66, 365, 20);
    deliveryPanel.add(offeringDateTextField);

    offeringHourTextField = new JTextField();
    offeringHourTextField.setBounds(623, 90, 365, 20);
    deliveryPanel.add(offeringHourTextField);

    scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 129, 978, 355);
    deliveryPanel.add(scrollPane);

    deliveryTableModel = new DefaultTableModel();// All Clients Items
    deliveryTableModel.addColumn("Company");
    deliveryTableModel.addColumn("Item Code");
    deliveryTableModel.addColumn("Description");
    deliveryTableModel.addColumn("Quantity Delivered");
    deliveryTableModel.addColumn("Expected Quantity");
    deliveryTableModel.addColumn("Quantity Remain");
    deliveryTableModel.addColumn("Delivery Date");
    deliveryTableModel.addColumn("Measurement ID");
    deliveryTableModel.addColumn("Quantity");
    deliveryTable = new JTable(deliveryTableModel);
    deliveryTable.setFont(new Font("Arial Narrow", Font.PLAIN, 10));
    deliveryTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    scrollPane.setViewportView(deliveryTable);

    ListSelectionModel rowSM = deliveryTable.getSelectionModel();

    printReportButton = new JButton();
    printReportButton.setText("Print Report");
    printReportButton.setBounds(860, 520, 117, 26);
    deliveryPanel.add(printReportButton);

    saveReportButton = new JButton();
    saveReportButton.setText("Save Report");
    saveReportButton.setBounds(614, 520, 117, 26);
    deliveryPanel.add(saveReportButton);

    activateDoorButton = new JButton();
    activateDoorButton.addMouseListener(new ActivateDoorButtonMouseListener());
    activateDoorButton.setText("Activate Door");
    activateDoorButton.setBounds(50, 520, 117, 26);
    deliveryPanel.add(activateDoorButton);

    deactivateDoorButton = new JButton();
    deactivateDoorButton.addMouseListener(new DeactivateDoorButtonMouseListener());
    deactivateDoorButton.setText("Dectivate Door");
    deactivateDoorButton.setBounds(173, 520, 117, 26);
    deliveryPanel.add(deactivateDoorButton);

    clearReportButton = new JButton();
    clearReportButton.addMouseListener(new ClearReportButtonMouseListener());
    clearReportButton.setText("Clear Report");
    clearReportButton.setBounds(737, 520, 117, 26);
    deliveryPanel.add(clearReportButton);
    rowSM.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            // Ignore extra messages.
            if (e.getValueIsAdjusting())
                return;

            ListSelectionModel lsm = (ListSelectionModel) e.getSource();
            if (lsm.isSelectionEmpty()) {
                // no rows are selected
            } else {
                selectedRow = lsm.getMinSelectionIndex();
                System.out.println("selectedRow = " + selectedRow);

            }
        }
    });

    shipmentPanel = new JPanel();
    tabbedPane.addTab("Shipment", null, shipmentPanel, null);

    panel = new JPanel();
    panel.setLayout(null);
    tabbedPane.addTab("Door Config", null, panel, null);

    aleListeningPortTextField = new JTextField();
    aleListeningPortTextField.setText("9999");
    aleListeningPortTextField.setBounds(172, 41, 330, 20);
    panel.add(aleListeningPortTextField);

    epcisRepositoryURLTextField = new JTextField();
    epcisRepositoryURLTextField.setText("http://localhost:8080/aspire0.3.0EpcisRepository/capture");
    epcisRepositoryURLTextField.setBounds(172, 65, 330, 20);
    panel.add(epcisRepositoryURLTextField);

    entryDateLabel_3_3 = new JLabel();
    entryDateLabel_3_3.setText("EPCIS Rep. URL .........");
    entryDateLabel_3_3.setBounds(51, 67, 117, 16);
    panel.add(entryDateLabel_3_3);

    entryDateLabel_2_1 = new JLabel();
    entryDateLabel_2_1.setText("ALE Listening Port ....");
    entryDateLabel_2_1.setBounds(51, 43, 117, 16);
    panel.add(entryDateLabel_2_1);

}

From source file:org.processmining.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Updates both the visualization and the performance metrics by taking only
 * the selected instances into account. If all instances have been selected,
 * the result corresponds to the initial state.
 *//*w w  w  . j  ava 2  s  . c o  m*/
private void updateResults() {
    try {
        // check if selection is empty --> if so select whole log
        ListSelectionModel selectionModel = processInstanceIDsTable.getSelectionModel();
        if (selectionModel.isSelectionEmpty()) {
            selectionModel.addSelectionInterval(0, extendedLog.getSizeOfLog() - 1);
        }
        // invoke redraw of vizualization for selected process instances
        // only..
        ArrayList selectedInstanceIDs = getSelectedInstanceIDs();
        ArrayList selectedInstances = getSelectedInstances();

        grappaPanel = replayResult.getVisualization(selectedInstanceIDs);
        grappaPanel.addGrappaListener(new ExtendedGrappaAdapter());
        mapping = new HashMap();
        buildGraphMapping(mapping, grappaPanel.getSubgraph());
        modelContainer = new JScrollPane(grappaPanel);
        centerPanel.removeAll();
        centerPanel.add(modelContainer, BorderLayout.CENTER);
        centerPanel.validate();
        centerPanel.repaint();
        // update process metrics and display them
        displayProcessMetrics(selectedInstances);
        // calculate the values for the simulation model
        calculateValuesForSimulationModel(getSelectedInstances(), getSelectedInstanceIDs());
        // update the provided object (visualization might have changed)
        extendedPetriNet = (ExtendedPetriNet) replayResult.replayedPetriNet;
        // Make sure that what was selected before the update, is now
        // selected again.
        if (elt1 instanceof ExtendedTransition) {
            // transition was selected, select it again in sb1
            ExtendedTransition trans = (ExtendedTransition) elt1;
            sb1.setSelectedItem("Transition - " + trans.getLogEvent().getModelElementName() + " "
                    + trans.getLogEvent().getEventType());
            if (elt2 instanceof ExtendedTransition) {
                // another transition was selected too, select it again in
                // sb2
                trans = (ExtendedTransition) elt2;
                sb2.setSelectedItem("Transition - " + trans.getLogEvent().getModelElementName() + " "
                        + trans.getLogEvent().getEventType());
            }
        } else if (elt1 instanceof ExtendedPlace) {
            // place was selected, select it in sb1
            ExtendedPlace place = (ExtendedPlace) elt1;
            sb1.setSelectedItem("Place - " + place.getIdentifier());
        } else {
            // nothing selected, set sb1 and sb2 to index 0
            sb1.setSelectedIndex(0);
            sb2.setSelectedIndex(0);
        }
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(this, "An internal error occured while\nupdating the visualization.");
        Message.add("Probably not found.\n" + ex.toString(), 2);
        ex.printStackTrace();
    }
}

From source file:org.prom5.analysis.performance.PerformanceAnalysisGUI.java

/**
 * Updates both the visualization and the performance metrics by taking only
 * the selected instances into account. If all instances have been selected,
 * the result corresponds to the initial state.
 *///from   w ww. ja  v a 2 s.  com
private void updateResults() {
    try {
        // check if selection is empty --> if so select whole log
        ListSelectionModel selectionModel = processInstanceIDsTable.getSelectionModel();
        if (selectionModel.isSelectionEmpty()) {
            selectionModel.addSelectionInterval(0, extendedLog.getSizeOfLog() - 1);
        }
        // invoke redraw of vizualization for selected process instances only..
        ArrayList selectedInstanceIDs = getSelectedInstanceIDs();
        ArrayList selectedInstances = getSelectedInstances();

        grappaPanel = replayResult.getVisualization(selectedInstanceIDs);
        grappaPanel.addGrappaListener(new ExtendedGrappaAdapter());
        mapping = new HashMap();
        buildGraphMapping(mapping, grappaPanel.getSubgraph());
        modelContainer = new JScrollPane(grappaPanel);
        centerPanel.removeAll();
        centerPanel.add(modelContainer, BorderLayout.CENTER);
        centerPanel.validate();
        centerPanel.repaint();
        //update process metrics and display them
        displayProcessMetrics(selectedInstances);
        //calculate the values for the simulation model
        calculateValuesForSimulationModel(getSelectedInstances(), getSelectedInstanceIDs());
        // update the provided object (visualization might have changed)
        extendedPetriNet = (ExtendedPetriNet) replayResult.replayedPetriNet;
        //Make sure that what was selected before the update, is now
        //selected again.
        if (elt1 instanceof ExtendedTransition) {
            //transition was selected, select it again in sb1
            ExtendedTransition trans = (ExtendedTransition) elt1;
            sb1.setSelectedItem("Transition - " + trans.getLogEvent().getModelElementName() + " "
                    + trans.getLogEvent().getEventType());
            if (elt2 instanceof ExtendedTransition) {
                //another transition was selected too, select it again in sb2
                trans = (ExtendedTransition) elt2;
                sb2.setSelectedItem("Transition - " + trans.getLogEvent().getModelElementName() + " "
                        + trans.getLogEvent().getEventType());
            }
        } else if (elt1 instanceof ExtendedPlace) {
            //place was selected, select it in sb1
            ExtendedPlace place = (ExtendedPlace) elt1;
            sb1.setSelectedItem("Place - " + place.getIdentifier());
        } else {
            //nothing selected, set sb1 and sb2 to index 0
            sb1.setSelectedIndex(0);
            sb2.setSelectedIndex(0);
        }
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(this, "An internal error occured while\nupdating the visualization.");
        Message.add("Probably not found.\n" + ex.toString(), 2);
        ex.printStackTrace();
    }
}

From source file:org.spottedplaid.ui.Mainframe.java

/**
 * Create the frame.//from   www . ja v a  2  s  .co m
 *
 * @param _Sqliteops the _ sqliteops
 * @param _Crypto the _ crypto
 */
public Mainframe(SQliteOps _Sqliteops, Crypto _Crypto) {

    l_sqliteops = _Sqliteops;
    l_crypto = _Crypto;

    setTitle("The Password Saver - Management");
    setResizable(false);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setBounds(100, 100, 982, 656);

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnFile = new JMenu("File");
    menuBar.add(mnFile);

    JMenuItem mntmExit = new JMenuItem("Exit");
    mntmExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            System.exit(0);
        }
    });

    mnFile.add(mntmExit);

    JMenu mnTools = new JMenu("Tools");
    menuBar.add(mnTools);

    JMenuItem mntmChgpwd = new JMenuItem("Change Passphrase");
    mntmChgpwd.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Changepwd changePwd = new Changepwd(l_crypto, l_sqliteops);
            changePwd.setVisible(true);
        }
    });

    mnTools.add(mntmChgpwd);

    JMenuItem mntmExpirationReport = new JMenuItem("Expiration Report");
    mntmExpirationReport.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            DbRecord dbRecExp = new DbRecord();
            dbRecExp.setType(Pwdtypes.S_EXP_RPT);
            ArrayList<String> arrData = l_sqliteops.getRecords(dbRecExp);
            String[] sRecord = new String[3];
            String sData = "";
            int iElement = 0;

            /// Cycle through the data, output to text file, and open in WordPad
            if (arrData != null && arrData.size() > 0) {
                try {
                    String sFilename = "ExpirationReport.txt";
                    File fileExpRpt = new File(sFilename);

                    BufferedWriter buffWriter = new BufferedWriter(new FileWriter(fileExpRpt));
                    buffWriter.write("URL/Application                Challenge            Expiration");
                    buffWriter.write("\n");
                    buffWriter.write("--------------------------------------------------------------");
                    buffWriter.write("\n");
                    for (int iCount = 0; iCount < arrData.size(); iCount++) {
                        sData = arrData.get(iCount);
                        System.out.println("DEBUG->sData [" + sData + "]");
                        StringTokenizer st = new StringTokenizer(sData, "|");
                        iElement = 0;
                        while (st.hasMoreTokens()) {
                            sRecord[iElement] = st.nextToken();
                            iElement++;
                        }

                        /// Define the padding for the output
                        int iPadValue1 = 35 - sRecord[0].length();
                        if (iPadValue1 < 0) {
                            iPadValue1 = 2;
                        }

                        int iPadValue2 = 55 - (35 + sRecord[1].length());
                        if (iPadValue2 < 0) {
                            iPadValue2 = 2;
                        }

                        iPadValue1 += sRecord[1].length();
                        iPadValue2 += sRecord[2].length();

                        buffWriter.write(sRecord[0] + StringUtils.leftPad(sRecord[1], iPadValue1)
                                + StringUtils.leftPad(sRecord[2], iPadValue2) + "\n");
                        buffWriter.write("\n");
                    }
                    buffWriter.close();

                    /// Opens WordPad on Windows systems.  This could be changed to use a property in order to work on a linux/unix/apple system
                    ProcessBuilder pb = new ProcessBuilder("write.exe", sFilename);
                    pb.start();
                } catch (IOException ie) {
                    System.out.println("Expiration Report IO Exception [" + ie.getMessage() + "]");
                    ie.printStackTrace();
                }

            } else {
                JOptionPane.showMessageDialog(null, "No expiring records found");
            }
        }
    });
    mnTools.add(mntmExpirationReport);

    JMenuItem mntmViewLogs = new JMenuItem("View Logs");
    mntmViewLogs.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DbRecord dbRecLogs = new DbRecord();
            dbRecLogs.setType(Pwdtypes.S_LOG_TYPE);
            ArrayList<String> arrData = l_sqliteops.getRecords(dbRecLogs);
            String[] sRecord = new String[3];
            String sData = "";
            String sTitle = "Display Data Changes";
            String sDisplay = "Date                  Log Message";
            sDisplay += "\n";
            int iElement = 0;

            /// Cycle through the data, output to text file, and open in WordPad
            if (arrData != null) {
                for (int iCount = 0; iCount < arrData.size(); iCount++) {
                    sData = arrData.get(iCount);
                    System.out.println("DEBUG->sData [" + sData + "]");
                    StringTokenizer st = new StringTokenizer(sData, "|");
                    iElement = 0;
                    while (st.hasMoreTokens()) {
                        sRecord[iElement] = st.nextToken();
                        iElement++;
                    }
                    sDisplay += sRecord[2] + ":" + sRecord[1];
                    sDisplay += "\n";
                }

                if (arrData.size() > 0) {
                    JOptionPane.showMessageDialog(null, sDisplay, sTitle, JOptionPane.INFORMATION_MESSAGE);
                }

            }
        }
    });

    mnTools.add(mntmViewLogs);

    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);

    JLabel lblThePasswordSaver = new JLabel("The Password Saver - Manage Passwords");
    lblThePasswordSaver.setFont(new Font("Arial", Font.BOLD, 16));
    lblThePasswordSaver.setHorizontalAlignment(SwingConstants.CENTER);

    JLabel lblUrlapplication = new JLabel("URL/Application");

    jtxtApp = new JTextField();
    jtxtApp.setColumns(10);

    JLabel lblDescription = new JLabel("Description");

    jtxtDesc = new JTextField();
    jtxtDesc.setColumns(10);

    /// Button - Add button for clients/apps
    JButton btnAdd = new JButton("Add");
    btnAdd.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (FormValidation.verifyAppData(jtxtApp.getText().toString(), jtxtDesc.getText().toString()) < 0) {
                JOptionPane.showMessageDialog(null, "URL/Application and Description are required");
            } else {
                dbRec = new DbRecord();
                dbRec.setType(Pwdtypes.S_CLIENT_TYPE);
                dbRec.setClientName(jtxtApp.getText().toString());
                dbRec.setClientDesc(jtxtDesc.getText().toString());
                int l_iClientId = l_sqliteops.insertRecord(dbRec);
                if (l_iClientId <= 0) {
                    JOptionPane.showMessageDialog(null, "Insert record failed [" + dbRec.getResult() + "]");
                } else {
                    dbRec.setClientId(l_iClientId);
                    addToTable();
                }
            }
        }
    });

    /// Buttons - Replace button for clients/apps
    btnReplace = new JButton("Replace");
    btnReplace.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (iClientId <= 0) {
                JOptionPane.showMessageDialog(null, "Update record warning: Please select record to continue");
                return;
            }
            dbRec = new DbRecord();
            dbRec.setType(Pwdtypes.S_CLIENT_TYPE);
            dbRec.setClientId(iClientId);
            dbRec.setClientName(jtxtApp.getText().toString());
            dbRec.setClientDesc(jtxtDesc.getText().toString());
            if (l_sqliteops.updateRecord(dbRec) < 0) {
                JOptionPane.showMessageDialog(null, "Update record failed [" + dbRec.getResult() + "]");
            } else {
                int iRow = jtabApps.getSelectedRow();
                jtabApps.setValueAt(jtxtApp.getText().toString(), iRow, 1);
                jtabApps.setValueAt(jtxtDesc.getText().toString(), iRow, 2);

                clearFields();
            }
        }
    });

    btnReplace.setEnabled(false);

    /// Button - Delete button for clients/apps
    btnDelete = new JButton("Delete");
    btnDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (iClientId <= 0) {
                JOptionPane.showMessageDialog(null,
                        "Delete record failed: Please select a record then click Delete");
                return;
            }
            dbRec = new DbRecord();
            dbRec.setType("clients");
            dbRec.setClientId(iClientId);
            dbRec.setDelCreds(0);

            if (chkDelAssoc.isSelected()) {
                dbRec.setDelCreds(1);
            }

            if (l_sqliteops.deleteRecord(dbRec) < 0) {
                JOptionPane.showMessageDialog(null, "Delete record failed [" + dbRec.getResult() + "]");
            } else {
                DefaultTableModel jtabModel = (DefaultTableModel) jtabApps.getModel();
                jtabModel.removeRow(jtabApps.getSelectedRow());
                if (chkDelAssoc.isSelected()) {
                    DefaultTableModel model = (DefaultTableModel) jtabCreds.getModel();
                    model.setRowCount(0);
                }
                clearFields();
            }
        }
    });
    btnDelete.setEnabled(false);

    /// Buttons - Search button for clients/apps
    btnSearch = new JButton("Search");
    btnSearch.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dbRec = new DbRecord();
            dbRec.setType(Pwdtypes.S_CLIENT_TYPE);
            dbRec.setClientName(jtxtApp.getText().toString());
            dbRec.setClientDesc(jtxtDesc.getText().toString());
            loadTable(dbRec);
        }
    });

    btnClear = new JButton("Clear");
    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            clearFields();
        }
    });

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    /// Begin section for credentials challenges/responses - text fields and buttons
    JLabel lblChallenge = new JLabel("Challenge");

    JLabel lblResponse = new JLabel("Response");

    jtxtChlng = new JTextField();
    jtxtChlng.setColumns(10);

    jtxtRsp = new JTextField();
    jtxtRsp.setColumns(10);

    /// Buttons - Add button for credentials
    btnCredAdd = new JButton("Add");
    btnCredAdd.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (FormValidation.verifyCredData(jtxtChlng.getText().toString(),
                    jtxtRsp.getText().toString()) < 0) {
                JOptionPane.showMessageDialog(null, "Challenge and Response are required");
            } else {
                dbRec = new DbRecord();
                dbRec.setType(Pwdtypes.S_CREDS_TYPE);
                dbRec.setClientId(iClientId);
                dbRec.setChallenge(jtxtChlng.getText().toString());
                dbRec.setResponse(l_crypto.encrypt(jtxtRsp.getText().toString()));
                dbRec.setTrack(jcbTrack.getSelectedItem().toString());

                /// Set the modify date if the track days are > 0
                if (!jcbTrack.getSelectedItem().toString().equals("0")) {
                    Calendar calNow = Calendar.getInstance();
                    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
                    int iDaysToAdd = Integer.parseInt(jcbTrack.getSelectedItem().toString());

                    calNow.add(Calendar.DATE, iDaysToAdd);
                    String sValue = sdf.format(calNow.getTime());
                    dbRec.setModifyDate(sValue);
                }

                int l_iClientId = l_sqliteops.insertRecord(dbRec);
                if (l_iClientId <= 0) {
                    JOptionPane.showMessageDialog(null, "Insert record failed [" + dbRec.getResult() + "]");
                } else {
                    dbRec.setCredId(l_iClientId);
                    addToCredsTable();
                }
            }
        }
    });

    /// Button - Replace button for credentials
    btnCredReplace = new JButton("Replace");
    btnCredReplace.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            DbRecord dbRecLog = new DbRecord();
            int iDaysToAdd = 0;
            Calendar calNow = Calendar.getInstance();
            SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy");

            String sCurDate = sdf1.format(calNow.getTime());
            String sValue = sDateModified;
            String sLogMsg = "";
            StringBuilder sbLogMsg = new StringBuilder(sLogMsg);

            if (dbRec.getType().equals(Pwdtypes.S_CREDS_TYPE) && (dbRec.getCredId() > 0)) {
                dbRec.setClientId(iClientId);
                dbRec.setCredId(iCredId);
                dbRec.setChallenge(jtxtChlng.getText().toString());
                dbRec.setResponse(l_crypto.encrypt(jtxtRsp.getText().toString()));
                dbRec.setTrack(jcbTrack.getSelectedItem().toString());

                /** Check for changes and insert log if necessary */
                if (!sChallenge.equals(jtxtChlng.getText())) {
                    sbLogMsg.append("Application [" + jtxtApp.getText() + "], Challenge modified, old ["
                            + sChallenge + "], new [" + jtxtChlng.getText() + "]");
                }

                if (!sResponse.equals(jtxtRsp.getText())) {
                    if (sbLogMsg.toString().length() > 0) {
                        sbLogMsg.append(",");
                    } else {
                        sbLogMsg.append("Application [" + jtxtApp.getText() + "],");
                    }
                    sbLogMsg.append("Response modified, old [" + sResponse + "]");
                }

                if (sbLogMsg.toString().length() > 0) {
                    dbRecLog.setType(Pwdtypes.S_LOG_TYPE);
                    dbRecLog.setLog(sbLogMsg.toString());
                    dbRecLog.setModifyDate(sCurDate);
                    if (l_sqliteops.insertRecord(dbRecLog) < 0) {
                        JOptionPane.showMessageDialog(null,
                                "Insert log record failed [" + dbRecLog.getResult() + "]");
                    }
                }

                if (!jcbTrack.getSelectedItem().toString().equals("0")) {
                    iDaysToAdd = Integer.parseInt(jcbTrack.getSelectedItem().toString());

                    calNow.add(Calendar.DATE, iDaysToAdd);
                    sValue = sdf1.format(calNow.getTime());

                    System.out.println("DEBUG->Date (sValue) [" + sValue + "]");
                    dbRec.setModifyDate(sValue);
                }
                /// Update the record
                if (l_sqliteops.updateRecord(dbRec) < 0) {
                    JOptionPane.showMessageDialog(null, "Update record failed [" + dbRec.getResult() + "]");
                } else {
                    int iRow = jtabCreds.getSelectedRow();
                    jtabCreds.setValueAt(jtxtChlng.getText().toString(), iRow, 1);
                    jtabCreds.setValueAt(l_crypto.encrypt(jtxtRsp.getText().toString()), iRow, 2);
                    jtabCreds.setValueAt(jcbTrack.getSelectedItem().toString(), iRow, 3);
                    jtabCreds.setValueAt(sValue, iRow, 4);

                    jtabCreds.setValueAt(sValue, iRow, 4);
                    clearCredsFields();
                    enableCredsButtons();
                }
            }
        }
    });

    /// Button - Delete button for credentials
    btnCredDelete = new JButton("Delete");
    btnCredDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dbRec.setType(Pwdtypes.S_CREDS_TYPE);
            dbRec.setCredId(iCredId);
            dbRec.setChallenge(jtxtChlng.getText().toString());
            dbRec.setResponse(jtxtRsp.getText().toString());
            if (l_sqliteops.deleteRecord(dbRec) < 0) {
                JOptionPane.showMessageDialog(null,
                        "Delete credential record failed [" + dbRec.getResult() + "]");
            } else {
                DefaultTableModel jtabModel = (DefaultTableModel) jtabCreds.getModel();
                jtabModel.removeRow(jtabCreds.getSelectedRow());
                clearCredsFields();
                enableCredsButtons();
            }
        }
    });

    /// Button - Clear button for credentials
    btnCredClear = new JButton("Clear");
    btnCredClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            clearCredsFields();
            enableCredsButtons();
        }
    });

    /// End section for credentials challenges/responses - text fields and buttons

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);

    btnShowAssoc = new JButton("Display Associated Challenges/Responses in new window");

    /// Display the challenges/responses associated to the application in a popup window. 
    /// This is to make it easier to view when all of the values are needed
    btnShowAssoc.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String sTitle = "Credentials for: " + jtxtApp.getText();
            String sDisplay = "";

            sDisplay += "\n";
            DefaultTableModel jTmpModel = (DefaultTableModel) jtabCreds.getModel();
            for (int i = 0; i < jTmpModel.getRowCount(); i++) {
                sDisplay += "Q. " + jTmpModel.getValueAt(i, 1).toString() + "  A. "
                        + l_crypto.decrypt(jTmpModel.getValueAt(i, 2).toString()) + "\n";
            }

            JOptionPane.showMessageDialog(null, sDisplay, sTitle, JOptionPane.INFORMATION_MESSAGE);
        }
    });

    JLabel lblTrackUpdates = new JLabel("Exp Days");

    /// Values for expiration days are hardcoded, may want to move to a table for metadata
    jcbTrack.addItem("0");
    jcbTrack.addItem("30");
    jcbTrack.addItem("45");
    jcbTrack.addItem("60");
    jcbTrack.addItem("90");
    jcbTrack.addItem("180");
    jcbTrack.addItem("365");
    jcbTrack.setSelectedItem("0");

    btnEdit = new JButton("Edit");
    btnEdit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            jtxtChlng.setEnabled(true);
            jtxtRsp.setEnabled(true);
            jcbTrack.setEnabled(true);
            btnCredReplace.setEnabled(true);
            btnCredAdd.setEnabled(true);
        }
    });
    btnEdit.setEnabled(false);

    GroupLayout gl_contentPane = new GroupLayout(contentPane);
    gl_contentPane.setHorizontalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_contentPane.createSequentialGroup().addGroup(gl_contentPane
                    .createParallelGroup(Alignment.LEADING)
                    .addGroup(gl_contentPane.createSequentialGroup().addGap(207)
                            .addComponent(lblThePasswordSaver))
                    .addGroup(gl_contentPane.createSequentialGroup().addGap(23).addGroup(gl_contentPane
                            .createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_contentPane.createSequentialGroup().addComponent(btnAdd)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnReplace)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnDelete)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnSearch)
                                    .addPreferredGap(ComponentPlacement.RELATED).addComponent(btnClear))
                            .addGroup(gl_contentPane.createSequentialGroup().addGroup(gl_contentPane
                                    .createParallelGroup(Alignment.LEADING)
                                    .addGroup(gl_contentPane.createSequentialGroup()
                                            .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
                                                    .addComponent(lblUrlapplication)
                                                    .addComponent(lblDescription))
                                            .addPreferredGap(ComponentPlacement.RELATED)
                                            .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
                                                    .addComponent(jtxtApp, GroupLayout.PREFERRED_SIZE, 154,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jtxtDesc, GroupLayout.PREFERRED_SIZE, 260,
                                                            GroupLayout.PREFERRED_SIZE)))
                                    .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 355,
                                            GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                                    .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
                                            .addComponent(btnShowAssoc)
                                            .addGroup(gl_contentPane.createSequentialGroup()
                                                    .addGroup(gl_contentPane
                                                            .createParallelGroup(Alignment.TRAILING)
                                                            .addComponent(lblResponse)
                                                            .addComponent(lblChallenge))
                                                    .addGap(18)
                                                    .addGroup(gl_contentPane
                                                            .createParallelGroup(Alignment.LEADING)
                                                            .addGroup(gl_contentPane.createSequentialGroup()
                                                                    .addComponent(jtxtRsp, 272, 272, 272)
                                                                    .addGap(26).addComponent(lblTrackUpdates)
                                                                    .addPreferredGap(
                                                                            ComponentPlacement.UNRELATED)
                                                                    .addComponent(jcbTrack,
                                                                            GroupLayout.PREFERRED_SIZE, 55,
                                                                            GroupLayout.PREFERRED_SIZE))
                                                            .addComponent(jtxtChlng, GroupLayout.PREFERRED_SIZE,
                                                                    440, GroupLayout.PREFERRED_SIZE)))
                                            .addGroup(gl_contentPane
                                                    .createParallelGroup(Alignment.LEADING, false)
                                                    .addGroup(gl_contentPane.createSequentialGroup()
                                                            .addComponent(btnCredAdd,
                                                                    GroupLayout.PREFERRED_SIZE, 78,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addPreferredGap(ComponentPlacement.RELATED)
                                                            .addComponent(btnCredReplace)
                                                            .addPreferredGap(ComponentPlacement.RELATED)
                                                            .addComponent(btnCredDelete,
                                                                    GroupLayout.PREFERRED_SIZE, 75,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addPreferredGap(ComponentPlacement.UNRELATED)
                                                            .addComponent(btnCredClear)
                                                            .addPreferredGap(ComponentPlacement.RELATED,
                                                                    GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                            .addComponent(btnEdit))
                                                    .addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE,
                                                            GroupLayout.DEFAULT_SIZE,
                                                            GroupLayout.PREFERRED_SIZE))))))
                    .addGroup(gl_contentPane.createSequentialGroup().addGap(36).addComponent(chkDelAssoc)))
                    .addContainerGap(57, Short.MAX_VALUE)));
    gl_contentPane.setVerticalGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_contentPane.createSequentialGroup().addContainerGap().addComponent(lblThePasswordSaver)
                    .addGap(45)
                    .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
                            .addGroup(gl_contentPane.createSequentialGroup().addGroup(gl_contentPane
                                    .createParallelGroup(Alignment.BASELINE).addComponent(lblUrlapplication)
                                    .addComponent(jtxtApp, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblChallenge)).addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
                                            .addComponent(lblDescription)
                                            .addComponent(jtxtDesc, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblResponse)))
                            .addGroup(gl_contentPane.createSequentialGroup()
                                    .addComponent(jtxtChlng, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
                                            .addComponent(jtxtRsp, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                            .addComponent(lblTrackUpdates)
                                            .addComponent(jcbTrack, GroupLayout.PREFERRED_SIZE,
                                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
                    .addGap(18)
                    .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE).addComponent(btnAdd)
                            .addComponent(btnReplace).addComponent(btnDelete).addComponent(btnSearch)
                            .addComponent(btnClear).addComponent(btnCredAdd).addComponent(btnCredReplace)
                            .addComponent(btnCredDelete).addComponent(btnCredClear).addComponent(btnEdit))
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 208,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE, 109,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGroup(gl_contentPane.createSequentialGroup().addGap(120)
                                    .addComponent(btnShowAssoc)))
                    .addGap(18).addComponent(chkDelAssoc).addContainerGap(170, Short.MAX_VALUE)));

    /// JTable - Credentials table setup/definition - BEGIN
    jtabCreds = new JTable();
    jtabCreds.setModel(new DefaultTableModel(new Object[][] {},
            new String[] { "ID", "Challenge", "Response", "Exp Days", "Expiration Date" }) {
        Class[] columnTypes = new Class[] { Integer.class, String.class, String.class, String.class,
                String.class };

        public Class getColumnClass(int columnIndex) {
            return columnTypes[columnIndex];
        }
    });
    jtabCreds.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    scrollPane_1.setViewportView(jtabCreds);
    /// JTable - Credentials table setup/definition - END

    jtabApps = new JTable();
    scrollPane.setViewportView(jtabApps);

    jtabApps.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    jtabApps.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
    jtabApps.setModel(
            new DefaultTableModel(new Object[][] {}, new String[] { "ID", "URL/Application", "Description" }) {
                Class[] columnTypes = new Class[] { Integer.class, String.class, String.class };

                public Class getColumnClass(int columnIndex) {
                    return columnTypes[columnIndex];
                }

                @Override
                public boolean isCellEditable(int row, int column) {
                    //all cells false
                    return false;
                }
            });
    jtabApps.getColumnModel().getColumn(1).setMinWidth(55);
    jtabApps.getColumnModel().getColumn(2).setMinWidth(55);
    contentPane.setLayout(gl_contentPane);
    contentPane.setFocusTraversalPolicy(new FocusTraversalOnArray(new Component[] { jtxtChlng,
            lblThePasswordSaver, jtxtApp, jtxtDesc, btnAdd, btnReplace, btnDelete, btnSearch, btnClear, jtxtRsp,
            btnCredAdd, btnCredReplace, btnCredDelete, btnCredClear, scrollPane, jtabApps, lblUrlapplication,
            lblDescription, chkDelAssoc, lblChallenge, lblResponse, scrollPane_1, jtabCreds }));
    setFocusTraversalPolicy(new FocusTraversalOnArray(
            new Component[] { menuBar, jtxtApp, jtxtDesc, btnAdd, btnReplace, btnDelete, btnSearch, btnClear,
                    jtxtChlng, jtxtRsp, btnCredAdd, btnCredReplace, btnCredDelete, btnCredClear, contentPane,
                    mnFile, mntmExit, lblThePasswordSaver, scrollPane, jtabApps, lblUrlapplication,
                    lblDescription, chkDelAssoc, lblChallenge, lblResponse, scrollPane_1, jtabCreds }));

    /// Initial data load
    dbRec = new DbRecord();
    dbRec.setType(Pwdtypes.S_CLIENT_TYPE);
    dbRec.setClientName("");
    dbRec.setClientDesc("");
    loadTable(dbRec);
    disableCredsButtons();

    ListSelectionModel rowSM = jtabApps.getSelectionModel();

    //Listener for client row change;
    rowSM.addListSelectionListener(new ListSelectionListener() {

        /// Fill the form values when a row is selected in the JTable
        @Override
        public void valueChanged(ListSelectionEvent e) {
            ListSelectionModel lsmData = (ListSelectionModel) e.getSource();
            if (!lsmData.isSelectionEmpty()) {
                int iRow = lsmData.getMinSelectionIndex();
                iClientId = Integer.parseInt(jtabApps.getValueAt(iRow, 0).toString());
                jtxtApp.setText(jtabApps.getValueAt(iRow, 1).toString());
                jtxtDesc.setText(jtabApps.getValueAt(iRow, 2).toString());

                dbRec.setType(Pwdtypes.S_CREDS_TYPE);
                dbRec.setClientId(iClientId);
                loadTable(dbRec);
                enableButtons();
                clearCredsFields();
                enableCredsButtons();
            }
        }
    });

    ListSelectionModel rowCred = jtabCreds.getSelectionModel();

    //Listener for credential row change;
    rowCred.addListSelectionListener(new ListSelectionListener() {

        /// Fill the form values when a row is selected in the JTable
        @Override
        public void valueChanged(ListSelectionEvent e) {
            ListSelectionModel lsmData = (ListSelectionModel) e.getSource();
            if (!lsmData.isSelectionEmpty()) {
                int iRow = lsmData.getMinSelectionIndex();
                iCredId = Integer.parseInt(jtabCreds.getValueAt(iRow, 0).toString());
                jtxtChlng.setText(jtabCreds.getValueAt(iRow, 1).toString());
                jtxtRsp.setText(l_crypto.decrypt(jtabCreds.getValueAt(iRow, 2).toString()));
                jcbTrack.setSelectedItem(jtabCreds.getValueAt(iRow, 3).toString());
                if (null == jtabCreds.getValueAt(iRow, 4)) {
                    sDateModified = "";
                } else {
                    sDateModified = jtabCreds.getValueAt(iRow, 4).toString();
                }
                sChallenge = jtxtChlng.getText();
                sResponse = jtxtRsp.getText();
                dbRec.setType(Pwdtypes.S_CREDS_TYPE);
                dbRec.setCredId(iClientId);
                jtxtChlng.setEnabled(false);
                jtxtRsp.setEnabled(false);
                jcbTrack.setEnabled(false);
                btnEdit.setEnabled(true);
                btnCredDelete.setEnabled(true);
                btnCredClear.setEnabled(true);
            }
        }
    });

}

From source file:org.tinymediamanager.ui.movies.MoviePanel.java

/**
 * Create the panel./*from  ww w .ja v a 2s.  co m*/
 */
public MoviePanel() {
    super();
    // load movielist
    LOGGER.debug("loading MovieList");
    movieList = MovieList.getInstance();
    sortedMovies = new SortedList<>(GlazedListsSwing.swingThreadProxyList(movieList.getMovies()),
            new MovieComparator());
    sortedMovies.setMode(SortedList.AVOID_MOVING_ELEMENTS);

    // build menu
    menu = new JMenu(BUNDLE.getString("tmm.movies")); //$NON-NLS-1$
    JFrame mainFrame = MainWindow.getFrame();
    JMenuBar menuBar = mainFrame.getJMenuBar();
    menuBar.add(menu);

    setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("850px:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("500px:grow"), }));

    splitPaneHorizontal = new JSplitPane();
    splitPaneHorizontal.setContinuousLayout(true);
    add(splitPaneHorizontal, "2, 2, fill, fill");

    JPanel panelMovieList = new JPanel();
    splitPaneHorizontal.setLeftComponent(panelMovieList);
    panelMovieList.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    FormFactory.DEFAULT_COLSPEC, },
            new RowSpec[] { RowSpec.decode("26px"), FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("fill:max(200px;default):grow"), FormFactory.RELATED_GAP_ROWSPEC,
                    FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));

    JToolBar toolBar = new JToolBar();
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    toolBar.setOpaque(false);
    panelMovieList.add(toolBar, "2, 1, left, fill");

    // udpate datasource
    // toolBar.add(actionUpdateDataSources);
    final JSplitButton buttonUpdateDatasource = new JSplitButton(IconManager.REFRESH);
    // temp fix for size of the button
    buttonUpdateDatasource.setText("   ");
    buttonUpdateDatasource.setHorizontalAlignment(JButton.LEFT);
    // buttonScrape.setMargin(new Insets(2, 2, 2, 24));
    buttonUpdateDatasource.setSplitWidth(18);
    buttonUpdateDatasource.setToolTipText(BUNDLE.getString("update.datasource")); //$NON-NLS-1$
    buttonUpdateDatasource.addSplitButtonActionListener(new SplitButtonActionListener() {
        public void buttonClicked(ActionEvent e) {
            actionUpdateDataSources.actionPerformed(e);
        }

        public void splitButtonClicked(ActionEvent e) {
            // build the popupmenu on the fly
            buttonUpdateDatasource.getPopupMenu().removeAll();
            JMenuItem item = new JMenuItem(actionUpdateDataSources2);
            buttonUpdateDatasource.getPopupMenu().add(item);
            buttonUpdateDatasource.getPopupMenu().addSeparator();
            for (String ds : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) {
                buttonUpdateDatasource.getPopupMenu()
                        .add(new JMenuItem(new MovieUpdateSingleDatasourceAction(ds)));
            }

            buttonUpdateDatasource.getPopupMenu().pack();
        }
    });

    JPopupMenu popup = new JPopupMenu("popup");
    buttonUpdateDatasource.setPopupMenu(popup);
    toolBar.add(buttonUpdateDatasource);

    JSplitButton buttonScrape = new JSplitButton(IconManager.SEARCH);
    // temp fix for size of the button
    buttonScrape.setText("   ");
    buttonScrape.setHorizontalAlignment(JButton.LEFT);
    // buttonScrape.setMargin(new Insets(2, 2, 2, 24));
    buttonScrape.setSplitWidth(18);
    buttonScrape.setToolTipText(BUNDLE.getString("movie.scrape.selected")); //$NON-NLS-1$

    // register for listener
    buttonScrape.addSplitButtonActionListener(new SplitButtonActionListener() {
        public void buttonClicked(ActionEvent e) {
            actionScrape.actionPerformed(e);
        }

        public void splitButtonClicked(ActionEvent e) {
        }
    });

    popup = new JPopupMenu("popup");
    JMenuItem item = new JMenuItem(actionScrape2);
    popup.add(item);
    item = new JMenuItem(actionScrapeUnscraped);
    popup.add(item);
    item = new JMenuItem(actionScrapeSelected);
    popup.add(item);
    buttonScrape.setPopupMenu(popup);
    toolBar.add(buttonScrape);

    toolBar.add(actionEditMovie);

    btnRen = new JButton("REN");
    btnRen.setAction(actionRename);
    toolBar.add(btnRen);

    btnMediaInformation = new JButton("MI");
    btnMediaInformation.setAction(actionMediaInformation);
    toolBar.add(btnMediaInformation);

    JButton btnCreateOflline = new JButton();
    btnCreateOflline.setAction(new MovieCreateOfflineAction(false));
    toolBar.add(btnCreateOflline);

    textField = EnhancedTextField.createSearchTextField();
    panelMovieList.add(textField, "3, 1, right, bottom");
    textField.setColumns(13);

    // table = new JTable();
    // build JTable

    MatcherEditor<Movie> textMatcherEditor = new TextComponentMatcherEditor<>(textField, new MovieFilterator());
    MovieMatcherEditor movieMatcherEditor = new MovieMatcherEditor();
    FilterList<Movie> extendedFilteredMovies = new FilterList<>(sortedMovies, movieMatcherEditor);
    textFilteredMovies = new FilterList<>(extendedFilteredMovies, textMatcherEditor);
    movieSelectionModel = new MovieSelectionModel(sortedMovies, textFilteredMovies, movieMatcherEditor);
    movieTableModel = new DefaultEventTableModel<>(GlazedListsSwing.swingThreadProxyList(textFilteredMovies),
            new MovieTableFormat());
    table = new ZebraJTable(movieTableModel);

    movieTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            lblMovieCountFiltered.setText(String.valueOf(movieTableModel.getRowCount()));
            // select first movie if nothing is selected
            ListSelectionModel selectionModel = table.getSelectionModel();
            if (selectionModel.isSelectionEmpty() && movieTableModel.getRowCount() > 0) {
                selectionModel.setSelectionInterval(0, 0);
            }
            if (selectionModel.isSelectionEmpty() && movieTableModel.getRowCount() == 0) {
                movieSelectionModel.setSelectedMovie(null);
            }
        }
    });

    // install and save the comparator on the Table
    movieSelectionModel.setTableComparatorChooser(
            TableComparatorChooser.install(table, sortedMovies, TableComparatorChooser.SINGLE_COLUMN));

    // table = new MyTable();
    table.setNewFontSize((float) ((int) Math.round(getFont().getSize() * 0.916)));
    // scrollPane.setViewportView(table);

    // JScrollPane scrollPane = new JScrollPane(table);
    JScrollPane scrollPane = ZebraJTable.createStripedJScrollPane(table);
    panelMovieList.add(scrollPane, "2, 3, 4, 1, fill, fill");

    {
        final JToggleButton filterButton = new JToggleButton(IconManager.FILTER);
        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
        panelMovieList.add(filterButton, "5, 1, right, bottom");

        // add a propertychangelistener which reacts on setting a filter
        movieSelectionModel.addPropertyChangeListener(new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if ("filterChanged".equals(evt.getPropertyName())) {
                    if (Boolean.TRUE.equals(evt.getNewValue())) {
                        filterButton.setIcon(IconManager.FILTER_ACTIVE);
                        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options.active")); //$NON-NLS-1$
                    } else {
                        filterButton.setIcon(IconManager.FILTER);
                        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
                    }
                }
            }
        });

        panelExtendedSearch = new MovieExtendedSearchPanel(movieSelectionModel);
        panelExtendedSearch.setVisible(false);
        // panelMovieList.add(panelExtendedSearch, "2, 5, 2, 1, fill, fill");
        filterButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (panelExtendedSearch.isVisible() == true) {
                    panelExtendedSearch.setVisible(false);
                } else {
                    panelExtendedSearch.setVisible(true);
                }
            }
        });
    }

    JPanel panelStatus = new JPanel();
    panelMovieList.add(panelStatus, "2, 6, 2, 1");
    panelStatus.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("1px"),
                    ColumnSpec.decode("146px:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("fill:default:grow"), }));

    panelMovieCount = new JPanel();
    panelStatus.add(panelMovieCount, "3, 1, left, fill");

    lblMovieCount = new JLabel(BUNDLE.getString("tmm.movies") + ":"); //$NON-NLS-1$
    panelMovieCount.add(lblMovieCount);

    lblMovieCountFiltered = new JLabel("");
    panelMovieCount.add(lblMovieCountFiltered);

    lblMovieCountOf = new JLabel(BUNDLE.getString("tmm.of")); //$NON-NLS-1$
    panelMovieCount.add(lblMovieCountOf);

    lblMovieCountTotal = new JLabel("");
    panelMovieCount.add(lblMovieCountTotal);

    JLayeredPane layeredPaneRight = new JLayeredPane();
    layeredPaneRight.setLayout(
            new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default"), ColumnSpec.decode("default:grow") },
                    new RowSpec[] { RowSpec.decode("default"), RowSpec.decode("default:grow") }));
    panelRight = new MovieInformationPanel(movieSelectionModel);
    layeredPaneRight.add(panelRight, "1, 1, 2, 2, fill, fill");
    layeredPaneRight.setLayer(panelRight, 0);

    // glass pane
    layeredPaneRight.add(panelExtendedSearch, "1, 1, fill, fill");
    layeredPaneRight.setLayer(panelExtendedSearch, 1);

    splitPaneHorizontal.setRightComponent(layeredPaneRight);
    splitPaneHorizontal.setContinuousLayout(true);

    // beansbinding init
    initDataBindings();

    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentHidden(ComponentEvent e) {
            menu.setVisible(false);
            super.componentHidden(e);
        }

        @Override
        public void componentShown(ComponentEvent e) {
            menu.setVisible(true);
            super.componentHidden(e);
        }
    });

    // further initializations
    init();

    // filter
    if (MovieModuleManager.MOVIE_SETTINGS.isStoreUiFilters()) {
        movieList.searchDuplicates();
        movieSelectionModel.filterMovies(MovieModuleManager.MOVIE_SETTINGS.getUiFilters());
    }
}

From source file:org.tinymediamanager.ui.movies.MoviePanel.java

/**
 * further initializations./*from www .  j  a v a2  s .  c om*/
 */
private void init() {
    // build menu
    buildMenu();

    // moviename column
    table.getColumnModel().getColumn(0).setCellRenderer(new BorderCellRenderer());
    table.getColumnModel().getColumn(0).setIdentifier("title"); //$NON-NLS-1$

    // year column
    int width = table.getFontMetrics(table.getFont()).stringWidth(" 2000");
    int titleWidth = table.getFontMetrics(table.getFont()).stringWidth(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
    if (titleWidth > width) {
        width = titleWidth;
    }
    table.getTableHeader().getColumnModel().getColumn(1).setPreferredWidth(width);
    table.getTableHeader().getColumnModel().getColumn(1).setMinWidth(width);
    table.getTableHeader().getColumnModel().getColumn(1).setMaxWidth((int) (width * 1.5));
    table.getTableHeader().getColumnModel().getColumn(1).setIdentifier("year"); //$NON-NLS-1$

    // rating column
    width = table.getFontMetrics(table.getFont()).stringWidth(" 10.0");
    titleWidth = table.getFontMetrics(table.getFont()).stringWidth(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$
    if (titleWidth > width) {
        width = titleWidth;
    }
    table.getTableHeader().getColumnModel().getColumn(2).setPreferredWidth((int) (width * 1.2));
    table.getTableHeader().getColumnModel().getColumn(2).setMinWidth((int) (width * 1.2));
    table.getTableHeader().getColumnModel().getColumn(2).setMaxWidth((int) (width * 1.5));
    table.getTableHeader().getColumnModel().getColumn(2).setIdentifier("rating"); //$NON-NLS-1$

    // date added column
    width = table.getFontMetrics(table.getFont()).stringWidth("01. Jan. 2000");
    titleWidth = table.getFontMetrics(table.getFont()).stringWidth(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$
    if (titleWidth > width) {
        width = titleWidth;
    }
    table.getTableHeader().getColumnModel().getColumn(3).setPreferredWidth((int) (width * 1.2));
    table.getTableHeader().getColumnModel().getColumn(3).setMinWidth((int) (width * 1.2));
    table.getTableHeader().getColumnModel().getColumn(3).setMaxWidth((int) (width * 1.2));
    table.getTableHeader().getColumnModel().getColumn(3).setIdentifier("dateadded"); //$NON-NLS-1$

    // NFO column
    table.getTableHeader().getColumnModel().getColumn(4)
            .setHeaderRenderer(new IconRenderer(BUNDLE.getString("tmm.nfo"))); //$NON-NLS-1$
    table.getTableHeader().getColumnModel().getColumn(4).setMaxWidth(20);
    table.getColumnModel().getColumn(4).setHeaderValue(IconManager.INFO);
    table.getTableHeader().getColumnModel().getColumn(4).setIdentifier("nfo"); //$NON-NLS-1$

    // Meta data column
    table.getTableHeader().getColumnModel().getColumn(5)
            .setHeaderRenderer(new IconRenderer(BUNDLE.getString("tmm.metadata"))); //$NON-NLS-1$
    table.getTableHeader().getColumnModel().getColumn(5).setMaxWidth(20);
    table.getColumnModel().getColumn(5).setHeaderValue(IconManager.SEARCH);
    table.getTableHeader().getColumnModel().getColumn(5).setIdentifier("metadata"); //$NON-NLS-1$

    // Images column
    table.getTableHeader().getColumnModel().getColumn(6)
            .setHeaderRenderer(new IconRenderer(BUNDLE.getString("tmm.images"))); //$NON-NLS-1$
    table.getTableHeader().getColumnModel().getColumn(6).setMaxWidth(20);
    table.getColumnModel().getColumn(6).setHeaderValue(IconManager.IMAGE);
    table.getTableHeader().getColumnModel().getColumn(6).setIdentifier("images"); //$NON-NLS-1$

    // trailer column
    table.getTableHeader().getColumnModel().getColumn(7)
            .setHeaderRenderer(new IconRenderer(BUNDLE.getString("tmm.trailer"))); //$NON-NLS-1$
    table.getTableHeader().getColumnModel().getColumn(7).setMaxWidth(20);
    table.getColumnModel().getColumn(7).setHeaderValue(IconManager.CLAPBOARD);
    table.getTableHeader().getColumnModel().getColumn(7).setIdentifier("trailer"); //$NON-NLS-1$

    // subtitles column
    table.getTableHeader().getColumnModel().getColumn(8)
            .setHeaderRenderer(new IconRenderer(BUNDLE.getString("tmm.subtitles"))); //$NON-NLS-1$
    table.getTableHeader().getColumnModel().getColumn(8).setMaxWidth(20);
    table.getColumnModel().getColumn(8).setHeaderValue(IconManager.SUBTITLE);
    table.getTableHeader().getColumnModel().getColumn(8).setIdentifier("subtitle"); //$NON-NLS-1$

    // watched column
    table.getTableHeader().getColumnModel().getColumn(9)
            .setHeaderRenderer(new IconRenderer(BUNDLE.getString("metatag.watched"))); //$NON-NLS-1$
    table.getTableHeader().getColumnModel().getColumn(9).setMaxWidth(20);
    table.getColumnModel().getColumn(9).setHeaderValue(IconManager.PLAY_SMALL);
    table.getTableHeader().getColumnModel().getColumn(9).setIdentifier("watched"); //$NON-NLS-1$

    table.setSelectionModel(movieSelectionModel.getSelectionModel());
    // selecting first movie at startup
    if (movieList.getMovies() != null && movieList.getMovies().size() > 0) {
        ListSelectionModel selectionModel = table.getSelectionModel();
        if (selectionModel.isSelectionEmpty()) {
            selectionModel.setSelectionInterval(0, 0);
        }
    }

    // hide columns if needed
    if (!MovieModuleManager.MOVIE_SETTINGS.isYearColumnVisible()) {
        table.hideColumn("year"); //$NON-NLS-1$
    }
    if (!MovieModuleManager.MOVIE_SETTINGS.isRatingColumnVisible()) {
        table.hideColumn("rating"); //$NON-NLS-1$
    }
    if (!MovieModuleManager.MOVIE_SETTINGS.isDateAddedColumnVisible()) {
        table.hideColumn("dateadded"); //$NON-NLS-1$
    }
    if (!MovieModuleManager.MOVIE_SETTINGS.isNfoColumnVisible()) {
        table.hideColumn("nfo"); //$NON-NLS-1$
    }
    if (!MovieModuleManager.MOVIE_SETTINGS.isMetadataColumnVisible()) {
        table.hideColumn("metadata"); //$NON-NLS-1$
    }
    if (!MovieModuleManager.MOVIE_SETTINGS.isImageColumnVisible()) {
        table.hideColumn("images"); //$NON-NLS-1$
    }
    if (!MovieModuleManager.MOVIE_SETTINGS.isTrailerColumnVisible()) {
        table.hideColumn("trailer"); //$NON-NLS-1$
    }
    if (!MovieModuleManager.MOVIE_SETTINGS.isSubtitleColumnVisible()) {
        table.hideColumn("subtitle"); //$NON-NLS-1$
    }
    if (!MovieModuleManager.MOVIE_SETTINGS.isWatchedColumnVisible()) {
        table.hideColumn("watched"); //$NON-NLS-1$
    }

    // and add a propertychangelistener to the columnhider
    PropertyChangeListener settingsPropertyChangeListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getSource() instanceof MovieSettings) {
                if ("yearColumnVisible".equals(evt.getPropertyName())) {
                    setColumnVisibility("year", (Boolean) evt.getNewValue()); //$NON-NLS-1$
                }
                if ("ratingColumnVisible".equals(evt.getPropertyName())) {
                    setColumnVisibility("rating", (Boolean) evt.getNewValue()); //$NON-NLS-1$
                }
                if ("nfoColumnVisible".equals(evt.getPropertyName())) {
                    setColumnVisibility("nfo", (Boolean) evt.getNewValue());
                }
                if ("metadataColumnVisible".equals(evt.getPropertyName())) {
                    setColumnVisibility("metadata", (Boolean) evt.getNewValue());
                }
                if ("dateAddedColumnVisible".equals(evt.getPropertyName())) {
                    setColumnVisibility("dateadded", (Boolean) evt.getNewValue());
                }
                if ("imageColumnVisible".equals(evt.getPropertyName())) {
                    setColumnVisibility("images", (Boolean) evt.getNewValue()); //$NON-NLS-1$
                }
                if ("trailerColumnVisible".equals(evt.getPropertyName())) {
                    setColumnVisibility("trailer", (Boolean) evt.getNewValue()); //$NON-NLS-1$
                }
                if ("subtitleColumnVisible".equals(evt.getPropertyName())) {
                    setColumnVisibility("subtitle", (Boolean) evt.getNewValue()); //$NON-NLS-1$
                }
                if ("watchedColumnVisible".equals(evt.getPropertyName())) {
                    setColumnVisibility("watched", (Boolean) evt.getNewValue()); //$NON-NLS-1$
                }
            }
        }

        private void setColumnVisibility(Object identifier, Boolean visible) {
            if (visible) {
                table.showColumn(identifier);
            } else {
                table.hideColumn(identifier);
            }

        }
    };

    MovieModuleManager.MOVIE_SETTINGS.addPropertyChangeListener(settingsPropertyChangeListener);

    // initialize filteredCount
    lblMovieCountFiltered.setText(String.valueOf(movieTableModel.getRowCount()));

    addKeyListener();
}