Example usage for javax.swing JToolBar addSeparator

List of usage examples for javax.swing JToolBar addSeparator

Introduction

In this page you can find the example usage for javax.swing JToolBar addSeparator.

Prototype

public void addSeparator() 

Source Link

Document

Appends a separator of default size to the end of the tool bar.

Usage

From source file:com.lynk.hrm.ui.dialog.InfoEmployee.java

private void initComponents() {
    addWindowListener(new WindowAdapter() {
        @Override/* www.  ja v a2s.  c o m*/
        public void windowClosing(WindowEvent e) {
            thisWindowClosing(e);
        }
    });
    setSize(836, 674);
    setTitle("");
    setIconImage(
            Toolkit.getDefaultToolkit().getImage(InfoEmployee.class.getResource("/resource/image/icon.png")));
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));
    {
        JToolBar toolBar = new JToolBar();
        toolBar.setFloatable(false);
        getContentPane().add(toolBar, BorderLayout.NORTH);
        {
            JButton uiSave = new JButton("?");
            uiSave.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    uiSaveActionPerformed(true);
                }
            });
            uiSave.setFocusable(false);
            uiSave.setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/emp_save.png")));
            uiSave.setFont(APP_FONT);
            toolBar.add(uiSave);
        }
        toolBar.addSeparator();
        {
            JButton uiReadIdCard = new JButton("??");
            uiReadIdCard.setFont(APP_FONT);
            uiReadIdCard.setIcon(
                    new ImageIcon(InfoEmployee.class.getResource("/resource/image/manager_teacher.png")));
            uiReadIdCard.setFocusable(false);
            uiReadIdCard.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    uiReadIdCardActionPerformed(e);
                }
            });
            toolBar.add(uiReadIdCard);
        }
        toolBar.addSeparator();
        {
            JButton uiInputFinger = new JButton("");
            uiInputFinger.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    uiInputFingerActionPerformed(e);
                }
            });
            uiInputFinger.setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/finger.png")));
            uiInputFinger.setFont(APP_FONT);
            uiInputFinger.setFocusable(false);
            toolBar.add(uiInputFinger);
        }
        toolBar.addSeparator();
        {
            JButton uiSetSuspend = new JButton("??");
            uiSetSuspend.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    uiSetSuspendActionPerformed(e);
                }
            });
            uiSetSuspend
                    .setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/emp_retire.png")));
            uiSetSuspend.setFont(APP_FONT);
            uiSetSuspend.setFocusable(false);
            toolBar.add(uiSetSuspend);
        }
    }

    {
        JPanel panel = new JPanel();
        getContentPane().add(panel);
        panel.setLayout(new MigLayout("", "[]5[grow]25[]5[grow]25[]5[grow]5[102]", "[][][][]"));
        {
            JLabel label = new JLabel("?");
            label.setHorizontalAlignment(SwingConstants.RIGHT);
            label.setFont(APP_FONT);
            panel.add(label, "cell 0 0");
        }
        {
            uiId = new LynkTextField();
            uiId.setEditable(false);
            uiId.setForeground(Color.BLUE);
            panel.add(uiId, "cell 1 0,growx");
        }
        {
            JLabel label = new JLabel("??");
            label.setHorizontalAlignment(SwingConstants.RIGHT);
            label.setFont(APP_FONT);
            panel.add(label, "cell 2 0");
        }
        {
            uiName = new LynkTextField();
            uiName.addFocusListener(new FocusAdapter() {
                @Override
                public void focusLost(FocusEvent e) {
                    uiNameFocusLost(e);
                }
            });
            panel.add(uiName, "cell 3 0,growx");
        }
        {
            JLabel label = new JLabel("?");
            label.setHorizontalAlignment(SwingConstants.RIGHT);
            label.setFont(APP_FONT);
            panel.add(label, "cell 4 0");
        }
        {
            uiNamePy = new LynkTextField();
            panel.add(uiNamePy, "cell 5 0,growx");
        }
        {
            JLabel label = new JLabel("?");
            label.setHorizontalAlignment(SwingConstants.RIGHT);
            label.setFont(APP_FONT);
            panel.add(label, "cell 0 1");
        }
        {
            uiState = new JComboBox<String>();
            uiState.setForeground(Color.BLUE);
            uiState.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    uiStateActionPerformed(e);
                }
            });
            uiState.setModel(new DefaultComboBoxModel<String>(new String[] { "", Employee.STATE_PROBATION,
                    Employee.STATE_CONTRACT, Employee.STATE_SUSPEND, Employee.STATE_LEAVE,
                    Employee.STATE_RETIRE, Employee.STATE_DELETE }));
            uiState.setFont(APP_FONT);
            panel.add(uiState, "cell 1 1,growx");
        }
        {
            uiInfoTab = new JideTabbedPane(JTabbedPane.TOP);
            uiInfoTab.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    uiInfoTabStateChanged(e);
                }
            });
            uiInfoTab.setColorTheme(JideTabbedPane.COLOR_THEME_DEFAULT);
            uiInfoTab.setFont(APP_FONT);
            panel.add(uiInfoTab, "cell 0 3 7 1");
            {
                JPanel uiInfoBasic = new JPanel();
                uiInfoBasic.setLayout(new MigLayout("", "[473px,grow][307px,grow]", "[grow][289px][149px]"));
                uiInfoTab.addTab("?", uiInfoBasic);
                {
                    JPanel uiIdCardPane = new JPanel();
                    uiIdCardPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                    uiIdCardPane.setLayout(new MigLayout("", "[]5[grow]10[]", "[][][][][40px:40px:40px,grow]"));
                    uiInfoBasic.add(uiIdCardPane, "cell 0 0,grow");
                    {
                        JLabel label = new JLabel("??");
                        uiIdCardPane.add(label, "cell 0 0");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiIdCard = new LynkTextField();
                        uiIdCardPane.add(uiIdCard, "cell 1 0,growx");
                    }
                    {
                        JPanel pane = new JPanel();
                        uiIdCardPane.add(pane, "cell 2 0 1 5,grow");
                        pane.setLayout(new MigLayout("insets 0", "[102px:102px:102px]", "[126px:126px:126px]"));
                        {
                            uiPhoto = new ImagePane();
                            pane.add(uiPhoto, "cell 0 0,grow");
                        }
                    }
                    //                  {
                    //                     JPanel photoPane = new JPanel();
                    //                     photoPane.setLayout(new MigLayout("insets 0", "[grow]", "[grow][]"));
                    //                     uiIdCardPane.add(photoPane, "cell 2 0 2 4,grow");
                    //                     {
                    //                        uiPhoto = new ImagePane();
                    //                        photoPane.add(uiPhoto, "cell 0 0,grow");
                    //                     }
                    //                     {
                    //                        JButton uiReadIdCardDirect = new JButton("??");
                    //                        uiReadIdCardDirect.addActionListener(new ActionListener() {
                    //                           public void actionPerformed(ActionEvent e) {
                    //                              uiReadIdCardDirectActionPerformed(e);
                    //                           }
                    //                        });
                    //                        uiReadIdCardDirect.setFont(APP_FONT);
                    //                        uiReadIdCardDirect.setFocusable(false);
                    //                        photoPane.add(uiReadIdCardDirect, "cell 0 1,grow");
                    //                     }
                    //                  }
                    {
                        JLabel label = new JLabel("");
                        uiIdCardPane.add(label, "cell 0 1");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiBirthday = new LynkTextField();
                        uiIdCardPane.add(uiBirthday, "cell 1 1,growx");
                    }
                    {
                        JLabel label = new JLabel("");
                        uiIdCardPane.add(label, "cell 0 2");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiAge = new LynkTextField();
                        uiIdCardPane.add(uiAge, "cell 1 2,growx");
                    }
                    {
                        JLabel label = new JLabel("");
                        uiIdCardPane.add(label, "cell 0 3,aligny top");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiGender = new LynkTextField();
                        uiIdCardPane.add(uiGender, "cell 1 3,growx,aligny top");
                    }
                    {
                        JLabel label = new JLabel("??");
                        label.setFont(APP_FONT);
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        uiIdCardPane.add(label, "cell 0 4");
                    }
                    {
                        JScrollPane scrollPane = new JScrollPane();
                        uiIdCardPane.add(scrollPane, "cell 1 4,grow");
                        {
                            uiCensusAddress = new JTextArea();
                            uiCensusAddress.setWrapStyleWord(true);
                            uiCensusAddress.setLineWrap(true);
                            scrollPane.setViewportView(uiCensusAddress);
                            uiCensusAddress.setFont(APP_FONT);
                        }
                    }
                }
                {
                    JPanel uiIdCardPane = new JPanel();
                    uiIdCardPane.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                    uiIdCardPane
                            .setLayout(new MigLayout("", "[]5[grow]25[]5[grow]", "[][][40px:40px:40px,grow]"));
                    uiInfoBasic.add(uiIdCardPane, "cell 0 1,grow");
                    {
                        JLabel label = new JLabel("");
                        uiIdCardPane.add(label, "cell 0 0");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiMarital = new JComboBox<String>();
                        uiIdCardPane.add(uiMarital, "cell 1 0,growx");
                        uiMarital.setModel(new DefaultComboBoxModel<String>(
                                new String[] { Employee.MARITAL_YES, Employee.MARITAL_NO }));
                        uiMarital.setFont(APP_FONT);
                    }
                    {
                        JLabel label = new JLabel("?");
                        uiIdCardPane.add(label, "cell 2 0");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiContact = new LynkTextField();
                        uiIdCardPane.add(uiContact, "cell 3 0,growx");
                    }
                    {
                        JLabel label = new JLabel("?");
                        uiIdCardPane.add(label, "cell 0 1");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiCensus = new JComboBox<String>();
                        uiIdCardPane.add(uiCensus, "cell 1 1,growx");
                        uiCensus.setModel(new DefaultComboBoxModel<String>(
                                new String[] { Employee.CENSUS_A, Employee.CENSUS_B, Employee.CENSUS_C,
                                        Employee.CENSUS_D, Employee.CENSUS_E, Employee.CENSUS_F }));
                        uiCensus.setFont(APP_FONT);
                    }
                    {
                        JLabel label = new JLabel("??");
                        uiIdCardPane.add(label, "cell 2 1");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiResidencePermit = new JComboBox<String>();
                        uiIdCardPane.add(uiResidencePermit, "cell 3 1,growx");
                        uiResidencePermit
                                .setModel(new DefaultComboBoxModel<String>(new String[] { "", "", "" }));
                        uiResidencePermit.setFont(APP_FONT);
                    }
                    {
                        JLabel label = new JLabel("");
                        uiIdCardPane.add(label, "cell 0 2");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        JScrollPane scrollPane = new JScrollPane();
                        uiIdCardPane.add(scrollPane, "cell 1 2 3 1,grow");
                        {
                            uiAddress = new JTextArea();
                            uiAddress.setWrapStyleWord(true);
                            uiAddress.setLineWrap(true);
                            scrollPane.setViewportView(uiAddress);
                            uiAddress.setFont(APP_FONT);
                        }
                    }
                }
                {
                    JPanel uiCompanyPanel = new JPanel();
                    uiCompanyPanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                    uiCompanyPanel.setLayout(new MigLayout("", "[]5[grow][]25[]5[grow][]", "[][][][][][][][]"));
                    uiInfoBasic.add(uiCompanyPanel, "cell 0 2,growx,aligny top");
                    {
                        JLabel label = new JLabel(Employee.SUSPEND_NOTE);
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                        uiCompanyPanel.add(label, "cell 0 0");
                    }
                    {
                        uiFactory = new JComboBox<String>(new DefaultComboBoxModel<String>(
                                new String[] { Employee.FACROTY_TC, Employee.FACTORY_SX }));
                        uiFactory.setFont(APP_FONT);
                        uiCompanyPanel.add(uiFactory, "cell 1 0 2 1,growx");
                    }
                    {
                        JLabel label = new JLabel("");
                        uiCompanyPanel.add(label, "cell 3 0");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiDept = new LynkTextField();
                        uiDept.setEditable(false);
                        uiCompanyPanel.add(uiDept, "cell 4 0,growx");
                    }
                    {
                        JButton uiChooseDept = new JButton();
                        uiChooseDept.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                uiChooseDeptActionPerformed(e);
                            }
                        });
                        uiChooseDept.setIcon(new ImageIcon(
                                InfoEmployee.class.getResource("/resource/image/choose_more.png")));
                        uiChooseDept.setMargin(new Insets(1, 1, 1, 1));
                        uiCompanyPanel.add(uiChooseDept, "cell 5 0,growx");
                    }
                    {
                        JLabel label = new JLabel("?");
                        uiCompanyPanel.add(label, "cell 0 1");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiJob = new LynkTextField();
                        uiJob.setEditable(false);
                        uiCompanyPanel.add(uiJob, "cell 1 1,growx");
                    }
                    {
                        JButton uiChooseJob = new JButton();
                        uiChooseJob.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                uiChooseJobActionPerformed(e);
                            }
                        });
                        uiChooseJob.setIcon(new ImageIcon(
                                InfoEmployee.class.getResource("/resource/image/choose_more.png")));
                        uiChooseJob.setMargin(new Insets(1, 1, 1, 1));
                        uiCompanyPanel.add(uiChooseJob, "cell 2 1,growx");
                    }
                    {
                        JLabel label = new JLabel(Employee.SUSPEND_START);
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                        uiCompanyPanel.add(label, "cell 3 1");
                    }
                    {
                        uiDdg = new JComboBox<String>(
                                new DefaultComboBoxModel<>(new String[] { Employee.DDG_N, Employee.DDG_Y }));
                        uiDdg.setFont(APP_FONT);
                        uiCompanyPanel.add(uiDdg, "cell 4 1 2 1,growx");
                    }
                    {
                        JLabel label = new JLabel("");
                        uiCompanyPanel.add(label, "cell 0 2");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiEntryDate = new JDateChooser();
                        uiCompanyPanel.add(uiEntryDate, "cell 1 2 2 1,growx");
                        uiEntryDate.setDateFormatString("yyyy-MM-dd");
                        uiEntryDate.setFont(APP_FONT);
                        uiEntryDate.getJCalendar().setTodayButtonVisible(true);
                        uiEntryDate.addPropertyChangeListener(new PropertyChangeListener() {

                            @Override
                            public void propertyChange(PropertyChangeEvent evt) {
                                if ("date".equals(evt.getPropertyName())) {
                                    setWorkAge();
                                }
                            }
                        });
                    }
                    {
                        JLabel label = new JLabel("");
                        uiCompanyPanel.add(label, "cell 3 2");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiWorkAge = new LynkTextField("0");
                        uiCompanyPanel.add(uiWorkAge, "cell 4 2 2 1,growx");
                        uiWorkAge.setEditable(false);
                    }
                    {
                        JLabel label = new JLabel("?");
                        uiCompanyPanel.add(label, "cell 0 3");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiProbation = new JDateChooser();
                        uiCompanyPanel.add(uiProbation, "cell 1 3 2 1,growx");
                        uiProbation.setDateFormatString("yyyy-MM-dd");
                        uiProbation.setFont(APP_FONT);
                        uiProbation.getJCalendar().setTodayButtonVisible(true);
                    }
                    {
                        JLabel label = new JLabel("??");
                        uiCompanyPanel.add(label, "cell 3 3");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiExpiration = new JDateChooser();
                        uiCompanyPanel.add(uiExpiration, "cell 4 3 2 1,growx");
                        uiExpiration.setDateFormatString("yyyy-MM-dd");
                        uiExpiration.setFont(APP_FONT);
                        uiExpiration.getJCalendar().setLeftButtonText(Employee.EXPIRATION_NO);
                        uiExpiration.getJCalendar().setLeftButtonVisible(true);
                        uiExpiration.getJCalendar().setRightButtonText(Employee.EXPIRATION_LONG);
                        uiExpiration.getJCalendar().setRightButtonVisible(true);
                    }
                    {
                        JLabel label = new JLabel("");
                        uiCompanyPanel.add(label, "cell 0 4");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiSchool = new LynkTextField();
                        uiCompanyPanel.add(uiSchool, "cell 1 4 2 1,growx");
                    }
                    {
                        JLabel label = new JLabel("");
                        uiCompanyPanel.add(label, "cell 3 4");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiDegree = new JComboBox<String>();
                        uiCompanyPanel.add(uiDegree, "cell 4 4 2 1,growx");
                        uiDegree.setMaximumRowCount(12);
                        uiDegree.setModel(new DefaultComboBoxModel<String>(new String[] { "", Employee.DEGREE_A,
                                Employee.DEGREE_B, Employee.DEGREE_C, Employee.DEGREE_D, Employee.DEGREE_E,
                                Employee.DEGREE_F, Employee.DEGREE_G, Employee.DEGREE_H, Employee.DEGREE_I,
                                Employee.DEGREE_J }));
                        uiDegree.setFont(APP_FONT);
                    }
                    {
                        JLabel label = new JLabel("");
                        uiCompanyPanel.add(label, "cell 0 5");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                    }
                    {
                        uiMajor = new LynkTextField();
                        uiCompanyPanel.add(uiMajor, "cell 1 5 2 1,growx");
                    }
                    {
                        JLabel label = new JLabel("");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                        uiCompanyPanel.add(label, "cell 3 5");
                    }
                    {
                        uiGuide = new LynkTextField();
                        uiCompanyPanel.add(uiGuide, "cell 4 5 2 1,growx");
                    }
                    {
                        JLabel label = new JLabel("?");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT_BLOD);
                        uiCompanyPanel.add(label, "cell 0 6");
                    }
                    {
                        uiPhoneShort = new LynkTextField();
                        uiPhoneShort.setFont(APP_FONT_BLOD);
                        uiCompanyPanel.add(uiPhoneShort, "cell 1 6 2 1,growx");
                    }
                    {
                        JLabel label = new JLabel("?");
                        label.setHorizontalAlignment(SwingConstants.RIGHT);
                        label.setFont(APP_FONT);
                        uiCompanyPanel.add(label, "cell 3 6");
                    }
                    {
                        uiPerformance = new LynkTextField();
                        uiCompanyPanel.add(uiPerformance, "cell 4 6 2 1,growx");
                    }
                    //                  {
                    //                     JLabel label = new JLabel("??");
                    //                     label.setHorizontalAlignment(SwingConstants.RIGHT);
                    //                     label.setFont(APP_FONT);
                    //                     uiCompanyPanel.add(label, "cell 0 7");
                    //                  }
                    //                  {
                    //                     uiSuspendEnd = new LynkTextField();
                    //                     uiCompanyPanel.add(uiSuspendEnd, "cell 1 7 5 1,growx");
                    //                  }
                }
                {
                    JPanel panel4 = new JPanel();
                    panel4.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
                    panel4.setLayout(new MigLayout("", "[]5[grow]", "[][][][grow][grow]"));
                    uiInfoBasic.add(panel4, "cell 1 0 1 3,grow");
                    {
                        JLabel label = new JLabel("???");
                        panel4.add(label, "cell 0 0,grow");
                        label.setFont(APP_FONT);
                    }
                    {
                        uiSocialCard = new LynkTextField();
                        panel4.add(uiSocialCard, "cell 1 0,grow");
                    }
                    {
                        JLabel label = new JLabel("?");
                        panel4.add(label, "cell 0 1,grow");
                        label.setFont(APP_FONT);
                    }
                    {
                        uiHousingCard = new LynkTextField();
                        panel4.add(uiHousingCard, "cell 1 1,grow");
                    }
                    {
                        JLabel label = new JLabel("??");
                        panel4.add(label, "cell 0 2,grow");
                        label.setFont(APP_FONT);
                    }
                    {
                        uiBankCard = new LynkTextField();
                        panel4.add(uiBankCard, "cell 1 2,grow");
                    }
                    {
                        JLabel label = new JLabel("?");
                        panel4.add(label, "cell 0 3,growx,aligny top");
                        label.setFont(APP_FONT);
                    }
                    {
                        JScrollPane scrollPane = new JScrollPane();
                        panel4.add(scrollPane, "cell 1 3,grow");
                        uiWorkExperience = new JTextArea();
                        uiWorkExperience.setFont(APP_FONT);
                        scrollPane.setViewportView(uiWorkExperience);
                    }
                    {
                        JLabel label = new JLabel("");
                        panel4.add(label, "cell 0 4,growx,aligny top");
                        label.setFont(APP_FONT);
                    }
                    {
                        JScrollPane scrollPane = new JScrollPane();
                        panel4.add(scrollPane, "cell 1 4,grow");
                        {
                            uiNote = new JTextArea();
                            uiNote.setFont(APP_FONT);
                            scrollPane.setViewportView(uiNote);
                        }
                    }
                }
            }
            {
                JPanel uiInfoLeave = new JPanel();
                uiInfoLeave.setLayout(new MigLayout("", "[]5[150px]25[]5[150px]", "[][][][grow][]"));
                uiInfoTab.addTab("??", uiInfoLeave);
                {
                    uiLabelLeaveDate = new JLabel("?");
                    uiLabelLeaveDate.setFont(APP_FONT);
                    uiInfoLeave.add(uiLabelLeaveDate, "cell 0 0,grow");
                }
                {
                    uiLeaveDate = new JDateChooser();
                    uiLeaveDate.setDateFormatString("yyyy-MM-dd");
                    uiLeaveDate.setFont(APP_FONT);
                    uiLeaveDate.getJCalendar().setTodayButtonVisible(true);
                    uiLeaveDate.getJCalendar().setNullDateButtonVisible(true);
                    uiInfoLeave.add(uiLeaveDate, "cell 1 0,growx,aligny top");
                }
                {
                    uiLabelSocialEnd = new JLabel("??");
                    uiLabelSocialEnd.setFont(APP_FONT);
                    uiInfoLeave.add(uiLabelSocialEnd, "cell 0 1,grow");
                }
                {
                    uiLabelHousingEnd = new JLabel("?");
                    uiLabelHousingEnd.setFont(APP_FONT);
                    uiInfoLeave.add(uiLabelHousingEnd, "cell 2 1,grow");
                }
                {
                    uiHousingEndDate = new JDateChooser();
                    uiHousingEndDate.setDateFormatString("yyyy-MM-dd");
                    uiHousingEndDate.setFont(APP_FONT);
                    uiHousingEndDate.getJCalendar().setLeftButtonText("");
                    uiHousingEndDate.getJCalendar().setLeftButtonVisible(true);
                    uiHousingEndDate.getJCalendar().setTodayButtonVisible(true);
                    uiHousingEndDate.getJCalendar().setNullDateButtonVisible(true);
                    uiInfoLeave.add(uiHousingEndDate, "cell 3 1,growx,aligny top");
                }
                {
                    uiLabelLeaveType = new JLabel("?");
                    uiLabelLeaveType.setFont(APP_FONT);
                    uiInfoLeave.add(uiLabelLeaveType, "cell 0 2,grow");
                }
                {
                    uiSocialEndDate = new JDateChooser();
                    uiSocialEndDate.setDateFormatString("yyyy-MM-dd");
                    uiSocialEndDate.setFont(APP_FONT);
                    uiSocialEndDate.getJCalendar().setLeftButtonText("");
                    uiSocialEndDate.getJCalendar().setLeftButtonVisible(true);
                    uiSocialEndDate.getJCalendar().setTodayButtonVisible(true);
                    uiSocialEndDate.getJCalendar().setNullDateButtonVisible(true);
                    uiInfoLeave.add(uiSocialEndDate, "cell 1 1,growx,aligny top");
                }
                {
                    uiLeaveType = new JComboBox<String>(new DefaultComboBoxModel<String>(
                            new String[] { "", Employee.LEAVE_TYPE_A, Employee.LEAVE_TYPE_B,
                                    Employee.LEAVE_TYPE_C, Employee.LEAVE_TYPE_D, Employee.LEAVE_TYPE_E,
                                    Employee.LEAVE_TYPE_F, Employee.LEAVE_TYPE_G, Employee.LEAVE_TYPE_H }));
                    uiLeaveType.setMaximumRowCount(10);
                    uiLeaveType.setFont(APP_FONT);
                    uiInfoLeave.add(uiLeaveType, "cell 1 2 3 1,grow");
                }
                {
                    uiLabelLeaveReason = new JLabel("?");
                    uiLabelLeaveReason.setFont(APP_FONT);
                    uiInfoLeave.add(uiLabelLeaveReason, "cell 0 3,growx,aligny top");
                }
                {
                    JScrollPane scrollPane_2 = new JScrollPane();
                    uiInfoLeave.add(scrollPane_2, "cell 1 3 3 1,grow");
                    {
                        uiLeaveReason = new JTextArea();
                        scrollPane_2.setViewportView(uiLeaveReason);
                        uiLeaveReason.setFont(APP_FONT);
                    }
                }
                {
                    JLabel label = new JLabel("??");
                    label.setHorizontalAlignment(SwingConstants.RIGHT);
                    label.setFont(APP_FONT);
                    uiInfoLeave.add(label, "cell 0 4");
                }
                {
                    uiTimeCardLeaveCertify = new LynkTextField();
                    uiTimeCardLeaveCertify.setEditable(false);
                    uiInfoLeave.add(uiTimeCardLeaveCertify, "cell 1 4 2 1,growx");
                }
                {
                    JButton uiPrintLeaveCertify = new JButton("???");
                    uiPrintLeaveCertify.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            uiPrintLeaveCertifyActionPerformed(e);
                        }
                    });
                    uiPrintLeaveCertify.setToolTipText("???!");
                    uiPrintLeaveCertify.setFont(APP_FONT);
                    uiPrintLeaveCertify.setFocusable(false);
                    uiInfoLeave.add(uiPrintLeaveCertify, "cell 3 4,alignx right");
                }
            }
            {
                JPanel uiInfoSuspendHistory = new JPanel();
                uiInfoSuspendHistory.setLayout(new BorderLayout(0, 0));
                uiInfoTab.addTab("???", uiInfoSuspendHistory);
                {
                    JScrollPane scrollPane = new JScrollPane();
                    uiInfoSuspendHistory.add(scrollPane, BorderLayout.CENTER);
                    {
                        suspendModel = new EmployeeSuspendModel();
                        uiEmpSuspend = new LynkTable(suspendModel);
                        uiEmpSuspend.addHighlighter(UtilsClient.createAlignHighlighter());
                        uiEmpSuspend.setAutoResizeMode(LynkTable.AUTO_RESIZE_ALL_COLUMNS);
                        scrollPane.setRowHeaderView(new TableRowHead(uiEmpSuspend));
                        scrollPane.setViewportView(uiEmpSuspend);
                    }
                }
            }
            {
                JPanel uiInfoEmpHistory = new JPanel();
                uiInfoEmpHistory.setLayout(new BorderLayout(0, 0));
                uiInfoTab.addTab("?", uiInfoEmpHistory);
                {
                    JPanel pane = new JPanel();
                    pane.setLayout(new MigLayout("", "[][][][100px:100px:100px][]", "[]"));
                    uiInfoEmpHistory.add(pane, BorderLayout.NORTH);
                    {
                        JLabel label = new JLabel("");
                        label.setFont(APP_FONT);
                        pane.add(label, "cell 0 0");
                    }
                    {
                        uiHistoryType = new JComboBox<String>(new DefaultComboBoxModel<>(
                                new String[] { "", PraisePunish.TYPE_A, PraisePunish.TYPE_B,
                                        PraisePunish.TYPE_C, PraisePunish.TYPE_D, PraisePunish.TYPE_E,
                                        PraisePunish.TYPE_F, PraisePunish.TYPE_G, PraisePunish.TYPE_H }));
                        uiHistoryType.setFont(APP_FONT);
                        pane.add(uiHistoryType, "cell 1 0");
                    }
                    {
                        JLabel label = new JLabel("?");
                        label.setFont(APP_FONT);
                        pane.add(label, "cell 2 0");
                    }
                    {
                        uiHistoryOperator = new LynkTextField();
                        pane.add(uiHistoryOperator, "cell 3 0,growx");
                    }
                    {
                        JButton uiRefresh = new JButton("");
                        uiRefresh.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                uiRefreshActionPerformed(e);
                            }
                        });
                        uiRefresh.setIcon(
                                new ImageIcon(InfoEmployee.class.getResource("/resource/image/refresh.png")));
                        uiRefresh.setFont(APP_FONT);
                        uiRefresh.setFocusable(false);
                        pane.add(uiRefresh, "cell 4 0");
                    }
                }
                {
                    JScrollPane scrollPane = new JScrollPane();
                    uiInfoEmpHistory.add(scrollPane, BorderLayout.CENTER);
                    {
                        historyModel = new EmployeeHistoryModel();
                        uiEmployeeHistory = new LynkTable(historyModel);
                        uiEmployeeHistory.setColumnSize(70, 540, 50, 130, 90);
                        scrollPane.setViewportView(uiEmployeeHistory);
                        scrollPane.setRowHeaderView(new TableRowHead(uiEmployeeHistory));

                    }
                }
            }
            {
                JPanel uiInfoJobAdjustment = new JPanel();
                uiInfoJobAdjustment.setLayout(new BorderLayout(0, 0));
                uiInfoTab.addTab("?", uiInfoJobAdjustment);
                {
                    JToolBar toolBar = new JToolBar();
                    toolBar.setFloatable(false);
                    uiInfoJobAdjustment.add(toolBar, BorderLayout.NORTH);
                    {
                        {
                            JButton uiAddJobAdjust = new JButton("?");
                            uiAddJobAdjust.addActionListener(new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    uiAddJobAdjustActionPerformed(e);
                                }
                            });
                            uiAddJobAdjust.setIcon(
                                    new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png")));
                            uiAddJobAdjust.setFont(APP_FONT);
                            toolBar.add(uiAddJobAdjust);
                        }
                    }
                }
                {
                    JScrollPane scrollPane = new JScrollPane();
                    uiInfoJobAdjustment.add(scrollPane, BorderLayout.CENTER);
                    {
                        jobAdjustmentModel = new JobAdjustmentModel();
                        uiJobAdjustment = new LynkTable(jobAdjustmentModel);
                        uiJobAdjustment.setColumnSize(50, 100, 100, 100, 100, 100, 80, 100, 150);
                        scrollPane.setRowHeaderView(new TableRowHead(uiJobAdjustment));
                        scrollPane.setViewportView(uiJobAdjustment);
                    }
                }
            }
            {
                JPanel uiInfoPraisePunish = new JPanel();
                uiInfoTab.addTab("", uiInfoPraisePunish);
                uiInfoPraisePunish.setLayout(
                        new MigLayout("", "[]10[grow]30[]10[120]5[]5[120]20[]20[][grow]", "[][grow]"));
                {
                    uiPraisePunishDateStart = new JDateChooser();
                    uiPraisePunishDateStart.setFont(APP_FONT);
                    uiPraisePunishDateStart.setDateFormatString("yyyy-MM-dd");
                    uiInfoPraisePunish.add(uiPraisePunishDateStart, "cell 3 0,growx");
                }
                {
                    uiPraisePunishDateEnd = new JDateChooser();
                    uiPraisePunishDateEnd.setFont(APP_FONT);
                    uiPraisePunishDateEnd.setDateFormatString("yyyy-MM-dd");
                    uiInfoPraisePunish.add(uiPraisePunishDateEnd, "cell 5 0,growx");

                }

                JButton uiAddPraisePunish = new JButton("");
                uiAddPraisePunish.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        uiAddPraisePunishActionPerformed(e);
                    }
                });
                {
                    JButton uiFindPraisePunish = new JButton("");
                    uiFindPraisePunish.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                            uiFindPraisePunishActionPerformed(e);
                        }
                    });
                    {
                        JLabel label = new JLabel("");
                        label.setFont(APP_FONT);
                        uiInfoPraisePunish.add(label, "cell 0 0,alignx trailing");
                    }
                    {
                        uiPraisePunishType = new JComboBox<String>(
                                new DefaultComboBoxModel<String>(new String[] { "", PraisePunish.TYPE_A,
                                        PraisePunish.TYPE_B, PraisePunish.TYPE_C, PraisePunish.TYPE_D,
                                        PraisePunish.TYPE_E, PraisePunish.TYPE_F, PraisePunish.TYPE_G }));
                        uiPraisePunishType.setEditable(true);
                        uiPraisePunishType.setFont(APP_FONT);
                        uiInfoPraisePunish.add(uiPraisePunishType, "cell 1 0,growx");
                    }

                    {
                        JLabel label = new JLabel("");
                        label.setFont(APP_FONT);
                        uiInfoPraisePunish.add(label, "cell 2 0");
                    }
                    {
                        JLabel label = new JLabel("");
                        label.setFont(APP_FONT);
                        uiInfoPraisePunish.add(label, "cell 4 0");
                    }
                    uiFindPraisePunish.setFocusable(false);
                    uiFindPraisePunish.setIcon(
                            new ImageIcon(InfoEmployee.class.getResource("/resource/image/refresh.png")));
                    uiFindPraisePunish.setFont(APP_FONT);
                    uiInfoPraisePunish.add(uiFindPraisePunish, "cell 6 0");
                }
                uiAddPraisePunish
                        .setIcon(new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png")));
                uiAddPraisePunish.setFont(APP_FONT);
                uiAddPraisePunish.setFocusable(false);
                uiInfoPraisePunish.add(uiAddPraisePunish, "cell 7 0");

                JScrollPane scrollPane = new JScrollPane();
                uiInfoPraisePunish.add(scrollPane, "cell 0 1 9 1,grow");
                {
                    praisePunishModel = new PraisePunishModel(
                            new String[] { PraisePunish.COLUMN_TYPE, PraisePunish.COLUMN_ACTION,
                                    PraisePunish.COLUMN_ACTION_DATE, PraisePunish.COLUMN_DEAL,
                                    PraisePunish.COLUMN_DEAL_DATE, PraisePunish.COLUMN_NOTE });
                    uiPraisePunish = new LynkTable(praisePunishModel);
                    uiPraisePunish.setColumnVisible(
                            new String[] { PraisePunish.COLUMN_TYPE, PraisePunish.COLUMN_ACTION,
                                    PraisePunish.COLUMN_ACTION_DATE, PraisePunish.COLUMN_DEAL,
                                    PraisePunish.COLUMN_DEAL_DATE, PraisePunish.COLUMN_NOTE });
                    uiPraisePunish.setDefaultRenderer(Object.class, new PraisePunishColorRenderer());
                    uiPraisePunish.setMouseDoubleClick(new MouseDoubleClick() {

                        @Override
                        public void doubleClick(int index) {
                            if (index != -1) {
                                index = uiPraisePunish.convertRowIndexToModel(index);
                                PraisePunish pp = praisePunishModel.getPp(index);
                                pp = InfoPraisePunish.showdialog(InfoEmployee.this, pp, null);
                                if (pp != null) {
                                    praisePunishModel.updatePp(pp);
                                }
                            }
                        }
                    });
                    scrollPane.setViewportView(uiPraisePunish);
                    scrollPane.setRowHeaderView(new TableRowHead(uiPraisePunish));
                }
            }
            {
                JPanel uiPanelVacation = new JPanel();
                uiPanelVacation.setLayout(new BorderLayout());
                uiInfoTab.addTab("?", uiPanelVacation);
                {
                    JToolBar uiVacationToolBar = new JToolBar();
                    uiVacationToolBar.setFloatable(false);
                    uiPanelVacation.add(uiVacationToolBar, BorderLayout.NORTH);
                    {
                        JButton uiVacationRefresh = new JButton("");
                        uiVacationRefresh.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                uiVacationRefreshActionPerformed(e);
                            }
                        });
                        uiVacationRefresh.setIcon(
                                new ImageIcon(InfoEmployee.class.getResource("/resource/image/refresh.png")));
                        uiVacationRefresh.setFocusable(false);
                        uiVacationRefresh.setFont(APP_FONT);
                        uiVacationToolBar.add(uiVacationRefresh);
                    }
                    uiVacationToolBar.addSeparator();
                    {
                        uiVacationHistoryAdd = new JButton("");
                        uiVacationHistoryAdd.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                uiVacationAddActionPerformed(e);
                            }
                        });
                        uiVacationHistoryAdd.setIcon(
                                new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png")));
                        uiVacationHistoryAdd.setFocusable(false);
                        uiVacationHistoryAdd.setFont(APP_FONT);
                        uiVacationToolBar.add(uiVacationHistoryAdd);
                    }
                    uiVacationToolBar.addSeparator();
                    {
                        JButton uiEndLastLeft = new JButton("");
                        uiEndLastLeft.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent e) {
                                uiEndLastLeftActionPerformed(e);
                            }
                        });
                        uiEndLastLeft.setIcon(
                                new ImageIcon(InfoEmployee.class.getResource("/resource/image/add.png")));
                        uiEndLastLeft.setFocusable(false);
                        uiEndLastLeft.setFont(APP_FONT);
                        uiVacationToolBar.add(uiEndLastLeft);
                    }
                }
                {
                    JPanel uiPanelVacationInfo = new JPanel();
                    uiPanelVacation.add(uiPanelVacationInfo, BorderLayout.CENTER);
                    uiPanelVacationInfo.setLayout(new MigLayout("", "[grow]", "[][grow]"));

                    JPanel paneAv = new JPanel();
                    uiPanelVacationInfo.add(paneAv, "cell 0 0,grow");
                    paneAv.setLayout(new MigLayout("", "[][grow]50[][grow]", "[][][]"));
                    {
                        uiVacationStartEnd = new JLabel("Time");
                        uiVacationStartEnd.setHorizontalAlignment(SwingConstants.CENTER);
                        paneAv.add(uiVacationStartEnd, "cell 0 0 4 1,growx");
                        uiVacationStartEnd.setForeground(Color.BLUE);
                        uiVacationStartEnd.setFont(APP_FONT.deriveFont(16f));
                    }
                    {
                        JLabel labe = new JLabel(":");
                        paneAv.add(labe, "cell 0 1");
                        labe.setFont(APP_FONT.deriveFont(16f));
                    }
                    {
                        uiLastTotal = new JLabel("");
                        paneAv.add(uiLastTotal, "cell 1 1,alignx left");
                        uiLastTotal.setForeground(Color.BLUE);
                        uiLastTotal.setFont(APP_FONT.deriveFont(16f));
                    }
                    {
                        JLabel labe = new JLabel(":");
                        paneAv.add(labe, "cell 2 1");
                        labe.setFont(APP_FONT.deriveFont(16f));
                    }
                    {
                        uiLastLeft = new JLabel("");
                        paneAv.add(uiLastLeft, "cell 3 1,alignx left");
                        uiLastLeft.setForeground(Color.BLUE);
                        uiLastLeft.setFont(APP_FONT.deriveFont(16f));
                    }
                    {
                        JLabel labe = new JLabel(":");
                        paneAv.add(labe, "cell 0 2");
                        labe.setFont(APP_FONT.deriveFont(16f));
                    }
                    {
                        uiCurrentTotal = new JLabel("");
                        paneAv.add(uiCurrentTotal, "cell 1 2,alignx left");
                        uiCurrentTotal.setForeground(Color.BLUE);
                        uiCurrentTotal.setFont(APP_FONT.deriveFont(16f));
                    }
                    {
                        JLabel labe = new JLabel("?:");
                        paneAv.add(labe, "cell 2 2");
                        labe.setFont(APP_FONT.deriveFont(16f));
                    }
                    {
                        uiLeftHours = new JLabel("");
                        paneAv.add(uiLeftHours, "cell 3 2,alignx left");
                        uiLeftHours.setForeground(Color.BLUE);
                        uiLeftHours.setFont(APP_FONT.deriveFont(16f));
                    }

                    JScrollPane scrollPane = new JScrollPane();
                    uiPanelVacationInfo.add(scrollPane, "cell 0 1,grow");
                    {
                        attendanceVacationModel = new AttendanceVacationHistoryModel();
                        uiAttendanceVacationHistory = new LynkTable(attendanceVacationModel);
                        uiAttendanceVacationHistory.setAutoResizeMode(LynkTable.AUTO_RESIZE_ALL_COLUMNS);
                        scrollPane.setViewportView(uiAttendanceVacationHistory);
                        scrollPane.setRowHeaderView(new TableRowHead(uiAttendanceVacationHistory));
                    }
                }
            }
        }
    }

}

