Example usage for java.awt Component RIGHT_ALIGNMENT

List of usage examples for java.awt Component RIGHT_ALIGNMENT

Introduction

In this page you can find the example usage for java.awt Component RIGHT_ALIGNMENT.

Prototype

float RIGHT_ALIGNMENT

To view the source code for java.awt Component RIGHT_ALIGNMENT.

Click Source Link

Document

Ease-of-use constant for getAlignmentX .

Usage

From source file:gg.pistol.sweeper.gui.component.DecoratedPanel.java

private <T extends JComponent> T alignHorizontally(T component, float alignment) {
    Preconditions.checkNotNull(component);

    if (!ComponentOrientation.getOrientation(i18n.getLocale()).isLeftToRight()) {
        if (alignment == Component.LEFT_ALIGNMENT) {
            alignment = Component.RIGHT_ALIGNMENT;
        } else if (alignment == Component.RIGHT_ALIGNMENT) {
            alignment = Component.LEFT_ALIGNMENT;
        }/*from  www  .j a v  a2 s . co m*/
    }
    component.setComponentOrientation(ComponentOrientation.getOrientation(i18n.getLocale()));
    component.setAlignmentX(alignment);
    return component;
}

From source file:lol.search.RankedStatsPage.java

private JPanel headerPanel() {
    //init spacers for header
    for (int i = 0; i < 10; i++) {
        JLabel label = new JLabel("--");
        label.setForeground(new Color(0, 0, 0, 0));
        spacers.add(label);//from  w ww.java  2  s  . c om
    }
    //header -- to set this semi-transparent i had to remove setOpaque and replace with setBackground(...)
    JPanel headerPanel = new JPanel();
    headerPanel.setLayout(new BorderLayout());
    //headerPanel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
    headerPanel.setBackground(backgroundColor);
    headerPanel.setPreferredSize(headerDimension);
    //back button
    JPanel buttonHolder = new JPanel();
    ImageIcon buttonImage = new ImageIcon("assets\\other\\button.png");
    ImageIcon buttonPressedImage = new ImageIcon("assets\\other\\buttonPressed.png");
    Image tempImage = buttonImage.getImage();
    Image newTempImg = tempImage.getScaledInstance(75, 35, Image.SCALE_SMOOTH);
    buttonImage = new ImageIcon(newTempImg);
    JButton backButton = new JButton("BACK");
    backButton.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 10)); //custom font
    backButton.setForeground(Color.WHITE); //text color
    backButton.setBackground(new Color(0, 0, 0, 0));
    backButton.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    backButton.setHorizontalTextPosition(AbstractButton.CENTER);
    backButton.setPreferredSize(new Dimension(75, 35));
    //pressed button
    Image tempImage2 = buttonPressedImage.getImage();
    Image newTempImg2 = tempImage2.getScaledInstance(75, 35, Image.SCALE_SMOOTH);
    buttonPressedImage = new ImageIcon(newTempImg2);
    backButton.setIcon(buttonImage);
    backButton.setRolloverIcon(buttonPressedImage);
    backButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) { //button pressed
            System.out.println("Going back...\n");
            masterFrame.getContentPane().removeAll();
            masterFrame.revalidate();
            masterFrame.repaint();
            MainPage MAIN_PAGE = new MainPage(masterFrame, summonerName);
        }
    });
    buttonHolder.add(backButton);
    buttonHolder.setOpaque(false);
    headerPanel.add(buttonHolder, BorderLayout.LINE_START);
    //centerpanel
    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new GridLayout(1, 2));
    centerPanel.setOpaque(false);
    //centerPanel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
    //rightcenter
    JPanel rightCenter = new JPanel();
    rightCenter.setOpaque(false);
    rightCenter.setLayout(new GridLayout(2, 1));
    //top center panel
    JPanel topCenter = new JPanel();
    topCenter.setOpaque(false);
    topCenter.setLayout(new BoxLayout(topCenter, BoxLayout.X_AXIS));
    //profile icon
    JPanel proIconPanel = new JPanel();
    proIconPanel.setOpaque(false);
    proIconPanel.setLayout(new BoxLayout(proIconPanel, BoxLayout.Y_AXIS));
    JLabel profileIconLabel = new JLabel(this.profileIcon);
    //profileIconLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
    profileIconLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
    proIconPanel.add(profileIconLabel);
    centerPanel.add(proIconPanel);
    //empty spacer
    topCenter.add(spacers.get(0));
    //summoner name
    JLabel summonerNameLabel = new JLabel(this.summonerName);
    summonerNameLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 15)); //custom font
    summonerNameLabel.setForeground(Color.WHITE); //text color
    summonerNameLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    topCenter.add(summonerNameLabel);
    //empty spacer
    topCenter.add(spacers.get(1));
    //tier
    JLabel tierLabel = new JLabel(this.tier);
    tierLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 13)); //custom font
    tierLabel.setForeground(new Color(219, 219, 219)); //text color
    tierLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    topCenter.add(tierLabel);
    //empty spacer
    topCenter.add(spacers.get(2));
    //division
    JLabel divisionLabel = new JLabel(this.division);
    divisionLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 13)); //custom font
    divisionLabel.setForeground(new Color(219, 219, 219)); //text color
    divisionLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    topCenter.add(divisionLabel);
    //bottom center panel
    JPanel bottomCenter = new JPanel();
    bottomCenter.setOpaque(false);
    bottomCenter.setLayout(new BoxLayout(bottomCenter, BoxLayout.X_AXIS));
    //empty spacer
    bottomCenter.add(spacers.get(3));
    //season
    JLabel winsLabel = new JLabel(this.season);
    winsLabel.setFont(new Font("Sen-Regular", Font.CENTER_BASELINE, 14)); //custom font
    winsLabel.setForeground(new Color(219, 219, 219)); //text color
    winsLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    bottomCenter.add(winsLabel);

    rightCenter.add(topCenter);
    rightCenter.add(bottomCenter);
    centerPanel.add(rightCenter);
    headerPanel.add(centerPanel, BorderLayout.CENTER);
    //empty panel to balance right side
    JPanel ee = new JPanel();
    ee.setOpaque(false);
    ee.setPreferredSize(new Dimension(260, 50));
    headerPanel.add(ee, BorderLayout.LINE_END);
    return headerPanel;
}

