Example usage for javax.swing JPanel setBackground

List of usage examples for javax.swing JPanel setBackground

Introduction

In this page you can find the example usage for javax.swing JPanel setBackground.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.")
public void setBackground(Color bg) 

Source Link

Document

Sets the background color of this component.

Usage

From source file:op.care.med.structure.PnlMed.java

private void prepareSearchArea() {
    searchPanes = new CollapsiblePanes();
    searchPanes.setLayout(new JideBoxLayout(searchPanes, JideBoxLayout.Y_AXIS));
    jspSearch.setViewportView(searchPanes);

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

    CollapsiblePane searchPane = new CollapsiblePane(SYSTools.xx(internalClassID));
    searchPane.setStyle(CollapsiblePane.PLAIN_STYLE);
    searchPane.setCollapsible(false);//from  ww w .  jav  a 2 s.c om

    try {
        searchPane.setCollapsed(false);
    } catch (PropertyVetoException e) {
        OPDE.error(e);
    }

    GUITools.addAllComponents(mypanel, addCommands());
    GUITools.addAllComponents(mypanel, addFilters());

    searchPane.setContentPane(mypanel);

    searchPanes.add(searchPane);
    searchPanes.addExpansion();

}

From source file:op.care.nursingprocess.PnlNursingProcess.java

private CollapsiblePane createCP4(final ResInfoCategory cat) {
    /***/*ww  w  .j  a v a 2 s.c  o  m*/
     *                          _        ____ ____  _  _               _
     *       ___ _ __ ___  __ _| |_ ___ / ___|  _ \| || |     ___ __ _| |_ ___  __ _  ___  _ __ _   _
     *      / __| '__/ _ \/ _` | __/ _ \ |   | |_) | || |_   / __/ _` | __/ _ \/ _` |/ _ \| '__| | | |
     *     | (__| | |  __/ (_| | ||  __/ |___|  __/|__   _| | (_| (_| | ||  __/ (_| | (_) | |  | |_| |
     *      \___|_|  \___|\__,_|\__\___|\____|_|      |_|    \___\__,_|\__\___|\__, |\___/|_|   \__, |
     *                                                                         |___/            |___/
     */
    final String keyCat = cat.getID() + ".xcategory";
    if (!cpMap.containsKey(keyCat)) {
        cpMap.put(keyCat, new CollapsiblePane());
        try {
            cpMap.get(keyCat).setCollapsed(true);
        } catch (PropertyVetoException e) {
            // Bah!
        }
    }
    final CollapsiblePane cpCat = cpMap.get(keyCat);

    String title = "<html><font size=+1><b>" + cat.getText() + "</b></font></html>";

    DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                //                    if (cpCat.isCollapsed() && !tbInactive.isSelected()  && !isEmpty(cat) && containsOnlyClosedNPs(cat)) {
                //                        tbInactive.setSelected(true);
                //                    }
                cpCat.setCollapsed(!cpCat.isCollapsed());
            } catch (PropertyVetoException pve) {
                // BAH!
            }
        }
    });

    if (isEmpty(cat)) {
        cptitle.getButton().setIcon(SYSConst.icon22ledGreenOff);
    } else if (containsOnlyClosedNPs(cat)) {
        cptitle.getButton().setIcon(SYSConst.icon22stopSign);
    } else {
        cptitle.getButton().setIcon(getIcon(getMinimumNextEvalDays(cat)));
    }

    cpCat.setTitleLabelComponent(cptitle.getMain());
    cpCat.setSlidingDirection(SwingConstants.SOUTH);
    cpCat.setBackground(getColor(cat)[SYSConst.medium2]);
    cpCat.setOpaque(true);
    cpCat.setHorizontalAlignment(SwingConstants.LEADING);

    cpCat.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
        @Override
        public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
            JPanel pnlContent = new JPanel(new VerticalLayout());
            if (valuecache.containsKey(cat)) {
                int i = 0; // for zebra pattern
                for (NursingProcess np : valuecache.get(cat)) {
                    //                        if (!np.isClosed()) { // tbInactive.isSelected() ||
                    JPanel pnl = createNPPanel(np);
                    pnl.setBackground(i % 2 == 0 ? Color.WHITE : getColor(cat)[SYSConst.light3]);
                    pnl.setOpaque(true);
                    pnlContent.add(pnl);
                    i++;
                    //                        }
                }
            }
            cpCat.setContentPane(pnlContent);
        }
    });

    if (!cpCat.isCollapsed()) {
        JPanel pnlContent = new JPanel(new VerticalLayout());
        if (valuecache.containsKey(cat)) {
            int i = 0; // for zebra pattern
            for (NursingProcess np : valuecache.get(cat)) {
                //                    if (!np.isClosed()) { // tbInactive.isSelected() ||
                JPanel pnl = createNPPanel(np);
                pnl.setBackground(i % 2 == 0 ? Color.WHITE : getColor(cat)[SYSConst.light3]);
                pnl.setOpaque(true);
                pnlContent.add(pnl);
                i++;
                //                    }
            }
        }
        cpCat.setContentPane(pnlContent);
    }

    return cpCat;
}