From source file:it.cnr.icar.eric.client.ui.swing.graph.JBGraph.java

/**
 * DOCUMENT ME!//from ww  w  .  j  a  v  a 2 s  .c o  m
 *
 * @return DOCUMENT ME!
 */
public JToolBar createToolBar() {
    JButton button = null;
    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);

    //TODO: SwingBoost: Localize this
    TreeNode tempTreeNode = new DefaultMutableTreeNode("loading object types...");
    objectTypeCombo = new it.cnr.icar.eric.client.ui.swing.TreeCombo(new DefaultTreeModel(tempTreeNode));
    toolbar.add(objectTypeCombo);

    // use a SwingWorker to get the real model, since it might not have been initialized yet
    final SwingWorker worker = new SwingWorker(this) {
        public Object doNonUILogic() {
            ConceptsTreeModel objectTypesTreeModel = BusinessQueryPanel.getObjectTypesTreeModel();
            return objectTypesTreeModel;
        }

        public void doUIUpdateLogic() {
            ConceptsTreeModel objectTypesTreeModel = (ConceptsTreeModel) get();
            objectTypeCombo.setModel(objectTypesTreeModel);
        }
    };
    worker.start();

    // Insert
    URL insertUrl = getClass().getClassLoader().getResource("icons/insert.gif");
    ImageIcon insertIcon = new ImageIcon(insertUrl);
    button = toolbar.add(new AbstractAction("", insertIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            insert(new Point(10, 10));
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Insert");

    // Toggle Connect Mode
    URL connectUrl = getClass().getClassLoader().getResource("icons/connecton.gif");
    ImageIcon connectIcon = new ImageIcon(connectUrl);
    button = toolbar.add(new AbstractAction("", connectIcon) {

        /**
        * 
        */
        private static final long serialVersionUID = 657528648199915209L;

        public void actionPerformed(ActionEvent e) {
            setPortsVisible(!isPortsVisible());

            URL connectUrl;

            if (isPortsVisible()) {
                connectUrl = getClass().getClassLoader().getResource("icons/connecton.gif");
            } else {
                connectUrl = getClass().getClassLoader().getResource("icons/connectoff.gif");
            }

            ImageIcon connectIcon = new ImageIcon(connectUrl);
            putValue(SMALL_ICON, connectIcon);
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Toggle Connect Mode");

    // Undo
    toolbar.addSeparator();

    URL undoUrl = getClass().getClassLoader().getResource("icons/undo.gif");
    ImageIcon undoIcon = new ImageIcon(undoUrl);
    undo = new AbstractAction("", undoIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -740055667372297781L;

        public void actionPerformed(ActionEvent e) {
            undo();
        }
    };
    undo.setEnabled(false);
    button = toolbar.add(undo);
    button.setText(""); //an icon-only button
    button.setToolTipText("Undo");

    // Redo
    URL redoUrl = getClass().getClassLoader().getResource("icons/redo.gif");
    ImageIcon redoIcon = new ImageIcon(redoUrl);
    redo = new AbstractAction("", redoIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = 5021485220988522968L;

        public void actionPerformed(ActionEvent e) {
            redo();
        }
    };
    redo.setEnabled(false);
    button = toolbar.add(redo);
    button.setText(""); //an icon-only button
    button.setToolTipText("Redo");

    //
    // Edit Block
    //
    toolbar.addSeparator();

    Action action;
    URL url;

    // Copy
    action = TransferHandler.getCopyAction();
    url = getClass().getClassLoader().getResource("icons/copy.gif");
    action.putValue(Action.SMALL_ICON, new ImageIcon(url));

    //Commented out until we can figure out how to assign new id to copied objects
    //button = toolbar.add(copy = new EventRedirector(action));
    button.setText(""); //an icon-only button
    button.setToolTipText("Copy");

    // Paste
    action = TransferHandler.getPasteAction();
    url = getClass().getClassLoader().getResource("icons/paste.gif");
    action.putValue(Action.SMALL_ICON, new ImageIcon(url));

    //Commented out until we can figure out how to assign new id to copied objects
    //button = toolbar.add(paste = new EventRedirector(action));
    button.setText(""); //an icon-only button
    button.setToolTipText("Paste");

    // Cut
    action = TransferHandler.getCutAction();
    url = getClass().getClassLoader().getResource("icons/cut.gif");
    action.putValue(Action.SMALL_ICON, new ImageIcon(url));

    //Commented out until we can figure out how to assign new id to copied objects
    //button = toolbar.add(cut = new EventRedirector(action));
    button.setText(""); //an icon-only button
    button.setToolTipText("Cut");

    // Remove
    URL removeUrl = getClass().getClassLoader().getResource("icons/delete.gif");
    ImageIcon removeIcon = new ImageIcon(removeUrl);
    remove = new AbstractAction("", removeIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = 6889927067487680474L;

        public void actionPerformed(ActionEvent e) {
            if (!isSelectionEmpty()) {
                Object[] cells = getSelectionCells();
                cells = getDescendants(cells);
                getModel().remove(cells);

                //Remove entry from map of cells on the graph
                for (int i = 0; i < cells.length; i++) {
                    Object cell = cells[i];

                    if (cell instanceof JBGraphCell) {
                        RegistryObject ro = ((JBGraphCell) cell).getRegistryObject();
                        registryObjectToCellMap.remove(ro);
                    }
                }
            }
        }
    };
    remove.setEnabled(false);
    button = toolbar.add(remove);
    button.setText(""); //an icon-only button
    button.setToolTipText(resourceBundle.getString("menu.graphPanel.removeFromView"));

    // Zoom Std
    toolbar.addSeparator();

    URL zoomUrl = getClass().getClassLoader().getResource("icons/zoom.gif");
    ImageIcon zoomIcon = new ImageIcon(zoomUrl);
    button = toolbar.add(new AbstractAction("", zoomIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -4404610379022823602L;

        public void actionPerformed(ActionEvent e) {
            setScale(1.0);
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Zoom");

    // Zoom In
    URL zoomInUrl = getClass().getClassLoader().getResource("icons/zoomin.gif");
    ImageIcon zoomInIcon = new ImageIcon(zoomInUrl);
    button = toolbar.add(new AbstractAction("", zoomInIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = 6782766891458235321L;

        public void actionPerformed(ActionEvent e) {
            setScale(2 * getScale());
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Zoom In");

    // Zoom Out
    URL zoomOutUrl = getClass().getClassLoader().getResource("icons/zoomout.gif");
    ImageIcon zoomOutIcon = new ImageIcon(zoomOutUrl);
    button = toolbar.add(new AbstractAction("", zoomOutIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -5480242207934335070L;

        public void actionPerformed(ActionEvent e) {
            setScale(getScale() / 2);
        }
    });
    button.setText(""); //an icon-only button
    button.setToolTipText("Zoom Out");

    // Group
    /*
    toolbar.addSeparator();
            
    URL groupUrl          =
    getClass().getClassLoader().getResource("icons/group.gif");
    ImageIcon groupIcon   = new ImageIcon(groupUrl);
    group =
    new AbstractAction("", groupIcon) {
            public void actionPerformed(ActionEvent e) {
                group(getSelectionCells());
            }
        };
    group.setEnabled(false);
    //button                = toolbar.add(group);
    button.setText(""); //an icon-only button
    button.setToolTipText("Group");
            
    // Ungroup
    URL ungroupUrl        =
    getClass().getClassLoader().getResource("icons/ungroup.gif");
    ImageIcon ungroupIcon = new ImageIcon(ungroupUrl);
    ungroup =
    new AbstractAction("", ungroupIcon) {
            public void actionPerformed(ActionEvent e) {
                ungroup(getSelectionCells());
            }
        };
    ungroup.setEnabled(false);
    //button                = toolbar.add(ungroup);
    button.setText(""); //an icon-only button
    button.setToolTipText("Ungroup");
     */
    // To Front
    toolbar.addSeparator();

    URL toFrontUrl = getClass().getClassLoader().getResource("icons/tofront.gif");
    ImageIcon toFrontIcon = new ImageIcon(toFrontUrl);
    tofront = new AbstractAction("", toFrontIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -4901428890590828561L;

        public void actionPerformed(ActionEvent e) {
            if (!isSelectionEmpty()) {
                toFront(getSelectionCells());
            }
        }
    };
    tofront.setEnabled(false);
    button = toolbar.add(tofront);
    button.setText(""); //an icon-only button
    button.setToolTipText("To Front");

    // To Back
    URL toBackUrl = getClass().getClassLoader().getResource("icons/toback.gif");
    ImageIcon toBackIcon = new ImageIcon(toBackUrl);
    toback = new AbstractAction("", toBackIcon) {
        /**
        * 
        */
        private static final long serialVersionUID = -5942025518651424307L;

        public void actionPerformed(ActionEvent e) {
            if (!isSelectionEmpty()) {
                toBack(getSelectionCells());
            }
        }
    };
    toback.setEnabled(false);
    button = toolbar.add(toback);
    button.setText(""); //an icon-only button
    button.setToolTipText("To Back");

    return toolbar;
}

From source file:com.maxl.java.amikodesk.AMiKoDesk.java

private static void createAndShowFullGUI() {
    // Create and setup window
    final JFrame jframe = new JFrame(Constants.APP_NAME);
    jframe.setName(Constants.APP_NAME + ".main");

    int min_width = CML_OPT_WIDTH;
    int min_height = CML_OPT_HEIGHT;
    jframe.setPreferredSize(new Dimension(min_width, min_height));
    jframe.setMinimumSize(new Dimension(min_width, min_height));
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width - min_width) / 2;
    int y = (screen.height - min_height) / 2;
    jframe.setBounds(x, y, min_width, min_height);

    // Set application icon
    if (Utilities.appCustomization().equals("ywesee")) {
        ImageIcon img = new ImageIcon(Constants.AMIKO_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("desitin")) {
        ImageIcon img = new ImageIcon(Constants.DESITIN_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("meddrugs")) {
        ImageIcon img = new ImageIcon(Constants.MEDDRUGS_ICON);
        jframe.setIconImage(img.getImage());
    } else if (Utilities.appCustomization().equals("zurrose")) {
        ImageIcon img = new ImageIcon(Constants.AMIKO_ICON);
        jframe.setIconImage(img.getImage());
    }/*w  w w.j a va  2 s  . co  m*/

    // ------ Setup menubar ------
    JMenuBar menu_bar = new JMenuBar();
    // menu_bar.add(Box.createHorizontalGlue()); // --> aligns menu items to the right!
    // -- Menu "Datei" --
    JMenu datei_menu = new JMenu("Datei");
    if (Utilities.appLanguage().equals("fr"))
        datei_menu.setText("Fichier");
    menu_bar.add(datei_menu);
    JMenuItem print_item = new JMenuItem("Drucken...");
    JMenuItem settings_item = new JMenuItem(m_rb.getString("settings") + "...");
    JMenuItem quit_item = new JMenuItem("Beenden");
    if (Utilities.appLanguage().equals("fr")) {
        print_item.setText("Imprimer");
        quit_item.setText("Terminer");
    }
    datei_menu.add(print_item);
    datei_menu.addSeparator();
    datei_menu.add(settings_item);
    datei_menu.addSeparator();
    datei_menu.add(quit_item);

    // -- Menu "Aktualisieren" --
    JMenu update_menu = new JMenu("Aktualisieren");
    if (Utilities.appLanguage().equals("fr"))
        update_menu.setText("Mise  jour");
    menu_bar.add(update_menu);
    final JMenuItem updatedb_item = new JMenuItem("Aktualisieren via Internet...");
    updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK));
    JMenuItem choosedb_item = new JMenuItem("Aktualisieren via Datei...");
    update_menu.add(updatedb_item);
    update_menu.add(choosedb_item);
    if (Utilities.appLanguage().equals("fr")) {
        updatedb_item.setText("Tlcharger la banque de donnes...");
        updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK));
        choosedb_item.setText("Ajourner la banque de donnes...");
    }

    // -- Menu "Hilfe" --
    JMenu hilfe_menu = new JMenu("Hilfe");
    if (Utilities.appLanguage().equals("fr"))
        hilfe_menu.setText("Aide");
    menu_bar.add(hilfe_menu);

    JMenuItem about_item = new JMenuItem("ber " + Constants.APP_NAME + "...");
    JMenuItem ywesee_item = new JMenuItem(Constants.APP_NAME + " im Internet");
    if (Utilities.appCustomization().equals("meddrugs"))
        ywesee_item.setText("med-drugs im Internet");
    JMenuItem report_item = new JMenuItem("Error Report...");
    JMenuItem contact_item = new JMenuItem("Kontakt...");

    if (Utilities.appLanguage().equals("fr")) {
        // Extrawunsch med-drugs
        if (Utilities.appCustomization().equals("meddrugs"))
            about_item.setText(Constants.APP_NAME);
        else
            about_item.setText("A propos de " + Constants.APP_NAME + "...");
        contact_item.setText("Contact...");
        if (Utilities.appCustomization().equals("meddrugs"))
            ywesee_item.setText("med-drugs sur Internet");
        else
            ywesee_item.setText(Constants.APP_NAME + " sur Internet");
        report_item.setText("Rapport d'erreur...");
    }
    hilfe_menu.add(about_item);
    hilfe_menu.add(ywesee_item);
    hilfe_menu.addSeparator();
    hilfe_menu.add(report_item);
    hilfe_menu.addSeparator();
    hilfe_menu.add(contact_item);

    // Menu "Abonnieren" (only for ywesee)
    JMenu subscribe_menu = new JMenu("Abonnieren");
    if (Utilities.appLanguage().equals("fr"))
        subscribe_menu.setText("Abonnement");
    if (Utilities.appCustomization().equals("ywesee")) {
        menu_bar.add(subscribe_menu);
    }

    jframe.setJMenuBar(menu_bar);

    // ------ Setup toolbar ------
    JToolBar toolBar = new JToolBar("Database");
    toolBar.setPreferredSize(new Dimension(jframe.getWidth(), 64));
    final JToggleButton selectAipsButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "aips32x32_bright.png"));
    final JToggleButton selectFavoritesButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "favorites32x32_bright.png"));
    final JToggleButton selectInteractionsButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "interactions32x32_bright.png"));
    final JToggleButton selectShoppingCartButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "shoppingcart32x32_bright.png"));
    final JToggleButton selectComparisonCartButton = new JToggleButton(
            new ImageIcon(Constants.IMG_FOLDER + "comparisoncart32x32_bright.png"));

    final JToggleButton list_of_buttons[] = { selectAipsButton, selectFavoritesButton, selectInteractionsButton,
            selectShoppingCartButton, selectComparisonCartButton };

    if (Utilities.appLanguage().equals("de")) {
        setupButton(selectAipsButton, "Kompendium", "aips32x32_gray.png", "aips32x32_dark.png");
        setupButton(selectFavoritesButton, "Favoriten", "favorites32x32_gray.png", "favorites32x32_dark.png");
        setupButton(selectInteractionsButton, "Interaktionen", "interactions32x32_gray.png",
                "interactions32x32_dark.png");
        setupButton(selectShoppingCartButton, "Warenkorb", "shoppingcart32x32_gray.png",
                "shoppingcart32x32_dark.png");
        setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png",
                "comparisoncart32x32_dark.png");
    } else if (Utilities.appLanguage().equals("fr")) {
        setupButton(selectAipsButton, "Compendium", "aips32x32_gray.png", "aips32x32_dark.png");
        setupButton(selectFavoritesButton, "Favorites", "favorites32x32_gray.png", "favorites32x32_dark.png");
        setupButton(selectInteractionsButton, "Interactions", "interactions32x32_gray.png",
                "interactions32x32_dark.png");
        setupButton(selectShoppingCartButton, "Panier", "shoppingcart32x32_gray.png",
                "shoppingcart32x32_dark.png");
        setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png",
                "comparisoncart32x32_dark.png");
    }

    // Add to toolbar and set up
    toolBar.setBackground(m_toolbar_bg);
    toolBar.add(selectAipsButton);
    toolBar.addSeparator();
    toolBar.add(selectFavoritesButton);
    toolBar.addSeparator();
    toolBar.add(selectInteractionsButton);
    if (!Utilities.appCustomization().equals("zurrose")) {
        toolBar.addSeparator();
        toolBar.add(selectShoppingCartButton);
    }
    if (Utilities.appCustomization().equals("zurrorse")) {
        toolBar.addSeparator();
        toolBar.add(selectComparisonCartButton);
    }
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    // Progress indicator (not working...)
    toolBar.addSeparator(new Dimension(32, 32));
    toolBar.add(m_progress_indicator);

    // ------ Setup settingspage ------
    final SettingsPage settingsPage = new SettingsPage(jframe, m_rb);
    // Attach observer to it
    settingsPage.addObserver(new Observer() {
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            if (m_shopping_cart != null) {
                // Refresh some stuff
                m_shopping_basket.clear();
                int index = m_shopping_cart.getCartIndex();
                if (index > 0)
                    m_web_panel.saveShoppingCartWithIndex(index);
                m_web_panel.updateShoppingHtml();
            }
        }
    });

    jframe.addWindowListener(new WindowListener() {
        // Use WindowAdapter!
        @Override
        public void windowOpened(WindowEvent e) {
        }

        @Override
        public void windowClosed(WindowEvent e) {
            m_web_panel.dispose();
            Runtime.getRuntime().exit(0);
        }

        @Override
        public void windowClosing(WindowEvent e) {
            // Save shopping cart
            int index = m_shopping_cart.getCartIndex();
            if (index > 0 && m_web_panel != null)
                m_web_panel.saveShoppingCartWithIndex(index);
        }

        @Override
        public void windowIconified(WindowEvent e) {
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
        }

        @Override
        public void windowActivated(WindowEvent e) {
        }

        @Override
        public void windowDeactivated(WindowEvent e) {
        }
    });
    print_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            m_web_panel.print();
        }
    });
    settings_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            settingsPage.display();
        }
    });
    quit_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            try {
                // Save shopping cart
                int index = m_shopping_cart.getCartIndex();
                if (index > 0 && m_web_panel != null)
                    m_web_panel.saveShoppingCartWithIndex(index);
                // Save settings
                WindowSaver.saveSettings();
                m_web_panel.dispose();
                Runtime.getRuntime().exit(0);
            } catch (Exception e) {
                System.out.println(e);
            }
        }
    });
    subscribe_menu.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(MenuEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI(
                                "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3UM84Z6WLFKZE"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }

        @Override
        public void menuDeselected(MenuEvent event) {
            // do nothing
        }

        @Override
        public void menuCanceled(MenuEvent event) {
            // do nothing
        }
    });
    contact_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI
                                .create("mailto:zdavatz@ywesee.com?subject=AmiKo%20Desktop%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("desitin")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI
                                .create("mailto:info@desitin.ch?subject=AmiKo%20Desktop%20Desitin%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("meddrugs")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        URI mail_to_uri = URI.create(
                                "mailto:med-drugs@just-medical.com?subject=med-drugs%20desktop%20Feedback");
                        Desktop.getDesktop().mail(mail_to_uri);
                    } catch (IOException e) {
                        // TODO:
                    }
                } else {
                    AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
                    cd.ContactDialog();
                }
            } else if (Utilities.appCustomization().equals("zurrose")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }
    });
    report_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            // Check first m_application_folder otherwise resort to
            // pre-installed report
            String report_file = m_application_data_folder + "\\" + Constants.DEFAULT_AMIKO_REPORT_BASE
                    + Utilities.appLanguage() + ".html";
            if (!(new File(report_file)).exists())
                report_file = System.getProperty("user.dir") + "/dbs/" + Constants.DEFAULT_AMIKO_REPORT_BASE
                        + Utilities.appLanguage() + ".html";
            // Open report file in browser
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new File(report_file).toURI());
                } catch (IOException e) {
                    // TODO:
                }
            }
        }
    });
    ywesee_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (Utilities.appCustomization().equals("ywesee")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("http://www.ywesee.com/AmiKo/Desktop"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("desitin")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(
                                new URI("http://www.desitin.ch/produkte/arzneimittel-kompendium-apps/"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("meddrugs")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        if (Utilities.appLanguage().equals("de"))
                            Desktop.getDesktop().browse(new URI("http://www.med-drugs.ch"));
                        else if (Utilities.appLanguage().equals("fr"))
                            Desktop.getDesktop()
                                    .browse(new URI("http://www.med-drugs.ch/index.cfm?&newlang=fr"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            } else if (Utilities.appCustomization().equals("zurrose")) {
                if (Desktop.isDesktopSupported()) {
                    try {
                        Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko"));
                    } catch (IOException e) {
                        // TODO:
                    } catch (URISyntaxException r) {
                        // TODO:
                    }
                }
            }
        }
    });
    about_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            AmiKoDialogs ad = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization());
            ad.AboutDialog();
        }
    });

    // Container
    final Container container = jframe.getContentPane();
    container.setBackground(Color.WHITE);
    container.setLayout(new BorderLayout());

    // ==== Toolbar =====
    container.add(toolBar, BorderLayout.NORTH);

    // ==== Left panel ====
    JPanel left_panel = new JPanel();
    left_panel.setBackground(Color.WHITE);
    left_panel.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(2, 2, 2, 2);

    // ---- Search field ----
    final SearchField searchField = new SearchField("Suche Prparat");
    if (Utilities.appLanguage().equals("fr"))
        searchField.setText("Recherche Specialit");
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(searchField, gbc);
    left_panel.add(searchField, gbc);

    // ---- Buttons ----
    // Names
    String l_title = "Prparat";
    String l_author = "Inhaberin";
    String l_atccode = "Wirkstoff / ATC Code";
    String l_regnr = "Zulassungsnummer";
    String l_ingredient = "Wirkstoff";
    String l_therapy = "Therapie";
    String l_search = "Suche";

    if (Utilities.appLanguage().equals("fr")) {
        l_title = "Spcialit";
        l_author = "Titulaire";
        l_atccode = "Principe Active / Code ATC";
        l_regnr = "Nombre Enregistration";
        l_ingredient = "Principe Active";
        l_therapy = "Thrapie";
        l_search = "Recherche";
    }

    ButtonGroup bg = new ButtonGroup();

    JToggleButton but_title = new JToggleButton(l_title);
    setupToggleButton(but_title);
    bg.add(but_title);
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_title, gbc);
    left_panel.add(but_title, gbc);

    JToggleButton but_auth = new JToggleButton(l_author);
    setupToggleButton(but_auth);
    bg.add(but_auth);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_auth, gbc);
    left_panel.add(but_auth, gbc);

    JToggleButton but_atccode = new JToggleButton(l_atccode);
    setupToggleButton(but_atccode);
    bg.add(but_atccode);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_atccode, gbc);
    left_panel.add(but_atccode, gbc);

    JToggleButton but_regnr = new JToggleButton(l_regnr);
    setupToggleButton(but_regnr);
    bg.add(but_regnr);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_regnr, gbc);
    left_panel.add(but_regnr, gbc);

    JToggleButton but_therapy = new JToggleButton(l_therapy);
    setupToggleButton(but_therapy);
    bg.add(but_therapy);
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = gbc.gridheight = 1;
    gbc.weightx = gbc.weighty = 0.0;
    // --> container.add(but_therapy, gbc);
    left_panel.add(but_therapy, gbc);

    // ---- Card layout ----
    final CardLayout cardl = new CardLayout();
    cardl.setHgap(-4); // HACK to make things look better!!
    final JPanel p_results = new JPanel(cardl);
    m_list_titles = new ListPanel();
    m_list_auths = new ListPanel();
    m_list_regnrs = new ListPanel();
    m_list_atccodes = new ListPanel();
    m_list_ingredients = new ListPanel();
    m_list_therapies = new ListPanel();
    // Contraints
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy += 1;
    gbc.gridwidth = 1;
    gbc.gridheight = 10;
    gbc.weightx = 1.0;
    gbc.weighty = 1.0;
    //
    p_results.add(m_list_titles, l_title);
    p_results.add(m_list_auths, l_author);
    p_results.add(m_list_regnrs, l_regnr);
    p_results.add(m_list_atccodes, l_atccode);
    p_results.add(m_list_ingredients, l_ingredient);
    p_results.add(m_list_therapies, l_therapy);

    // --> container.add(p_results, gbc);
    left_panel.add(p_results, gbc);
    left_panel.setBorder(null);
    // First card to show
    cardl.show(p_results, l_title);

    // ==== Right panel ====
    JPanel right_panel = new JPanel();
    right_panel.setBackground(Color.WHITE);
    right_panel.setLayout(new GridBagLayout());

    // ---- Section titles ----
    m_section_titles = null;
    if (Utilities.appLanguage().equals("de")) {
        m_section_titles = new IndexPanel(SectionTitle_DE);
    } else if (Utilities.appLanguage().equals("fr")) {
        m_section_titles = new IndexPanel(SectionTitle_FR);
    }
    m_section_titles.setMinimumSize(new Dimension(150, 150));
    m_section_titles.setMaximumSize(new Dimension(320, 1000));

    // ---- Fachinformation ----
    m_web_panel = new WebPanel2();
    m_web_panel.setMinimumSize(new Dimension(320, 150));

    // Add JSplitPane on the RIGHT
    final int Divider_location = 150;
    final int Divider_size = 10;
    final JSplitPane split_pane_right = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, m_section_titles,
            m_web_panel);
    split_pane_right.setOneTouchExpandable(true);
    split_pane_right.setDividerLocation(Divider_location);
    split_pane_right.setDividerSize(Divider_size);

    // Add JSplitPane on the LEFT
    JSplitPane split_pane_left = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left_panel,
            split_pane_right /* right_panel */);
    split_pane_left.setOneTouchExpandable(true);
    split_pane_left.setDividerLocation(320); // Sets the pane divider location
    split_pane_left.setDividerSize(Divider_size);
    container.add(split_pane_left, BorderLayout.CENTER);

    // Add status bar on the bottom
    JPanel statusPanel = new JPanel();
    statusPanel.setPreferredSize(new Dimension(jframe.getWidth(), 16));
    statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
    container.add(statusPanel, BorderLayout.SOUTH);

    final JLabel m_status_label = new JLabel("");
    m_status_label.setHorizontalAlignment(SwingConstants.LEFT);
    statusPanel.add(m_status_label);

    // Add mouse listener
    searchField.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            searchField.setText("");
        }
    });

    final String final_title = l_title;
    final String final_author = l_author;
    final String final_atccode = l_atccode;
    final String final_regnr = l_regnr;
    final String final_therapy = l_therapy;
    final String final_search = l_search;

    // Internal class that implements switching between buttons
    final class Toggle {
        public void toggleButton(JToggleButton jbn) {
            for (int i = 0; i < list_of_buttons.length; ++i) {
                if (jbn == list_of_buttons[i])
                    list_of_buttons[i].setSelected(true);
                else
                    list_of_buttons[i].setSelected(false);
            }
        }
    }
    ;

    // ------ Add toolbar action listeners ------
    selectAipsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectAipsButton);
            // Set state 'aips'
            if (!m_curr_uistate.getUseMode().equals("aips")) {
                m_curr_uistate.setUseMode("aips");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        m_query_str = searchField.getText();
                        int num_hits = retrieveAipsSearchResults(false);
                        m_status_label.setText(med_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                        //
                        if (med_index < 0 && prev_med_index >= 0)
                            med_index = prev_med_index;
                        m_web_panel.updateText();
                        if (num_hits == 0) {
                            m_web_panel.emptyPage();
                        }
                    }
                });
            }
        }
    });
    selectFavoritesButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectFavoritesButton);
            // Set state 'favorites'
            if (!m_curr_uistate.getUseMode().equals("favorites")) {
                m_curr_uistate.setUseMode("favorites");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        // m_query_str = searchField.getText();
                        // Clear the search container
                        med_search.clear();
                        for (String regnr : favorite_meds_set) {
                            List<Medication> meds = m_sqldb.searchRegNr(regnr);
                            if (!meds.isEmpty()) { // Add med database ID
                                med_search.add(meds.get(0));
                            }
                        }
                        // Sort list of meds
                        Collections.sort(med_search, new Comparator<Medication>() {
                            @Override
                            public int compare(final Medication m1, final Medication m2) {
                                return m1.getTitle().compareTo(m2.getTitle());
                            }
                        });

                        sTitle();
                        cardl.show(p_results, final_title);

                        m_status_label.setText(med_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                    }
                });
            }
        }
    });
    selectInteractionsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectInteractionsButton);
            // Set state 'interactions'
            if (!m_curr_uistate.getUseMode().equals("interactions")) {
                m_curr_uistate.setUseMode("interactions");
                // Show middle pane
                split_pane_right.setDividerSize(Divider_size);
                split_pane_right.setDividerLocation(Divider_location);
                m_section_titles.setVisible(true);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_query_str = searchField.getText();
                        retrieveAipsSearchResults(false);
                        // Switch to interaction mode
                        m_web_panel.updateInteractionsCart();
                        m_web_panel.repaint();
                        m_web_panel.validate();
                    }
                });
            }
        }
    });
    selectShoppingCartButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            String email_adr = m_prefs.get("emailadresse", "");
            if (email_adr != null && email_adr.length() > 2) // Two chars is the minimum lenght for an email address
                m_preferences_ok = true;
            if (m_preferences_ok) {
                m_preferences_ok = false; // Check always
                new Toggle().toggleButton(selectShoppingCartButton);
                // Set state 'shopping'
                if (!m_curr_uistate.getUseMode().equals("shopping")) {
                    m_curr_uistate.setUseMode("shopping");
                    // Show middle pane
                    split_pane_right.setDividerSize(Divider_size);
                    split_pane_right.setDividerLocation(Divider_location);
                    m_section_titles.setVisible(true);
                    // Set right panel title
                    m_web_panel.setTitle(m_rb.getString("shoppingCart"));
                    // Switch to shopping cart
                    int index = 1;
                    if (m_shopping_cart != null) {
                        index = m_shopping_cart.getCartIndex();
                        m_web_panel.loadShoppingCartWithIndex(index);
                        // m_shopping_cart.printShoppingBasket();
                    }
                    // m_web_panel.updateShoppingHtml();
                    m_web_panel.updateListOfPackages();
                    if (m_first_pass == true) {
                        m_first_pass = false;
                        if (Utilities.appCustomization().equals("ywesee"))
                            med_search = m_sqldb.searchAuth("ibsa");
                        else if (Utilities.appCustomization().equals("desitin"))
                            med_search = m_sqldb.searchAuth("desitin");
                        sAuth();
                        cardl.show(p_results, final_author);
                    }
                }
            } else {
                selectShoppingCartButton.setSelected(false);
                settingsPage.display();
            }
        }
    });
    selectComparisonCartButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            new Toggle().toggleButton(selectComparisonCartButton);
            // Set state 'comparison'
            if (!m_curr_uistate.getUseMode().equals("comparison")) {
                m_curr_uistate.setUseMode("comparison");
                // Hide middle pane
                m_section_titles.setVisible(false);
                split_pane_right.setDividerLocation(0);
                split_pane_right.setDividerSize(0);
                //
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        m_start_time = System.currentTimeMillis();
                        // Set right panel title
                        m_web_panel.setTitle(getTitle("priceComp"));
                        if (med_index >= 0) {
                            if (med_id != null && med_index < med_id.size()) {
                                Medication m = m_sqldb.getMediWithId(med_id.get(med_index));
                                String atc_code = m.getAtcCode();
                                if (atc_code != null) {
                                    String atc = atc_code.split(";")[0];
                                    m_web_panel.fillComparisonBasket(atc);
                                    m_web_panel.updateComparisonCartHtml();
                                    // Update pane on the left
                                    retrieveAipsSearchResults(false);
                                }
                            }
                        }

                        m_status_label.setText(rose_search.size() + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");
                    }
                });
            }
        }
    });

    // ------ Add keylistener to text field (type as you go feature) ------
    searchField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyTyped(KeyEvent e) { // keyReleased(KeyEvent e)
            // invokeLater potentially in the wrong place... more testing
            // required
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (m_curr_uistate.isLoadCart())
                        m_curr_uistate.restoreUseMode();
                    m_start_time = System.currentTimeMillis();
                    m_query_str = searchField.getText();
                    // Queries for SQLite DB
                    if (!m_query_str.isEmpty()) {
                        if (m_query_type == 0) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchTitle(m_query_str);
                            } else {
                                med_search = m_sqldb.searchTitle(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sTitle();
                            cardl.show(p_results, final_title);
                        } else if (m_query_type == 1) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchSupplier(m_query_str);
                            } else {
                                med_search = m_sqldb.searchAuth(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sAuth();
                            cardl.show(p_results, final_author);
                        } else if (m_query_type == 2) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchATC(m_query_str);
                            } else {
                                med_search = m_sqldb.searchATC(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sATC();
                            cardl.show(p_results, final_atccode);
                        } else if (m_query_type == 3) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchEan(m_query_str);
                            } else {
                                med_search = m_sqldb.searchRegNr(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sRegNr();
                            cardl.show(p_results, final_regnr);
                        } else if (m_query_type == 4) {
                            if (m_curr_uistate.isComparisonMode()) {
                                rose_search = m_rosedb.searchTherapy(m_query_str);
                            } else {
                                med_search = m_sqldb.searchApplication(m_query_str);
                                if (m_curr_uistate.databaseUsed().equals("favorites"))
                                    retrieveFavorites();
                            }
                            sTherapy();
                            cardl.show(p_results, final_therapy);
                        } else {
                            // do nothing
                        }
                        int num_hits = 0;
                        if (m_curr_uistate.isComparisonMode())
                            num_hits = rose_search.size();
                        else
                            num_hits = med_search.size();
                        m_status_label.setText(num_hits + " Suchresultate in "
                                + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek.");

                    }
                }
            });
        }
    });

    // Add actionlisteners
    but_title.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_title);
            m_curr_uistate.setQueryType(m_query_type = 0);
            sTitle();
            cardl.show(p_results, final_title);
        }
    });
    but_auth.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_author);
            m_curr_uistate.setQueryType(m_query_type = 1);
            sAuth();
            cardl.show(p_results, final_author);
        }
    });
    but_atccode.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_atccode);
            m_curr_uistate.setQueryType(m_query_type = 2);
            sATC();
            cardl.show(p_results, final_atccode);
        }
    });
    but_regnr.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_regnr);
            m_curr_uistate.setQueryType(m_query_type = 3);
            sRegNr();
            cardl.show(p_results, final_regnr);
        }
    });
    but_therapy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (m_curr_uistate.isLoadCart())
                m_curr_uistate.restoreUseMode();
            searchField.setText(final_search + " " + final_therapy);
            m_curr_uistate.setQueryType(m_query_type = 4);
            sTherapy();
            cardl.show(p_results, final_therapy);
        }
    });

    // Display window
    jframe.pack();
    // jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    // jframe.setAlwaysOnTop(true);
    jframe.setVisible(true);

    // Check if user has selected an alternative database
    /*
     * NOTE: 21/11/2013: This solution is put on ice. Favored is a solution
     * where the database selected by the user is saved in a default folder
     * (see variable "m_application_data_folder")
     */
    /*
     * try { WindowSaver.loadSettings(jframe); String database_path =
     * WindowSaver.getDbPath(); if (database_path!=null)
     * m_sqldb.loadDBFromPath(database_path); } catch(IOException e) {
     * e.printStackTrace(); }
     */
    // Load AIPS database
    selectAipsButton.setSelected(true);
    selectFavoritesButton.setSelected(false);
    m_curr_uistate.setUseMode("aips");
    med_search = m_sqldb.searchTitle("");
    sTitle(); // Used instead of sTitle (which is slow)
    cardl.show(p_results, final_title);

    // Add menu item listeners
    updatedb_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            if (m_mutex_update == false) {
                m_mutex_update = true;
                String db_file = m_maindb_update.doIt(jframe, Utilities.appLanguage(),
                        Utilities.appCustomization(), m_application_data_folder, m_full_db_update);
                // ... and update time
                if (m_full_db_update == true) {
                    DateTime dT = new DateTime();
                    m_prefs.put("updateTime", dT.now().toString());
                }
                //
                if (!db_file.isEmpty()) {
                    // Save db path (can't hurt)
                    WindowSaver.setDbPath(db_file);
                }
            }
        }
    });

    choosedb_item.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            String db_file = m_maindb_update.chooseFromFile(jframe, Utilities.appLanguage(),
                    Utilities.appCustomization(), m_application_data_folder);
            // ... and update time
            DateTime dT = new DateTime();
            m_prefs.put("updateTime", dT.now().toString());
            //
            if (!db_file.isEmpty()) {
                // Save db path (can't hurt)
                WindowSaver.setDbPath(db_file);
            }
        }
    });

    /**
     * Observers
     */
    // Attach observer to 'm_update'
    m_maindb_update.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            // Reset flag
            m_full_db_update = true;
            m_mutex_update = false;
            // Refresh some stuff after update
            loadAuthors();
            m_emailer.loadMap();
            settingsPage.load_gln_codes();
            if (m_shopping_cart != null) {
                m_shopping_cart.load_conditions();
                m_shopping_cart.load_glns();
            }
            // Empty shopping basket
            if (m_curr_uistate.isShoppingMode()) {
                m_shopping_basket.clear();
                int index = m_shopping_cart.getCartIndex();
                if (index > 0)
                    m_web_panel.saveShoppingCartWithIndex(index);
                m_web_panel.updateShoppingHtml();
            }
            if (m_curr_uistate.isComparisonMode())
                m_web_panel.setTitle(getTitle("priceComp"));
        }
    });

    // Attach observer to 'm_emailer'
    m_emailer.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            // Empty shopping basket
            m_shopping_basket.clear();
            int index = m_shopping_cart.getCartIndex();
            if (index > 0)
                m_web_panel.saveShoppingCartWithIndex(index);
            m_web_panel.updateShoppingHtml();
        }
    });

    // Attach observer to "m_comparison_cart"
    m_comparison_cart.addObserver(new Observer() {
        @Override
        public void update(Observable o, Object arg) {
            System.out.println(arg);
            m_web_panel.setTitle(getTitle("priceComp"));
            m_comparison_cart.clearUploadList();
            m_web_panel.updateComparisonCartHtml();
            new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()).UploadDialog((String) arg);
        }
    });

    // If command line options are provided start app with a particular title or eancode
    if (commandLineOptionsProvided()) {
        if (!CML_OPT_TITLE.isEmpty())
            startAppWithTitle(but_title);
        else if (!CML_OPT_EANCODE.isEmpty())
            startAppWithEancode(but_regnr);
        else if (!CML_OPT_REGNR.isEmpty())
            startAppWithRegnr(but_regnr);
    }

    // Start timer
    Timer global_timer = new Timer();
    // Time checks all 2 minutes (120'000 milliseconds)
    global_timer.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            checkIfUpdateRequired(updatedb_item);
        }
    }, 2 * 60 * 1000, 2 * 60 * 1000);
}