From source file:op.allowance.PnlAllowance.java

private CollapsiblePane createCP4(final Resident resident) {
    /***/*from w  w w  .  j av a2s  .c o  m*/
     *                          _        ____ ____  _  _    ______           _     _            _ __
     *       ___ _ __ ___  __ _| |_ ___ / ___|  _ \| || |  / /  _ \ ___  ___(_) __| | ___ _ __ | |\ \
     *      / __| '__/ _ \/ _` | __/ _ \ |   | |_) | || |_| || |_) / _ \/ __| |/ _` |/ _ \ '_ \| __| |
     *     | (__| | |  __/ (_| | ||  __/ |___|  __/|__   _| ||  _ <  __/\__ \ | (_| |  __/ | | | |_| |
     *      \___|_|  \___|\__,_|\__\___|\____|_|      |_| | ||_| \_\___||___/_|\__,_|\___|_| |_|\__| |
     *                                                     \_\                                    /_/
     */
    final String key = resident.getRID();
    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 cpResident = cpMap.get(key);

    if (!carrySums.containsKey(getKey(resident, SYSCalendar.eoy(new LocalDate())))) {
        carrySums.put(getKey(resident, SYSCalendar.eoy(new LocalDate())),
                AllowanceTools.getSUM(resident, SYSCalendar.eoy(new LocalDate())));
    }

    BigDecimal sumOverall = carrySums.get(getKey(resident, SYSCalendar.eoy(new LocalDate())));

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

            "<td width=\"520\" align=\"left\"><font size=+1>" + resident.toString() + "</font></td>"
            + "<td width=\"200\" align=\"right\"><font size=+1"
            + (sumOverall.compareTo(BigDecimal.ZERO) < 0 ? " color=\"red\" " : "") + ">" + cf.format(sumOverall)
            + "</font></td>" +

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

            "</html>";

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

    if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.ARCHIVE, internalClassID)
            && OPDE.getAppInfo().isAllowedTo(InternalClassACL.PRINT, internalClassID)) {
        /***
         *      ____       _       _   ____           _     _            _
         *     |  _ \ _ __(_)_ __ | |_|  _ \ ___  ___(_) __| | ___ _ __ | |_
         *     | |_) | '__| | '_ \| __| |_) / _ \/ __| |/ _` |/ _ \ '_ \| __|
         *     |  __/| |  | | | | | |_|  _ <  __/\__ \ | (_| |  __/ | | | |_
         *     |_|   |_|  |_|_| |_|\__|_| \_\___||___/_|\__,_|\___|_| |_|\__|
         *
         */
        final JButton btnPrintResident = new JButton(SYSConst.icon22print2);
        btnPrintResident.setPressedIcon(SYSConst.icon22print2Pressed);
        btnPrintResident.setAlignmentX(Component.RIGHT_ALIGNMENT);
        btnPrintResident.setContentAreaFilled(false);
        btnPrintResident.setBorder(null);
        btnPrintResident.setToolTipText(SYSTools.xx("admin.residents.cash.btnprintresident.tooltip"));
        btnPrintResident.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                SYSFilesTools.print(
                        AllowanceTools.getAsHTML(AllowanceTools.getAll(resident), BigDecimal.ZERO, resident),
                        true);
            }

        });
        cptitle.getRight().add(btnPrintResident);
    }

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

    /***
     *           _ _      _            _                               _     _            _
     *       ___| (_) ___| | _____  __| |   ___  _ __    _ __ ___  ___(_) __| | ___ _ __ | |_
     *      / __| | |/ __| |/ / _ \/ _` |  / _ \| '_ \  | '__/ _ \/ __| |/ _` |/ _ \ '_ \| __|
     *     | (__| | | (__|   <  __/ (_| | | (_) | | | | | | |  __/\__ \ | (_| |  __/ | | | |_
     *      \___|_|_|\___|_|\_\___|\__,_|  \___/|_| |_| |_|  \___||___/_|\__,_|\___|_| |_|\__|
     *
     */
    cpResident.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
        @Override
        public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
            // somebody clicks on the name of the resident. the cash informations
            // are loaded from the database, if necessary.
            cpResident.setContentPane(createContentPanel4(resident));
        }
    });
    cpResident.setBackground(getBG(resident, 7));

    if (!cpResident.isCollapsed()) {
        cpResident.setContentPane(createContentPanel4(resident));
    }

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

    return cpResident;
}

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

