Example usage for java.beans PropertyChangeListener PropertyChangeListener

List of usage examples for java.beans PropertyChangeListener PropertyChangeListener

Introduction

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

Prototype

PropertyChangeListener

Source Link

Usage

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

private void initComponents() {
    addWindowListener(new WindowAdapter() {
        @Override/*from  w  w  w . j  a v a 2s  .  c  om*/
        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:com.marginallyclever.makelangelo.MainGUI.java

protected boolean LoadDXF(String filename) {
    if (ChooseImageConversionOptions(true) == false)
        return false;

    // where to save temp output file?
    final String destinationFile = GetTempDestinationFile();
    final String srcFile = filename;

    TabToLog();//from   w  w w.  j a  va 2  s  . c  o  m

    final ProgressMonitor pm = new ProgressMonitor(null, translator.get("Converting"), "", 0, 100);
    pm.setProgress(0);
    pm.setMillisToPopup(0);

    final SwingWorker<Void, Void> s = new SwingWorker<Void, Void>() {
        public boolean ok = false;

        @SuppressWarnings("unchecked")
        @Override
        public Void doInBackground() {
            Log("<font color='green'>" + translator.get("Converting") + " " + destinationFile + "</font>\n");

            Parser parser = ParserBuilder.createDefaultParser();

            double dxf_x2 = 0;
            double dxf_y2 = 0;
            OutputStreamWriter out = null;

            try {
                out = new OutputStreamWriter(new FileOutputStream(destinationFile), "UTF-8");
                DrawingTool tool = machineConfiguration.GetCurrentTool();
                out.write(machineConfiguration.GetConfigLine() + ";\n");
                out.write(machineConfiguration.GetBobbinLine() + ";\n");
                out.write("G00 G90;\n");
                tool.WriteChangeTo(out);
                tool.WriteOff(out);

                parser.parse(srcFile, DXFParser.DEFAULT_ENCODING);
                DXFDocument doc = parser.getDocument();
                Bounds b = doc.getBounds();
                double width = b.getMaximumX() - b.getMinimumX();
                double height = b.getMaximumY() - b.getMinimumY();
                double cx = (b.getMaximumX() + b.getMinimumX()) / 2.0f;
                double cy = (b.getMaximumY() + b.getMinimumY()) / 2.0f;
                double sy = machineConfiguration.GetPaperHeight() * 10 / height;
                double sx = machineConfiguration.GetPaperWidth() * 10 / width;
                double scale = (sx < sy ? sx : sy) * machineConfiguration.paper_margin;
                sx = scale * (machineConfiguration.reverseForGlass ? -1 : 1);
                // count all entities in all layers
                Iterator<DXFLayer> layer_iter = (Iterator<DXFLayer>) doc.getDXFLayerIterator();
                int entity_total = 0;
                int entity_count = 0;
                while (layer_iter.hasNext()) {
                    DXFLayer layer = (DXFLayer) layer_iter.next();
                    Log("<font color='yellow'>Found layer " + layer.getName() + "</font>\n");
                    Iterator<String> entity_iter = (Iterator<String>) layer.getDXFEntityTypeIterator();
                    while (entity_iter.hasNext()) {
                        String entity_type = (String) entity_iter.next();
                        List<DXFEntity> entity_list = (List<DXFEntity>) layer.getDXFEntities(entity_type);
                        Log("<font color='yellow'>+ Found " + entity_list.size() + " of type " + entity_type
                                + "</font>\n");
                        entity_total += entity_list.size();
                    }
                }
                // set the progress meter
                pm.setMinimum(0);
                pm.setMaximum(entity_total);

                // convert each entity
                layer_iter = doc.getDXFLayerIterator();
                while (layer_iter.hasNext()) {
                    DXFLayer layer = (DXFLayer) layer_iter.next();

                    Iterator<String> entity_type_iter = (Iterator<String>) layer.getDXFEntityTypeIterator();
                    while (entity_type_iter.hasNext()) {
                        String entity_type = (String) entity_type_iter.next();
                        List<DXFEntity> entity_list = layer.getDXFEntities(entity_type);

                        if (entity_type.equals(DXFConstants.ENTITY_TYPE_LINE)) {
                            for (int i = 0; i < entity_list.size(); ++i) {
                                pm.setProgress(entity_count++);
                                DXFLine entity = (DXFLine) entity_list.get(i);
                                Point start = entity.getStartPoint();
                                Point end = entity.getEndPoint();

                                double x = (start.getX() - cx) * sx;
                                double y = (start.getY() - cy) * sy;
                                double x2 = (end.getX() - cx) * sx;
                                double y2 = (end.getY() - cy) * sy;

                                // is it worth drawing this line?
                                double dx = x2 - x;
                                double dy = y2 - y;
                                if (dx * dx + dy * dy < tool.GetDiameter() / 2.0) {
                                    continue;
                                }

                                dx = dxf_x2 - x;
                                dy = dxf_y2 - y;

                                if (dx * dx + dy * dy > tool.GetDiameter() / 2.0) {
                                    if (tool.DrawIsOn()) {
                                        tool.WriteOff(out);
                                    }
                                    tool.WriteMoveTo(out, (float) x, (float) y);
                                }
                                if (tool.DrawIsOff()) {
                                    tool.WriteOn(out);
                                }
                                tool.WriteMoveTo(out, (float) x2, (float) y2);
                                dxf_x2 = x2;
                                dxf_y2 = y2;
                            }
                        } else if (entity_type.equals(DXFConstants.ENTITY_TYPE_SPLINE)) {
                            for (int i = 0; i < entity_list.size(); ++i) {
                                pm.setProgress(entity_count++);
                                DXFSpline entity = (DXFSpline) entity_list.get(i);
                                entity.setLineWeight(30);
                                DXFPolyline polyLine = DXFSplineConverter.toDXFPolyline(entity);
                                boolean first = true;
                                for (int j = 0; j < polyLine.getVertexCount(); ++j) {
                                    DXFVertex v = polyLine.getVertex(j);
                                    double x = (v.getX() - cx) * sx;
                                    double y = (v.getY() - cy) * sy;
                                    double dx = dxf_x2 - x;
                                    double dy = dxf_y2 - y;

                                    if (first == true) {
                                        first = false;
                                        if (dx * dx + dy * dy > tool.GetDiameter() / 2.0) {
                                            // line does not start at last tool location, lift and move.
                                            if (tool.DrawIsOn()) {
                                                tool.WriteOff(out);
                                            }
                                            tool.WriteMoveTo(out, (float) x, (float) y);
                                        }
                                        // else line starts right here, do nothing.
                                    } else {
                                        // not the first point, draw.
                                        if (tool.DrawIsOff())
                                            tool.WriteOn(out);
                                        if (j < polyLine.getVertexCount() - 1
                                                && dx * dx + dy * dy < tool.GetDiameter() / 2.0)
                                            continue; // less than 1mm movement?  Skip it. 
                                        tool.WriteMoveTo(out, (float) x, (float) y);
                                    }
                                    dxf_x2 = x;
                                    dxf_y2 = y;
                                }
                            }
                        } else if (entity_type.equals(DXFConstants.ENTITY_TYPE_POLYLINE)) {
                            for (int i = 0; i < entity_list.size(); ++i) {
                                pm.setProgress(entity_count++);
                                DXFPolyline entity = (DXFPolyline) entity_list.get(i);
                                boolean first = true;
                                for (int j = 0; j < entity.getVertexCount(); ++j) {
                                    DXFVertex v = entity.getVertex(j);
                                    double x = (v.getX() - cx) * sx;
                                    double y = (v.getY() - cy) * sy;
                                    double dx = dxf_x2 - x;
                                    double dy = dxf_y2 - y;

                                    if (first == true) {
                                        first = false;
                                        if (dx * dx + dy * dy > tool.GetDiameter() / 2.0) {
                                            // line does not start at last tool location, lift and move.
                                            if (tool.DrawIsOn()) {
                                                tool.WriteOff(out);
                                            }
                                            tool.WriteMoveTo(out, (float) x, (float) y);
                                        }
                                        // else line starts right here, do nothing.
                                    } else {
                                        // not the first point, draw.
                                        if (tool.DrawIsOff())
                                            tool.WriteOn(out);
                                        if (j < entity.getVertexCount() - 1
                                                && dx * dx + dy * dy < tool.GetDiameter() / 2.0)
                                            continue; // less than 1mm movement?  Skip it. 
                                        tool.WriteMoveTo(out, (float) x, (float) y);
                                    }
                                    dxf_x2 = x;
                                    dxf_y2 = y;
                                }
                            }
                        }
                    }
                }

                // entities finished.  Close up file.
                tool.WriteOff(out);
                tool.WriteMoveTo(out, 0, 0);

                ok = true;
            } catch (IOException e) {
                e.printStackTrace();
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } finally {
                try {
                    if (out != null)
                        out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }

            }

            pm.setProgress(100);
            return null;
        }

        @Override
        public void done() {
            pm.close();
            Log("<font color='green'>" + translator.get("Finished") + "</font>\n");
            PlayConversionFinishedSound();
            if (ok) {
                LoadGCode(destinationFile);
                TabToDraw();
            }
            Halt();
        }
    };

    s.addPropertyChangeListener(new PropertyChangeListener() {
        // Invoked when task's progress property changes.
        public void propertyChange(PropertyChangeEvent evt) {
            if ("progress" == evt.getPropertyName()) {
                int progress = (Integer) evt.getNewValue();
                pm.setProgress(progress);
                String message = String.format("%d%%\n", progress);
                pm.setNote(message);
                if (s.isDone()) {
                    Log("<font color='green'>" + translator.get("Finished") + "</font>\n");
                } else if (s.isCancelled() || pm.isCanceled()) {
                    if (pm.isCanceled()) {
                        s.cancel(true);
                    }
                    Log("<font color='green'>" + translator.get("Cancelled") + "</font>\n");
                }
            }
        }
    });

    s.execute();

    return true;
}

From source file:ca.uhn.hl7v2.testpanel.ui.editor.Hl7V2MessageEditorPanel.java

/**
 * @param theMessage/*from w w  w . j  av  a  2 s.c  o  m*/
 *            the message to set
 */
public void setMessage(Hl7V2MessageCollection theMessage) {
    Validate.isTrue(myMessage == null);

    myMessage = theMessage;

    myShowCombo.setModel(new ShowComboModel());

    // Prepopulate the "send to interface" combo to the last value it had
    if (StringUtils.isNotBlank(myMessage.getLastSendToInterfaceId())) {
        for (int i = 0; i < myOutboundInterfaceComboModelShadow.size(); i++) {
            if (myOutboundInterfaceComboModelShadow.get(i).getId()
                    .equals(myMessage.getLastSendToInterfaceId())) {
                myOutboundInterfaceCombo.setSelectedIndex(i);
                break;
            }
        }
    }

    updateEncodingButtons();
    myRdbtnEr7.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent theE) {
            removeHighlights();
            myMessage.setEncoding(Hl7V2EncodingTypeEnum.ER_7);
        }
    });
    myRdbtnXml.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent theE) {
            removeHighlights();
            myMessage.setEncoding(Hl7V2EncodingTypeEnum.XML);
        }
    });

    try {
        myDisableCaretUpdateHandling = true;
        updateMessageEditor();
    } finally {
        myDisableCaretUpdateHandling = false;
    }

    myMessageListeneer = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent theEvt) {
            if (myDontRespondToSourceMessageChanges) {
                return;
            }
            try {
                myDisableCaretUpdateHandling = true;
                updateMessageEditor();
            } finally {
                myDisableCaretUpdateHandling = false;
            }
        }
    };
    myMessage.addPropertyChangeListener(Hl7V2MessageCollection.SOURCE_MESSAGE_PROPERTY, myMessageListeneer);

    mySelectedPathListener = new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent theEvt) {
            String path = myMessage.getHighlitedPath();
            if (path == null) {
                path = "";
            }

            int index = path.indexOf('/');
            if (index > -1) {
                path = path.substring(index);
            }

            myTerserPathTextField.setText(path);
        }
    };
    myMessage.addPropertyChangeListener(Hl7V2MessageCollection.PROP_HIGHLITED_PATH, mySelectedPathListener);

    myTreePanel.setMessage(myMessage);

    myRangeListener = new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent theEvt) {
            if (theEvt.getNewValue() == null || !myFollowToggle.isSelected()) {
                return;
            }
            Range range = (Range) theEvt.getNewValue();

            // myMessageScrollPane.getHorizontalScrollBar().setValue(0);

            // myMessageEditor.select(range.getStart(), range.getEnd());
            // myMessageEditor.setCaretPosition(range.getStart());

            myMessageEditor.setCaretPosition(range.getStart());
            myMessageEditor.moveCaretPosition(range.getEnd());

            myMessageEditor.setCaretPosition(range.getEnd());
            myMessageEditor.moveCaretPosition(range.getStart());

            // myMessageEditor.grabFocus();
            myMessageEditor.repaint();

            String substring = myMessage.getSourceMessage().substring(range.getStart(), range.getEnd());
            ourLog.info("Selected range set to " + range + " which is " + substring);
        }
    };
    myMessage.addPropertyChangeListener(Hl7V2MessageCollection.PROP_HIGHLITED_RANGE, myRangeListener);

    myProfileComboboxModel.update();

    // Window Title
    myWindowTitleListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent theEvt) {
            updateWindowTitle();
        }
    };
    myMessage.addPropertyChangeListener(Hl7V2MessageCollection.SAVED_PROPERTY, myWindowTitleListener);
    myMessage.addPropertyChangeListener(Hl7V2MessageCollection.PROP_SAVE_FILENAME, myWindowTitleListener);
    updateWindowTitle();

    EventQueue.invokeLater(new Runnable() {

        public void run() {
            myMessageEditor.setCaretPosition(0);
            myMessageEditor.grabFocus();
        }
    });

}