From source file:src.gui.ItSIMPLE.java

/**
 * @return the planListFramePanel/*from ww  w  .j a  va 2s  .com*/
 */
private ItFramePanel getPlanListFramePanel() {
    if (planListFramePanel == null) {
        planListFramePanel = new ItFramePanel(":: Plan", ItFramePanel.MINIMIZE_MAXIMIZE);
        planListFramePanel.setParentSplitPane(planDetailsSplitPane);

        planListModel = new DefaultListModel();
        planList = new JList(planListModel);
        planList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                // this is done to enable or disable the remove plan action button
                if (planList.getSelectedIndex() < 0) {
                    removePlanActionButton.setEnabled(false);
                    editPlanActionButton.setEnabled(false);
                } else {
                    removePlanActionButton.setEnabled(true);
                    editPlanActionButton.setEnabled(true);
                }
            }
        });

        planList.addMouseListener(new MouseListener() {
            public void mouseClicked(MouseEvent e) {
                if (planList.getSelectedIndex() > 0 && e.getClickCount() == 2) {
                    editPlanAction.actionPerformed(null);
                }
            }

            public void mouseEntered(MouseEvent arg0) {
            }

            public void mouseExited(MouseEvent arg0) {
            }

            public void mousePressed(MouseEvent arg0) {
            }

            public void mouseReleased(MouseEvent arg0) {
            }

        });

        // initialize the buttons
        addPlanActionButton = new JButton(addPlanAction);
        addPlanActionButton.setToolTipText("Add an action to the plan");

        removePlanActionButton = new JButton(removePlanAction);
        removePlanActionButton.setToolTipText("Remove selected action");

        editPlanActionButton = new JButton(editPlanAction);
        editPlanActionButton.setToolTipText("Edit selected action");

        importPlanButton = new JButton(importPlanAction);
        importPlanButton.setToolTipText("Import plan from xml file");

        exportPlanButton = new JButton(exportPlanAction);
        exportPlanButton.setToolTipText("Export current plan");

        checkPlanValidityButton = new JButton(checkPlanValidity);
        checkPlanValidityButton.setToolTipText(
                "<html>Validate plan with validator VAL <br>(based on the generated PDDL model).</html>");

        //quickEvaluateButton = new JButton(quickEvaluation);
        //quickEvaluateButton.setToolTipText("Quick evaluation of the selected plan");

        //fullEvaluationButton = new JButton(generateEvaluatioReport);
        //fullEvaluationButton.setToolTipText("<html>Full evaluation of the selected plan. <br> Generate a plan evaluation in the planReport. <br> This is restricted to non-time-based domain only.</html>");
        //fullEvaluationButton.setText("");

        addPlanActionButton.setEnabled(false);
        removePlanActionButton.setEnabled(false);
        editPlanActionButton.setEnabled(false);
        checkPlanValidityButton.setEnabled(false);
        //quickEvaluateButton.setEnabled(false);
        //fullEvaluationButton.setEnabled(false);
        importPlanButton.setEnabled(false);
        exportPlanButton.setEnabled(false);

        JToolBar planListToolBar = new JToolBar();
        planListToolBar.add(addPlanActionButton);
        planListToolBar.add(removePlanActionButton);
        planListToolBar.add(editPlanActionButton);
        planListToolBar.addSeparator();
        planListToolBar.add(checkPlanValidityButton);
        //planListToolBar.add(quickEvaluateButton);
        //planListToolBar.add(fullEvaluationButton);
        planListToolBar.addSeparator();
        planListToolBar.add(importPlanButton);
        planListToolBar.add(exportPlanButton);

        JScrollPane listScrollPane = new JScrollPane(planList);

        JPanel listPanel = new JPanel(new BorderLayout());
        listPanel.add(listScrollPane, BorderLayout.CENTER);
        listPanel.add(planListToolBar, BorderLayout.SOUTH);

        planListFramePanel.setContent(listPanel, false);

    }

    return planListFramePanel;
}

