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:op.users.PnlUser.java

private CollapsiblePane createCP4(final Groups group) {
    final String key = group.getGID() + ".xgroups";
    if (!cpMap.containsKey(key)) {
        cpMap.put(key, new CollapsiblePane());
        cpMap.get(key).setSlidingDirection(SwingConstants.SOUTH);

        cpMap.get(key).setBackground(bg);
        cpMap.get(key).setForeground(fg);

        cpMap.get(key).addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
            @Override//from  w  w w.  jav a 2  s.  c  om
            public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
                if (!contentMap.containsKey(key)) {
                    contentMap.put(key, createContentPanel4(group));
                }
                cpMap.get(key).setContentPane(contentMap.get(key));
            }
        });
        cpMap.get(key).setHorizontalAlignment(SwingConstants.LEADING);
        cpMap.get(key).setOpaque(false);
        try {
            cpMap.get(key).setCollapsed(true);
        } catch (PropertyVetoException e) {
            e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        }

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

    DefaultCPTitle cpTitle = new DefaultCPTitle("<html><font size=+1>" + group.getGID().toUpperCase()
            + (group.isQualified() ? ", " + SYSTools.xx("opde.users.qualifiedGroup") : "") + "</font></html>",
            new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        cp.setCollapsed(!cp.isCollapsed());
                    } catch (PropertyVetoException pve) {
                        // BAH!
                    }
                }
            });

    /***
     *          _      _      _
     *       __| | ___| | ___| |_ ___    __ _ _ __ ___  _   _ _ __
     *      / _` |/ _ \ |/ _ \ __/ _ \  / _` | '__/ _ \| | | | '_ \
     *     | (_| |  __/ |  __/ ||  __/ | (_| | | | (_) | |_| | |_) |
     *      \__,_|\___|_|\___|\__\___|  \__, |_|  \___/ \__,_| .__/
     *                                  |___/                |_|
     */
    final JButton btnDeleteGroup = new JButton(SYSConst.icon22delete);
    btnDeleteGroup.setPressedIcon(SYSConst.icon22deletePressed);
    btnDeleteGroup.setAlignmentX(Component.RIGHT_ALIGNMENT);
    btnDeleteGroup.setContentAreaFilled(false);
    btnDeleteGroup.setBorder(null);
    btnDeleteGroup.setToolTipText(SYSTools.xx("opde.users.btnDeleteGroup"));
    btnDeleteGroup.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            new DlgYesNo(SYSTools.xx("misc.questions.delete1") + "<br/><i>" + group.getGID() + "</i><br/>"
                    + SYSTools.xx("misc.questions.delete2"), SYSConst.icon48delete, new Closure() {
                        @Override
                        public void execute(Object o) {
                            if (o.equals(JOptionPane.YES_OPTION)) {
                                EntityManager em = OPDE.createEM();
                                try {
                                    em.getTransaction().begin();
                                    Groups myGroup = em.merge(group);
                                    em.remove(myGroup);
                                    em.getTransaction().commit();
                                    lstGroups.remove(group);
                                    cpMap.remove(key);
                                    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();
                                }
                            }
                        }
                    });

        }

    });
    btnDeleteGroup.setEnabled(!group.isSystem());
    cpTitle.getRight().add(btnDeleteGroup);

    cp.setTitleLabelComponent(cpTitle.getMain());

    if (!cp.isCollapsed()) {
        if (!contentMap.containsKey(key)) {
            contentMap.put(key, createContentPanel4(group));
        }
        cp.setContentPane(contentMap.get(key));
    }

    return cp;
}

From source file:com.moss.bdbadmin.client.ui.BdbAdminClient.java