From source file:ome.formats.importer.gui.GuiImporter.java

/**
 * Display errors in import dialog /*  w ww .j a v  a  2s  . co m*/
 * 
 * @param frame - parent frame
 */
private void importErrorsCollected(Component frame) {
    final JOptionPane optionPane = new JOptionPane(
            "\nYour import has produced one or more errors, " + "\nvisit the 'Import Errors' tab for details.",
            JOptionPane.WARNING_MESSAGE);
    final JDialog errorDialog = new JDialog(this, "Errors Collected", false);
    errorDialog.setContentPane(optionPane);

    optionPane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();

            if (errorDialog.isVisible() && (e.getSource() == optionPane)
                    && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                errorDialog.dispose();
            }
        }
    });

    errorDialog.toFront();
    errorDialog.pack();
    errorDialog.setLocationRelativeTo(frame);
    errorDialog.setVisible(true);
}

From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java

private JPanel createFieldListPanel() {

    JPanel container = new JPanel();
    container.setBackground(UIHelper.BG_COLOR);
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));

    JPanel headerLab = new JPanel(new GridLayout(1, 1));
    headerLab.setOpaque(false);//from   w  w  w . j  av  a  2 s.c  o m

    JLabel lab = new JLabel(fieldListTitle);
    headerLab.add(lab);

    container.add(headerLab);
    container.add(Box.createVerticalStrut(5));

    elementModel = new DefaultListModel();
    elementList = new ReOrderableJList(elementModel);
    elementList.setCellRenderer(new CustomReOrderableListCellRenderer(elementList));
    elementList.setDragEnabled(true);
    elementList.setBackground(UIHelper.BG_COLOR);

    elementList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent event) {
            Display selectedNode = (Display) elementList.getSelectedValue();
            if (selectedNode != null) {
                try {
                    saveCurrentField(false, false);
                } catch (DataNotCompleteException dce) {
                    showMessagePane(dce.getMessage(), JOptionPane.ERROR_MESSAGE);
                }
                if (selectedNode instanceof FieldElement) {
                    fieldInterface.setCurrentField((FieldElement) selectedNode);
                    if (currentPage != fieldInterface) {
                        setCurrentPage(fieldInterface);
                    }
                    removeElementButton.setEnabled(!standardISAFields.isFieldRequired(selectedNode.toString()));
                } else {
                    setCurrentPage(structureElement);
                }
            }
        }
    });

    elementList.addPropertyChangeListener("orderChanged", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            updateFieldOrder();

            if (tableList.getSelectedValue() instanceof MappingObject) {
                validateFormOrTable(ApplicationManager.getCurrentMappingObject());
            }
        }
    });

    JScrollPane listScroller = new JScrollPane(elementList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    listScroller.getViewport().setBackground(UIHelper.BG_COLOR);
    listScroller.setBorder(new EmptyBorder(2, 2, 2, 10));
    listScroller.setPreferredSize(new Dimension(((int) (WIDTH * 0.25)), ((int) (HEIGHT * 0.75))));
    IAppWidgetFactory.makeIAppScrollPane(listScroller);

    container.add(listScroller);
    container.add(Box.createVerticalStrut(5));

    elementCountInfo = UIHelper.createLabel("", UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR);

    container.add(UIHelper.wrapComponentInPanel(elementCountInfo));
    container.add(Box.createVerticalStrut(5));

    // create button panel to add and remove tables
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.setBackground(UIHelper.BG_COLOR);

    final JLabel addFieldButton = new JLabel(addElement, JLabel.LEFT);
    addFieldButton.setOpaque(false);

    addFieldButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            addFieldButton.setIcon(addElementOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            addFieldButton.setIcon(addElement);
        }

        public void mousePressed(MouseEvent event) {
            addFieldButton.setIcon(addElement);
            showAddFieldUI();
        }

    });

    addFieldButton.setToolTipText(
            "<html><b>Add Field to table</b><p>Add a new field to currently selected table</b></p></html>");

    removeElementButton = new JLabel(removeElement, JLabel.LEFT);
    removeElementButton.setOpaque(false);

    removeElementButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            removeElementButton.setIcon(removeElementOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            removeElementButton.setIcon(removeElement);
        }

        public void mousePressed(MouseEvent event) {
            removeElementButton.setIcon(removeElement);
            if (removeElementButton.isEnabled()) {
                removeSelectedElement();
            }
        }

    });

    removeElementButton.setToolTipText(
            "<html><b>Remove Field from table</b><p>Remove this field from this list and the currently selected table.</b></p></html>");

    final JLabel moveDownButton = new JLabel(moveDown);
    moveDownButton.setOpaque(false);
    moveDownButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            moveDownButton.setIcon(moveDownOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            moveDownButton.setIcon(moveDown);
        }

        public void mousePressed(MouseEvent event) {
            moveDownButton.setIcon(moveDown);
            if (elementList.getSelectedIndex() != -1) {
                int toMoveDown = elementList.getSelectedIndex();

                if (toMoveDown != (elementModel.getSize() - 1)) {
                    swapElements(elementList, elementModel, toMoveDown, toMoveDown + 1);
                }

                updateFieldOrder();
                validateFormOrTable(ApplicationManager.getCurrentMappingObject());
            }
        }
    });

    moveDownButton.setToolTipText(
            "<html><b>Move Field Down</b><p>Move the selected field down <b>one</b> position in the list.</p></html>");

    final JLabel moveUpButton = new JLabel(moveUp);
    moveUpButton.setOpaque(false);
    moveUpButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            moveUpButton.setIcon(moveUpOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            moveUpButton.setIcon(moveUp);
        }

        public void mousePressed(MouseEvent event) {
            moveUpButton.setIcon(moveUp);
            if (elementList.getSelectedIndex() != -1) {
                int toMoveUp = elementList.getSelectedIndex();

                if (toMoveUp != 0) {
                    swapElements(elementList, elementModel, toMoveUp, toMoveUp - 1);
                }

                updateFieldOrder();
                validateFormOrTable(ApplicationManager.getCurrentMappingObject());

            }
        }

    });

    moveUpButton.setToolTipText(
            "<html><b>Move Field Up</b><p>Move the selected field up <b>one</b> position in the list.</p></html>");

    buttonPanel.add(addFieldButton);
    buttonPanel.add(removeElementButton);
    buttonPanel.add(moveDownButton);
    buttonPanel.add(moveUpButton);

    container.add(buttonPanel);

    container.add(Box.createVerticalGlue());

    return container;
}