From source file:src.gui.ItSIMPLE.java

private JToolBar getRationaleDatabaseToolBar() {

    JToolBar rationaleDatabaseToolBar = new JToolBar();
    rationaleDatabaseToolBar.setRollover(true);

    // create the buttons

    //select rationales from data base
    JButton searchButton = new JButton("Search", new ImageIcon("resources/images/searchdatabase.png"));
    searchButton.setToolTipText("Search rationales in the database");
    searchButton.addActionListener(new java.awt.event.ActionListener() {
        @Override/*  www  .ja va  2 s  . c o m*/
        public void actionPerformed(ActionEvent e) {
            //RUN search plan from database
            searchRationaleInDatabaseAction.actionPerformed(e);
        }
    });
    rationaleDatabaseToolBar.add(searchButton);

    rationaleDatabaseToolBar.addSeparator();

    /*
    //insert new rationale into data base
    JButton addRationaleToDatabaseButton = new JButton("Add Plan",  new ImageIcon("resources/images/addplantodatabase.png"));
    addRationaleToDatabaseButton.setToolTipText("Add current plan to the database");
    addRationaleToDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //RUN plan evaluation edit
                insertPlanIntoDatabaseAction.actionPerformed(e);
            }
    });
    rationaleDatabaseToolBar.add(addRationaleToDatabaseButton);
     */

    //edit rationale from database
    JButton editRatioanleFromDatabaseButton = new JButton("Edit Rationale",
            new ImageIcon("resources/images/editrationalefromdatabase.png"));
    editRatioanleFromDatabaseButton.setToolTipText("Edit selected rationale");
    editRatioanleFromDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN editing plan
            editRationaleFromDatabaseAction.actionPerformed(e);
        }
    });
    rationaleDatabaseToolBar.add(editRatioanleFromDatabaseButton);

    //delete rationale from database
    JButton deleteRationaleFromDatabaseButton = new JButton("Delete Rationale",
            new ImageIcon("resources/images/deleteplanfromdatabase.png"));
    deleteRationaleFromDatabaseButton.setToolTipText("Delete selected rationale");
    deleteRationaleFromDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN loading plan
            deleteRationaleFromDatabaseAction.actionPerformed(e);
        }
    });
    rationaleDatabaseToolBar.add(deleteRationaleFromDatabaseButton);

    rationaleDatabaseToolBar.addSeparator();

    //load reference plan from database
    JButton loadReferencePlanFromDatabaseButton = new JButton("Load Plan",
            new ImageIcon("resources/images/getfromdatabase.png"));
    loadReferencePlanFromDatabaseButton.setToolTipText("Load reference plan of the selected rationale");
    loadReferencePlanFromDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN editing plan
            loadReferencePlanFromDatabaseAction.actionPerformed(e);
        }
    });
    rationaleDatabaseToolBar.add(loadReferencePlanFromDatabaseButton);

    return rationaleDatabaseToolBar;
}

