Example usage for java.beans PropertyVetoException printStackTrace

List of usage examples for java.beans PropertyVetoException printStackTrace

Introduction

In this page you can find the example usage for java.beans PropertyVetoException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:canreg.client.gui.dataentry.ImportView.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*www.j  av a  2s .  c o m*/
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    tabbedPane = new javax.swing.JTabbedPane();
    chooseFilePanel = new javax.swing.JPanel();
    fileNameTextField = new javax.swing.JTextField();
    browseButton = new javax.swing.JButton();
    previewPanel = new javax.swing.JPanel();
    numberOfRecordsLabel = new javax.swing.JLabel();
    numberOfRecordsTextField = new javax.swing.JTextField();
    previewTableScrollPane = new javax.swing.JScrollPane();
    previewTable = new javax.swing.JTable();
    numberOfRecordsShownLabel = new javax.swing.JLabel();
    numberOfRecordsShownTextField = new javax.swing.JTextField();
    previewButton = new javax.swing.JButton();
    fileLabel = new javax.swing.JLabel();
    separatingCharacterComboBox = new javax.swing.JComboBox();
    separatingCharacterLabel = new javax.swing.JLabel();
    autodetectButton = new javax.swing.JButton();
    fileEncodingLabel = new javax.swing.JLabel();
    charsetsComboBox = new javax.swing.JComboBox();
    associateVariablesPanel = new javax.swing.JPanel();
    jLabel8 = new javax.swing.JLabel();
    variablesScrollPane = new javax.swing.JScrollPane();
    variablesPanel = new javax.swing.JPanel();
    jSplitPane1 = new javax.swing.JSplitPane();
    jLabel2 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    importFilePanel = new javax.swing.JPanel();
    importButton = new javax.swing.JButton();
    discrepanciesPanel = new javax.swing.JPanel();
    rejectRadioButton = new javax.swing.JRadioButton();
    updateRadioButton = new javax.swing.JRadioButton();
    overwriteRadioButton = new javax.swing.JRadioButton();
    jPanel7 = new javax.swing.JPanel();
    doChecksCheckBox = new javax.swing.JCheckBox();
    personSearchCheckBox = new javax.swing.JCheckBox();
    queryNewNameCheckBox = new javax.swing.JCheckBox();
    previousCanRegDataCheckBox = new javax.swing.JCheckBox();
    maxLinesPanel = new javax.swing.JPanel();
    maxLinesTextField = new javax.swing.JTextField();
    testOnlyCheckBox = new javax.swing.JCheckBox();
    jPanel1 = new javax.swing.JPanel();
    progressBar = new javax.swing.JProgressBar();
    nextButton = new javax.swing.JButton();
    cancelButton = new javax.swing.JButton();
    backButton = new javax.swing.JButton();

    setIconifiable(true);
    setMaximizable(true);
    setResizable(true);
    org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application
            .getInstance(canreg.client.CanRegClientApp.class).getContext().getResourceMap(ImportView.class);
    setTitle(resourceMap.getString("Form.title")); // NOI18N
    setFrameIcon(resourceMap.getIcon("Form.frameIcon")); // NOI18N
    setName("Form"); // NOI18N
    try {
        setSelected(true);
    } catch (java.beans.PropertyVetoException e1) {
        e1.printStackTrace();
    }

    tabbedPane.setName("tabbedPane"); // NOI18N

    chooseFilePanel.setName("chooseFilePanel"); // NOI18N

    fileNameTextField.setName("fileNameTextField"); // NOI18N
    fileNameTextField.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mousePressed(java.awt.event.MouseEvent evt) {
            fileNameTextFieldMousePressed(evt);
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
            fileNameTextFieldMouseReleased(evt);
        }
    });
    fileNameTextField.addFocusListener(new java.awt.event.FocusAdapter() {
        public void focusLost(java.awt.event.FocusEvent evt) {
            fileNameTextFieldFocusLost(evt);
        }
    });

    javax.swing.ActionMap actionMap = org.jdesktop.application.Application
            .getInstance(canreg.client.CanRegClientApp.class).getContext().getActionMap(ImportView.class, this);
    browseButton.setAction(actionMap.get("browseFiles")); // NOI18N
    browseButton.setName("browseButton"); // NOI18N

    previewPanel.setBorder(
            javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("previewPanel.border.title"))); // NOI18N
    previewPanel.setEnabled(false);
    previewPanel.setName("previewPanel"); // NOI18N

    numberOfRecordsLabel.setText(resourceMap.getString("numberOfRecordsLabel.text")); // NOI18N
    numberOfRecordsLabel.setFocusable(false);
    numberOfRecordsLabel.setName("numberOfRecordsLabel"); // NOI18N

    numberOfRecordsTextField.setEditable(false);
    numberOfRecordsTextField.setText(resourceMap.getString("numberOfRecordsTextField.text")); // NOI18N
    numberOfRecordsTextField.setFocusable(false);
    numberOfRecordsTextField.setName("numberOfRecordsTextField"); // NOI18N

    previewTableScrollPane.setName("previewTableScrollPane"); // NOI18N

    previewTable
            .setModel(new javax.swing.table.DefaultTableModel(
                    new Object[][] { { null, null, null, null }, { null, null, null, null },
                            { null, null, null, null }, { null, null, null, null } },
                    new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
    previewTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
    previewTable.setEnabled(false);
    previewTable.setFocusable(false);
    previewTable.setName("previewTable"); // NOI18N
    previewTableScrollPane.setViewportView(previewTable);

    numberOfRecordsShownLabel.setText(resourceMap.getString("numberOfRecordsShownLabel.text")); // NOI18N
    numberOfRecordsShownLabel.setFocusable(false);
    numberOfRecordsShownLabel.setName("numberOfRecordsShownLabel"); // NOI18N

    numberOfRecordsShownTextField.setEditable(false);
    numberOfRecordsShownTextField.setFocusable(false);
    numberOfRecordsShownTextField.setName("numberOfRecordsShownTextField"); // NOI18N

    javax.swing.GroupLayout previewPanelLayout = new javax.swing.GroupLayout(previewPanel);
    previewPanel.setLayout(previewPanelLayout);
    previewPanelLayout.setHorizontalGroup(
            previewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(previewPanelLayout.createSequentialGroup().addComponent(numberOfRecordsLabel)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(numberOfRecordsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 95,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(numberOfRecordsShownLabel)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(numberOfRecordsShownTextField, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    102, Short.MAX_VALUE))
                    .addComponent(previewTableScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 523,
                            Short.MAX_VALUE));
    previewPanelLayout.setVerticalGroup(previewPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(previewPanelLayout.createSequentialGroup().addGroup(previewPanelLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(numberOfRecordsLabel)
                    .addComponent(numberOfRecordsTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(numberOfRecordsShownLabel).addComponent(numberOfRecordsShownTextField,
                            javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(previewTableScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 219,
                            Short.MAX_VALUE)));

    previewButton.setAction(actionMap.get("previewAction")); // NOI18N
    previewButton.setName("previewButton"); // NOI18N

    fileLabel.setText(resourceMap.getString("fileLabel.text")); // NOI18N
    fileLabel.setName("fileLabel"); // NOI18N

    separatingCharacterComboBox.setEditable(true);
    separatingCharacterComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tab", "Comma" }));
    separatingCharacterComboBox.setAction(actionMap.get("comboBoxChanged")); // NOI18N
    separatingCharacterComboBox.setName("separatingCharacterComboBox"); // NOI18N

    separatingCharacterLabel.setText(resourceMap.getString("separatingCharacterLabel.text")); // NOI18N
    separatingCharacterLabel.setName("separatingCharacterLabel"); // NOI18N

    autodetectButton.setAction(actionMap.get("autodetectFileEncodingAction")); // NOI18N
    autodetectButton.setText(resourceMap.getString("autodetectButton.text")); // NOI18N
    autodetectButton.setToolTipText(resourceMap.getString("autodetectButton.toolTipText")); // NOI18N
    autodetectButton.setName("autodetectButton"); // NOI18N

    fileEncodingLabel.setText(resourceMap.getString("fileEncodingLabel.text")); // NOI18N
    fileEncodingLabel.setName("fileEncodingLabel"); // NOI18N

    charsetsComboBox.setModel(
            new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    charsetsComboBox.setName("charsetsComboBox"); // NOI18N

    javax.swing.GroupLayout chooseFilePanelLayout = new javax.swing.GroupLayout(chooseFilePanel);
    chooseFilePanel.setLayout(chooseFilePanelLayout);
    chooseFilePanelLayout.setHorizontalGroup(chooseFilePanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, chooseFilePanelLayout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(chooseFilePanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(previewPanel, javax.swing.GroupLayout.Alignment.LEADING,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addGroup(chooseFilePanelLayout.createSequentialGroup()
                                    .addGroup(chooseFilePanelLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(chooseFilePanelLayout.createSequentialGroup()
                                                    .addComponent(fileLabel)
                                                    .addPreferredGap(
                                                            javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(fileNameTextField,
                                                            javax.swing.GroupLayout.DEFAULT_SIZE, 365,
                                                            Short.MAX_VALUE))
                                            .addGroup(chooseFilePanelLayout.createSequentialGroup()
                                                    .addComponent(fileEncodingLabel)
                                                    .addPreferredGap(
                                                            javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(charsetsComboBox,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE, 117,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(
                                                            javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(autodetectButton)
                                                    .addPreferredGap(
                                                            javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(separatingCharacterLabel)))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(chooseFilePanelLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                    false)
                                            .addComponent(separatingCharacterComboBox, 0,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                    chooseFilePanelLayout.createSequentialGroup()
                                                            .addComponent(browseButton)
                                                            .addPreferredGap(
                                                                    javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                            .addComponent(previewButton)))))
                    .addContainerGap()));
    chooseFilePanelLayout.setVerticalGroup(chooseFilePanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(chooseFilePanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(chooseFilePanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(previewButton).addComponent(browseButton).addComponent(fileLabel)
                            .addComponent(fileNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(chooseFilePanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(fileEncodingLabel)
                            .addComponent(charsetsComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(separatingCharacterComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(autodetectButton).addComponent(separatingCharacterLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(previewPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));

    tabbedPane.addTab("Choose File", chooseFilePanel);

    associateVariablesPanel.setName("associateVariablesPanel"); // NOI18N

    jLabel8.setName("jLabel8"); // NOI18N

    variablesScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    variablesScrollPane.setName("variablesScrollPane"); // NOI18N

    variablesPanel.setName("variablesPanel"); // NOI18N
    variablesPanel.setLayout(new java.awt.GridLayout(0, 1));
    variablesScrollPane.setViewportView(variablesPanel);

    jSplitPane1.setDividerLocation(200);
    jSplitPane1.setResizeWeight(0.5);
    jSplitPane1.setName("jSplitPane1"); // NOI18N

    jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
    jLabel2.setName("jLabel2"); // NOI18N
    jSplitPane1.setLeftComponent(jLabel2);

    jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
    jLabel4.setMaximumSize(new java.awt.Dimension(139, 14));
    jLabel4.setMinimumSize(new java.awt.Dimension(139, 14));
    jLabel4.setName("jLabel4"); // NOI18N
    jSplitPane1.setRightComponent(jLabel4);

    javax.swing.GroupLayout associateVariablesPanelLayout = new javax.swing.GroupLayout(
            associateVariablesPanel);
    associateVariablesPanel.setLayout(associateVariablesPanelLayout);
    associateVariablesPanelLayout.setHorizontalGroup(associateVariablesPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(associateVariablesPanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(associateVariablesPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 539,
                                    Short.MAX_VALUE)
                            .addComponent(jLabel8).addComponent(variablesScrollPane,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, 539, Short.MAX_VALUE))
                    .addContainerGap()));
    associateVariablesPanelLayout.setVerticalGroup(associateVariablesPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(associateVariablesPanelLayout.createSequentialGroup().addContainerGap()
                    .addComponent(jLabel8).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jSplitPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(variablesScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 305,
                            Short.MAX_VALUE)
                    .addContainerGap()));

    tabbedPane.addTab("Associate Variables", associateVariablesPanel);

    importFilePanel.setName("importFilePanel"); // NOI18N

    importButton.setAction(actionMap.get("importAction")); // NOI18N
    importButton.setName("importButton"); // NOI18N

    discrepanciesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Discrepancies"));
    discrepanciesPanel.setToolTipText(resourceMap.getString("discrepanciesPanel.toolTipText")); // NOI18N
    discrepanciesPanel.setEnabled(false);
    discrepanciesPanel.setName("discrepanciesPanel"); // NOI18N

    rejectRadioButton.setText(resourceMap.getString("rejectRadioButton.text")); // NOI18N
    rejectRadioButton.setEnabled(false);
    rejectRadioButton.setName("rejectRadioButton"); // NOI18N

    updateRadioButton.setSelected(true);
    updateRadioButton.setText(resourceMap.getString("updateRadioButton.text")); // NOI18N
    updateRadioButton.setEnabled(false);
    updateRadioButton.setName("updateRadioButton"); // NOI18N

    overwriteRadioButton.setText(resourceMap.getString("overwriteRadioButton.text")); // NOI18N
    overwriteRadioButton.setEnabled(false);
    overwriteRadioButton.setName("overwriteRadioButton"); // NOI18N

    javax.swing.GroupLayout discrepanciesPanelLayout = new javax.swing.GroupLayout(discrepanciesPanel);
    discrepanciesPanel.setLayout(discrepanciesPanelLayout);
    discrepanciesPanelLayout.setHorizontalGroup(
            discrepanciesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(discrepanciesPanelLayout.createSequentialGroup().addContainerGap()
                            .addGroup(discrepanciesPanelLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(rejectRadioButton).addComponent(updateRadioButton)
                                    .addComponent(overwriteRadioButton))
                            .addContainerGap(12, Short.MAX_VALUE)));
    discrepanciesPanelLayout.setVerticalGroup(
            discrepanciesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(discrepanciesPanelLayout.createSequentialGroup().addComponent(rejectRadioButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(updateRadioButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(overwriteRadioButton).addContainerGap(24, Short.MAX_VALUE)));

    jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("CanReg data"));
    jPanel7.setName("jPanel7"); // NOI18N

    doChecksCheckBox.setText(resourceMap.getString("doChecksCheckBox.text")); // NOI18N
    doChecksCheckBox.setToolTipText(resourceMap.getString("doChecksCheckBox.toolTipText")); // NOI18N
    doChecksCheckBox.setEnabled(false);
    doChecksCheckBox.setName("doChecksCheckBox"); // NOI18N

    personSearchCheckBox.setSelected(true);
    personSearchCheckBox.setText(resourceMap.getString("personSearchCheckBox.text")); // NOI18N
    personSearchCheckBox.setToolTipText(resourceMap.getString("personSearchCheckBox.toolTipText")); // NOI18N
    personSearchCheckBox.setEnabled(false);
    personSearchCheckBox.setName("personSearchCheckBox"); // NOI18N

    queryNewNameCheckBox.setText(resourceMap.getString("queryNewNameCheckBox.text")); // NOI18N
    queryNewNameCheckBox.setToolTipText(resourceMap.getString("queryNewNameCheckBox.toolTipText")); // NOI18N
    queryNewNameCheckBox.setEnabled(false);
    queryNewNameCheckBox.setName("queryNewNameCheckBox"); // NOI18N

    previousCanRegDataCheckBox.setSelected(true);
    previousCanRegDataCheckBox.setText(resourceMap.getString("previousCanRegDataCheckBox.text")); // NOI18N
    previousCanRegDataCheckBox.setToolTipText(resourceMap.getString("previousCanRegDataCheckBox.toolTipText")); // NOI18N
    previousCanRegDataCheckBox.setName("previousCanRegDataCheckBox"); // NOI18N

    javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
    jPanel7.setLayout(jPanel7Layout);
    jPanel7Layout.setHorizontalGroup(jPanel7Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap()
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(doChecksCheckBox).addComponent(personSearchCheckBox)
                            .addComponent(queryNewNameCheckBox).addComponent(previousCanRegDataCheckBox))
                    .addContainerGap(94, Short.MAX_VALUE)));
    jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup().addComponent(doChecksCheckBox)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(personSearchCheckBox)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(queryNewNameCheckBox)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(previousCanRegDataCheckBox)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    maxLinesPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Max Lines"));
    maxLinesPanel.setName("maxLinesPanel"); // NOI18N

    maxLinesTextField.setToolTipText(resourceMap.getString("maxLinesTextField.toolTipText")); // NOI18N
    maxLinesTextField.setName("maxLinesTextField"); // NOI18N
    maxLinesTextField.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mousePressed(java.awt.event.MouseEvent evt) {
            maxLinesTextFieldMousePressed(evt);
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
            maxLinesTextFieldMouseReleased(evt);
        }
    });

    testOnlyCheckBox.setText(resourceMap.getString("testOnlyCheckBox.text")); // NOI18N
    testOnlyCheckBox.setToolTipText(resourceMap.getString("testOnlyCheckBox.toolTipText")); // NOI18N
    testOnlyCheckBox.setName("testOnlyCheckBox"); // NOI18N

    javax.swing.GroupLayout maxLinesPanelLayout = new javax.swing.GroupLayout(maxLinesPanel);
    maxLinesPanel.setLayout(maxLinesPanelLayout);
    maxLinesPanelLayout.setHorizontalGroup(
            maxLinesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                    javax.swing.GroupLayout.Alignment.TRAILING,
                    maxLinesPanelLayout.createSequentialGroup().addContainerGap()
                            .addGroup(maxLinesPanelLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(testOnlyCheckBox).addComponent(maxLinesTextField,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE))
                            .addContainerGap()));
    maxLinesPanelLayout.setVerticalGroup(maxLinesPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(maxLinesPanelLayout.createSequentialGroup()
                    .addComponent(maxLinesTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(testOnlyCheckBox).addContainerGap(54, Short.MAX_VALUE)));

    jPanel1.setBorder(
            javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N
    jPanel1.setName("jPanel1"); // NOI18N

    progressBar.setName("progressBar"); // NOI18N

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout
            .setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(progressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 523, Short.MAX_VALUE));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE));

    javax.swing.GroupLayout importFilePanelLayout = new javax.swing.GroupLayout(importFilePanel);
    importFilePanel.setLayout(importFilePanelLayout);
    importFilePanelLayout.setHorizontalGroup(importFilePanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(importFilePanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(importFilePanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(importFilePanelLayout.createSequentialGroup()
                                    .addComponent(discrepanciesPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(maxLinesPanel, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(importButton, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addContainerGap()));
    importFilePanelLayout.setVerticalGroup(importFilePanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(importFilePanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(importFilePanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(discrepanciesPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(maxLinesPanel, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(importButton).addGap(115, 115, 115)));

    tabbedPane.addTab("Import File", importFilePanel);

    nextButton.setAction(actionMap.get("jumpToNextTabAction")); // NOI18N
    nextButton.setName("nextButton"); // NOI18N

    cancelButton.setAction(actionMap.get("cancelAction")); // NOI18N
    cancelButton.setName("cancelButton"); // NOI18N

    backButton.setAction(actionMap.get("jumpToPreviousTabAction")); // NOI18N
    backButton.setName("backButton"); // NOI18N

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
            javax.swing.GroupLayout.Alignment.TRAILING,
            layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(tabbedPane, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup().addComponent(backButton)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(cancelButton)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(nextButton)))
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
            javax.swing.GroupLayout.Alignment.TRAILING,
            layout.createSequentialGroup().addContainerGap()
                    .addComponent(tabbedPane, javax.swing.GroupLayout.DEFAULT_SIZE, 383, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nextButton).addComponent(cancelButton).addComponent(backButton))
                    .addContainerGap()));

    pack();
}

From source file:op.care.reports.PnlReport.java

private CollapsiblePane createCP4Day(final LocalDate day) {
    final String key = DateFormat.getDateInstance().format(day.toDate());
    synchronized (cpMap) {
        if (!cpMap.containsKey(key)) {
            cpMap.put(key, new CollapsiblePane());
            try {
                cpMap.get(key).setCollapsed(true);
            } catch (PropertyVetoException e) {
                e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
            }/*  w  w w  .  j  a  va  2 s.  c  om*/
        }
    }
    final CollapsiblePane cpDay = cpMap.get(key);
    String titleDay = "<html><font size=+1>" + dayFormat.format(day.toDate())
            + SYSTools.catchNull(holidays.get(day), " (", ")") + "</font></html>";
    final DefaultCPTitle titleCPDay = new DefaultCPTitle(titleDay, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                cpDay.setCollapsed(!cpDay.isCollapsed());
            } catch (PropertyVetoException pve) {
                // BAH!
            }
        }
    });

    if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.PRINT, internalClassID)) {
        final JButton btnPrintDay = new JButton(SYSConst.icon22print2);
        btnPrintDay.setPressedIcon(SYSConst.icon22print2Pressed);
        btnPrintDay.setAlignmentX(Component.RIGHT_ALIGNMENT);
        btnPrintDay.setContentAreaFilled(false);
        btnPrintDay.setBorder(null);
        btnPrintDay.setToolTipText(SYSTools.xx("misc.tooltips.btnprintday"));
        btnPrintDay.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                SYSFilesTools.print(NReportTools.getNReportsAsHTML(NReportTools.getNReports4Day(resident, day),
                        true, null, null), false);
            }
        });
        titleCPDay.getRight().add(btnPrintDay);
    }

    cpDay.setTitleLabelComponent(titleCPDay.getMain());
    cpDay.setSlidingDirection(SwingConstants.SOUTH);

    if (holidays.containsKey(day)) {
        cpDay.setBackground(SYSConst.red1[SYSConst.medium1]);
    } else if (day.getDayOfWeek() == DateTimeConstants.SATURDAY
            || day.getDayOfWeek() == DateTimeConstants.SUNDAY) {
        cpDay.setBackground(SYSConst.red1[SYSConst.light3]);
    } else {
        cpDay.setBackground(SYSConst.orange1[SYSConst.light3]);
    }
    cpDay.setOpaque(true);

    cpDay.setHorizontalAlignment(SwingConstants.LEADING);
    cpDay.setStyle(CollapsiblePane.PLAIN_STYLE);
    cpDay.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
        @Override
        public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
            cpDay.setContentPane(createContentPanel4Day(day));
        }
    });

    if (!cpDay.isCollapsed()) {
        cpDay.setContentPane(createContentPanel4Day(day));
    }

    return cpDay;
}

From source file:op.care.reports.PnlReport.java

private CollapsiblePane createCP4Month(final LocalDate month) {
    /***//  www. j  a va 2  s . c  om
     *                          _        ____ ____     __                      __  __  ___  _   _ _____ _   _
     *       ___ _ __ ___  __ _| |_ ___ / ___|  _ \   / _| ___  _ __    __ _  |  \/  |/ _ \| \ | |_   _| | | |
     *      / __| '__/ _ \/ _` | __/ _ \ |   | |_) | | |_ / _ \| '__|  / _` | | |\/| | | | |  \| | | | | |_| |
     *     | (__| | |  __/ (_| | ||  __/ |___|  __/  |  _| (_) | |    | (_| | | |  | | |_| | |\  | | | |  _  |
     *      \___|_|  \___|\__,_|\__\___|\____|_|     |_|  \___/|_|     \__,_| |_|  |_|\___/|_| \_| |_| |_| |_|
     *
     */
    final String key = monthFormatter.format(month.toDate()) + ".month";
    synchronized (cpMap) {
        if (!cpMap.containsKey(key)) {
            cpMap.put(key, new CollapsiblePane());
            try {
                cpMap.get(key).setCollapsed(true);
            } catch (PropertyVetoException e) {
                e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
            }

        }
    }
    final CollapsiblePane cpMonth = cpMap.get(key);

    String title = "<html><font size=+1><b>" + monthFormatter.format(month.toDate()) + "</b>"
            + "</font></html>";

    DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                cpMonth.setCollapsed(!cpMonth.isCollapsed());
            } catch (PropertyVetoException pve) {
                // BAH!
            }
        }
    });

    if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.PRINT, internalClassID)) {
        /***
         *      ____       _       _   __  __             _   _
         *     |  _ \ _ __(_)_ __ | |_|  \/  | ___  _ __ | |_| |__
         *     | |_) | '__| | '_ \| __| |\/| |/ _ \| '_ \| __| '_ \
         *     |  __/| |  | | | | | |_| |  | | (_) | | | | |_| | | |
         *     |_|   |_|  |_|_| |_|\__|_|  |_|\___/|_| |_|\__|_| |_|
         *
         */
        final JButton btnPrintMonth = new JButton(SYSConst.icon22print2);
        btnPrintMonth.setPressedIcon(SYSConst.icon22print2Pressed);
        btnPrintMonth.setAlignmentX(Component.RIGHT_ALIGNMENT);
        btnPrintMonth.setContentAreaFilled(false);
        btnPrintMonth.setBorder(null);
        btnPrintMonth.setToolTipText(SYSTools.xx("misc.tooltips.btnprintmonth"));
        btnPrintMonth.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                SYSFilesTools.print(NReportTools.getNReportsAsHTML(
                        NReportTools.getNReports4Month(resident, month), true, null, null), false);
            }
        });
        cptitle.getRight().add(btnPrintMonth);
    }
    cpMonth.setTitleLabelComponent(cptitle.getMain());
    cpMonth.setSlidingDirection(SwingConstants.SOUTH);
    cpMonth.setBackground(SYSConst.orange1[SYSConst.medium2]);
    cpMonth.setOpaque(true);
    cpMonth.setHorizontalAlignment(SwingConstants.LEADING);

    cpMonth.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
        @Override
        public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
            cpMonth.setContentPane(createContentPanel4Month(month));
        }
    });

    if (!cpMonth.isCollapsed()) {
        cpMonth.setContentPane(createContentPanel4Month(month));
    }

    return cpMonth;
}

From source file:op.care.reports.PnlReport.java

private CollapsiblePane createCP4Week(final LocalDate week) {
    final String key = weekFormater.format(week.toDate()) + ".week";
    synchronized (cpMap) {
        if (!cpMap.containsKey(key)) {
            cpMap.put(key, new CollapsiblePane());
            try {
                cpMap.get(key).setCollapsed(true);
            } catch (PropertyVetoException e) {
                e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
            }/*from w  w w  . j  a  v a2 s  . c om*/

        }
    }
    final CollapsiblePane cpWeek = cpMap.get(key);

    String title = "<html><font size=+1><b>"
            + DateFormat.getDateInstance(DateFormat.SHORT).format(week.dayOfWeek().withMaximumValue().toDate())
            + " - "
            + DateFormat.getDateInstance(DateFormat.SHORT).format(week.dayOfWeek().withMinimumValue().toDate())
            + " (" + SYSTools.xx("misc.msg.weekinyear") + week.getWeekOfWeekyear() + ")" + "</b>"
            + "</font></html>";

    DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                cpWeek.setCollapsed(!cpWeek.isCollapsed());
            } catch (PropertyVetoException pve) {
                // BAH!
            }
        }
    });

    GUITools.addExpandCollapseButtons(cpWeek, cptitle.getRight());

    if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.PRINT, internalClassID)) {
        final JButton btnPrintWeek = new JButton(SYSConst.icon22print2);
        btnPrintWeek.setPressedIcon(SYSConst.icon22print2Pressed);
        btnPrintWeek.setAlignmentX(Component.RIGHT_ALIGNMENT);
        btnPrintWeek.setContentAreaFilled(false);
        btnPrintWeek.setBorder(null);
        btnPrintWeek.setToolTipText(SYSTools.xx("misc.tooltips.btnprintweek"));
        btnPrintWeek.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                SYSFilesTools.print(NReportTools.getNReportsAsHTML(
                        NReportTools.getNReports4Week(resident, week), true, null, null), false);
            }
        });
        cptitle.getRight().add(btnPrintWeek);
    }

    cpWeek.setTitleLabelComponent(cptitle.getMain());
    cpWeek.setSlidingDirection(SwingConstants.SOUTH);

    cpWeek.setBackground(SYSConst.orange1[SYSConst.medium1]);
    cpWeek.setOpaque(false);
    cpWeek.setHorizontalAlignment(SwingConstants.LEADING);
    //        cpMonth.setBackground(getColor(vtype, SYSConst.light3));

    /***
     *           _ _      _            _                                       _   _
     *       ___| (_) ___| | _____  __| |   ___  _ __    _ __ ___   ___  _ __ | |_| |__
     *      / __| | |/ __| |/ / _ \/ _` |  / _ \| '_ \  | '_ ` _ \ / _ \| '_ \| __| '_ \
     *     | (__| | | (__|   <  __/ (_| | | (_) | | | | | | | | | | (_) | | | | |_| | | |
     *      \___|_|_|\___|_|\_\___|\__,_|  \___/|_| |_| |_| |_| |_|\___/|_| |_|\__|_| |_|
     *
     */
    cpWeek.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
        @Override
        public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
            cpWeek.setContentPane(createContenPanel4Week(week));
        }
    });

    if (!cpWeek.isCollapsed()) {
        cpWeek.setContentPane(createContenPanel4Week(week));
    }

    return cpWeek;
}

From source file:op.care.reports.PnlReport.java

private CollapsiblePane createCP4Year(final int year, LocalDate min, LocalDate max) {
    /***//from ww w .  ja v a 2s  .  co  m
     *                          _        ____ ____     __             __   _______    _    ____
     *       ___ _ __ ___  __ _| |_ ___ / ___|  _ \   / _| ___  _ __  \ \ / / ____|  / \  |  _ \
     *      / __| '__/ _ \/ _` | __/ _ \ |   | |_) | | |_ / _ \| '__|  \ V /|  _|   / _ \ | |_) |
     *     | (__| | |  __/ (_| | ||  __/ |___|  __/  |  _| (_) | |      | | | |___ / ___ \|  _ <
     *      \___|_|  \___|\__,_|\__\___|\____|_|     |_|  \___/|_|      |_| |_____/_/   \_\_| \_\
     *
     */

    final LocalDate start = new LocalDate(year, 1, 1).isBefore(min.dayOfMonth().withMinimumValue())
            ? min.dayOfMonth().withMinimumValue()
            : new LocalDate(year, 1, 1);
    final LocalDate end = new LocalDate(year, 12, 31).isAfter(max.dayOfMonth().withMaximumValue())
            ? max.dayOfMonth().withMaximumValue()
            : new LocalDate(year, 12, 31);

    final String keyYear = Integer.toString(year) + ".year";
    synchronized (cpMap) {
        if (!cpMap.containsKey(keyYear)) {
            cpMap.put(keyYear, new CollapsiblePane());
            try {
                cpMap.get(keyYear).setCollapsed(true);
            } catch (PropertyVetoException e) {
                e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
            }

        }
    }

    final CollapsiblePane cpYear = cpMap.get(keyYear);

    String title = "<html><font size=+1>" + "<b>" + Integer.toString(year) + "</b>" + "</font></html>";

    DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                cpYear.setCollapsed(!cpYear.isCollapsed());
            } catch (PropertyVetoException pve) {
                // BAH!
            }
        }
    });

    cpYear.setTitleLabelComponent(cptitle.getMain());
    cpYear.setSlidingDirection(SwingConstants.SOUTH);
    cpYear.setBackground(SYSConst.orange1[SYSConst.medium3]);
    cpYear.setOpaque(true);

    /***
     *           _ _      _            _
     *       ___| (_) ___| | _____  __| |   ___  _ __    _   _  ___  __ _ _ __
     *      / __| | |/ __| |/ / _ \/ _` |  / _ \| '_ \  | | | |/ _ \/ _` | '__|
     *     | (__| | | (__|   <  __/ (_| | | (_) | | | | | |_| |  __/ (_| | |
     *      \___|_|_|\___|_|\_\___|\__,_|  \___/|_| |_|  \__, |\___|\__,_|_|
     *                                                   |___/
     */
    cpYear.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
        @Override
        public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
            JPanel pnlContent = new JPanel(new VerticalLayout());

            // somebody clicked on the year
            for (LocalDate month = end; month.compareTo(start) >= 0; month = month.minusMonths(1)) {
                pnlContent.add(createCP4Month(month));
            }

            cpYear.setContentPane(pnlContent);

        }
    });
    //        cpYear.setBackground(getColor(vtype, SYSConst.light4));

    if (!cpYear.isCollapsed()) {
        JPanel pnlContent = new JPanel(new VerticalLayout());

        for (LocalDate month = end; month.compareTo(start) >= 0; month = month.minusMonths(1)) {
            pnlContent.add(createCP4Month(month));
        }

        cpYear.setContentPane(pnlContent);
        cpYear.setOpaque(false);
    }

    cpYear.setHorizontalAlignment(SwingConstants.LEADING);
    cpYear.setOpaque(false);

    return cpYear;
}