From source file:tauargus.model.batch.java

/**
 * Read the <SUPPRESS> command in a batch file with all its parameters 
 * and calls the required suppression method
 * @throws ArgusException /*w  w w.jav a2s. com*/
 */
static void suppressBatch() throws ArgusException {
    String SuppressType, token;
    int i;
    boolean linked;
    String[] tail = new String[1];
    String hs;
    final TableSet tableset;

    SuppressType = tokenizer.nextField("(").toUpperCase();
    tail[0] = tokenizer.getLine();
    tokenizer.clearLine();
    token = nextToken(tail);
    int n = Integer.parseInt(token);
    if (n < 0 || n > TableService.numberOfTables()) {
        throw new ArgusException("Wrong table number in Suppression");
    }
    linked = (n == 0);
    if (linked) {
        if (!SuppressType.equals("GH") && !SuppressType.equals("MOD")) {
            throw new ArgusException("Linked tables is only possible for Modular or Hypercube");
        }
        for (i = 0; i < TableService.numberOfTables(); i++) {
            TableService.undoSuppress(i);
        }
        tableset = tauargus.service.TableService.getTable(0);
    } else {
        tableset = tauargus.service.TableService.getTable(n - 1);
        TableService.undoSuppress(n - 1);
    }

    switch (SuppressType) {
    case "GH": {//TabNo, A priori Bounds Percentage, ModelSize, ApplySingleton) 
        token = nextChar(tail);
        if (token.equals(",")) {
            token = nextToken(tail);
            tableset.ghMiterAprioryPercentage = Integer.parseInt(token);
            token = nextChar(tail);
        }
        if (token.equals(",")) {
            token = nextToken(tail);
            tableset.ghMiterSize = Integer.parseInt(token);
            token = nextChar(tail);
        }
        if (token.equals(",")) {
            token = nextToken(tail);
            tableset.ghMiterApplySingleton = token.equals("1");
            token = nextChar(tail);
        }
        if (linked) {
            LinkedTables.buildCoverTable();
            LinkedTables.runLinkedGHMiter();
            hs = "";
            TableSet ts;
            for (i = 0; i < TableService.numberOfTables(); i++) {
                ts = tauargus.service.TableService.getTable(i);
                hs = hs + ts.CountSecondaries() + " cells have been suppressed in table " + (i + 1) + "\n";
            }
            hs = hs.substring(0, hs.length() - 1);
        } else {
            GHMiter.RunGHMiter(tableset);
            hs = tableset.CountSecondaries() + " cells have been suppressed";
        }
        reportProgress("The hypercube procedure has been applied\n" + hs);
        break;
    }
    case "MOD": {//TabNo, MaxTimePerSubtable
        token = nextChar(tail);
        if (token.equals(",")) {
            token = nextToken(tail);
            tableset.maxHitasTime = Integer.parseInt(token);
            Application.generalMaxHitasTime = tableset.maxHitasTime;
            // The generalMAxHitasTime is used in the runModular procedure.
            token = nextChar(tail);
        }
        i = 0;
        while (token.equals(",") && (i < 3)) {
            i++;
            token = nextToken(tail);
            switch (i) {
            case 1:
                tableset.singletonSingletonCheck = token.equals("1");
                break;
            case 2:
                tableset.singletonMultipleCheck = token.equals("1");
                break;
            case 3:
                tableset.minFreqCheck = token.equals("1");
                break;
            }
            token = nextChar(tail);

        }
        if (linked) {
            LinkedTables.buildCoverTable();
            LinkedTables.runLinkedModular(null);
        } else { // single table
            if (token.equals(",")) { //MSC specified
                token = nextToken(tail);
                tableset.maxScaleCost = StrUtils.toDouble(token);
                if (tableset.maxScaleCost <= 0) {
                    throw new ArgusException("Illegal Max Scaling Cost: " + token);
                }
            }

            try { // Make sure that PropertyChanges are not processed in batch-mode by overriding propertyChange to do nothing
                if (Application.batchType() == Application.BATCH_COMMANDLINE) {
                    OptiSuppress.runModular(tableset, new PropertyChangeListener() {
                        @Override
                        public void propertyChange(PropertyChangeEvent evt) {
                        }
                    });
                    reportProgressInfo("The modular procedure has been applied\n" + tableset.CountSecondaries()
                            + " cells have been suppressed");
                } else {
                    final SwingWorker<Integer, Void> worker = new ProgressSwingWorker<Integer, Void>(
                            ProgressSwingWorker.DOUBLE, "Modular approach") {
                        @Override
                        protected Integer doInBackground() throws ArgusException, Exception {
                            super.doInBackground();
                            OptiSuppress.runModular(tableset, getPropertyChangeListener());
                            reportProgressInfo("The modular procedure has been applied\n"
                                    + tableset.CountSecondaries() + " cells have been suppressed");
                            return null;
                        }

                        @Override
                        protected void done() {
                            super.done();
                            try {
                                get();
                                tableset.undoAudit();
                                // Wat doet dit? Hoeft niet. Alleen voor GUI                            
                                //                            ((AbstractTableModel)table.getModel()).fireTableDataChanged();
                            } catch (InterruptedException ex) {
                                logger.log(Level.SEVERE, null, ex);
                            } catch (ExecutionException ex) {
                                JOptionPane.showMessageDialog(null, ex.getCause().getMessage());
                            }
                        }
                    };
                    worker.execute();
                    while (!worker.isDone()) {
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException ex) {
                        }
                    }
                }
            } catch (IOException ex) {
                throw new ArgusException("Modular failed\n" + ex.getMessage());
            }
        }

        break;
    }
    case "OPT": {//TabNo, MaxComputingTime
        if (n == 0) {
            throw new ArgusException("Linked tables is not possible for Optimal");
        }
        token = nextChar(tail);
        if (token.equals(",")) {
            token = nextToken(tail);
            tableset.maxHitasTime = Integer.parseInt(token);
            token = nextChar(tail);
        }

        if (Application.batchType() == Application.BATCH_COMMANDLINE) {
            try {
                OptiSuppress.runOptimal(tableset, new PropertyChangeListener() {
                    @Override
                    public void propertyChange(PropertyChangeEvent evt) {
                    }
                }, false, false, 1);
            } catch (IOException ex) {
            }
        } else { // From menu with swingworker
            final SwingWorker<Integer, Void> worker = new ProgressSwingWorker<Integer, Void>(
                    ProgressSwingWorker.DOUBLE, "Modular approach") {
                @Override
                protected Integer doInBackground() throws ArgusException, Exception {
                    super.doInBackground();
                    try {
                        OptiSuppress.runOptimal(tableset, new PropertyChangeListener() {
                            @Override
                            public void propertyChange(PropertyChangeEvent evt) {
                            }
                        }, false, false, 1);
                    } catch (IOException ex) {
                    }
                    return null;
                }

                @Override
                protected void done() {
                    super.done();
                    try {
                        get();
                    } catch (InterruptedException ex) {
                        logger.log(Level.SEVERE, null, ex);
                    } catch (ExecutionException ex) {
                        JOptionPane.showMessageDialog(null, ex.getCause().getMessage());
                    }
                }
            };
            worker.execute();
            while (!worker.isDone()) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException ex) {
                }
            }
        }

        //TODO
        reportProgressInfo("The optimal procedure has been applied\n" + tableset.CountSecondaries()
                + " cells have been suppressed");

        break;
    }
    case "RND": {//TabNo, RoundingBase, Steps, Time, Partitions, StopRule
                 // OK after Roundbase: Default Step = 0 (no step), time = 10, Nopartitions part = 0, stoprule = 2(optimal)
        if (n == 0) {
            throw new ArgusException("Linked tables is not possible for Rounding");
        }
        if (Application.solverSelected == Application.SOLVER_CPLEX)
        //{throw new ArgusException("Controlled rounding cannot be used when Cplex is selected as solver");}
        {
            reportProgressInfo(
                    "Whether controlled rounding can be used when Cplex is selected as solver, depends on your specific license.\n Incorrect license may cause errors.");
        }
        token = nextChar(tail);
        if (!token.equals(",")) {
            throw new ArgusException("a komma(,) expected");
        }
        token = nextToken(tail);
        tableset.roundBase = Integer.parseInt(token);
        long mrb = TableSet.computeMinRoundBase(tableset);
        if (tableset.roundBase < mrb) {
            throw new ArgusException(
                    "The rounding base is too small\n" + "A minimum of " + mrb + " is required");
        }
        //set the defaults
        tableset.roundMaxStep = 0;
        tableset.roundMaxTime = 10;
        tableset.roundPartitions = 0;
        tableset.roundStoppingRule = 2;
        token = nextChar(tail);

        if (token.equals(",")) { //steps
            token = nextToken(tail);
            tableset.roundMaxStep = StrUtils.toInteger(token);
            token = nextChar(tail);
        } else {
            if (!token.equals(")"))
                throw new ArgusException("a komma(,) or \")\" expected");
        }

        if (token.equals(",")) { //max time
            token = nextToken(tail);
            tableset.roundMaxTime = Integer.parseInt(token);
            if (tableset.roundMaxTime <= 0) {
                throw new ArgusException("Illegal value for max time: " + tableset.roundMaxTime);
            }
            token = nextChar(tail);
        } else {
            if (!token.equals(")"))
                throw new ArgusException("a komma(,) or \")\" expected");
        }

        if (token.equals(",")) { //partitions
            token = nextToken(tail);
            tableset.roundPartitions = Integer.parseInt(token);
            if (tableset.roundPartitions < 0 || tableset.roundPartitions > 1) {
                throw new ArgusException("Illegal value for partitions: " + tableset.roundPartitions);
            }
            token = nextChar(tail);
        } else {
            if (!token.equals(")"))
                throw new ArgusException("a komma(,) or \")\" expected");
        }

        if (token.equals(",")) { //Stop rule
            token = nextToken(tail);
            tableset.roundStoppingRule = Integer.parseInt(token);
            if (tableset.roundStoppingRule <= 0 || tableset.roundStoppingRule > 2) {
                throw new ArgusException("Illegal value for max time: " + tableset.roundStoppingRule);
            }
            token = nextChar(tail);
        } else {
            if (!token.equals(")"))
                throw new ArgusException("a komma(,) or \")\" expected");
        }

        if (token.equals(",")) { //Unit cost function
            token = nextToken(tail);
            if (token.equals("1")) {
                tableset.roundUnitCost = true;
            } else if (token.equals("0")) {
                tableset.roundUnitCost = false;
            } else {
                throw new ArgusException("Illegal value UnitCost parameter: only 0 or 1 allowed");
            }
            token = nextChar(tail);
        } else {
            if (!token.equals(")"))
                throw new ArgusException("a komma(,) or \")\" expected");
        }

        // all parameters have been handeled. Run the rounder.
        if (Application.batchType() == Application.BATCH_COMMANDLINE) {
            try {
                OptiSuppress.runRounder(tableset, new PropertyChangeListener() {
                    @Override
                    public void propertyChange(PropertyChangeEvent evt) {
                    }
                });
            } catch (IOException ex) {
                throw new ArgusException(ex.getMessage());
            }
        } else //batch run from menu
        {
            final SwingWorker<Integer, Void> worker = new ProgressSwingWorker<Integer, Void>(
                    ProgressSwingWorker.ROUNDER, "Rounding") {
                @Override
                protected Integer doInBackground() throws ArgusException, Exception {
                    super.doInBackground();
                    try {
                        OptiSuppress.runRounder(tableset, new PropertyChangeListener() {
                            @Override
                            public void propertyChange(PropertyChangeEvent evt) {
                            }
                        });
                    } catch (IOException ex) {
                    }
                    return null;
                }

                @Override
                protected void done() {
                    super.done();
                    try {
                        get();
                    } catch (InterruptedException ex) {
                        logger.log(Level.SEVERE, null, ex);
                    } catch (ExecutionException ex) {
                        JOptionPane.showMessageDialog(null, ex.getCause().getMessage());
                    }
                }
            };
            worker.execute();
            while (!worker.isDone()) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException ex) {
                }
            }
        }
        reportProgressInfo("The table has been rounded\n" + "Number of steps: " + tableset.roundMaxStep + "\n"
                + "Max step: " + StrUtils.formatDouble(tableset.roundMaxJump, tableset.respVar.nDecimals));
        break;
    }
    case "CTA": {
        try {
            OptiSuppress.RunCTA(tableset, false);
            reportProgress("CTA run completed");
        } catch (IOException ex) {
            throw new ArgusException(ex.getMessage());
        }
        break;
    }
    case "NET": {
        OptiSuppress.TestNetwork(tableset);

        OptiSuppress.RunNetwork(tableset);

        break;
    }
    default:
        throw new ArgusException("Unknown suppression method (" + SuppressType + ") found");
    }

}