From source file:src.gui.ItSIMPLE.java

private JToolBar getPlanDatabaseToolBar() {

    JToolBar planDatabaseToolBar = new JToolBar();
    planDatabaseToolBar.setRollover(true);

    // create the buttons

    //select plans from data base

    JButton searchButton = new JButton("Search", new ImageIcon("resources/images/searchdatabase.png"));
    searchButton.setToolTipText("Search plans in the database");
    searchButton.addActionListener(new java.awt.event.ActionListener() {
        @Override// w w  w .j  a v a  2s . co  m
        public void actionPerformed(ActionEvent e) {
            //RUN search plan from database
            searchPlanInDatabaseAction.actionPerformed(e);
        }
    });
    planDatabaseToolBar.add(searchButton);

    final JButton filterButton = new JButton("Filter",
            new ImageIcon("resources/images/filtersearchdatabase.png"));
    filterButton
            .setToolTipText("Filter the search for plans in the database (use colunms of table 'plan' only)");
    filterButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //hide/show filter panel
            if (planFilterPanel.isVisible()) {
                planFilterPanel.setVisible(false);
                filterButton.setText("Filter");
            } else {
                planFilterPanel.setVisible(true);
                filterButton.setText("Don't filter");
            }
        }
    });
    planDatabaseToolBar.add(filterButton);

    planDatabaseToolBar.addSeparator();

    //insert plan into data base
    JButton addPlanToDatabaseButton = new JButton("Add Plan",
            new ImageIcon("resources/images/addplantodatabase.png"));
    addPlanToDatabaseButton.setToolTipText("Add current plan to the database");
    addPlanToDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN plan evaluation edit
            insertPlanIntoDatabaseAction.actionPerformed(e);
        }
    });
    planDatabaseToolBar.add(addPlanToDatabaseButton);

    //load plan from data base
    JButton loadPlanFromDatabaseButton = new JButton("Load Plan",
            new ImageIcon("resources/images/getfromdatabase.png"));
    loadPlanFromDatabaseButton.setToolTipText("Load selected plan into itSIMPLE");
    loadPlanFromDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN loading plan
            loadPlanFromDatabaseAction.actionPerformed(e);
        }
    });
    planDatabaseToolBar.add(loadPlanFromDatabaseButton);

    //delete plan from data base
    JButton deletePlanFromDatabaseButton = new JButton("Delete Plan",
            new ImageIcon("resources/images/deleteplanfromdatabase.png"));
    deletePlanFromDatabaseButton.setToolTipText("Delete selected plan");
    deletePlanFromDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN loading plan
            deletePlanFromDatabaseAction.actionPerformed(e);
        }
    });
    planDatabaseToolBar.add(deletePlanFromDatabaseButton);

    //update plan from data base
    JButton updatePlanFromDatabaseButton = new JButton("Update Plan",
            new ImageIcon("resources/images/updateplanfromdatabase.png"));
    updatePlanFromDatabaseButton.setToolTipText("Update current plan");
    updatePlanFromDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN update plan
            updatePlanFromDatabaseAction.actionPerformed(e);
        }
    });
    planDatabaseToolBar.add(updatePlanFromDatabaseButton);

    return planDatabaseToolBar;
}