private void showInDialog(String title, Component ancestor) {

    //      final JDialog dialog;

    //      if (ancestor instanceof JFrame) {
    //         dialog = new JDialog((JFrame)ancestor);
    //      }//  w  ww  .  j a  v  a  2  s.c  o m
    //      else if (ancestor instanceof JDialog) {
    //         dialog = new JDialog((JDialog)ancestor);
    //      }
    //      else if (ancestor == null) {
    //         dialog = new JDialog();
    //      }
    //      else {
    //         throw new RuntimeException();
    //      }

    JInternalFrame dialog = new JInternalFrame(title);

    //      dialog.setTitle(client.url() + dbPath);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    //      dialog.setModal(false);
    dialog.getContentPane().add(ancestor);
    dialog.setSize(400, 300);
    //      dialog.setLocationRelativeTo(ancestor);
    dialog.setResizable(true);
    dialog.setClosable(true);
    dialog.setIconifiable(true);
    dialog.setMaximizable(true);
    getDesktopPane().add(dialog);
    try {
        dialog.setMaximum(true);
    } catch (PropertyVetoException e) {
        e.printStackTrace();
    }
    dialog.setVisible(true);
}

From source file:op.users.PnlUser.java

private CollapsiblePane createCP4(final Users user) {
    final String key = user.getUID() + ".xusers";
    if (!cpMap.containsKey(key)) {
        cpMap.put(key, new CollapsiblePane());
        try {/* ww w .  ja va 2 s.c  om*/
            cpMap.get(key).setCollapsed(true);
        } catch (PropertyVetoException e) {
            e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
        }

    }
    final CollapsiblePane cp = cpMap.get(key);
    DefaultCPTitle cptitle = new DefaultCPTitle("<html><font size=+1>" + user.toString()
            + (UsersTools.isQualified(user) ? ", " + SYSTools.xx("opde.users.qualifiedNurse") : "")
            + "</font></html>", new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        cp.setCollapsed(!cp.isCollapsed());
                    } catch (PropertyVetoException pve) {
                        // BAH!
                    }
                }
            });

    /***
     *       ____ _                            ______        __
     *      / ___| |__   __ _ _ __   __ _  ___|  _ \ \      / /
     *     | |   | '_ \ / _` | '_ \ / _` |/ _ \ |_) \ \ /\ / /
     *     | |___| | | | (_| | | | | (_| |  __/  __/ \ V  V /
     *      \____|_| |_|\__,_|_| |_|\__, |\___|_|     \_/\_/
     *                              |___/
     */
    final JButton btnChangePW = new JButton(SYSConst.icon22password);
    btnChangePW.setPressedIcon(SYSConst.icon22passwordPressed);
    btnChangePW.setAlignmentX(Component.RIGHT_ALIGNMENT);
    btnChangePW.setContentAreaFilled(false);
    btnChangePW.setBorder(null);
    btnChangePW.setToolTipText(SYSTools.xx("opde.users.btnChangePW.tooltip"));
    btnChangePW.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {

            EntityManager em = OPDE.createEM();
            try {
                em.getTransaction().begin();
                Users myUser = em.merge(usermap.get(user.getUID()));
                String newpw = SYSTools.generatePassword(myUser.getVorname(), myUser.getName());
                em.lock(myUser, LockModeType.OPTIMISTIC);
                myUser.setMd5pw(SYSTools.hashword(newpw));
                em.getTransaction().commit();

                lstUsers.remove(user);
                lstUsers.add(myUser);
                usermap.put(key, myUser);
                Collections.sort(lstUsers);

                SYSTools.printpw(newpw, myUser);

                OPDE.getDisplayManager().addSubMessage(new DisplayMessage(SYSTools.xx("opde.users.pwchanged")));
            } catch (OptimisticLockException ole) {
                OPDE.warn(ole);
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }

                OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage());
            } catch (Exception e) {
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                OPDE.fatal(e);
            } finally {
                em.close();
            }

        }
    });
    btnChangePW.setEnabled(user.isActive());
    cptitle.getRight().add(btnChangePW);

    /***
     *      _     _            _        _   _           ___                  _   _
     *     | |__ | |_ _ __    / \   ___| |_(_)_   _____|_ _|_ __   __ _  ___| |_(_)_   _____
     *     | '_ \| __| '_ \  / _ \ / __| __| \ \ / / _ \| || '_ \ / _` |/ __| __| \ \ / / _ \
     *     | |_) | |_| | | |/ ___ \ (__| |_| |\ V /  __/| || | | | (_| | (__| |_| |\ V /  __/
     *     |_.__/ \__|_| |_/_/   \_\___|\__|_| \_/ \___|___|_| |_|\__,_|\___|\__|_| \_/ \___|
     *
     */
    final JButton btnActiveInactive = new JButton(
            user.isActive() ? SYSConst.icon22stop : SYSConst.icon22playerPlay);
    btnActiveInactive
            .setPressedIcon(user.isActive() ? SYSConst.icon22stopPressed : SYSConst.icon22playerPlayPressed);
    btnActiveInactive.setAlignmentX(Component.RIGHT_ALIGNMENT);
    btnActiveInactive.setContentAreaFilled(false);
    btnActiveInactive.setBorder(null);
    btnActiveInactive.setToolTipText(SYSTools
            .xx(internalClassID + (user.isActive() ? ".btnActiveInactive.stop" : ".btnActiveInactive.play")));
    btnActiveInactive.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {

            EntityManager em = OPDE.createEM();
            try {
                em.getTransaction().begin();
                Users myUser = em.merge(usermap.get(user.getUID()));
                em.lock(myUser, LockModeType.OPTIMISTIC);

                myUser.setStatus(myUser.isActive() ? UsersTools.STATUS_INACTIVE : UsersTools.STATUS_ACTIVE);
                em.getTransaction().commit();
                lstUsers.remove(user);
                lstUsers.add(myUser);
                usermap.put(myUser.getUID(), myUser);
                Collections.sort(lstUsers);
                CollapsiblePane cp = createCP4(myUser);
                boolean wasCollapsed = cpMap.get(key).isCollapsed();
                cpMap.put(key, cp);

                cp.setCollapsed(myUser.isActive() ? wasCollapsed : true);
                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(btnActiveInactive);

    /***
     *               _ _ _
     *       ___  __| (_) |_
     *      / _ \/ _` | | __|
     *     |  __/ (_| | | |_
     *      \___|\__,_|_|\__|
     *
     */
    final JButton btnEdit = new JButton(SYSConst.icon22edit3);
    btnEdit.setPressedIcon(SYSConst.icon22edit3Pressed);
    btnEdit.setAlignmentX(Component.RIGHT_ALIGNMENT);
    btnEdit.setContentAreaFilled(false);
    btnEdit.setBorder(null);
    btnEdit.setToolTipText(SYSTools.xx("opde.users.btnEdit"));
    btnEdit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {

            new DlgUser(user, new Closure() {
                @Override
                public void execute(Object o) {
                    if (o != null) {
                        EntityManager em = OPDE.createEM();
                        try {
                            em.getTransaction().begin();
                            Users myUser = em.merge((Users) o);
                            em.lock(myUser, LockModeType.OPTIMISTIC);
                            em.getTransaction().commit();
                            lstUsers.remove(user);
                            lstUsers.add(myUser);
                            usermap.put(myUser.getUID(), myUser);
                            Collections.sort(lstUsers);
                            CollapsiblePane cp = createCP4(myUser);
                            boolean wasCollapsed = cpMap.get(key).isCollapsed();
                            cpMap.put(key, cp);

                            cp.setCollapsed(myUser.isActive() ? wasCollapsed : true);
                            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(btnEdit);

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

    /***
     *       ___ ___  _  _ _____ ___ _  _ _____
     *      / __/ _ \| \| |_   _| __| \| |_   _|
     *     | (_| (_) | .` | | | | _|| .` | | |
     *      \___\___/|_|\_| |_| |___|_|\_| |_|
     *
     */

    cp.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
        @Override
        public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
            if (!contentMap.containsKey(key)) {
                contentMap.put(key, new PnlEditMemberships(user, lstGroups));
            }
            cp.setContentPane(contentMap.get(key));
            cp.setOpaque(false);
        }
    }

    );
    cp.setBackground(UsersTools.getBG1(user));
    cp.setCollapsible(user.isActive());

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

    return cp;
}

From source file:op.FrmMain.java

private CollapsiblePane addNursingRecords(final Station station) {
    //        bwButtonMap = new HashMap<Resident, JideButton>();

    EntityManager em = OPDE.createEM();//from  w w w .  j a  v  a2  s. c  o m
    Query query;
    if (station == null) {
        query = em.createQuery("SELECT b FROM Resident b WHERE b.station IS NULL ORDER BY b.name, b.firstname");
    } else {
        query = em.createQuery(
                "SELECT b FROM Resident b WHERE b.station = :station ORDER BY b.name, b.firstname");
        query.setParameter("station", station);
    }
    ArrayList<Resident> residentList = new ArrayList<Resident>(query.getResultList());
    em.close();

    CollapsiblePane mypane = new CollapsiblePane(
            station == null ? SYSTools.xx("misc.msg.Archive") : station.getName());
    mypane.setFont(SYSConst.ARIAL14);
    mypane.setEmphasized(station != null && station.equals(StationTools.getStationForThisHost()));
    mypane.setStyle(CollapsiblePane.PLAIN_STYLE);

    JPanel labelPanel = new JPanel();
    labelPanel.setLayout(new VerticalLayout());
    labelPanel.setBackground(Color.WHITE);

    try {
        mypane.setCollapsed(!mypane.isEmphasized());
    } catch (PropertyVetoException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    }

    if (!residentList.isEmpty() && station != null) {
        JideButton button = GUITools.createHyperlinkButton("opde.mainframe.printdailyplan",
                SYSConst.icon22print2, new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        if ((e.getModifiers() & InputEvent.CTRL_MASK) != 0) {
                            PrescriptionTools.printDailyPlan(station, "html");
                        } else {
                            PrescriptionTools.printDailyPlan(station, "pdf");
                        }
                    }
                });
        button.setBackground(Color.WHITE);
        labelPanel.add(button);
    }

    for (final Resident resident : residentList) {
        ActionListener actionListener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                if (currentResident != resident) {

                    if (previousProgButton != null) {
                        previousProgButton.setBackground(Color.WHITE);
                        previousProgButton.setOpaque(false);
                    }

                    previousProgButton = (JideButton) actionEvent.getSource();
                    previousProgButton.setBackground(Color.YELLOW);
                    previousProgButton.setOpaque(true);

                    currentResident = resident;

                    if (currentVisiblePanel instanceof PnlCare) {
                        ((NursingRecordsPanel) currentVisiblePanel).switchResident(resident);
                    } else {
                        setPanelTo(new PnlCare(resident, jspSearch));
                    }

                }
            }
        };

        JPanel singleButtonPanel = new JPanel();
        singleButtonPanel.setLayout(new BoxLayout(singleButtonPanel, BoxLayout.X_AXIS));
        singleButtonPanel.setBorder(null);

        singleButtonPanel.setOpaque(false);

        String titel = resident.getName() + ", " + resident.getFirstname() + " [" + resident.getRIDAnonymous()
                + "]";
        JideButton button = GUITools.createHyperlinkButton(titel, null, actionListener);
        button.setForegroundOfState(ThemePainter.STATE_DEFAULT,
                resident.getGender() == ResidentTools.FEMALE ? Color.red : Color.blue);
        button.setBackground(Color.WHITE);

        singleButtonPanel.add(button);

        OPDE.getDisplayManager().clearSubMessages();

        if (station != null) { // not for the archive
            JPanel pnl = new JPanel();
            pnl.setLayout(new BoxLayout(pnl, BoxLayout.X_AXIS));
            pnl.setOpaque(false);
            pnl.setBorder(null);

            setIconPanel(pnl, resident);

            synchronized (iconPanels) {
                iconPanels.put(resident, pnl);
            }

            singleButtonPanel.add(pnl);
        }

        labelPanel.add(singleButtonPanel);
    }

    mypane.setContentPane(labelPanel);
    listOfNursingrecords.add(mypane);
    return mypane;
}