From source file:ome.formats.importer.gui.GuiImporter.java

/**
 * Display errors in candidates dialog//from w ww .ja v a 2  s  . c om
 * 
 * @param frame - parent frame
 */
public void candidateErrorsCollected(Component frame) {
    errors_pending = false;
    final JOptionPane optionPane = new JOptionPane(
            "\nAdding these files to the queue has produced one or more errors and some"
                    + "\n files will not be displayed on the queue. View the 'Import Errors' tab for details.",
            JOptionPane.WARNING_MESSAGE);
    final JDialog errorDialog = new JDialog(this, "Errors Collected", true);
    errorDialog.setContentPane(optionPane);

    optionPane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();

            if (errorDialog.isVisible() && (e.getSource() == optionPane)
                    && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                errorDialog.dispose();
            }
        }
    });

    errorDialog.toFront();
    errorDialog.pack();
    errorDialog.setLocationRelativeTo(frame);
    errorDialog.setVisible(true);
}

From source file:EditorPaneExample20.java

public HTMLInsertFrame(String title, JEditorPane editor) {
    super(title);
    this.pane = editor;

    // Build the layout
    textArea = new JTextArea(10, 32);
    textArea.setLineWrap(true);/* w ww  .j  a  va2s  .  com*/
    textArea.setWrapStyleWord(true);
    insertButton = new JButton("Insert HTML");
    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "HTML Source",
            TitledBorder.CENTER, TitledBorder.TOP));
    topPanel.add(new JScrollPane(textArea), BorderLayout.CENTER);
    JPanel bottomPanel = new JPanel();
    bottomPanel.add(insertButton);

    getContentPane().add(topPanel, BorderLayout.CENTER);
    getContentPane().add(bottomPanel, BorderLayout.SOUTH);

    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                setGUIState();
            }
        }
    });

    insertButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            EditorKit kit = pane.getEditorKit();
            if (kit instanceof HTMLEditorKit) {
                String htmlString = textArea.getText();
                if (htmlString.trim().equals("") == false) {
                    try {
                        ((HTMLEditorKit) kit).read(new StringReader(htmlString), pane.getDocument(),
                                pane.getCaretPosition());
                    } catch (Exception e) {
                    }
                }
            }
        }
    });

    setGUIState(); // Disable if not HTML content
    pack();
}