From source file:src.gui.ItSIMPLE.java

/**
 * @return Returns the planAnalysisFramePanel.
 *//*  ww w.  j ava2s .c o  m*/
private ItFramePanel getPlanAnalysisFramePanel() {
    if (planAnalysisFramePanel == null) {
        planAnalysisFramePanel = new ItFramePanel(":: Plan Analysis", ItFramePanel.NO_MINIMIZE_MAXIMIZE);

        // tool bar
        JToolBar chartsToolBar = new JToolBar();
        chartsToolBar.add(new JButton(drawChartAction));

        // charts panel
        chartsPanel = new JPanel();
        chartsPanel.setLayout(new BoxLayout(chartsPanel, BoxLayout.Y_AXIS));

        ItFramePanel variableSelectionPanel = new ItFramePanel(".: Select variables to be tracked",
                ItFramePanel.NO_MINIMIZE_MAXIMIZE);
        //variableSelectionPanel.setBackground(new Color(151,151,157));

        JSplitPane split = new JSplitPane();
        split.setContinuousLayout(true);
        split.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
        split.setDividerLocation(2 * screenSize.height / 3);

        split.setDividerSize(8);
        //split.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50));
        //split.setPreferredSize(new Dimension(screenSize.width/4-20, 120));
        split.setLeftComponent(new JScrollPane(variablesPlanTree));
        split.setRightComponent(new JScrollPane(selectedVariablesPlanTree));

        variableSelectionPanel.setContent(split, false);
        //variableSelectionPanel.setParentSplitPane()

        //JPanel variableSelectionPanel  = new JPanel(new BorderLayout());
        //variableSelectionPanel.add(new JScrollPane(variablesPlanTree), BorderLayout.CENTER);
        //variableSelectionPanel.add(new JScrollPane(selectedVariablesPlanTree), BorderLayout.EAST);

        ItFramePanel variableGraphPanel = new ItFramePanel(".: Chart", ItFramePanel.NO_MINIMIZE_MAXIMIZE);
        variableGraphPanel.setContent(chartsPanel, true);

        JSplitPane mainvariablesplit = new JSplitPane();
        mainvariablesplit.setContinuousLayout(true);
        mainvariablesplit.setOrientation(JSplitPane.VERTICAL_SPLIT);
        mainvariablesplit.setDividerLocation(150);
        mainvariablesplit.setDividerSize(8);
        //mainvariablesplit.setPreferredSize(new Dimension(screenSize.width/4-20, screenSize.height/2 - 50));
        mainvariablesplit.setTopComponent(variableSelectionPanel);
        mainvariablesplit.setBottomComponent(variableGraphPanel);

        // main charts panel - used to locate the tool bar above the charts panel
        JPanel mainChartsPanel = new JPanel(new BorderLayout());
        mainChartsPanel.add(chartsToolBar, BorderLayout.NORTH);
        //mainChartsPanel.add(new JScrollPane(chartsPanel), BorderLayout.CENTER);
        mainChartsPanel.add(mainvariablesplit, BorderLayout.CENTER);

        //Results
        planInfoEditorPane = new JEditorPane();
        planInfoEditorPane.setContentType("text/html");
        planInfoEditorPane.setEditable(false);
        planInfoEditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR));
        planInfoEditorPane.setBackground(Color.WHITE);

        JPanel resultsPanel = new JPanel(new BorderLayout());

        JToolBar resultsToolBar = new JToolBar();
        resultsToolBar.setRollover(true);

        JButton planReportButton = new JButton("View Full Report",
                new ImageIcon("resources/images/viewreport.png"));
        planReportButton.setToolTipText("<html>View full plan report.<br> For multiple plans you will need "
                + "access to the Internet.<br> The components used in the report require such access (no data is "
                + "sent through the Internet).</html>");
        planReportButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //Opens html with defaut browser
                String path = "resources/report/Report.html";
                File report = new File(path);
                path = report.getAbsolutePath();
                try {
                    BrowserLauncher launcher = new BrowserLauncher();
                    launcher.openURLinBrowser("file://" + path);
                } catch (BrowserLaunchingInitializingException ex) {
                    Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
                    appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n");
                } catch (UnsupportedOperatingSystemException ex) {
                    Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
                    appendOutputPanelText("ERROR. Problem while trying to open the default browser. \n");
                }
            }
        });
        resultsToolBar.add(planReportButton);

        resultsToolBar.addSeparator();
        JButton planReportDataButton = new JButton("Save Report Data",
                new ImageIcon("resources/images/savePDDL.png"));
        planReportDataButton.setToolTipText("<html>Save report data to file</html>");
        planReportDataButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //Save report data
                if (solveResult != null) {
                    Element lastOpenFolderElement = itSettings.getChild("generalSettings")
                            .getChild("lastOpenFolder");
                    JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText());
                    fc.setDialogTitle("Save Report Data");
                    fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                    fc.setFileFilter(new XMLFileFilter());

                    int returnVal = fc.showSaveDialog(ItSIMPLE.this);
                    if (returnVal == JFileChooser.APPROVE_OPTION) {
                        File selectedFile = fc.getSelectedFile();
                        String path = selectedFile.getPath();

                        if (!path.toLowerCase().endsWith(".xml")) {
                            path += ".xml";
                        }
                        //save file (xml)
                        try {
                            FileWriter file = new FileWriter(path);
                            file.write(XMLUtilities.toString(solveResult));
                            file.close();
                        } catch (IOException e1) {
                            e1.printStackTrace();
                        }

                        //Save as a last open folder
                        String folder = selectedFile.getParent();
                        //Element lastOpenFolderElement = itSettings.getChild("generalSettings").getChild("lastOpenFolder");
                        lastOpenFolderElement.setText(folder);
                        XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument());

                        //Ask if the user wants to save plans individually too.
                        boolean needToSavePlans = false;
                        int option = JOptionPane.showOptionDialog(instance,
                                "<html><center>Do you also want to save the plans"
                                        + "<br>in individual files?</center></html>",
                                "Save plans", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null,
                                null, null);
                        switch (option) {
                        case JOptionPane.YES_OPTION: {
                            needToSavePlans = true;
                        }
                            break;
                        case JOptionPane.NO_OPTION: {
                            needToSavePlans = false;
                        }
                            break;
                        }

                        if (needToSavePlans) {
                            //Close Open tabs
                            List<?> problems = null;
                            try {
                                XPath ppath = new JDOMXPath("project/domains/domain/problems/problem");
                                problems = ppath.selectNodes(solveResult);
                            } catch (JaxenException e2) {
                                e2.printStackTrace();
                            }

                            for (int i = 0; i < problems.size(); i++) {
                                Element problem = (Element) problems.get(i);
                                //create a folder for each problem and put all plans inside as xml files
                                String folderName = problem.getChildText("name");
                                String folderPath = selectedFile.getAbsolutePath()
                                        .replace(selectedFile.getName(), folderName);
                                //System.out.println(folderPath);
                                File planfolder = new File(folderPath);
                                boolean canSavePlan = false;
                                try {
                                    if (planfolder.mkdir()) {
                                        System.out.println("Directory '" + folderPath + "' created.");
                                        canSavePlan = true;
                                    } else {
                                        System.out.println("Directory '" + folderPath + "' was not created.");
                                    }

                                } catch (Exception ep) {
                                    ep.printStackTrace();
                                }

                                if (canSavePlan) {
                                    Element plans = problem.getChild("plans");
                                    for (Iterator<Element> it = plans.getChildren("xmlPlan").iterator(); it
                                            .hasNext();) {
                                        Element eaplan = it.next();
                                        Element theplanner = eaplan.getChild("planner");
                                        //save file (xml)
                                        String planFileName = "solution" + theplanner.getChildText("name") + "-"
                                                + theplanner.getChildText("version") + "-"
                                                + Integer.toString(plans.getChildren().indexOf(eaplan))
                                                + ".xml";
                                        String planPath = folderPath + File.separator + planFileName;
                                        /*
                                        try {
                                            FileWriter planfile = new FileWriter(planPath);
                                            planfile.write(XMLUtilities.toString(eaplan));
                                            planfile.close();
                                            System.out.println("File '" + planPath + "' created.");
                                        } catch (IOException e1) {
                                            e1.printStackTrace();
                                        }
                                        *
                                        */
                                        if (eaplan.getChild("plan").getChildren().size() > 0) {

                                            //TODO: save the plan in PDDL too. It should be done through the XPDDL/PDDL classes
                                            String pddlplan = ToXPDDL.XMLtoXPDDLPlan(eaplan);
                                            String planFileNamePDDL = "solution"
                                                    + theplanner.getChildText("name") + "-"
                                                    + theplanner.getChildText("version") + "-"
                                                    + Integer.toString(plans.getChildren().indexOf(eaplan))
                                                    + ".pddl";
                                            String planPathPDDL = folderPath + File.separator
                                                    + planFileNamePDDL;

                                            //String cfolderPath = selectedFile.getAbsolutePath().replace(selectedFile.getName(), "");
                                            //String planFileNamePDDL = theplanner.getChildText("name")+"-"+theplanner.getChildText("version") + "-" + folderName+"-solution.pddl";
                                            //String planPathPDDL = cfolderPath + File.separator + planFileNamePDDL;
                                            //if (!theplanner.getChildText("name").contains("MIPS")){
                                            try {
                                                FileWriter planfile = new FileWriter(planPathPDDL);
                                                planfile.write(pddlplan);
                                                planfile.close();
                                                System.out.println("File '" + planPathPDDL + "' created.");
                                            } catch (IOException e1) {
                                                e1.printStackTrace();
                                            }
                                        } //}

                                    }

                                }

                            }
                        }

                    }
                } else {
                    appendOutputPanelText(">> No report data available to save! \n");
                }

            }
        });
        resultsToolBar.add(planReportDataButton);

        JButton openPlanReportDataButton = new JButton("Open Report Data",
                new ImageIcon("resources/images/openreport.png"));
        openPlanReportDataButton.setToolTipText("<html>Open report data to file</html>");
        openPlanReportDataButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                planSimStatusBar.setText("Status: Opening File...");
                appendOutputPanelText(">> Opening File... \n");
                //Open report data
                Element lastOpenFolderElement = itSettings.getChild("generalSettings")
                        .getChild("lastOpenFolder");
                JFileChooser fc = new JFileChooser(lastOpenFolderElement.getText());
                fc.setDialogTitle("Open Report Data");
                fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
                fc.setFileFilter(new XMLFileFilter());

                int returnVal = fc.showOpenDialog(ItSIMPLE.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {

                    File file = fc.getSelectedFile();
                    // Get itSIMPLE itSettings from itSettings.xml
                    org.jdom.Document resultsDoc = null;
                    try {
                        resultsDoc = XMLUtilities.readFromFile(file.getPath());
                        solveResult = resultsDoc.getRootElement();
                        //XMLUtilities.printXML(solveResult);
                        if (solveResult.getName().equals("projects")) {

                            String report = PlanAnalyzer.generatePlannersComparisonReport(solveResult);
                            String comparisonReport = PlanAnalyzer
                                    .generateFullPlannersComparisonReport(solveResult);
                            //Save Comparison Report file
                            saveFile("resources/report/Report.html", comparisonReport);
                            setPlanInfoPanelText(report);
                            setPlanEvaluationInfoPanelText("");
                            appendOutputPanelText(">> Report data read! \n");

                            //My experiments
                            PlanAnalyzer.myAnalysis(itPlanners.getChild("planners"), solveResult);
                        }
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }

                    //Save as a last open folder
                    String folder = fc.getSelectedFile().getParent();
                    lastOpenFolderElement.setText(folder);
                    XMLUtilities.writeToFile("resources/settings/itSettings.xml", itSettings.getDocument());

                } else {
                    planSimStatusBar.setText("Status:");
                    appendOutputPanelText(">> Canceled \n");
                }

            }
        });
        resultsToolBar.add(openPlanReportDataButton);

        JButton compareProjectReportDataButton = new JButton("Compare Project Data",
                new ImageIcon("resources/images/compare.png"));
        compareProjectReportDataButton.setToolTipText(
                "<html>Compare different project report data <br> This is commonly use to compare diferent domain models with different adjustments.<br>"
                        + "One project data must be chosen as a reference; others will be compared to this referencial one.</html>");
        compareProjectReportDataButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                final ProjectComparisonDialog dialog = new ProjectComparisonDialog();
                dialog.setVisible(true);

                final List<String> files = dialog.getFiles();

                if (files.size() > 1) {

                    new Thread() {
                        public void run() {
                            appendOutputPanelText(">> Project comparison report requested. Processing... \n");

                            planSimStatusBar.setText("Status: Reading files ...");
                            appendOutputPanelText(">> Reading files ... \n");

                            //base project file
                            String baseFileName = files.get(0);
                            appendOutputPanelText(">> Reading file '" + baseFileName + "' \n");
                            org.jdom.Document baseProjectDoc = null;
                            try {
                                baseProjectDoc = XMLUtilities.readFromFile(baseFileName);
                            } catch (Exception ec) {
                                ec.printStackTrace();
                            }
                            Element baseProject = null;
                            if (baseProjectDoc != null) {
                                baseProject = baseProjectDoc.getRootElement().getChild("project");
                            }

                            //The comparible projects
                            List<Element> comparableProjects = new ArrayList<Element>();

                            for (int i = 1; i < files.size(); i++) {
                                String eafile = files.get(i);
                                appendOutputPanelText(">> Reading file '" + eafile + "' \n");
                                org.jdom.Document eaProjectDoc = null;
                                try {
                                    eaProjectDoc = XMLUtilities.readFromFile(eafile);
                                } catch (Exception ec) {
                                    ec.printStackTrace();
                                }
                                if (eaProjectDoc != null) {
                                    comparableProjects.add(eaProjectDoc.getRootElement().getChild("project"));
                                }

                            }
                            appendOutputPanelText(">> Files read. Building report... \n");

                            String comparisonReport = PlanAnalyzer.generateProjectComparisonReport(baseProject,
                                    comparableProjects);
                            saveFile("resources/report/Report.html", comparisonReport);
                            appendOutputPanelText(
                                    ">> Project comparison report generated. Press 'View Full Report'\n");
                            appendOutputPanelText(" \n");

                        }
                    }.start();

                }

            }
        });
        resultsToolBar.add(compareProjectReportDataButton);

        resultsPanel.add(resultsToolBar, BorderLayout.NORTH);
        resultsPanel.add(new JScrollPane(planInfoEditorPane), BorderLayout.CENTER);

        JTabbedPane planAnalysisTabbedPane = new JTabbedPane();
        planAnalysisTabbedPane.addTab("Results", resultsPanel);
        planAnalysisTabbedPane.addTab("Variable Tracking", mainChartsPanel);
        planAnalysisTabbedPane.addTab("Movie Maker", getMovieMakerPanel());
        planAnalysisTabbedPane.addTab("Plan Evaluation", getPlanEvaluationPanel());
        planAnalysisTabbedPane.addTab("Plan Database", getPlanDatabasePanel());
        planAnalysisTabbedPane.addTab("Rationale Database", getRationaleDatabasePanel());

        JPanel planAnalysisPanel = new JPanel(new BorderLayout());
        //planAnalysisPanel.add(chartsToolBar, BorderLayout.NORTH);
        planAnalysisPanel.add(planAnalysisTabbedPane, BorderLayout.CENTER);
        planAnalysisFramePanel.setContent(planAnalysisPanel, false);

    }

    return planAnalysisFramePanel;
}