From source file:op.care.supervisor.PnlHandover.java

private CollapsiblePane createCP4Month(final LocalDate month) {
    /***/*from  ww w.j  av  a  2s .  c  o m*/
     *                          _        ____ ____     __                      __  __  ___  _   _ _____ _   _
     *       ___ _ __ ___  __ _| |_ ___ / ___|  _ \   / _| ___  _ __    __ _  |  \/  |/ _ \| \ | |_   _| | | |
     *      / __| '__/ _ \/ _` | __/ _ \ |   | |_) | | |_ / _ \| '__|  / _` | | |\/| | | | |  \| | | | | |_| |
     *     | (__| | |  __/ (_| | ||  __/ |___|  __/  |  _| (_) | |    | (_| | | |  | | |_| | |\  | | | |  _  |
     *      \___|_|  \___|\__,_|\__\___|\____|_|     |_|  \___/|_|     \__,_| |_|  |_|\___/|_| \_| |_| |_| |_|
     *
     */
    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!
            }
        }
    });

    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.supervisor.PnlHandover.java

private CollapsiblePane createCP4Year(final int year, LocalDate min, LocalDate max) {
    /***/*from   w w w  . j  av a 2  s  .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);

        }
    });

    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.supervisor.PnlHandover.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();
            }/*from  ww  w .j ava2s .co m*/
        }
    }
    final CollapsiblePane cpDay = cpMap.get(key);
    if (hollidays == null) {
        hollidays = SYSCalendar.getHolidays(day.getYear(), day.getYear());
    }
    String titleDay = "<html><font size=+1>" + dayFormat.format(day.toDate())
            + SYSTools.catchNull(hollidays.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!
            }
        }
    });

    final JButton btnAcknowledge = new JButton(SYSConst.icon163ledGreenOn);
    btnAcknowledge.setAlignmentX(Component.RIGHT_ALIGNMENT);
    btnAcknowledge.setToolTipText(SYSTools.xx("nursingrecords.handover.tooltips.btnAcknowledge"));
    btnAcknowledge.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            EntityManager em = OPDE.createEM();
            try {
                em.getTransaction().begin();

                synchronized (cacheHO) {
                    ArrayList<Handovers> listHO = new ArrayList<Handovers>(cacheHO.get(key));
                    for (final Handovers ho : listHO) {
                        if (!Handover2UserTools.containsUser(em, ho, OPDE.getLogin().getUser())) {
                            Handovers myHO = em.merge(ho);
                            Handover2User connObj = em
                                    .merge(new Handover2User(myHO, em.merge(OPDE.getLogin().getUser())));
                            myHO.getUsersAcknowledged().add(connObj);
                        }
                    }
                }

                synchronized (cacheNR) {
                    ArrayList<NReport> listNR = new ArrayList<NReport>(cacheNR.get(key));
                    for (final NReport nreport : listNR) {
                        if (!NR2UserTools.containsUser(em, nreport, OPDE.getLogin().getUser())) {
                            NReport myNR = em.merge(nreport);
                            NR2User connObj = em.merge(new NR2User(myNR, em.merge(OPDE.getLogin().getUser())));
                            myNR.getUsersAcknowledged().add(connObj);
                        }
                    }
                }

                em.getTransaction().commit();
                createCP4Day(day);
                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();
            }

        }

    });
    titleCPDay.getRight().add(btnAcknowledge);

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

    if (hollidays.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) {
            createContentPanel4Day(day, cpDay);
            btnAcknowledge.setEnabled(true);
        }

        @Override
        public void paneCollapsed(CollapsiblePaneEvent collapsiblePaneEvent) {
            btnAcknowledge.setEnabled(false);
        }
    });

    btnAcknowledge.setEnabled(!cpDay.isCollapsed());
    if (!cpDay.isCollapsed()) {
        createContentPanel4Day(day, cpDay);
    }

    return cpDay;
}

From source file:op.care.values.PnlValues.java

private CollapsiblePane getCP(String key) {
    CollapsiblePane cp;//from   w  ww  .j a v a2 s . c  o  m
    synchronized (cpMap) {
        if (!cpMap.containsKey(key)) {
            cpMap.put(key, new CollapsiblePane());
            cpMap.get(key).setStyle(CollapsiblePane.TREE_STYLE);
            try {
                cpMap.get(key).setCollapsed(true);
            } catch (PropertyVetoException e) {
                e.printStackTrace();
            }
        }
        cp = cpMap.get(key);
    }
    return cp;
}

From source file:com.opendoorlogistics.studio.AppFrame.java

private void minimiseWindows() {
    for (JInternalFrame frame : desktopPane.getAllFrames()) {
        try {//from  w w  w .jav a  2 s.co m
            frame.setIcon(true);
        } catch (PropertyVetoException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:op.allowance.PnlAllowance.java

private CollapsiblePane createCP4(final Resident resident, final LocalDate month) {
    final String key = getKey(resident, month);
    if (!cpMap.containsKey(key)) {
        cpMap.put(key, new CollapsiblePane());
        try {// w w w.ja v a2  s  . c  o  m
            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);

    if (!carrySums.containsKey(key)) {
        carrySums.put(key, AllowanceTools.getSUM(resident, SYSCalendar.eom(month)));
    }

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

            "<td width=\"520\" align=\"left\">" + monthFormatter.format(month.toDate()) + "</td>"
            + "<td width=\"200\" align=\"right\">"
            + (carrySums.get(key).compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "")
            + cf.format(carrySums.get(key))
            + (carrySums.get(key).compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" + "</tr>"
            + "</table>" +

            "</font></html>";

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

    /***
     *      ____       _       _   __  __             _   _
     *     |  _ \ _ __(_)_ __ | |_|  \/  | ___  _ __ | |_| |__
     *     | |_) | '__| | '_ \| __| |\/| |/ _ \| '_ \| __| '_ \
     *     |  __/| |  | | | | | |_| |  | | (_) | | | | |_| | | |
     *     |_|   |_|  |_|_| |_|\__|_|  |_|\___/|_| |_|\__|_| |_|
     *
     */
    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) {
            if (!cashmap.containsKey(key)) {
                cashmap.put(key, AllowanceTools.getMonth(resident, month.toDate()));
            }

            final BigDecimal carry4print = AllowanceTools.getSUM(resident,
                    SYSCalendar.eom(month.minusMonths(1)));
            SYSFilesTools.print(AllowanceTools.getAsHTML(cashmap.get(key), carry4print, resident), true);
        }
    });

    cptitle.getRight().add(btnPrintMonth);

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

    cpMonth.setBackground(getBG(resident, 10));

    /***
     *           _ _      _            _                                       _   _
     *       ___| (_) ___| | _____  __| |   ___  _ __    _ __ ___   ___  _ __ | |_| |__
     *      / __| | |/ __| |/ / _ \/ _` |  / _ \| '_ \  | '_ ` _ \ / _ \| '_ \| __| '_ \
     *     | (__| | | (__|   <  __/ (_| | | (_) | | | | | | | | | | (_) | | | | |_| | | |
     *      \___|_|_|\___|_|\_\___|\__,_|  \___/|_| |_| |_| |_| |_|\___/|_| |_|\__|_| |_|
     *
     */
    cpMonth.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
        @Override
        public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {

            cpMonth.setContentPane(createContentPanel4(resident, month));
            cpMonth.setOpaque(false);
        }
    });

    if (!cpMonth.isCollapsed()) {
        cpMonth.setContentPane(createContentPanel4(resident, month));
    }

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

    return cpMonth;
}