From source file:op.care.nursingprocess.PnlNursingProcess.java

private void prepareSearchArea() {
    searchPanes = new CollapsiblePanes();
    searchPanes.setLayout(new JideBoxLayout(searchPanes, JideBoxLayout.Y_AXIS));
    jspSearch.setViewportView(searchPanes);

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

    CollapsiblePane searchPane = new CollapsiblePane(SYSTools.xx(internalClassID));
    searchPane.setStyle(CollapsiblePane.PLAIN_STYLE);
    searchPane.setCollapsible(false);//from www. ja  va 2  s  .  co  m

    try {
        searchPane.setCollapsed(false);
    } catch (PropertyVetoException e) {
        OPDE.error(e);
    }

    GUITools.addAllComponents(mypanel, addCommands());
    GUITools.addAllComponents(mypanel, addFilters());
    GUITools.addAllComponents(mypanel, addKey());

    searchPane.setContentPane(mypanel);

    searchPanes.add(searchPane);
    searchPanes.addExpansion();
}

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

private void prepareSearchArea() {
    searchPanes = new CollapsiblePanes();
    searchPanes.setLayout(new JideBoxLayout(searchPanes, JideBoxLayout.Y_AXIS));
    jspSearch.setViewportView(searchPanes);

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

    CollapsiblePane searchPane = new CollapsiblePane(SYSTools.xx(internalClassID));
    searchPane.setStyle(CollapsiblePane.PLAIN_STYLE);
    searchPane.setCollapsible(false);/*from  w  w  w . j a va  2 s.  c  o  m*/

    try {
        searchPane.setCollapsed(false);
    } catch (PropertyVetoException e) {
        OPDE.error(e);
    }

    GUITools.addAllComponents(mypanel, addCommands());
    GUITools.addAllComponents(mypanel, addFilters());
    GUITools.addAllComponents(mypanel, addKey());

    searchPane.setContentPane(mypanel);

    searchPanes.add(searchPane);
    searchPanes.addExpansion();

}

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

private void prepareSearchArea() {
    if (searchPanes != null)
        searchPanes.removeAll();/*from   www.  j av a 2 s.c  o m*/

    searchPanes = new CollapsiblePanes();
    searchPanes.setLayout(new JideBoxLayout(searchPanes, JideBoxLayout.Y_AXIS));
    jspSearch.setViewportView(searchPanes);

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

    CollapsiblePane searchPane = new CollapsiblePane(SYSTools.xx(internalClassID));
    searchPane.setStyle(CollapsiblePane.PLAIN_STYLE);
    searchPane.setCollapsible(false);

    try {
        searchPane.setCollapsed(false);
    } catch (PropertyVetoException e) {
        OPDE.error(e);
    }

    GUITools.addAllComponents(mypanel, addCommands());
    GUITools.addAllComponents(mypanel, addFilters());

    searchPane.setContentPane(mypanel);

    searchPanes.add(searchPane);
    searchPanes.addExpansion();

}

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