From source file:src.gui.ItSIMPLE.java

private JToolBar getPlanEvaluationToolBar() {

    JToolBar planEvaluationToolBar = new JToolBar();
    planEvaluationToolBar.setRollover(true);

    // create the buttons

    // plan evaluation

    JButton planEvaluationButton = new JButton("Evaluate Plan", new ImageIcon("resources/images/eval.png"));
    planEvaluationButton.setToolTipText(
            "<html>Evaluate current plan based on the specified metrics. <br> This is restricted to non-time-based domain only.</html>");
    planEvaluationButton.addActionListener(new java.awt.event.ActionListener() {
        @Override/*from   w ww . j a  va  2  s . c  o m*/
        public void actionPerformed(ActionEvent e) {
            //RUN plan evaluation
            quickEvaluation.actionPerformed(e);
        }
    });
    planEvaluationToolBar.add(planEvaluationButton);

    JButton planEvaluationReportButton = new JButton("Evaluation Report",
            new ImageIcon("resources/images/viewreport.png"));
    planEvaluationReportButton.setToolTipText(
            "<html>Generate a html plan evaluation in the planReport. <br> This is restricted to non-time-based domain only.</html>");
    planEvaluationReportButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN plan evaluation
            generateEvaluationReport.actionPerformed(e);
        }
    });
    planEvaluationToolBar.add(planEvaluationReportButton);

    JButton editEvaluationButton = new JButton("Edit Evaluation", new ImageIcon("resources/images/edit.png"));
    editEvaluationButton.setToolTipText("<html>Modify plan classification and its metrics evaluation.</html>");
    editEvaluationButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN plan evaluation edit
            changePlanEvaluationAction.actionPerformed(e);
        }
    });
    planEvaluationToolBar.add(editEvaluationButton);

    //JButton applyNewEvaluationButton = new JButton("Apply Modified Evaluation",  new ImageIcon("resources/images/apply.png"));
    //planEvaluationToolBar.add(applyNewEvaluationButton);

    planEvaluationToolBar.addSeparator();

    JButton insertRationaleButton = new JButton("Insert Rationale",
            new ImageIcon("resources/images/feedbackrationale.png"));
    insertRationaleButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN plan evaluation edit
            insertPlanEvaluationRationaleAction.actionPerformed(e);
        }
    });
    planEvaluationToolBar.add(insertRationaleButton);

    checkExistingRationaleButton = new JButton("Reuse Existing Rationales",
            new ImageIcon("resources/images/feedbackrationale.png"));
    checkExistingRationaleButton.setActionCommand("reuse");
    checkExistingRationaleButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //RUN rationales reuse
            if (checkExistingRationaleButton.getActionCommand().equals("reuse")) {
                checkExistingRationaleButton.setActionCommand("stop");
                checkExistingRationaleButton.setText("Stop Reasoning");
                reuseRationalesAction.actionPerformed(e);
            } else {
                //stop the thread
                if (reuserationaleThread.isAlive()) {
                    try {
                        // waits for the thread to return
                        reuserationaleThread.join(2000);// 2 seconds time-out
                    } catch (InterruptedException e1) {
                        e1.printStackTrace();
                    }
                    if (reuserationaleThread.isAlive()) {
                        reuserationaleThread.interrupt();
                    }
                }
                checkExistingRationaleButton.setActionCommand("reuse");
                checkExistingRationaleButton.setText("Reuse Existing Rationales");
                planSimStatusBar.setText("Status: Reasoning process stopped.");

            }

            /*
            try {
                    
                        
                String theoryText = "casa(a1). \n"+
                "casa(a2).\n"+
                "casa(a3).\n";
                         
                Prolog engine = new Prolog();
                Theory t = new Theory(new java.io.FileInputStream("/home/tiago/Desktop/base.pl"));
                //Theory t = new Theory(theoryText);
                engine.setTheory(t);
                //SolveInfo answer = engine.solve("casa(X).");
                        
                SolveInfo answer = engine.solve("teste(p1,_).");
                while (answer.isSuccess()) {
                    System.out.println("solution: " + answer.getSolution() + " - bindings: " + answer);                                
                    System.out.println("X: " + answer.getTerm("X"));
                    if (engine.hasOpenAlternatives()) {
                try {
                    answer = engine.solveNext();
                } catch (NoMoreSolutionException ex) {
                    Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
                }
                    } else {
                        break;
                    }
                }
                    
                //engine.solveHalt();
                    
                        
            } catch (UnknownVarException ex) {
                Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
            } catch (NoSolutionException ex) {
                Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
            } catch (MalformedGoalException ex) {
                Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InvalidTheoryException ex) {
                Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
            }
            */

        }
    });
    planEvaluationToolBar.add(checkExistingRationaleButton);

    //JButton addPlanToDatabaseButton = new JButton("Add Plan to Database",  new ImageIcon("resources/images/addplantodatabase.png"));
    //addPlanToDatabaseButton.addActionListener(new java.awt.event.ActionListener() {
    //        @Override
    //        public void actionPerformed(ActionEvent e) {
    //            //RUN plan evaluation edit
    //            insertPlanIntoDatabaseAction.actionPerformed(e);
    //        }
    //});
    //planEvaluationToolBar.add(addPlanToDatabaseButton);

    return planEvaluationToolBar;
}