private CollapsiblePane createCP4(final Prescription prescription) {
    /***/*w ww.ja v a2s  .c om*/
     *                          _        ____ ____  _  _    ______                          _       _   _           __
     *       ___ _ __ ___  __ _| |_ ___ / ___|  _ \| || |  / /  _ \ _ __ ___  ___  ___ _ __(_)_ __ | |_(_) ___  _ __\ \
     *      / __| '__/ _ \/ _` | __/ _ \ |   | |_) | || |_| || |_) | '__/ _ \/ __|/ __| '__| | '_ \| __| |/ _ \| '_ \| |
     *     | (__| | |  __/ (_| | ||  __/ |___|  __/|__   _| ||  __/| | |  __/\__ \ (__| |  | | |_) | |_| | (_) | | | | |
     *      \___|_|  \___|\__,_|\__\___|\____|_|      |_| | ||_|   |_|  \___||___/\___|_|  |_| .__/ \__|_|\___/|_| |_| |
     *                                                     \_\                               |_|                    /_/
     */
    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.values.PnlValues.java

private CollapsiblePane createCP4Type(final ResValueTypes vtype) {
    final String keyType = vtype.getID() + ".xtypes";
    final CollapsiblePane cpType = getCP(keyType);

    final DefaultCPTitle cptitle = new DefaultCPTitle(vtype.getText(), new ActionListener() {
        @Override//from w  w  w  .ja  v a2 s  .co  m
        public void actionPerformed(ActionEvent e) {
            try {
                cpType.setCollapsed(!cpType.isCollapsed());
            } catch (PropertyVetoException pve) {
                // BAH!
            }
        }
    });
    cptitle.getButton().setFont(SYSConst.ARIAL24);
    cptitle.getButton().setForeground(vtype.getColor());
    cpType.setBackground(Color.white);

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

    if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.UPDATE, internalClassID)) {
        /***
         *         _       _     _    __                  _____               __
         *        / \   __| | __| |  / /_ __   ___ _ __  |_   _|   _ _ __   __\ \
         *       / _ \ / _` |/ _` | | || '_ \ / _ \ '__|   | || | | | '_ \ / _ \ |
         *      / ___ \ (_| | (_| | | || |_) |  __/ |      | || |_| | |_) |  __/ |
         *     /_/   \_\__,_|\__,_| | || .__/ \___|_|      |_| \__, | .__/ \___| |
         *                           \_\_|                     |___/|_|       /_/
         */
        final JButton btnAdd = new JButton(SYSConst.icon22add);
        btnAdd.setPressedIcon(SYSConst.icon22addPressed);
        btnAdd.setAlignmentX(Component.RIGHT_ALIGNMENT);
        btnAdd.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        btnAdd.setContentAreaFilled(false);
        btnAdd.setBorder(null);
        btnAdd.setToolTipText(
                SYSTools.xx("nursingrecords.vitalparameters.btnAdd.tooltip") + " (" + vtype.getText() + ")");
        btnAdd.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                addValue(vtype);
            }
        });
        cptitle.getRight().add(btnAdd);
        btnAdd.setEnabled(resident.isActive());
    }

    cpType.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
        @Override
        public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
            cpType.setContentPane(createContentPanel4Type(vtype));
        }
    });

    if (!cpType.isCollapsed()) {
        cpType.setContentPane(createContentPanel4Type(vtype));
    }

    if (!ResValueTools.getYearsWithValues(resident, vtype).isEmpty()) {
        //            cptitle.getTitleButton().setIcon(SYSConst.icon22ledGreenOn);
        cpType.setCollapsible(true);
    } else {
        //            cptitle.getTitleButton().setIcon(SYSConst.icon22ledGreenOff);
        cpType.setCollapsible(false);
    }

    cpType.setHorizontalAlignment(SwingConstants.LEADING);
    cpType.setOpaque(false);
    //        cpType.setBackground(getColor(vtype, SYSConst.medium1));

    return cpType;
}

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