private JPanel createContentPanel4Day(LocalDate day) {
    //        OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage("misc.msg.wait", progress, progressMax));
    //        progress++;

    final String key = DateFormat.getDateInstance().format(day.toDate());
    synchronized (contentmap) {
        if (contentmap.containsKey(key)) {
            return contentmap.get(key);
        }/*from   w  ww . j  a  v  a 2  s  .  co  m*/
    }
    final JPanel dayPanel = new JPanel(new VerticalLayout());
    dayPanel.setOpaque(false);
    synchronized (valuecache) {
        if (!valuecache.containsKey(key)) {
            valuecache.put(key, NReportTools.getNReports4Day(resident, day));
        }

        int i = 0; // for zebra pattern
        for (final NReport nreport : valuecache.get(key)) {

            if (tbShowReplaced.isSelected() || !nreport.isObsolete()) {

                String title = SYSTools.toHTMLForScreen(SYSConst.html_table(SYSConst
                        .html_table_tr("<td width=\"800\" align=\"left\">" + "<b><p>"
                                + (nreport.isObsolete() ? SYSConst.html_16x16_Eraser_internal : "")
                                + (nreport.isReplacement() ? SYSConst.html_16x16_Edited_internal : "")
                                + DateFormat.getTimeInstance(DateFormat.SHORT).format(nreport.getPit()) + " "
                                + SYSTools.xx("misc.msg.Time.short") + ", " + nreport.getMinutes() + " "
                                + SYSTools.xx("misc.msg.Minute(s)") + ", " + nreport.getUser().getFullname()
                                + (nreport.getCommontags().isEmpty() ? ""
                                        : " " + CommontagsTools.getAsHTML(nreport.getCommontags(),
                                                SYSConst.html_16x16_tagPurple_internal))
                                + "</p></b></td>")
                        + SYSConst.html_table_tr("<td width=\"800\" align=\"left\">"
                                + SYSTools.replace(nreport.getText(), "\n", "<br/>", false) + "</td>"),
                        "0"));

                final DefaultCPTitle pnlSingle = new DefaultCPTitle(SYSTools.toHTMLForScreen(title), null);
                pnlSingle.getButton().addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        GUITools.showPopup(GUITools.getHTMLPopup(pnlSingle.getButton(),
                                NReportTools.getInfoAsHTML(nreport)), SwingConstants.NORTH);
                    }
                });

                if (!nreport.getAttachedFilesConnections().isEmpty()) {
                    /***
                     *      _     _         _____ _ _
                     *     | |__ | |_ _ __ |  ___(_) | ___  ___
                     *     | '_ \| __| '_ \| |_  | | |/ _ \/ __|
                     *     | |_) | |_| | | |  _| | | |  __/\__ \
                     *     |_.__/ \__|_| |_|_|   |_|_|\___||___/
                     *
                     */
                    final JButton btnFiles = new JButton(
                            Integer.toString(nreport.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) {
                            Closure fileHandleClosure = OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE,
                                    internalClassID) ? null : new Closure() {
                                        @Override
                                        public void execute(Object o) {
                                            EntityManager em = OPDE.createEM();
                                            final NReport myReport = em.find(NReport.class, nreport.getID());
                                            em.close();

                                            final String keyNewDay = DateFormat.getDateInstance()
                                                    .format(myReport.getPit());

                                            synchronized (contentmap) {
                                                contentmap.remove(keyNewDay);
                                            }
                                            synchronized (linemap) {
                                                linemap.remove(nreport);
                                            }

                                            synchronized (valuecache) {
                                                valuecache.get(keyNewDay).remove(nreport);
                                                valuecache.get(keyNewDay).add(myReport);
                                                Collections.sort(valuecache.get(keyNewDay));
                                            }

                                            createCP4Day(new LocalDate(myReport.getPit()));

                                            buildPanel();
                                            GUITools.flashBackground(linemap.get(myReport), Color.YELLOW, 2);
                                        }
                                    };
                            new DlgFiles(nreport, fileHandleClosure);
                        }
                    });
                    btnFiles.setEnabled(OPDE.isFTPworking());
                    pnlSingle.getRight().add(btnFiles);
                }

                if (!nreport.getAttachedQProcessConnections().isEmpty()) {
                    /***
                     *      _     _         ____
                     *     | |__ | |_ _ __ |  _ \ _ __ ___   ___ ___  ___ ___
                     *     | '_ \| __| '_ \| |_) | '__/ _ \ / __/ _ \/ __/ __|
                     *     | |_) | |_| | | |  __/| | | (_) | (_|  __/\__ \__ \
                     *     |_.__/ \__|_| |_|_|   |_|  \___/ \___\___||___/___/
                     *
                     */
                    final JButton btnProcess = new JButton(
                            Integer.toString(nreport.getAttachedQProcessConnections().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(nreport, 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);
                                        NReport myReport = em.merge(nreport);
                                        em.lock(myReport, LockModeType.OPTIMISTIC_FORCE_INCREMENT);

                                        ArrayList<SYSNR2PROCESS> attached = new ArrayList<SYSNR2PROCESS>(
                                                myReport.getAttachedQProcessConnections());
                                        for (SYSNR2PROCESS linkObject : attached) {
                                            if (unassigned.contains(linkObject.getQProcess())) {
                                                linkObject.getQProcess().getAttachedNReportConnections()
                                                        .remove(linkObject);
                                                linkObject.getNReport().getAttachedQProcessConnections()
                                                        .remove(linkObject);
                                                em.merge(new PReport(
                                                        SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT)
                                                                + ": " + nreport.getTitle() + " ID: "
                                                                + nreport.getID(),
                                                        PReportTools.PREPORT_TYPE_REMOVE_ELEMENT,
                                                        linkObject.getQProcess()));

                                                em.remove(linkObject);
                                            }
                                        }
                                        attached.clear();

                                        for (QProcess qProcess : assigned) {
                                            java.util.List<QProcessElement> listElements = qProcess
                                                    .getElements();
                                            if (!listElements.contains(myReport)) {
                                                QProcess myQProcess = em.merge(qProcess);
                                                SYSNR2PROCESS myLinkObject = em
                                                        .merge(new SYSNR2PROCESS(myQProcess, myReport));
                                                em.merge(new PReport(
                                                        SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT)
                                                                + ": " + nreport.getTitle() + " ID: "
                                                                + nreport.getID(),
                                                        PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess));
                                                qProcess.getAttachedNReportConnections().add(myLinkObject);
                                                myReport.getAttachedQProcessConnections().add(myLinkObject);
                                            }
                                        }

                                        em.getTransaction().commit();

                                        final String keyNewDay = DateFormat.getDateInstance()
                                                .format(myReport.getPit());

                                        synchronized (contentmap) {
                                            contentmap.remove(keyNewDay);
                                        }
                                        synchronized (linemap) {
                                            linemap.remove(nreport);
                                        }

                                        synchronized (valuecache) {
                                            valuecache.get(keyNewDay).remove(nreport);
                                            valuecache.get(keyNewDay).add(myReport);
                                            Collections.sort(valuecache.get(keyNewDay));
                                        }

                                        createCP4Day(new LocalDate(myReport.getPit()));

                                        buildPanel();
                                        GUITools.flashBackground(linemap.get(myReport), 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();
                                        } else {
                                            reloadDisplay(true);
                                        }
                                    } 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();
                                    }

                                }
                            });
                        }
                    });
                    btnProcess.setEnabled(
                            OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID));
                    pnlSingle.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(nreport);
                        popup.getContentPane().add(pnl);
                        popup.setDefaultFocusComponent(pnl);

                        GUITools.showPopup(popup, SwingConstants.WEST);
                    }
                });
                btnMenu.setEnabled(!nreport.isObsolete());
                pnlSingle.getRight().add(btnMenu);

                JPanel zebra = new JPanel();
                zebra.setLayout(new BoxLayout(zebra, BoxLayout.LINE_AXIS));
                zebra.setOpaque(true);
                if (i % 2 == 0) {
                    zebra.setBackground(SYSConst.orange1[SYSConst.light2]);
                } else {
                    zebra.setBackground(Color.WHITE);
                }
                zebra.add(pnlSingle.getMain());
                i++;

                dayPanel.add(zebra);
                linemap.put(nreport, pnlSingle.getMain());
            }
        }
    }
    synchronized (contentmap) {
        contentmap.put(key, dayPanel);
    }
    return dayPanel;
}

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