From source file:src.gui.ItSIMPLE.java

/**
 * This method initializes movieMakerToolBar
 *
 * @return javax.swing.JToolBar/*from www  .ja  v  a  2 s  .  co m*/
 */
private JToolBar getMovieMakerToolBar() {

    JToolBar movieMakerToolBar = new JToolBar();
    movieMakerToolBar.setRollover(true);

    // create the buttons

    // generate movie
    JButton generateMovieButton = new JButton("Generate Movie",
            new ImageIcon("resources/images/makemovie.png"));
    generateMovieButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {

            // the thread is created so the status bar can be refreshed
            new Thread() {
                public void run() {
                    ItTreeNode selectedNode = (ItTreeNode) problemsPlanTree.getLastSelectedPathComponent();
                    if (selectedNode != null && selectedNode.getLevel() == 3) {

                        Element problem = selectedNode.getData();
                        movie = PlanSimulator.getMovie(xmlPlan, problem);
                        //XMLUtilities.printXML(xmlPlan);
                        //XMLUtilities.printXML(movie);

                        //IN CASE WE WANT TO RUN THE METRICS WITH SIMULATION
                        //Element domain = problem.getParentElement().getParentElement();
                        //Element metrics = PlanSimulator.createMetricsNode(problem, domain);
                        //if(metrics.getChildren().size() > 0){
                        //    PlanSimulator.createMetricDatasets(metrics, xmlPlan, problem, domain, movie);
                        //}
                        //XMLUtilities.printXML(metrics);

                        PlanNavigationList.getInstance().setList(xmlPlan, movie,
                                problem.getParentElement().getParentElement(),
                                (JPanel) movieMakerSplitPane.getLeftComponent(),
                                (JPanel) movieMakerSplitPane.getRightComponent());
                        replanMenu.setEnabled(true);
                    }
                }
            }.start();
        }
    });
    movieMakerToolBar.add(generateMovieButton);

    // back
    JButton backButton = new JButton("Backward", new ImageIcon("resources/images/backward.png"));
    backButton.setToolTipText("Backward");
    backButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JList navigationList = PlanNavigationList.getInstance().getPlanList();
            final int selected = navigationList.getSelectedIndex();
            if (selected > 0) {
                navigationList.setSelectedIndex(selected - 1);
            }
        }

    });
    movieMakerToolBar.add(backButton);

    // forward
    JButton forwardButton = new JButton("Forward", new ImageIcon("resources/images/forward.png"));
    forwardButton.setToolTipText("Forward");
    forwardButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JList navigationList = PlanNavigationList.getInstance().getPlanList();
            final int selected = navigationList.getSelectedIndex();
            if (selected > -1 && selected < navigationList.getModel().getSize() - 1) {
                navigationList.setSelectedIndex(selected + 1);
            }
        }

    });
    movieMakerToolBar.add(forwardButton);

    movieMakerToolBar.addSeparator();

    // zoom in
    //JButton zoomInButton = new JButton("Zoom In",new ImageIcon("resources/images/zoomIN.png"));
    JButton zoomInButton = new JButton(new ImageIcon("resources/images/zoomIN.png"));
    zoomInButton.setToolTipText("Zoom In");
    zoomInButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {

            try {
                ItGraph leftGraph = (ItGraph) ((JScrollPane) ((JPanel) movieMakerSplitPane.getLeftComponent())
                        .getComponent(0)).getViewport().getView();
                leftGraph.setScale(leftGraph.getScale() * 1.25);

                ItGraph rightGraph = (ItGraph) ((JScrollPane) ((JPanel) movieMakerSplitPane.getRightComponent())
                        .getComponent(0)).getViewport().getView();
                rightGraph.setScale(rightGraph.getScale() * 1.25);
            } catch (Exception e1) {
            }

        }
    });
    movieMakerToolBar.add(zoomInButton);

    // zoom out
    //JButton zoomOutButton = new JButton("Zoom Out",new ImageIcon("resources/images/zoomOUT.png"));
    JButton zoomOutButton = new JButton(new ImageIcon("resources/images/zoomOUT.png"));
    zoomOutButton.setToolTipText("Zoom Out");
    zoomOutButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {

            try {
                ItGraph leftGraph = (ItGraph) ((JScrollPane) ((JPanel) movieMakerSplitPane.getLeftComponent())
                        .getComponent(0)).getViewport().getView();
                leftGraph.setScale(leftGraph.getScale() * 0.8);

                ItGraph rightGraph = (ItGraph) ((JScrollPane) ((JPanel) movieMakerSplitPane.getRightComponent())
                        .getComponent(0)).getViewport().getView();
                rightGraph.setScale(rightGraph.getScale() * 0.8);
            } catch (Exception e1) {
            }

        }
    });
    movieMakerToolBar.add(zoomOutButton);

    // 1:1
    JButton oneToOneScaleButton = new JButton("1:1");
    oneToOneScaleButton.setToolTipText("1:1");
    oneToOneScaleButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent e) {

            try {
                ItGraph leftGraph = (ItGraph) ((JScrollPane) ((JPanel) movieMakerSplitPane.getLeftComponent())
                        .getComponent(0)).getViewport().getView();
                leftGraph.setScale(1.0);

                ItGraph rightGraph = (ItGraph) ((JScrollPane) ((JPanel) movieMakerSplitPane.getRightComponent())
                        .getComponent(0)).getViewport().getView();
                rightGraph.setScale(1.0);
            } catch (Exception e1) {
            }

        }
    });
    movieMakerToolBar.add(oneToOneScaleButton);

    movieMakerToolBar.addSeparator();

    // edit state
    JButton editStateButton = new JButton("Edit", new ImageIcon("resources/images/edit.png"));
    editStateButton.setToolTipText("Edit current state");
    editStateButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            // take the current state
            Element currentState = PlanNavigationList.getInstance().getCurrentState();

            ItTreeNode problemNode = (ItTreeNode) problemsPlanTree.getLastSelectedPathComponent();
            ItTreeNode domainNode = (ItTreeNode) problemNode.getParent();
            ItTreeNode projectNode = (ItTreeNode) domainNode.getParent();

            // the object diagram must have parent
            //add the current state to the domain
            Element currentStateClone = (Element) currentState.clone();
            problemNode.getData().getChild("objectDiagrams").addContent(currentStateClone);

            graphTabbedPane.openEditStateTab(currentStateClone, domainNode.getData(), projectNode.getData());

            //mainTabbedPane.setSelectedIndex(0);
            CardLayout cl = (CardLayout) (mainTabbedPane.getLayout());
            cl.show(mainTabbedPane, "UML");
        }
    });
    movieMakerToolBar.add(editStateButton);

    movieMakerToolBar.addSeparator();
    // plan evaluation

    /*
    JButton planEvaluationButton = new JButton("Evaluate Plan", new ImageIcon("resources/images/eval.png"));
    planEvaluationButton.setToolTipText("<html>Generate a plan evaluation in the planReport. <br> This is restricted to non-time-based domain only.</html>");
    planEvaluationButton.addActionListener(new java.awt.event.ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        //RUN plan evaluation
    generateEvaluatioReport.actionPerformed(e);
    }
    });
    movieMakerToolBar.add( planEvaluationButton);
     */

    // virtual reality

    JButton virtualRealityButton = new JButton("Virtual Prototyping",
            new ImageIcon("resources/images/virtualprototype.png"));
    virtualRealityButton.setToolTipText("Generate virtual prototype files");
    virtualRealityButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ItTreeNode problemNode = (ItTreeNode) problemsPlanTree.getLastSelectedPathComponent();
            ItTreeNode domainNode = (ItTreeNode) problemNode.getParent();
            //ItTreeNode projectNode = (ItTreeNode)domainNode.getParent();
            try {

                VirtualPrototypingBlender.generatePrototypeFiles(domainNode.getData(), problemNode.getData(),
                        xmlPlan);
                //VirtualRealityRobotNavigationDomain.generateBackgroundFile(problemNode.getData(), xmlPlan);
            } catch (IOException ex) {
                Logger.getLogger(ItSIMPLE.class.getName()).log(Level.SEVERE, null, ex);
            }
            //VirtualRealityRobotNavigationDomain.generateBackgroundFile(problemNode.getData(), xmlPlan);
        }
    });
    movieMakerToolBar.add(virtualRealityButton);

    return movieMakerToolBar;
}

From source file:org.apache.cayenne.modeler.CayenneModelerFrame.java

/** Initializes main toolbar. */
protected void initToolbar() {
    JToolBar toolBar = new JToolBar();

    toolBar.add(getAction(NewProjectAction.class).buildButton());
    toolBar.add(getAction(OpenProjectAction.class).buildButton());
    toolBar.add(getAction(SaveAction.class).buildButton());

    toolBar.addSeparator();
    toolBar.add(getAction(RemoveAction.class).buildButton());

    toolBar.addSeparator();//ww w.jav a2  s . c  o  m

    toolBar.add(getAction(CutAction.class).buildButton());
    toolBar.add(getAction(CopyAction.class).buildButton());
    toolBar.add(getAction(PasteAction.class).buildButton());

    toolBar.addSeparator();

    toolBar.add(getAction(UndoAction.class).buildButton());
    toolBar.add(getAction(RedoAction.class).buildButton());

    toolBar.addSeparator();

    toolBar.add(getAction(CreateNodeAction.class).buildButton());
    toolBar.add(getAction(CreateDataMapAction.class).buildButton());

    toolBar.addSeparator();

    toolBar.add(getAction(CreateDbEntityAction.class).buildButton());
    toolBar.add(getAction(CreateProcedureAction.class).buildButton());

    toolBar.addSeparator();

    toolBar.add(getAction(CreateObjEntityAction.class).buildButton());
    toolBar.add(getAction(CreateEmbeddableAction.class).buildButton());
    toolBar.add(getAction(CreateQueryAction.class).buildButton());

    toolBar.addSeparator();

    toolBar.add(getAction(NavigateBackwardAction.class).buildButton());
    toolBar.add(getAction(NavigateForwardAction.class).buildButton());

    JPanel east = new JPanel(new BorderLayout()); // is used to place search feature
    // components the most right on a
    // toolbar
    final JTextField findField = new JTextField(10);
    findField.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() != KeyEvent.VK_ENTER) {
                findField.setBackground(Color.white);
            }
        }

        public void keyReleased(KeyEvent e) {
        }

        public void keyTyped(KeyEvent e) {
        }

    });
    findField.setAction(getAction(FindAction.class));
    JLabel findLabel = new JLabel("Search:");
    findLabel.setLabelFor(findField);
    Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {

        public void eventDispatched(AWTEvent event) {

            if (event instanceof KeyEvent) {

                if (((KeyEvent) event).getModifiers() == Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
                        && ((KeyEvent) event).getKeyCode() == KeyEvent.VK_F) {
                    findField.requestFocus();
                }
            }
        }

    }, AWTEvent.KEY_EVENT_MASK);

    JPanel box = new JPanel(); // is used to place label and text field one after
    // another
    box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS));
    box.add(findLabel);
    box.add(findField);
    east.add(box, BorderLayout.EAST);
    toolBar.add(east);

    getContentPane().add(toolBar, BorderLayout.NORTH);
}