private JPanel createNPPanel(final NursingProcess np) {
    /***/*  www.ja  va2s . co m*/
     *                          _        ____ ____  _  _     _   _ ____
     *       ___ _ __ ___  __ _| |_ ___ / ___|  _ \| || |   | \ | |  _ \
     *      / __| '__/ _ \/ _` | __/ _ \ |   | |_) | || |_  |  \| | |_) |
     *     | (__| | |  __/ (_| | ||  __/ |___|  __/|__   _| | |\  |  __/
     *      \___|_|  \___|\__,_|\__\___|\____|_|      |_|   |_| \_|_|
     *
     */
    if (!contenPanelMap.containsKey(np)) {
        String title = "<html><table border=\"0\">";

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

        title += "<tr valign=\"top\">" + "<td width=\"280\" align=\"left\">" + np.getPITAsHTML() + "</td>"
                + "<td width=\"500\" align=\"left\">" + (np.isClosed() ? "<s>" : "") + np.getContentAsHTML()
                + (np.isClosed() ? "</s>" : "") + "</td></tr>";
        title += "</table>" + "</html>";

        DefaultCPTitle cptitle = new DefaultCPTitle(title, null);
        cptitle.getButton().setVerticalTextPosition(SwingConstants.TOP);

        if (!np.getAttachedFilesConnections().isEmpty()) {
            /***
             *      _     _         _____ _ _
             *     | |__ | |_ _ __ |  ___(_) | ___  ___
             *     | '_ \| __| '_ \| |_  | | |/ _ \/ __|
             *     | |_) | |_| | | |  _| | | |  __/\__ \
             *     |_.__/ \__|_| |_|_|   |_|_|\___||___/
             *
             */
            final JButton btnFiles = new JButton(Integer.toString(np.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 = np.isClosed() ? null : new Closure() {
                        @Override
                        public void execute(Object o) {
                            EntityManager em = OPDE.createEM();
                            final NursingProcess myNP = em.find(NursingProcess.class, np.getID());
                            em.close();
                            // Refresh Display
                            valuecache.get(np.getCategory()).remove(np);
                            contenPanelMap.remove(np);
                            valuecache.get(myNP.getCategory()).add(myNP);
                            Collections.sort(valuecache.get(myNP.getCategory()));

                            createCP4(myNP.getCategory());
                            buildPanel();
                        }
                    };
                    new DlgFiles(np, fileHandleClosure);
                }
            });
            btnFiles.setEnabled(OPDE.isFTPworking());
            cptitle.getRight().add(btnFiles);
        }

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

                                ArrayList<SYSNP2PROCESS> attached = new ArrayList<SYSNP2PROCESS>(
                                        myNP.getAttachedQProcessConnections());
                                for (SYSNP2PROCESS linkObject : attached) {
                                    if (unassigned.contains(linkObject.getQProcess())) {
                                        linkObject.getQProcess().getAttachedNReportConnections()
                                                .remove(linkObject);
                                        linkObject.getNursingProcess().getAttachedQProcessConnections()
                                                .remove(linkObject);
                                        em.merge(new PReport(
                                                SYSTools.xx(PReportTools.PREPORT_TEXT_REMOVE_ELEMENT) + ": "
                                                        + myNP.getTitle() + " ID: " + myNP.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(myNP)) {
                                        QProcess myQProcess = em.merge(qProcess);
                                        SYSNP2PROCESS myLinkObject = em
                                                .merge(new SYSNP2PROCESS(myQProcess, myNP));
                                        em.merge(new PReport(
                                                SYSTools.xx(PReportTools.PREPORT_TEXT_ASSIGN_ELEMENT) + ": "
                                                        + myNP.getTitle() + " ID: " + myNP.getID(),
                                                PReportTools.PREPORT_TYPE_ASSIGN_ELEMENT, myQProcess));
                                        qProcess.getAttachedNursingProcessesConnections().add(myLinkObject);
                                        myNP.getAttachedQProcessConnections().add(myLinkObject);
                                    }
                                }

                                em.getTransaction().commit();

                                // Refresh Display
                                valuecache.get(np.getCategory()).remove(np);
                                contenPanelMap.remove(np);
                                valuecache.get(myNP.getCategory()).add(myNP);
                                Collections.sort(valuecache.get(myNP.getCategory()));

                                createCP4(myNP.getCategory());
                                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();
                                } else {
                                    reloadDisplay();
                                }
                            } 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));
            cptitle.getRight().add(btnProcess);
        }

        if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.PRINT, internalClassID)) {
            /***
             *      _     _         ____       _       _
             *     | |__ | |_ _ __ |  _ \ _ __(_)_ __ | |_
             *     | '_ \| __| '_ \| |_) | '__| | '_ \| __|
             *     | |_) | |_| | | |  __/| |  | | | | | |_
             *     |_.__/ \__|_| |_|_|   |_|  |_|_| |_|\__|
             *
             */
            JButton btnPrint = new JButton(SYSConst.icon22print2);
            btnPrint.setContentAreaFilled(false);
            btnPrint.setBorder(null);
            btnPrint.setPressedIcon(SYSConst.icon22print2Pressed);
            btnPrint.setAlignmentX(Component.RIGHT_ALIGNMENT);
            btnPrint.setAlignmentY(Component.TOP_ALIGNMENT);
            btnPrint.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent actionEvent) {
                    SYSFilesTools.print(NursingProcessTools.getAsHTML(np, true, true, true, true), true);
                }
            });

            cptitle.getRight().add(btnPrint);
            //                cptitle.getTitleButton().setVerticalTextPosition(SwingConstants.TOP);
        }

        /***
         *      __  __
         *     |  \/  | ___ _ __  _   _
         *     | |\/| |/ _ \ '_ \| | | |
         *     | |  | |  __/ | | | |_| |
         *     |_|  |_|\___|_| |_|\__,_|
         *
         */
        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(np);
                popup.getContentPane().add(pnl);
                popup.setDefaultFocusComponent(pnl);

                GUITools.showPopup(popup, SwingConstants.WEST);
            }
        });

        btnMenu.setEnabled(!np.isClosed());
        cptitle.getButton().setIcon(getIcon(np));

        cptitle.getRight().add(btnMenu);
        cptitle.getMain().setBackground(getColor(np.getCategory())[SYSConst.light2]);
        cptitle.getMain().setOpaque(true);
        contenPanelMap.put(np, cptitle.getMain());
    }

    return contenPanelMap.get(np);
}

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 {/* w  w w  .  j a 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.care.values.PnlValues.java

private CollapsiblePane createCP4Year(final ResValueTypes vtype, final int year) {
    final String keyYears = vtype.getID() + ".xtypes." + Integer.toString(year) + ".year";
    final CollapsiblePane cpYear = getCP(keyYears);

    DefaultCPTitle cptitle = new DefaultCPTitle(Integer.toString(year), new ActionListener() {
        @Override//from ww w.  j  a  v  a2s  .c  o  m
        public void actionPerformed(ActionEvent e) {
            try {
                cpYear.setCollapsed(!cpYear.isCollapsed());
            } catch (PropertyVetoException pve) {
                // BAH!
            }
        }
    });

    cptitle.getButton().setFont(SYSConst.ARIAL18);
    cptitle.getButton().setForeground(GUITools.blend(vtype.getColor(), Color.BLACK, 0.75f));
    cpYear.setBackground(Color.white);

    if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.PRINT, internalClassID)) {
        final JButton btnPrintYear = new JButton(SYSConst.icon22print2);
        btnPrintYear.setPressedIcon(SYSConst.icon22print2Pressed);
        btnPrintYear.setAlignmentX(Component.RIGHT_ALIGNMENT);
        btnPrintYear.setContentAreaFilled(false);
        btnPrintYear.setBorder(null);
        btnPrintYear.setToolTipText(SYSTools.xx("misc.tooltips.btnprintyear"));
        btnPrintYear.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                if (!mapType2Values.containsKey(keyYears)) {
                    mapType2Values.put(keyYears, ResValueTools.getResValues(resident, vtype, year));
                }
                SYSFilesTools.print(SYSTools.toHTML(ResValueTools.getAsHTML(mapType2Values.get(keyYears))),
                        true);
            }
        });
        cptitle.getRight().add(btnPrintYear);
    }

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

    cpYear.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
        @Override
        public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
            //                if (vtype.getValType() == ResValueTypesTools.LIQUIDBALANCE) {
            //                    cpYear.setContentPane(createContentPanel4Year(year));
            //                } else {
            cpYear.setContentPane(createContentPanel4Year(vtype, year));
            //                }
            cpYear.setOpaque(false);
        }

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

    if (!cpYear.isCollapsed()) {
        //            if (vtype.getValType() == ResValueTypesTools.LIQUIDBALANCE) {
        //                cpYear.setContentPane(createContentPanel4Year(year));
        //            } else {
        cpYear.setContentPane(createContentPanel4Year(vtype, year));
        //            }
        cpYear.setOpaque(false);
    }

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

    return cpYear;
}

From source file:metdemo.Finance.SHNetworks.java

/**
 * /*from   ww w. java 2s .  c  o  m*/
 * @param jp
 * @param usersarray
 * @param viphm_hashmap
 */
protected void addBottomControls(final JPanel jp, String[] usersarray) {
    // create the control panel which will hold settings and picked list
    final JPanel control_panel = new JPanel();
    jp.add(control_panel, BorderLayout.SOUTH);
    control_panel.setLayout(new BorderLayout());

    // create the settings panel which will hold all of the settings
    Box settings_box = Box.createVerticalBox();
    settings_box.setBorder(BorderFactory.createTitledBorder("Display Settings"));
    control_panel.add(settings_box, BorderLayout.NORTH);
    JPanel settings_panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));

    // add the zoom controls to the settings panel
    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // call listener in GraphMouse instead of manipulating vv scale
            // directly
            // this is so the crossover from zoom to scale works with the
            // buttons
            // as well as with the mouse wheel
            Dimension d = m_visualizationview.getSize();
            m_graphmouse.mouseWheelMoved(
                    new MouseWheelEvent(m_visualizationview, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(),
                            0, d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, 1));
        }
    });
    JButton minus = new JButton(" - ");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // call listener in GraphMouse instead of manipulating vv scale
            // directly
            // this is so the crossover from zoom to scale works with the
            // buttons
            // as well as with the mouse wheel
            Dimension d = m_visualizationview.getSize();
            m_graphmouse.mouseWheelMoved(
                    new MouseWheelEvent(m_visualizationview, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(),
                            0, d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, -1));
        }
    });
    Box zoomPanel = Box.createHorizontalBox();
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));
    minus.setAlignmentX(Component.LEFT_ALIGNMENT);
    plus.setAlignmentX(Component.RIGHT_ALIGNMENT);
    zoomPanel.add(minus);
    zoomPanel.add(plus);
    settings_panel.add(zoomPanel);

    // add the mouse mode combo box to the settings panel
    JComboBox modeBox = m_graphmouse.getModeComboBox();
    modeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    m_graphmouse.setMode(ModalGraphMouse.Mode.PICKING);
    JPanel modePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);
    settings_panel.add(modePanel);

    // add the display type combo box to the settings panel
    String[] layoutTypeStrings = { "OrgChart Layout", "FR Layout" };
    layoutTypeBox = new JComboBox(layoutTypeStrings);
    layoutTypeBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (layoutTypeBox.getSelectedIndex() == 0)
                moveVertices();//viphm_hashmap);
            else
                m_visualizationview.restart();
        }
    });
    layoutTypeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    JPanel displayTypePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    displayTypePanel.setBorder(BorderFactory.createTitledBorder("Display Type"));
    displayTypePanel.add(layoutTypeBox);
    settings_panel.add(displayTypePanel);

    // add user search to the panel - SHLOMO
    JPanel searchPanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    // take the users and organize it sorted
    /*
     * ArrayList<String> ta = new ArrayList<String>(userlist); String []
     * usersarray = (String[]) ta.toArray(new String[ta.size()]);
     */Arrays.sort(usersarray);
    usercombolist = new JComboBox(usersarray);

    usercombolist.insertItemAt("Anyone", 0);
    usercombolist.setSelectedIndex(0);// show only anyone choice
    // lets add all current users to the list

    searchPanel.setBorder(BorderFactory.createTitledBorder("Search User"));
    searchPanel.add(usercombolist);

    //add a check box to show not show labels on all vertices
    m_showLabels = new JCheckBox("Show name?", false);
    settings_panel.add(m_showLabels);

    settings_panel.add(searchPanel);

    usercombolist.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            // will need to react to the choice list
            if (usercombolist.getSelectedIndex() == 0) {
                // might have to reset something in case they move back
                PickedState picked_state = m_visualizationview.getPickedState();
                picked_state.clearPickedVertices();

                return;
            }
            String username = (String) usercombolist.getSelectedItem();

            for (Iterator walker = m_layout.getVertexIterator(); walker.hasNext();) {
                VIPVertex V = (VIPVertex) walker.next();

                // Integer indexNum = (Integer)index.getNumber(V);
                String seeName = V.getAcct();// accounts_arraylist.get(indexNum);
                if (username.equals(seeName)) {
                    PickedState picked_state = m_visualizationview.getPickedState();
                    picked_state.clearPickedVertices();
                    picked_state.pick(V, true);
                    /*
                     * int x= (int)m_layout.getX(V); int y=
                     * (int)m_layout.getY(V); //lets trigger the event
                     * m_graphmouse.mousePressed(new
                     * MouseEvent(m_visualizationview,MouseEvent.MOUSE_CLICKED,System.currentTimeMillis(),0,x,y,2,false));
                     */return;
                }
            }

        }
    });

    // add the settings panel to the settings box
    settings_box.add(settings_panel);

    // add the vip table to the control panel
    SortTableModel model = new SortTableModel();
    model.addColumn("Account");
    model.addColumn("ResponseScore");
    model.addColumn("SocialScore");
    m_timeTable = new JTable(model);
    model.addMouseListenerToHeaderInTable(m_timeTable);
    m_timeTable.setRowSelectionAllowed(true);
    m_timeTable.setColumnSelectionAllowed(false);
    m_timeTable.getTableHeader().setReorderingAllowed(false);
    m_timeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m_timeTable.setDefaultRenderer(model.getColumnClass(1), md5Renderer);
    tablePane = new JScrollPane(m_timeTable);
    tablePane.setPreferredSize(new Dimension(300, 150));
    control_panel.add(tablePane, BorderLayout.SOUTH);
}