private void prepareSearchArea() {

    searchPanes = new CollapsiblePanes();
    searchPanes.setLayout(new JideBoxLayout(searchPanes, JideBoxLayout.Y_AXIS));
    jspSearch.setViewportView(searchPanes);

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

    CollapsiblePane searchPane = new CollapsiblePane(SYSTools.xx(internalClassID));
    searchPane.setStyle(CollapsiblePane.PLAIN_STYLE);
    searchPane.setCollapsible(false);// w ww . ja v a2 s.  c  om

    try {
        searchPane.setCollapsed(false);
    } catch (PropertyVetoException e) {
        OPDE.error(e);
    }

    GUITools.addAllComponents(mypanel, addCommands());
    GUITools.addAllComponents(mypanel, addFilters());
    GUITools.addAllComponents(mypanel, addKey());

    searchPane.setContentPane(mypanel);

    searchPanes.add(searchPane);
    searchPanes.addExpansion();

}

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

private void createContentPanel4Day(final LocalDate day, final CollapsiblePane cpDay) {

    final JPanel dayPanel = new JPanel(new VerticalLayout());

    OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), -1, 100));
    OPDE.getMainframe().setBlocked(true);

    SwingWorker worker = new SwingWorker() {

        @Override//w  w  w.j a v  a2 s  .c  o  m
        protected Object doInBackground() throws Exception {

            //                final JPanel dayPanel = new JPanel(new VerticalLayout());
            dayPanel.setOpaque(false);

            ArrayList<Handovers> listHO = HandoversTools.getBy(day, (Homes) cmbHomes.getSelectedItem());
            ArrayList<NReport> listNR = NReportTools.getNReports4Handover(day,
                    (Homes) cmbHomes.getSelectedItem());

            Collections.sort(listNR, myComparator);

            int max = listHO.size() + listNR.size();
            int i = 0; // for zebra pattern and progress
            for (final Handovers handover : listHO) {
                OPDE.getDisplayManager()
                        .setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), i, max));

                String title = "<html><table border=\"0\">" + "<tr valign=\"top\">"
                        + "<td width=\"100\" align=\"left\">"
                        + DateFormat.getTimeInstance(DateFormat.SHORT).format(handover.getPit()) + " "
                        + SYSTools.xx("misc.msg.Time.short") + "</td>"
                        + "<td width=\"100\" align=\"center\">--</td>" + "<td width=\"400\" align=\"left\">"
                        + handover.getText() + "</td>" +

                        "<td width=\"100\" align=\"left\">" + handover.getUser().getFullname() + "</td>"
                        + "</tr>" + "</table>" + "</html>";

                final DefaultCPTitle pnlSingle = new DefaultCPTitle(SYSTools.toHTMLForScreen(title),
                        new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent evt) {
                                EntityManager em = OPDE.createEM();
                                if (Handover2UserTools.containsUser(em, handover, OPDE.getLogin().getUser())) {
                                    em.close();
                                    return;
                                }
                                try {
                                    em.getTransaction().begin();
                                    Handovers myHO = em.merge(handover);
                                    Handover2User connObj = em.merge(
                                            new Handover2User(myHO, em.merge(OPDE.getLogin().getUser())));
                                    myHO.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();
                                }
                            }
                        });

                final JButton btnInfo = new JButton(SYSConst.icon22info);
                btnInfo.setPressedIcon(SYSConst.icon22infoPressed);
                btnInfo.setAlignmentX(Component.RIGHT_ALIGNMENT);
                btnInfo.setAlignmentY(Component.TOP_ALIGNMENT);
                btnInfo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                btnInfo.setContentAreaFilled(false);
                btnInfo.setBorder(null);
                btnInfo.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        OPDE.getDisplayManager().setProgressBarMessage(
                                new DisplayMessage(SYSTools.xx("misc.msg.wait"), -1, 100));
                        OPDE.getMainframe().setBlocked(true);

                        SwingWorker worker = new SwingWorker() {

                            @Override
                            protected Object doInBackground() throws Exception {
                                SYSFilesTools.print(Handover2UserTools.getAsHTML(handover), false);
                                return null;
                            }

                            @Override
                            protected void done() {
                                try {
                                    get();
                                } catch (Exception ex1) {
                                    OPDE.fatal(ex1);
                                }
                                OPDE.getDisplayManager().setProgressBarMessage(null);
                                OPDE.getMainframe().setBlocked(false);
                            }

                        };
                        worker.execute();

                    }
                });
                pnlSingle.getRight().add(btnInfo);

                EntityManager em = OPDE.createEM();
                pnlSingle.getButton()
                        .setIcon(Handover2UserTools.containsUser(em, handover, OPDE.getLogin().getUser())
                                ? SYSConst.icon22ledGreenOn
                                : SYSConst.icon22ledRedOn);
                em.close();

                pnlSingle.getButton().setVerticalTextPosition(SwingConstants.TOP);

                JPanel zebra = new JPanel();
                zebra.setLayout(new BoxLayout(zebra, BoxLayout.LINE_AXIS));
                zebra.setOpaque(true);
                if (i % 2 == 0) {
                    zebra.setBackground(SYSConst.orange1[SYSConst.light2]);
                } else {
                    zebra.setBackground(Color.WHITE);
                }
                zebra.add(pnlSingle.getMain());
                i++;
                dayPanel.add(zebra);
            }
            for (final NReport nreport : listNR) {
                OPDE.getDisplayManager()
                        .setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), i, max));

                String title = "<html><table border=\"0\">" + "<tr valign=\"top\">"
                        + "<td width=\"100\" align=\"left\">"
                        + DateFormat.getTimeInstance(DateFormat.SHORT).format(nreport.getPit()) + " "
                        + SYSTools.xx("misc.msg.Time.short") + "<br/>" + nreport.getMinutes() + " "
                        + SYSTools.xx("misc.msg.Minute(s)") + "</td>" + "<td width=\"100\" align=\"left\">"
                        + ResidentTools.getTextCompact(nreport.getResident()) + "</td>"
                        + "<td width=\"400\" align=\"left\">" + nreport.getText() + "</td>" +

                        "<td width=\"100\" align=\"left\">" + nreport.getUser().getFullname() + "</td>"
                        + "</tr>" + "</table>" + "</html>";

                final DefaultCPTitle pnlSingle = new DefaultCPTitle(SYSTools.toHTMLForScreen(title),
                        new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent evt) {
                                EntityManager em = OPDE.createEM();
                                if (NR2UserTools.containsUser(em, nreport, OPDE.getLogin().getUser())) {
                                    em.close();
                                    return;
                                }

                                try {
                                    em.getTransaction().begin();
                                    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();
                                }
                            }
                        });

                final JButton btnInfo = new JButton(SYSConst.icon22info);
                btnInfo.setPressedIcon(SYSConst.icon22infoPressed);
                btnInfo.setAlignmentX(Component.RIGHT_ALIGNMENT);
                btnInfo.setAlignmentY(Component.TOP_ALIGNMENT);
                btnInfo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                btnInfo.setContentAreaFilled(false);
                btnInfo.setBorder(null);
                btnInfo.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {

                        SYSFilesTools.print(NR2UserTools.getAsHTML(nreport), false);

                        //                            OPDE.getDisplayManager().setProgressBarMessage(new DisplayMessage(SYSTools.xx("misc.msg.wait"), -1, 100));
                        //                            OPDE.getMainframe().setBlocked(true);
                        //
                        //                            SwingWorker worker = new SwingWorker() {
                        //
                        //                                @Override
                        //                                protected Object doInBackground() throws Exception {
                        //
                        //                                    return null;
                        //                                }
                        //
                        //                                @Override
                        //                                protected void done() {
                        //                                    OPDE.getDisplayManager().setProgressBarMessage(null);
                        //                                    OPDE.getMainframe().setBlocked(false);
                        //                                }
                        //
                        //                            };
                        //                            worker.execute();

                    }
                });
                pnlSingle.getRight().add(btnInfo);

                EntityManager em = OPDE.createEM();
                pnlSingle.getButton()
                        .setIcon(NR2UserTools.containsUser(em, nreport, OPDE.getLogin().getUser())
                                ? SYSConst.icon22ledGreenOn
                                : SYSConst.icon22ledRedOn);
                em.close();

                pnlSingle.getButton().setVerticalTextPosition(SwingConstants.TOP);

                JPanel zebra = new JPanel();
                zebra.setLayout(new BoxLayout(zebra, BoxLayout.LINE_AXIS));
                zebra.setOpaque(true);
                if (i % 2 == 0) {
                    zebra.setBackground(SYSConst.orange1[SYSConst.light2]);
                } else {
                    zebra.setBackground(Color.WHITE);
                }
                zebra.add(pnlSingle.getMain());
                i++;

                dayPanel.add(zebra);
            }
            final String key = DateFormat.getDateInstance().format(day.toDate());
            synchronized (cacheHO) {
                cacheHO.put(key, listHO);
            }
            synchronized (cacheNR) {
                cacheNR.put(key, listNR);
            }
            return null;

        }

        @Override
        protected void done() {
            try {
                get();
            } catch (Exception ex2) {
                OPDE.fatal(ex2);
            }
            cpDay.setContentPane(dayPanel);
            OPDE.getDisplayManager().setProgressBarMessage(null);
            OPDE.getMainframe().setBlocked(false);
        }
    };
    worker.execute();

}