From source file:op.care.med.inventory.PnlInventory.java

private CollapsiblePane createCP4(final MedStock stock) {
    /***//from   w  w  w  .j av a2  s  .c o  m
     *                          _        ____ ____  _  _    __   _             _   __
     *       ___ _ __ ___  __ _| |_ ___ / ___|  _ \| || |  / /__| |_ ___   ___| | _\ \
     *      / __| '__/ _ \/ _` | __/ _ \ |   | |_) | || |_| / __| __/ _ \ / __| |/ /| |
     *     | (__| | |  __/ (_| | ||  __/ |___|  __/|__   _| \__ \ || (_) | (__|   < | |
     *      \___|_|  \___|\__,_|\__\___|\____|_|      |_| | |___/\__\___/ \___|_|\_\| |
     *                                                     \_\                     /_/
     */
    final String key = stock.getID() + ".xstock";
    synchronized (cpMap) {
        if (!cpMap.containsKey(key)) {
            cpMap.put(key, new CollapsiblePane());
            try {
                cpMap.get(key).setCollapsed(true);
            } catch (PropertyVetoException e) {
                e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
            }

        }
        cpMap.get(key).setName("stock");

        BigDecimal sumStock = BigDecimal.ZERO;
        try {
            EntityManager em = OPDE.createEM();
            sumStock = MedStockTools.getSum(em, stock);
            em.close();
        } catch (Exception e) {
            OPDE.fatal(e);
        }

        String title = "<html><table border=\"0\">" + "<tr>" + (stock.isClosed() ? "<s>" : "")
                + "<td width=\"600\" align=\"left\">" + MedStockTools.getAsHTML(stock) + "</td>"
                + "<td width=\"200\" align=\"right\">" + NumberFormat.getNumberInstance().format(sumStock) + " "
                + DosageFormTools.getPackageText(MedInventoryTools.getForm(stock.getInventory())) + "</td>"
                + (stock.isClosed() ? "</s>" : "") + "</tr>" + "</table>" +

                "</html>";

        DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    cpMap.get(key).setCollapsed(!cpMap.get(key).isCollapsed());
                } catch (PropertyVetoException pve) {
                    // BAH!
                }
            }
        });

        cpMap.get(key).setTitleLabelComponent(cptitle.getMain());
        cpMap.get(key).setSlidingDirection(SwingConstants.SOUTH);

        cptitle.getRight().add(new StockPanel(stock));

        if (!stock.getInventory().isClosed()) {
            /***
             *      ____       _       _   _          _          _
             *     |  _ \ _ __(_)_ __ | |_| |    __ _| |__   ___| |
             *     | |_) | '__| | '_ \| __| |   / _` | '_ \ / _ \ |
             *     |  __/| |  | | | | | |_| |__| (_| | |_) |  __/ |
             *     |_|   |_|  |_|_| |_|\__|_____\__,_|_.__/ \___|_|
             *
             */
            final JButton btnPrintLabel = new JButton(SYSConst.icon22print2);
            btnPrintLabel.setPressedIcon(SYSConst.icon22print2Pressed);
            btnPrintLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
            btnPrintLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnPrintLabel.setContentAreaFilled(false);
            btnPrintLabel.setBorder(null);
            btnPrintLabel.setToolTipText(SYSTools.xx("nursingrecords.inventory.stock.btnprintlabel.tooltip"));
            btnPrintLabel.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent actionEvent) {
                    LogicalPrinter logicalPrinter = OPDE.getLogicalPrinters().getMapName2LogicalPrinter()
                            .get(OPDE.getProps().getProperty(SYSPropsTools.KEY_LOGICAL_PRINTER));
                    PrinterForm printerForm1 = logicalPrinter.getForms()
                            .get(OPDE.getProps().getProperty(SYSPropsTools.KEY_MEDSTOCK_LABEL));
                    OPDE.getPrintProcessor().addPrintJob(new PrintListElement(stock, logicalPrinter,
                            printerForm1, OPDE.getProps().getProperty(SYSPropsTools.KEY_PHYSICAL_PRINTER)));
                }
            });
            btnPrintLabel.setEnabled(OPDE.getPrintProcessor().isWorking());
            cptitle.getRight().add(btnPrintLabel);
        }

        /***
         *      __  __
         *     |  \/  | ___ _ __  _   _
         *     | |\/| |/ _ \ '_ \| | | |
         *     | |  | |  __/ | | | |_| |
         *     |_|  |_|\___|_| |_|\__,_|
         *
         */
        final JButton btnMenu = new JButton(SYSConst.icon22menu);
        btnMenu.setPressedIcon(SYSConst.icon22Pressed);
        btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT);
        //        btnMenu.setAlignmentY(Component.TOP_ALIGNMENT);
        btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnMenu.setContentAreaFilled(false);
        btnMenu.setBorder(null);
        btnMenu.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JidePopup popup = new JidePopup();
                popup.setMovable(false);
                popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS));
                popup.setOwner(btnMenu);
                popup.removeExcludedComponent(btnMenu);
                JPanel pnl = getMenu(stock);
                popup.getContentPane().add(pnl);
                popup.setDefaultFocusComponent(pnl);

                GUITools.showPopup(popup, SwingConstants.WEST);
            }
        });
        cptitle.getRight().add(btnMenu);

        CollapsiblePaneAdapter adapter = new CollapsiblePaneAdapter() {
            @Override
            public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
                cpMap.get(key).setContentPane(createContentPanel4(stock));
            }
        };
        synchronized (cpListener) {
            if (cpListener.containsKey(key)) {
                cpMap.get(key).removeCollapsiblePaneListener(cpListener.get(key));
            }
            cpListener.put(key, adapter);
            cpMap.get(key).addCollapsiblePaneListener(adapter);
        }

        if (!cpMap.get(key).isCollapsed()) {
            JPanel contentPane = createContentPanel4(stock);
            cpMap.get(key).setContentPane(contentPane);
        }

        cpMap.get(key).setHorizontalAlignment(SwingConstants.LEADING);
        cpMap.get(key).setOpaque(false);
        cpMap.get(key).setBackground(
                getColor(SYSConst.light3, lstInventories.indexOf(stock.getInventory()) % 2 != 0));

        return cpMap.get(key);
    }
}