From source file:op.allowance.PnlAllowance.java

private CollapsiblePane createCP4(final Resident resident, final int year) {
    LocalDate min = SYSCalendar.bom(minmax.get(resident).getFirst());
    LocalDate max = resident.isActive() ? new LocalDate() : SYSCalendar.eom(minmax.get(resident).getSecond());
    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 key = resident.getRID() + "-" + year;
    if (!cpMap.containsKey(key)) {
        cpMap.put(key, new CollapsiblePane());
        try {//from  w w w . ja  v a2 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 cpYear = cpMap.get(key);

    if (!carrySums.containsKey(key + "-12")) {
        carrySums.put(key + "-12", AllowanceTools.getSUM(resident, SYSCalendar.eoy(start)));
    }

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

            "<td width=\"520\" align=\"left\"><font size=+1>" + Integer.toString(year) + "</font></td>"
            + "<td width=\"200\" align=\"right\">"
            + (carrySums.get(key + "-12").compareTo(BigDecimal.ZERO) < 0 ? "<font color=\"red\">" : "")
            + cf.format(carrySums.get(key + "-12"))
            + (carrySums.get(key + "-12").compareTo(BigDecimal.ZERO) < 0 ? "</font>" : "") + "</td>" +

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

            "</font></html>";

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

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

    /***
     *      ____       _       _ __   __
     *     |  _ \ _ __(_)_ __ | |\ \ / /__  __ _ _ __
     *     | |_) | '__| | '_ \| __\ V / _ \/ _` | '__|
     *     |  __/| |  | | | | | |_ | |  __/ (_| | |
     *     |_|   |_|  |_|_| |_|\__||_|\___|\__,_|_|
     *
     */
    final JButton btnPrintYear = new JButton(SYSConst.icon22print2);
    btnPrintYear.setPressedIcon(SYSConst.icon22print2Pressed);
    btnPrintYear.setAlignmentX(Component.RIGHT_ALIGNMENT);
    btnPrintYear.setContentAreaFilled(false);
    btnPrintYear.setBorder(null);
    btnPrintYear.setToolTipText(SYSTools.xx("misc.tooltips.btnprintyear"));
    btnPrintYear.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            String carry4printKey = resident.getRID() + "-" + (year - 1) + "-12";
            if (!carrySums.containsKey(carry4printKey)) {
                carrySums.put(carry4printKey,
                        AllowanceTools.getSUM(resident, SYSCalendar.eoy(start.minusYears(1))));
            }
            SYSFilesTools.print(AllowanceTools.getAsHTML(AllowanceTools.getYear(resident, start.toDate()),
                    carrySums.get(carry4printKey), resident), true);
        }

    });
    cptitle.getRight().add(btnPrintYear);

    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
            // monthly informations will be generated. even if there
            // are no allowances for that month
            for (LocalDate month = end; month.compareTo(start) >= 0; month = month.minusMonths(1)) {
                pnlContent.add(createCP4(resident, month));
            }

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

    });
    cpYear.setBackground(getBG(resident, 9));

    if (!cpYear.isCollapsed()) {
        JPanel pnlContent = new JPanel(new VerticalLayout());
        for (LocalDate month = end; month.compareTo(start) > 0; month = month.minusMonths(1)) {
            pnlContent.add(createCP4(resident, month));
        }
        cpYear.setContentPane(pnlContent);
    }

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

    return cpYear;
}