From source file:op.care.sysfiles.PnlFiles.java

private CollapsiblePane addCommands() {
    JPanel mypanel = new JPanel();
    mypanel.setLayout(new VerticalLayout());
    mypanel.setBackground(Color.WHITE);

    CollapsiblePane cmdPane = new CollapsiblePane(SYSTools.xx(internalClassID));
    cmdPane.setStyle(CollapsiblePane.PLAIN_STYLE);
    cmdPane.setCollapsible(false);/*from  w  ww.ja  va2  s  . c om*/

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

    mypanel.add(GUITools.getDropPanel(new FileDrop.Listener() {
        public void filesDropped(java.io.File[] files) {
            java.util.List<SYSFiles> successful = SYSFilesTools.putFiles(files, resident);
            if (!successful.isEmpty()) {
                OPDE.getDisplayManager().addSubMessage(new DisplayMessage(successful.size() + " "
                        + SYSTools.xx("misc.msg.Files") + " " + SYSTools.xx("misc.msg.added")));
            }
            reloadTable();
        }
    }));

    cmdPane.setContentPane(mypanel);
    return cmdPane;
}

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

private void prepareSearchArea() {
    searchPanes = new CollapsiblePanes();
    searchPanes.setLayout(new JideBoxLayout(searchPanes, JideBoxLayout.Y_AXIS));
    jspSearch.setViewportView(searchPanes);

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

    CollapsiblePane searchPane = new CollapsiblePane(SYSTools.xx(internalClassID));
    searchPane.setStyle(CollapsiblePane.PLAIN_STYLE);
    searchPane.setCollapsible(false);//ww w  .  j a  v a2 s  .  c o  m

    try {
        searchPane.setCollapsed(false);
    } catch (PropertyVetoException e) {
        OPDE.error(e);
    }

    GUITools.addAllComponents(mypanel, addCommands());
    //        GUITools.addAllComponents(mypanel, addKey());

    searchPane.setContentPane(mypanel);

    searchPanes.add(searchPane);
    searchPanes.addExpansion();

}