From source file:canreg.client.gui.analysis.TableBuilderInternalFrame.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//from ww w. ja v a  2s .  co m
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    tabbedPane = new javax.swing.JTabbedPane();
    tableTypePanel = new javax.swing.JPanel();
    tableTypeScrollPane = new javax.swing.JScrollPane();
    tableTypeList = new javax.swing.JList();
    descriptionScrollPane = new javax.swing.JScrollPane();
    descriptionTextPane = new javax.swing.JTextPane();
    descriptionLabel = new javax.swing.JLabel();
    typeLabel = new javax.swing.JLabel();
    previewLabel = new javax.swing.JLabel();
    previewImageLabel = new javax.swing.JLabel();
    rangePanel = new javax.swing.JPanel();
    startYearChooser = new com.toedter.calendar.JYearChooser();
    startYearLabel = new javax.swing.JLabel();
    endYearLabel = new javax.swing.JLabel();
    endYearChooser = new com.toedter.calendar.JYearChooser();
    jLabel6 = new javax.swing.JLabel();
    midYearTextField = new javax.swing.JTextField();
    jLabel7 = new javax.swing.JLabel();
    numberOfYearsTextField = new javax.swing.JTextField();
    warningLabel = new javax.swing.JLabel();
    populationDatasetChooserPanel = new javax.swing.JPanel();
    pleaseChooseLabel = new javax.swing.JLabel();
    populationDatasetsScrollPane = new javax.swing.JScrollPane();
    populationDatasetChoosersPanel = new javax.swing.JPanel();
    dontUsePopulationDatasetCheckBox = new javax.swing.JCheckBox();
    filterPanel = new javax.swing.JPanel();
    writeOutPanel = new javax.swing.JPanel();
    postScriptButton = new javax.swing.JButton();
    tabulatedButton = new javax.swing.JButton();
    headerOfTableLabel = new javax.swing.JLabel();
    headerOfTableTextField = new javax.swing.JTextField();
    imageButton = new javax.swing.JButton();
    pdfButton = new javax.swing.JButton();
    svgButton = new javax.swing.JButton();
    wmfButton = new javax.swing.JButton();
    chartViewerButton = new javax.swing.JButton();
    seerPrepButton = new javax.swing.JButton();
    csvButton = new javax.swing.JButton();
    tiffButton = new javax.swing.JButton();
    docxButton = new javax.swing.JButton();
    pptxButton = new javax.swing.JButton();
    backButton = new javax.swing.JButton();
    cancelButton = new javax.swing.JButton();
    nextButton = new javax.swing.JButton();

    setClosable(true);
    setResizable(true);
    org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application
            .getInstance(canreg.client.CanRegClientApp.class).getContext()
            .getResourceMap(TableBuilderInternalFrame.class);
    setTitle(resourceMap.getString("Form.title")); // NOI18N
    setFrameIcon(resourceMap.getIcon("Form.frameIcon")); // NOI18N
    setName("Form"); // NOI18N
    try {
        setSelected(true);
    } catch (java.beans.PropertyVetoException e1) {
        e1.printStackTrace();
    }

    tabbedPane.setName("tabbedPane"); // NOI18N
    tabbedPane.addFocusListener(new java.awt.event.FocusAdapter() {
        public void focusLost(java.awt.event.FocusEvent evt) {
            tabbedPaneFocusLost(evt);
        }
    });

    tableTypePanel.setName("tableTypePanel"); // NOI18N
    tableTypePanel.addFocusListener(new java.awt.event.FocusAdapter() {
        public void focusLost(java.awt.event.FocusEvent evt) {
            tableTypePanelFocusLost(evt);
        }
    });

    tableTypeScrollPane.setName("tableTypeScrollPane"); // NOI18N

    tableTypeList.setModel(new javax.swing.AbstractListModel() {
        String[] strings = { "Incidence per 100000 by Age groups (Annual)",
                "Incidence per 100000 by Age groups (Period)" };

        public int getSize() {
            return strings.length;
        }

        public Object getElementAt(int i) {
            return strings[i];
        }
    });
    tableTypeList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    tableTypeList.setName("tableTypeList"); // NOI18N
    tableTypeList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            tableTypeListValueChanged(evt);
        }
    });
    tableTypeList.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            tableTypeListPropertyChange(evt);
        }
    });
    tableTypeScrollPane.setViewportView(tableTypeList);

    descriptionScrollPane.setName("descriptionScrollPane"); // NOI18N

    descriptionTextPane.setEditable(false);
    descriptionTextPane.setName("descriptionTextPane"); // NOI18N
    descriptionScrollPane.setViewportView(descriptionTextPane);

    descriptionLabel.setName("descriptionLabel"); // NOI18N

    typeLabel.setName("typeLabel"); // NOI18N

    previewLabel.setName("previewLabel"); // NOI18N

    previewImageLabel.setName("previewImageLabel"); // NOI18N

    javax.swing.GroupLayout tableTypePanelLayout = new javax.swing.GroupLayout(tableTypePanel);
    tableTypePanel.setLayout(tableTypePanelLayout);
    tableTypePanelLayout.setHorizontalGroup(tableTypePanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tableTypePanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(tableTypePanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tableTypeScrollPane, javax.swing.GroupLayout.Alignment.TRAILING,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                            .addComponent(typeLabel)
                            .addGroup(tableTypePanelLayout.createSequentialGroup()
                                    .addGroup(tableTypePanelLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(descriptionLabel).addComponent(descriptionScrollPane,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 240,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(tableTypePanelLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(previewLabel).addComponent(previewImageLabel,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, 230,
                                                    Short.MAX_VALUE))))
                    .addContainerGap()));
    tableTypePanelLayout.setVerticalGroup(tableTypePanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tableTypePanelLayout.createSequentialGroup().addContainerGap().addComponent(typeLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(tableTypeScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                            tableTypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(descriptionLabel).addComponent(previewLabel))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(
                            tableTypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(previewImageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 258,
                                            Short.MAX_VALUE)
                                    .addComponent(descriptionScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            258, Short.MAX_VALUE))
                    .addContainerGap()));

    tabbedPane.addTab(resourceMap.getString("tableTypePanel.TabConstraints.tabTitle"), tableTypePanel); // NOI18N

    rangePanel.setName("rangePanel"); // NOI18N

    startYearChooser.setName("startYearChooser"); // NOI18N
    startYearChooser.setStartYear(-292278994);
    startYearChooser.setValue(1999);
    startYearChooser.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            startYearChooserPropertyChange(evt);
        }
    });

    startYearLabel.setText(resourceMap.getString("startYearLabel.text")); // NOI18N
    startYearLabel.setName("startYearLabel"); // NOI18N

    endYearLabel.setText(resourceMap.getString("endYearLabel.text")); // NOI18N
    endYearLabel.setName("endYearLabel"); // NOI18N

    endYearChooser.setDayChooser(null);
    endYearChooser.setName("endYearChooser"); // NOI18N
    endYearChooser.setStartYear(-292278994);
    endYearChooser.setValue(2001);
    endYearChooser.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
            endYearChooserPropertyChange(evt);
        }
    });

    jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
    jLabel6.setName("jLabel6"); // NOI18N

    midYearTextField.setEditable(false);
    midYearTextField.setName("midYearTextField"); // NOI18N

    jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
    jLabel7.setName("jLabel7"); // NOI18N

    numberOfYearsTextField.setEditable(false);
    numberOfYearsTextField.setName("numberOfYearsTextField"); // NOI18N

    warningLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    warningLabel.setText(resourceMap.getString("warningLabel.text")); // NOI18N
    warningLabel.setName("warningLabel"); // NOI18N

    javax.swing.GroupLayout rangePanelLayout = new javax.swing.GroupLayout(rangePanel);
    rangePanel.setLayout(rangePanelLayout);
    rangePanelLayout
            .setHorizontalGroup(rangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, rangePanelLayout
                            .createSequentialGroup().addContainerGap().addGroup(rangePanelLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(
                                            warningLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 474,
                                            Short.MAX_VALUE)
                                    .addGroup(rangePanelLayout.createSequentialGroup().addGroup(rangePanelLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel6).addComponent(endYearLabel)
                                            .addComponent(startYearLabel).addComponent(jLabel7))
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                    179, Short.MAX_VALUE)
                                            .addGroup(rangePanelLayout
                                                    .createParallelGroup(
                                                            javax.swing.GroupLayout.Alignment.LEADING, false)
                                                    .addComponent(startYearChooser,
                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .addComponent(endYearChooser,
                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .addComponent(numberOfYearsTextField,
                                                            javax.swing.GroupLayout.Alignment.TRAILING,
                                                            javax.swing.GroupLayout.DEFAULT_SIZE, 211,
                                                            Short.MAX_VALUE)
                                                    .addComponent(midYearTextField,
                                                            javax.swing.GroupLayout.Alignment.TRAILING))))
                            .addContainerGap()));
    rangePanelLayout.setVerticalGroup(rangePanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(rangePanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(rangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(startYearLabel).addComponent(startYearChooser,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(rangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(endYearLabel)
                            .addComponent(endYearChooser, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(rangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6).addComponent(midYearTextField,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(rangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7).addComponent(numberOfYearsTextField,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(warningLabel).addContainerGap(308, Short.MAX_VALUE)));

    tabbedPane.addTab(resourceMap.getString("rangePanel.TabConstraints.tabTitle"), rangePanel); // NOI18N

    populationDatasetChooserPanel.setName("populationDatasetChooserPanel"); // NOI18N

    pleaseChooseLabel.setText(resourceMap.getString("pleaseChooseLabel.text")); // NOI18N
    pleaseChooseLabel.setName("pleaseChooseLabel"); // NOI18N

    populationDatasetsScrollPane.setName("populationDatasetsScrollPane"); // NOI18N

    populationDatasetChoosersPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
    populationDatasetChoosersPanel.setName("populationDatasetChoosersPanel"); // NOI18N
    populationDatasetChoosersPanel.setLayout(new java.awt.GridLayout(0, 1));
    populationDatasetsScrollPane.setViewportView(populationDatasetChoosersPanel);

    javax.swing.ActionMap actionMap = org.jdesktop.application.Application
            .getInstance(canreg.client.CanRegClientApp.class).getContext()
            .getActionMap(TableBuilderInternalFrame.class, this);
    dontUsePopulationDatasetCheckBox.setAction(actionMap.get("dontUsePopsCheckboxUpdated")); // NOI18N
    dontUsePopulationDatasetCheckBox.setText(resourceMap.getString("dontUsePopulationDatasetCheckBox.text")); // NOI18N
    dontUsePopulationDatasetCheckBox
            .setToolTipText(resourceMap.getString("dontUsePopulationDatasetCheckBox.toolTipText")); // NOI18N
    dontUsePopulationDatasetCheckBox.setName("dontUsePopulationDatasetCheckBox"); // NOI18N
    dontUsePopulationDatasetCheckBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            dontUsePopulationDatasetCheckBoxActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout populationDatasetChooserPanelLayout = new javax.swing.GroupLayout(
            populationDatasetChooserPanel);
    populationDatasetChooserPanel.setLayout(populationDatasetChooserPanelLayout);
    populationDatasetChooserPanelLayout.setHorizontalGroup(populationDatasetChooserPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(populationDatasetChooserPanelLayout.createSequentialGroup().addContainerGap()
                    .addGroup(populationDatasetChooserPanelLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(populationDatasetsScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    474, Short.MAX_VALUE)
                            .addComponent(pleaseChooseLabel).addComponent(dontUsePopulationDatasetCheckBox,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE))
                    .addContainerGap()));
    populationDatasetChooserPanelLayout.setVerticalGroup(populationDatasetChooserPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(populationDatasetChooserPanelLayout.createSequentialGroup().addContainerGap()
                    .addComponent(pleaseChooseLabel)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(populationDatasetsScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 352,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
                    .addComponent(dontUsePopulationDatasetCheckBox).addContainerGap()));

    tabbedPane.addTab(resourceMap.getString("populationDatasetChooserPanel.TabConstraints.tabTitle"),
            populationDatasetChooserPanel); // NOI18N

    filterPanel.setEnabled(false);
    filterPanel.setFocusable(false);
    filterPanel.setName("filterPanel"); // NOI18N
    filterPanel.setRequestFocusEnabled(false);
    tabbedPane.addTab(resourceMap.getString("filterPanel.TabConstraints.tabTitle"), filterPanel); // NOI18N

    writeOutPanel.setName("writeOutPanel"); // NOI18N

    postScriptButton.setAction(actionMap.get("generatePStable")); // NOI18N
    postScriptButton.setText(resourceMap.getString("postScriptButton.text")); // NOI18N
    postScriptButton.setToolTipText(resourceMap.getString("postScriptButton.toolTipText")); // NOI18N
    postScriptButton.setName("postScriptButton"); // NOI18N
    postScriptButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            postScriptButtonActionPerformed(evt);
        }
    });

    tabulatedButton.setAction(actionMap.get("generateTabulatedTables")); // NOI18N
    tabulatedButton.setText(resourceMap.getString("tabulatedButton.text")); // NOI18N
    tabulatedButton.setToolTipText(resourceMap.getString("tabulatedButton.toolTipText")); // NOI18N
    tabulatedButton.setName("tabulatedButton"); // NOI18N

    headerOfTableLabel.setText(resourceMap.getString("headerOfTableLabel.text")); // NOI18N
    headerOfTableLabel.setName("headerOfTableLabel"); // NOI18N

    headerOfTableTextField.setText(resourceMap.getString("headerOfTableTextField.text")); // NOI18N
    headerOfTableTextField.setName("headerOfTableTextField"); // NOI18N
    headerOfTableTextField.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mousePressed(java.awt.event.MouseEvent evt) {
            headerOfTableTextFieldMousePressed(evt);
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
            headerOfTableTextFieldMouseReleased(evt);
        }
    });

    imageButton.setAction(actionMap.get("generatePNGTable")); // NOI18N
    imageButton.setText(resourceMap.getString("imageButton.text")); // NOI18N
    imageButton.setToolTipText(resourceMap.getString("imageButton.toolTipText")); // NOI18N
    imageButton.setName("imageButton"); // NOI18N

    pdfButton.setAction(actionMap.get("generatePDFtable")); // NOI18N
    pdfButton.setText(resourceMap.getString("pdfButton.text")); // NOI18N
    pdfButton.setToolTipText(resourceMap.getString("pdfButton.toolTipText")); // NOI18N
    pdfButton.setName("pdfButton"); // NOI18N
    pdfButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            pdfButtonActionPerformed(evt);
        }
    });

    svgButton.setAction(actionMap.get("generateSVGFile")); // NOI18N
    svgButton.setText(resourceMap.getString("svgButton.text")); // NOI18N
    svgButton.setToolTipText(resourceMap.getString("svgButton.toolTipText")); // NOI18N
    svgButton.setName("svgButton"); // NOI18N
    svgButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            svgButtonActionPerformed(evt);
        }
    });

    wmfButton.setAction(actionMap.get("generateWMFAction")); // NOI18N
    wmfButton.setText(resourceMap.getString("wmfButton.text")); // NOI18N
    wmfButton.setToolTipText(resourceMap.getString("wmfButton.toolTipText")); // NOI18N
    wmfButton.setName("wmfButton"); // NOI18N
    wmfButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            wmfButtonActionPerformed(evt);
        }
    });

    chartViewerButton.setAction(actionMap.get("openInChartViewer")); // NOI18N
    chartViewerButton.setText(resourceMap.getString("chartViewerButton.text")); // NOI18N
    chartViewerButton.setToolTipText(resourceMap.getString("chartViewerButton.toolTipText")); // NOI18N
    chartViewerButton.setName("chartViewerButton"); // NOI18N

    seerPrepButton.setAction(actionMap.get("generateFilesForSEERPrepAction")); // NOI18N
    seerPrepButton.setText(resourceMap.getString("seerPrepButton.text")); // NOI18N
    seerPrepButton.setName("seerPrepButton"); // NOI18N

    csvButton.setAction(actionMap.get("generateCSV")); // NOI18N
    csvButton.setText(resourceMap.getString("csvButton.text")); // NOI18N
    csvButton.setToolTipText(resourceMap.getString("csvButton.toolTipText")); // NOI18N
    csvButton.setName("csvButton"); // NOI18N

    tiffButton.setAction(actionMap.get("generateTIFF")); // NOI18N
    tiffButton.setText(resourceMap.getString("tiffButton.text")); // NOI18N
    tiffButton.setToolTipText(resourceMap.getString("tiffButton.toolTipText")); // NOI18N
    tiffButton.setName("tiffButton"); // NOI18N

    docxButton.setAction(actionMap.get("generateDOCX")); // NOI18N
    docxButton.setText(resourceMap.getString("docxButton.text")); // NOI18N
    docxButton.setName("docxButton"); // NOI18N

    pptxButton.setAction(actionMap.get("generatePPTX")); // NOI18N
    pptxButton.setText(resourceMap.getString("pptxButton.text")); // NOI18N
    pptxButton.setToolTipText(resourceMap.getString("pptxButton.toolTipText")); // NOI18N
    pptxButton.setName("pptxButton"); // NOI18N

    javax.swing.GroupLayout writeOutPanelLayout = new javax.swing.GroupLayout(writeOutPanel);
    writeOutPanel.setLayout(writeOutPanelLayout);
    writeOutPanelLayout.setHorizontalGroup(writeOutPanelLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(writeOutPanelLayout.createSequentialGroup().addContainerGap().addGroup(writeOutPanelLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(writeOutPanelLayout.createSequentialGroup().addComponent(headerOfTableLabel)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(headerOfTableTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 387,
                                    Short.MAX_VALUE))
                    .addComponent(pdfButton, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addComponent(postScriptButton, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addComponent(wmfButton, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addComponent(tabulatedButton, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addComponent(svgButton, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addComponent(imageButton, javax.swing.GroupLayout.Alignment.TRAILING,
                            javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addComponent(csvButton, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addComponent(chartViewerButton, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addComponent(seerPrepButton, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addComponent(tiffButton, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addComponent(docxButton, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addComponent(pptxButton, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE))
                    .addContainerGap()));
    writeOutPanelLayout
            .setVerticalGroup(writeOutPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(writeOutPanelLayout.createSequentialGroup().addContainerGap()
                            .addGroup(writeOutPanelLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(headerOfTableLabel).addComponent(headerOfTableTextField,
                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(pdfButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(postScriptButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(svgButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(imageButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(wmfButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(tabulatedButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(tiffButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(docxButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(pptxButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(csvButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(chartViewerButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(seerPrepButton).addContainerGap(53, Short.MAX_VALUE)));

    tabbedPane.addTab(resourceMap.getString("writeOutPanel.TabConstraints.tabTitle"), writeOutPanel); // NOI18N

    backButton.setAction(actionMap.get("jumpToPreviousTabAction")); // NOI18N
    backButton.setName("backButton"); // NOI18N

    cancelButton.setAction(actionMap.get("cancelAction")); // NOI18N
    cancelButton.setName("cancelButton"); // NOI18N

    nextButton.setAction(actionMap.get("jumpToNextTabAction")); // NOI18N
    nextButton.setName("nextButton"); // NOI18N

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
            javax.swing.GroupLayout.Alignment.TRAILING,
            layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(tabbedPane, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup().addComponent(backButton)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(cancelButton)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(nextButton)))
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
            javax.swing.GroupLayout.Alignment.TRAILING,
            layout.createSequentialGroup().addContainerGap().addComponent(tabbedPane)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nextButton).addComponent(cancelButton).addComponent(backButton))
                    .addContainerGap()));

    pack();
}

From source file:op.care.prescription.PnlPrescription.java

private CollapsiblePane createCP4(final Prescription prescription) {
    /***//  w  ww .j  av a 2 s . c  o  m
     *                          _        ____ ____  _  _    ______                          _       _   _           __
     *       ___ _ __ ___  __ _| |_ ___ / ___|  _ \| || |  / /  _ \ _ __ ___  ___  ___ _ __(_)_ __ | |_(_) ___  _ __\ \
     *      / __| '__/ _ \/ _` | __/ _ \ |   | |_) | || |_| || |_) | '__/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \| |
     *     | (__| | |  __/ (_| | ||  __/ |___|  __/|__   _| ||  __/| | |  __/\__ \ (__| |  | | |_) | |_| | (_) | | | | |
     *      \___|_|  \___|\__,_|\__\___|\____|_|      |_| | ||_|   |_|  \___||___/\___|_|  |_| .__/ \__|_|\___/|_| |_| |
     *                                                     \_\                               |_|                    /_/
     */
    final String key = prescription.getID() + ".xprescription";
    if (!cpMap.containsKey(key)) {
        cpMap.put(key, new CollapsiblePane());
        try {
            cpMap.get(key).setCollapsed(true);
        } catch (PropertyVetoException e) {
            e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        }
    }
    final CollapsiblePane cpPres = cpMap.get(key);

    String title = "<html><table border=\"0\">" + "<tr valign=\"top\">" + "<td width=\"280\" align=\"left\">"
            + prescription.getPITAsHTML() + "</td>" + "<td width=\"380\" align=\"left\">" + "<font size=+1>"
            + PrescriptionTools.getShortDescription(prescription) + "</font>"
            + PrescriptionTools.getDoseAsHTML(prescription)
            + PrescriptionTools.getInventoryInformationAsHTML(prescription) + "</td>"
            + "<td width=\"200\" align=\"left\">" + PrescriptionTools.getOriginalPrescription(prescription)
            + PrescriptionTools.getRemark(prescription) + "</td>";

    if (!prescription.getCommontags().isEmpty()) {
        title += "<tr>" + "    <td colspan=\"3\">" + CommontagsTools.getAsHTML(prescription.getCommontags(),
                SYSConst.html_16x16_tagPurple_internal) + "</td>" + "  </tr>";
    }

    if (PrescriptionTools.isAnnotationNecessary(prescription)) {
        title += "<tr>" + "    <td colspan=\"3\">" + PrescriptionTools.getAnnontationsAsHTML(prescription)
                + "</td>" + "  </tr>";
    }

    title += "</table>" + "</html>";

    DefaultCPTitle cptitle = new DefaultCPTitle(title, null);
    cpPres.setCollapsible(false);
    cptitle.getButton().setIcon(getIcon(prescription));

    cpPres.setTitleLabelComponent(cptitle.getMain());
    cpPres.setSlidingDirection(SwingConstants.SOUTH);

    if (!prescription.getAttachedFilesConnections().isEmpty()) {
        /***
         *      _     _         _____ _ _
         *     | |__ | |_ _ __ |  ___(_) | ___  ___
         *     | '_ \| __| '_ \| |_  | | |/ _ \/ __|
         *     | |_) | |_| | | |  _| | | |  __/\__ \
         *     |_.__/ \__|_| |_|_|   |_|_|\___||___/
         *
         */
        final JButton btnFiles = new JButton(
                Integer.toString(prescription.getAttachedFilesConnections().size()), SYSConst.icon22greenStar);
        btnFiles.setToolTipText(SYSTools.xx("misc.btnfiles.tooltip"));
        btnFiles.setForeground(Color.BLUE);
        btnFiles.setHorizontalTextPosition(SwingUtilities.CENTER);
        btnFiles.setFont(SYSConst.ARIAL18BOLD);
        btnFiles.setPressedIcon(SYSConst.icon22Pressed);
        btnFiles.setAlignmentX(Component.RIGHT_ALIGNMENT);
        btnFiles.setAlignmentY(Component.TOP_ALIGNMENT);
        btnFiles.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnFiles.setContentAreaFilled(false);
        btnFiles.setBorder(null);

        btnFiles.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                // checked for acls
                Closure fileHandleClosure = OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE,
                        internalClassID) ? null : new Closure() {
                            @Override
                            public void execute(Object o) {
                                EntityManager em = OPDE.createEM();
                                final Prescription myPrescription = em.find(Prescription.class,
                                        prescription.getID());
                                em.close();
                                lstPrescriptions.remove(prescription);
                                lstPrescriptions.add(myPrescription);
                                Collections.sort(lstPrescriptions);
                                final CollapsiblePane myCP = createCP4(myPrescription);
                                buildPanel();
                                GUITools.flashBackground(myCP, Color.YELLOW, 2);
                            }
                        };
                new DlgFiles(prescription, fileHandleClosure);
            }
        });
        btnFiles.setEnabled(OPDE.isFTPworking());
        cptitle.getRight().add(btnFiles);
    }

    if (!prescription.getAttachedProcessConnections().isEmpty()) {
        /***
         *      _     _         ____
         *     | |__ | |_ _ __ |  _ \ _ __ ___   ___ ___  ___ ___
         *     | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __|
         *     | |_) | |_| | | |  __/| | | (_) | (_|  __/\__ \__ \
         *     |_.__/ \__|_| |_|_|   |_|  \___/ \___\___||___/___/
         *
         */
        final JButton btnProcess = new JButton(
                Integer.toString(prescription.getAttachedProcessConnections().size()), SYSConst.icon22redStar);
        btnProcess.setToolTipText(SYSTools.xx("misc.btnprocess.tooltip"));
        btnProcess.setForeground(Color.YELLOW);
        btnProcess.setHorizontalTextPosition(SwingUtilities.CENTER);
        btnProcess.setFont(SYSConst.ARIAL18BOLD);
        btnProcess.setPressedIcon(SYSConst.icon22Pressed);
        btnProcess.setAlignmentX(Component.RIGHT_ALIGNMENT);
        btnProcess.setAlignmentY(Component.TOP_ALIGNMENT);
        btnProcess.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnProcess.setContentAreaFilled(false);
        btnProcess.setBorder(null);
        btnProcess.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                new DlgProcessAssign(prescription, new Closure() {
                    @Override
                    public void execute(Object o) {
                        if (o == null) {
                            return;
                        }
                        Pair<ArrayList<QProcess>, ArrayList<QProcess>> result = (Pair<ArrayList<QProcess>, ArrayList<QProcess>>) o;

                        ArrayList<QProcess> assigned = result.getFirst();
                        ArrayList<QProcess> unassigned = result.getSecond();

                        EntityManager em = OPDE.createEM();

                        try {
                            em.getTransaction().begin();

                            em.lock(em.merge(resident), LockModeType.OPTIMISTIC);
                            Prescription myPrescription = em.merge(prescription);
                            em.lock(myPrescription, LockModeType.OPTIMISTIC_FORCE_INCREMENT);

                            ArrayList<SYSPRE2PROCESS> attached = new ArrayList<SYSPRE2PROCESS>(
                                    prescription.getAttachedProcessConnections());
                            for (SYSPRE2PROCESS linkObject : attached) {
                                if (unassigned.contains(linkObject.getQProcess())) {
                                    linkObject.getQProcess().getAttachedNReportConnections().remove(linkObject);
                                    linkObject.getPrescription().getAttachedProcessConnections()
                                            .remove(linkObject);
                                    em.merge(new PReport(
                                            SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": "
                                                    + myPrescription.getTitle() + " ID: "
                                                    + myPrescription.getID(),
                                            PReportTools.PREPORT_TYPE_REMOVE_ELEMENT,
                                            linkObject.getQProcess()));
                                    em.remove(linkObject);
                                }
                            }
                            attached.clear();

                            for (QProcess qProcess : assigned) {
                                List<QProcessElement> listElements = qProcess.getElements();
                                if (!listElements.contains(myPrescription)) {
                                    QProcess myQProcess = em.merge(qProcess);
                                    SYSPRE2PROCESS myLinkObject = em
                                            .merge(new SYSPRE2PROCESS(myQProcess, myPrescription));
                                    em.merge(new PReport(
                                            SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": "
                                                    + myPrescription.getTitle() + " ID: "
                                                    + myPrescription.getID(),
                                            PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess));
                                    qProcess.getAttachedPrescriptionConnections().add(myLinkObject);
                                    myPrescription.getAttachedProcessConnections().add(myLinkObject);
                                }
                            }

                            em.getTransaction().commit();

                            lstPrescriptions.remove(prescription);
                            lstPrescriptions.add(myPrescription);
                            Collections.sort(lstPrescriptions);
                            final CollapsiblePane myCP = createCP4(myPrescription);
                            buildPanel();
                            GUITools.flashBackground(myCP, Color.YELLOW, 2);

                        } catch (OptimisticLockException ole) {
                            OPDE.warn(ole);
                            if (em.getTransaction().isActive()) {
                                em.getTransaction().rollback();
                            }
                            if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                                OPDE.getMainframe().emptyFrame();
                                OPDE.getMainframe().afterLogin();
                            }
                            OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
                        } catch (RollbackException ole) {
                            if (em.getTransaction().isActive()) {
                                em.getTransaction().rollback();
                            }
                            if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                                OPDE.getMainframe().emptyFrame();
                                OPDE.getMainframe().afterLogin();
                            }
                            OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
                        } catch (Exception e) {
                            if (em.getTransaction().isActive()) {
                                em.getTransaction().rollback();
                            }
                            OPDE.fatal(e);
                        } finally {
                            em.close();
                        }

                    }
                });
            }
        });
        // checked for acls
        btnProcess.setEnabled(OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID));
        cptitle.getRight().add(btnProcess);
    }

    /***
     *      __  __
     *     |  \/  | ___ _ __  _   _
     *     | |\/| |/ _ \ '_ \| | | |
     *     | |  | |  __/ | | | |_| |
     *     |_|  |_|\___|_| |_|\__,_|
     *
     */
    final JButton btnMenu = new JButton(SYSConst.icon22menu);
    btnMenu.setPressedIcon(SYSConst.icon22Pressed);
    btnMenu.setAlignmentX(Component.RIGHT_ALIGNMENT);
    btnMenu.setAlignmentY(Component.TOP_ALIGNMENT);
    btnMenu.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    btnMenu.setContentAreaFilled(false);
    btnMenu.setBorder(null);
    btnMenu.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JidePopup popup = new JidePopup();
            popup.setMovable(false);
            popup.getContentPane().setLayout(new BoxLayout(popup.getContentPane(), BoxLayout.LINE_AXIS));
            popup.setOwner(btnMenu);
            popup.removeExcludedComponent(btnMenu);
            JPanel pnl = getMenu(prescription);
            popup.getContentPane().add(pnl);
            popup.setDefaultFocusComponent(pnl);

            GUITools.showPopup(popup, SwingConstants.WEST);
        }
    });
    cptitle.getRight().add(btnMenu);

    cpPres.setHorizontalAlignment(SwingConstants.LEADING);
    cpPres.setOpaque(false);

    return cpPres;
}

From source file:op.care.med.inventory.PnlInventory.java

private CollapsiblePane createCP4(final MedInventory inventory) {
    /***/*from w  w w  . j  a v  a2  s . c  om*/
     *                          _        ____ ____  _  _    _____                      _                 __
     *       ___ _ __ ___  __ _| |_ ___ / ___|  _ \| || |  / /_ _|_ ____   _____ _ __ | |_ ___  _ __ _   \ \
     *      / __| '__/ _ \/ _` | __/ _ \ |   | |_) | || |_| | | || '_ \ \ / / _ \ '_ \| __/ _ \| '__| | | | |
     *     | (__| | |  __/ (_| | ||  __/ |___|  __/|__   _| | | || | | \ V /  __/ | | | || (_) | |  | |_| | |
     *      \___|_|  \___|\__,_|\__\___|\____|_|      |_| | ||___|_| |_|\_/ \___|_| |_|\__\___/|_|   \__, | |
     *                                                     \_\                                       |___/_/
     */
    final String key = inventory.getID() + ".xinventory";
    synchronized (cpMap) {
        if (!cpMap.containsKey(key)) {
            cpMap.put(key, new CollapsiblePane());
            try {
                cpMap.get(key).setCollapsed(true);
            } catch (PropertyVetoException e) {
                e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
            }

        }

        cpMap.get(key).setName("inventory");

        //            final CollapsiblePane cpInventory = cpMap.get(key);

        BigDecimal sumInventory = BigDecimal.ZERO;
        try {
            EntityManager em = OPDE.createEM();
            sumInventory = MedInventoryTools.getSum(em, inventory);
            em.close();
        } catch (Exception e) {
            OPDE.fatal(e);
        }

        String title = "<html><table border=\"0\">" + "<tr>" +

                "<td width=\"520\" align=\"left\"><font size=+1>" + inventory.getText() + "</font></td>"
                + "<td width=\"200\" align=\"right\"><font size=+1>"
                + NumberFormat.getNumberInstance().format(sumInventory) + " "
                + DosageFormTools.getPackageText(MedInventoryTools.getForm(inventory)) + "</font></td>" +

                "</tr>" + "</table>" +

                "</html>";

        DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    cpMap.get(key).setCollapsed(!cpMap.get(key).isCollapsed());
                } catch (PropertyVetoException pve) {
                    // BAH!
                }
            }
        });
        cpMap.get(key).setTitleLabelComponent(cptitle.getMain());
        cpMap.get(key).setSlidingDirection(SwingConstants.SOUTH);
        cptitle.getButton().setIcon(inventory.isClosed() ? SYSConst.icon22stopSign : null);

        if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.MANAGER, "nursingrecords.inventory")) {
            /***
             *       ____ _                ___                      _
             *      / ___| | ___  ___  ___|_ _|_ ____   _____ _ __ | |_ ___  _ __ _   _
             *     | |   | |/ _ \/ __|/ _ \| || '_ \ \ / / _ \ '_ \| __/ _ \| '__| | | |
             *     | |___| | (_) \__ \  __/| || | | \ V /  __/ | | | || (_) | |  | |_| |
             *      \____|_|\___/|___/\___|___|_| |_|\_/ \___|_| |_|\__\___/|_|   \__, |
             *                                                                    |___/
             */
            final JButton btnCloseInventory = new JButton(SYSConst.icon22playerStop);
            btnCloseInventory.setPressedIcon(SYSConst.icon22playerStopPressed);
            btnCloseInventory.setAlignmentX(Component.RIGHT_ALIGNMENT);
            btnCloseInventory.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnCloseInventory.setContentAreaFilled(false);
            btnCloseInventory.setBorder(null);
            btnCloseInventory.setToolTipText(SYSTools.xx("nursingrecords.inventory.btncloseinventory.tooltip"));
            btnCloseInventory.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent actionEvent) {
                    new DlgYesNo(
                            SYSTools.xx("nursingrecords.inventory.question.close1") + "<br/><b>"
                                    + inventory.getText() + "</b>" + "<br/>"
                                    + SYSTools.xx("nursingrecords.inventory.question.close2"),
                            SYSConst.icon48playerStop, new Closure() {
                                @Override
                                public void execute(Object answer) {
                                    if (answer.equals(JOptionPane.YES_OPTION)) {
                                        EntityManager em = OPDE.createEM();
                                        try {
                                            em.getTransaction().begin();

                                            MedInventory myInventory = em.merge(inventory);
                                            em.lock(myInventory, LockModeType.OPTIMISTIC);
                                            em.lock(myInventory.getResident(), LockModeType.OPTIMISTIC);

                                            // close all stocks
                                            for (MedStock stock : MedStockTools.getAll(myInventory)) {
                                                if (!stock.isClosed()) {
                                                    MedStock mystock = em.merge(stock);
                                                    em.lock(mystock, LockModeType.OPTIMISTIC);
                                                    mystock.setNextStock(null);
                                                    MedStockTools.close(em, mystock, SYSTools.xx(
                                                            "nursingrecords.inventory.stock.msg.inventory_closed"),
                                                            MedStockTransactionTools.STATE_EDIT_INVENTORY_CLOSED);
                                                }
                                            }
                                            // close inventory
                                            myInventory.setTo(new Date());

                                            em.getTransaction().commit();

                                            createCP4(myInventory);
                                            buildPanel();
                                        } catch (OptimisticLockException ole) {
                                            OPDE.warn(ole);
                                            if (em.getTransaction().isActive()) {
                                                em.getTransaction().rollback();
                                            }
                                            if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                                                OPDE.getMainframe().emptyFrame();
                                                OPDE.getMainframe().afterLogin();
                                            }
                                            OPDE.getDisplayManager()
                                                    .addSubMessage(DisplayManager.getLockMessage());
                                        } catch (Exception e) {
                                            if (em.getTransaction().isActive()) {
                                                em.getTransaction().rollback();
                                            }
                                            OPDE.fatal(e);
                                        } finally {
                                            em.close();
                                        }
                                    }
                                }
                            });
                }
            });
            btnCloseInventory.setEnabled(!inventory.isClosed());
            cptitle.getRight().add(btnCloseInventory);
        }
        if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.DELETE, "nursingrecords.inventory")) {
            /***
             *      ____       _ ___                      _
             *     |  _ \  ___| |_ _|_ ____   _____ _ __ | |_ ___  _ __ _   _
             *     | | | |/ _ \ || || '_ \ \ / / _ \ '_ \| __/ _ \| '__| | | |
             *     | |_| |  __/ || || | | \ V /  __/ | | | || (_) | |  | |_| |
             *     |____/ \___|_|___|_| |_|\_/ \___|_| |_|\__\___/|_|   \__, |
             *                                                          |___/
             */
            final JButton btnDelInventory = new JButton(SYSConst.icon22delete);
            btnDelInventory.setPressedIcon(SYSConst.icon22deletePressed);
            btnDelInventory.setAlignmentX(Component.RIGHT_ALIGNMENT);
            btnDelInventory.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnDelInventory.setContentAreaFilled(false);
            btnDelInventory.setBorder(null);
            btnDelInventory.setToolTipText(SYSTools.xx("nursingrecords.inventory.btndelinventory.tooltip"));
            btnDelInventory.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent actionEvent) {
                    new DlgYesNo(
                            SYSTools.xx("nursingrecords.inventory.question.delete1") + "<br/><b>"
                                    + inventory.getText() + "</b>" + "<br/>"
                                    + SYSTools.xx("nursingrecords.inventory.question.delete2"),
                            SYSConst.icon48delete, new Closure() {
                                @Override
                                public void execute(Object answer) {
                                    if (answer.equals(JOptionPane.YES_OPTION)) {
                                        EntityManager em = OPDE.createEM();
                                        try {
                                            em.getTransaction().begin();

                                            MedInventory myInventory = em.merge(inventory);
                                            em.lock(myInventory, LockModeType.OPTIMISTIC);
                                            em.lock(myInventory.getResident(), LockModeType.OPTIMISTIC);

                                            em.remove(myInventory);

                                            em.getTransaction().commit();

                                            //                                        lstInventories.remove(inventory);
                                            buildPanel();
                                        } catch (OptimisticLockException ole) {
                                            OPDE.warn(ole);
                                            if (em.getTransaction().isActive()) {
                                                em.getTransaction().rollback();
                                            }
                                            if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) {
                                                OPDE.getMainframe().emptyFrame();
                                                OPDE.getMainframe().afterLogin();
                                            }
                                            OPDE.getDisplayManager()
                                                    .addSubMessage(DisplayManager.getLockMessage());
                                        } catch (Exception e) {
                                            if (em.getTransaction().isActive()) {
                                                em.getTransaction().rollback();
                                            }
                                            OPDE.fatal(e);
                                        } finally {
                                            em.close();
                                        }
                                    }
                                }
                            });
                }
            });
            cptitle.getRight().add(btnDelInventory);
        }

        final JToggleButton tbClosedStock = GUITools.getNiceToggleButton(null);
        tbClosedStock.setToolTipText(SYSTools.xx("nursingrecords.inventory.showclosedstocks"));
        if (!inventory.isClosed()) {
            tbClosedStock.addItemListener(new ItemListener() {
                @Override
                public void itemStateChanged(ItemEvent e) {
                    cpMap.get(key).setContentPane(createContentPanel4(inventory, tbClosedStock.isSelected()));
                }
            });
        }
        tbClosedStock.setSelected(inventory.isClosed());
        tbClosedStock.setEnabled(!inventory.isClosed());

        mapKey2ClosedToggleButton.put(key, tbClosedStock);

        cptitle.getRight().add(tbClosedStock);

        CollapsiblePaneAdapter adapter = new CollapsiblePaneAdapter() {
            @Override
            public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
                cpMap.get(key).setContentPane(createContentPanel4(inventory, tbClosedStock.isSelected()));
            }
        };
        synchronized (cpListener) {
            if (cpListener.containsKey(key)) {
                cpMap.get(key).removeCollapsiblePaneListener(cpListener.get(key));
            }
            cpListener.put(key, adapter);
            cpMap.get(key).addCollapsiblePaneListener(adapter);
        }

        if (!cpMap.get(key).isCollapsed()) {
            cpMap.get(key).setContentPane(createContentPanel4(inventory, tbClosedStock.isSelected()));
        }

        cpMap.get(key).setHorizontalAlignment(SwingConstants.LEADING);
        cpMap.get(key).setOpaque(false);
        cpMap.get(key).setBackground(getColor(SYSConst.medium2, lstInventories.indexOf(inventory) % 2 != 0));

        return cpMap.get(key);
    }
}

From source file:edu.umass.cs.gigapaxos.SQLPaxosLogger.java

private static DataSource setupDataSourceC3P0(String connectURI, Properties props) throws SQLException {

    ComboPooledDataSource cpds = new ComboPooledDataSource();
    try {//w ww .jav  a  2  s. c  om
        cpds.setDriverClass(SQL.getDriver(SQL_TYPE));
        cpds.setJdbcUrl(connectURI);
        if (!SQL_TYPE.equals(SQL.SQLType.EMBEDDED_H2)) {
            cpds.setUser(props.getProperty("user"));
            cpds.setPassword(props.getProperty("password"));
        }
        cpds.setAutoCommitOnClose(true);
        cpds.setMaxPoolSize(MAX_POOL_SIZE);
    } catch (PropertyVetoException pve) {
        pve.printStackTrace();
    }

    return cpds;
}