From source file:com.marginallyclever.makelangelo.MainGUI.java

public boolean LoadImage(String filename) {
    // where to save temp output file?
    final String sourceFile = filename;
    final String destinationFile = GetTempDestinationFile();

    LoadImageConverters();//from w  w w.  j  a va  2 s  . c  o  m
    if (ChooseImageConversionOptions(false) == false)
        return false;

    final ProgressMonitor pm = new ProgressMonitor(null, translator.get("Converting"), "", 0, 100);
    pm.setProgress(0);
    pm.setMillisToPopup(0);

    final SwingWorker<Void, Void> s = new SwingWorker<Void, Void>() {
        @Override
        public Void doInBackground() {
            // read in image
            BufferedImage img;
            try {
                Log("<font color='green'>" + translator.get("Converting") + " " + destinationFile
                        + "</font>\n");
                // convert with style
                img = ImageIO.read(new File(sourceFile));
                int style = GetDrawStyle();
                Filter f = image_converters.get(style);
                TabToLog();
                f.SetParent(this);
                f.SetProgressMonitor(pm);
                f.SetDestinationFile(destinationFile);
                f.Convert(img);
                TabToDraw();
                previewPane.ZoomToFitPaper();
            } catch (IOException e) {
                Log("<font color='red'>" + translator.get("Failed") + e.getLocalizedMessage() + "</font>\n");
                recentFiles.remove(sourceFile);
                updateMenuBar();
            }

            pm.setProgress(100);
            return null;
        }

        @Override
        public void done() {
            pm.close();
            Log("<font color='green'>" + translator.get("Finished") + "</font>\n");
            PlayConversionFinishedSound();
            LoadGCode(destinationFile);
        }
    };

    s.addPropertyChangeListener(new PropertyChangeListener() {
        // Invoked when task's progress property changes.
        public void propertyChange(PropertyChangeEvent evt) {
            if ("progress" == evt.getPropertyName()) {
                int progress = (Integer) evt.getNewValue();
                pm.setProgress(progress);
                String message = String.format("%d%%.\n", progress);
                pm.setNote(message);
                if (s.isDone()) {
                    Log("<font color='green'>" + translator.get("Finished") + "</font>\n");
                } else if (s.isCancelled() || pm.isCanceled()) {
                    if (pm.isCanceled()) {
                        s.cancel(true);
                    }
                    Log("<font color='green'>" + translator.get("Cancelled") + "</font>\n");
                }
            }
        }
    });

    s.execute();

    return true;
}

From source file:ome.formats.importer.gui.GuiImporter.java

/**
 * Display failed sending errors dialog//ww w .  j  a v a  2s. c  om
 * 
 * @param frame - parent frame
 */
public void sendingErrorsFailed(Component frame) {
    final JOptionPane optionPane = new JOptionPane(
            "\nDue to an error we were not able to send your error messages."
                    + "\nto our feedback server. Please try again.",
            JOptionPane.WARNING_MESSAGE);

    final JDialog failedDialog = new JDialog(this, "Feedback Failed!", true);

    failedDialog.setContentPane(optionPane);

    optionPane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();

            if (failedDialog.isVisible() && (e.getSource() == optionPane)
                    && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
                failedDialog.dispose();
            }
        }
    });

    failedDialog.toFront();
    failedDialog.pack();
    failedDialog.setLocationRelativeTo(frame);
    failedDialog.setVisible(true);
}