Example usage for java.awt.event KeyListener KeyListener

List of usage examples for java.awt.event KeyListener KeyListener

Introduction

In this page you can find the example usage for java.awt.event KeyListener KeyListener.

Prototype

KeyListener

Source Link

Usage

From source file:org.datanucleus.ide.idea.ui.DNEConfigForm.java

private void createUIComponents() {
    ////from  w  w  w . j  a  v a2 s  . c  o  m
    // ComboBox for selecting persistence implementation

    this.persistenceImplComboBox = new JComboBox();
    this.persistenceImplComboBox.addItem(this.guiStateBeforeChanges.getEnhancerSupport().getName());
    this.persistenceImplComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {

            if ("comboBoxChanged".equals(e.getActionCommand())) {
                final Object selectedItem = DNEConfigForm.this.persistenceImplComboBox.getSelectedItem();

                if (selectedItem != null) {
                    final String selectedEnhancerSupportName = (String) selectedItem;
                    final EnhancerSupport selectedEnhancerSupport = getByEnhancerSupportName(
                            DNEConfigForm.this.guiStateBeforeChanges, selectedEnhancerSupportName);

                    final PersistenceApi selectedApi = DNEConfigForm.this.jDORadioButton.isSelected()
                            ? PersistenceApi.JDO
                            : PersistenceApi.JPA;
                    final PersistenceApi supportedSelectedApi = selectedEnhancerSupport.isSupported(selectedApi)
                            ? selectedApi
                            : selectedEnhancerSupport.getDefaultPersistenceApi();

                    if (selectedApi != supportedSelectedApi) {
                        JOptionPane.showMessageDialog(null,
                                "Selected persistence implementation does not support " + selectedApi + ','
                                        + "\nreverting to " + supportedSelectedApi);
                    }

                    DNEConfigForm.this.jDORadioButton.setSelected(PersistenceApi.JDO == supportedSelectedApi);
                    DNEConfigForm.this.jPARadioButton.setSelected(PersistenceApi.JPA == supportedSelectedApi);
                    DNEConfigForm.this.jDORadioButton
                            .setEnabled(selectedEnhancerSupport.isSupported(PersistenceApi.JDO));
                    DNEConfigForm.this.jPARadioButton
                            .setEnabled(selectedEnhancerSupport.isSupported(PersistenceApi.JPA));
                    DNEConfigForm.this.persistenceImplComboBox
                            .setSelectedItem(selectedEnhancerSupport.getName());

                    if (selectedEnhancerSupport.getVersion() == EnhancerSupportVersion.V1_1_X) {
                        DNEConfigForm.this.depProjectModuleRadioButton
                                .setSelected(!DNEConfigForm.this.guiStateBeforeChanges.isDependenciesManual());
                        DNEConfigForm.this.depManualRadioButton
                                .setSelected(DNEConfigForm.this.guiStateBeforeChanges.isDependenciesManual());
                        DNEConfigForm.this.depManualRadioButton.setEnabled(true);
                        DNEConfigForm.this.depManualUnsupportedLabel.setVisible(false);
                    } else {
                        DNEConfigForm.this.depProjectModuleRadioButton.setSelected(true);
                        DNEConfigForm.this.depManualRadioButton.setSelected(false);
                        DNEConfigForm.this.depManualRadioButton.setEnabled(false);
                        DNEConfigForm.this.depManualUnsupportedLabel.setVisible(true);
                    }

                    DNEConfigForm.this.configPanel.repaint();

                    DNEConfigForm.this.dependenciesAddDeletePanel
                            .updateDependencyList(selectedEnhancerSupport.getId(), supportedSelectedApi);

                }
            }
        }
    });

    this.jDORadioButton = new JRadioButton();
    this.jDORadioButton.addChangeListener(new DeChatteringRadioButtonChangeListener() {
        @Override
        protected void changed(final ChangeEvent e, final JRadioButton source, final boolean selected) {
            final String selectedEnhSuppName = (String) DNEConfigForm.this.persistenceImplComboBox
                    .getSelectedItem();
            final PersistenceApi selectedApi = selected ? PersistenceApi.JDO : PersistenceApi.JPA;
            final EnhancerSupport enhSuppId = getByEnhancerSupportName(DNEConfigForm.this.guiStateBeforeChanges,
                    selectedEnhSuppName);

            DNEConfigForm.this.configPanel.repaint();

            DNEConfigForm.this.dependenciesAddDeletePanel.updateDependencyList(enhSuppId.getId(), selectedApi);
        }
    });

    //
    // TextBox for metadata-file extensions

    this.metadataExtensionTextField = new JHintingTextField();
    ((JHintingTextField) this.metadataExtensionTextField).setEmptyTextHint(METADATA_FILE_DISABLED);
    this.metadataExtensionTextField.addKeyListener(new KeyListener() {
        public void keyTyped(final KeyEvent e) {
            // do nothing
        }

        public void keyPressed(final KeyEvent e) {
            // do nothing
        }

        public void keyReleased(final KeyEvent e) {
            final String text = DNEConfigForm.this.metadataExtensionTextField.getText();
            final String trimmedText = text.trim();
            final boolean isEmpty = trimmedText.isEmpty();
            DNEConfigForm.this.addToCompilerResourceCheckBox.setEnabled(!isEmpty);
        }
    });

    //
    // Dependencies type selection and List

    // dependency list

    this.dependenciesAddDeletePanel.setVisible(false);
    this.dependenciesAddDeletePanel.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            final String actionCommand = e.getActionCommand();
            if (AbstractAddDeletePanel.EVENT_ADD.equals(actionCommand)
                    || AbstractAddDeletePanel.EVENT_REMOVE.equals(actionCommand)) {

                DNEConfigForm.this.parentPanel.firePropertyChange("dependenciesAddDeletePanel", 0, 1);
            }
        }
    });

    this.manualDependenciesDisabledInfoPanel = new JPanel();
    this.manualDependenciesDisabledInfoPanel
            .setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    this.manualDependenciesDisabledInfoPanel.setVisible(true);

    // dependencies type selection

    this.depProjectModuleRadioButton = new JRadioButton();
    this.depProjectModuleRadioButton.setSelected(true);
    this.depProjectModuleRadioButton.addChangeListener(new DeChatteringRadioButtonChangeListener() {
        @Override
        protected void changed(final ChangeEvent e, final JRadioButton source, final boolean selected) {
            DNEConfigForm.this.dependenciesAddDeletePanel.setVisible(!selected);
            DNEConfigForm.this.manualDependenciesDisabledInfoPanel.setVisible(selected);
        }
    });

    this.depManualRadioButton = new JRadioButton();
    this.depManualRadioButton.setSelected(false);
}

From source file:br.com.jinsync.view.FrmJInSync.java

/**
 * Initialize the contents of the frame.
 *///from w  ww.ja v a  2 s .c  o  m
private void initialize() {

    Language.loadParameters();

    setBounds(100, 100, 1136, 665);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 0, 0 };
    gridBagLayout.rowHeights = new int[] { 600, 53, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 1.0, 0.0, 0.0, Double.MIN_VALUE };
    getContentPane().setLayout(gridBagLayout);

    grpFontes = new JTabbedPane(SwingConstants.TOP);
    GridBagConstraints gbc_grpFontes = new GridBagConstraints();
    gbc_grpFontes.insets = new Insets(0, 0, 5, 0);
    gbc_grpFontes.fill = GridBagConstraints.BOTH;
    gbc_grpFontes.gridx = 0;
    gbc_grpFontes.gridy = 0;
    getContentPane().add(grpFontes, gbc_grpFontes);

    tabCopybook = new JPanel();
    tabCopybook.setBackground(Color.WHITE);
    grpFontes.addTab(Language.tabCopy, null, tabCopybook, null);

    GridBagLayout gbl_tabCopybook = new GridBagLayout();
    gbl_tabCopybook.columnWidths = new int[] { 10, 1, 0, 349, 0, 0, 62, 28, 71, 0, 0, 0 };
    gbl_tabCopybook.rowHeights = new int[] { 1, 0, 0, 0 };
    gbl_tabCopybook.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            Double.MIN_VALUE };
    gbl_tabCopybook.rowWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE };
    tabCopybook.setLayout(gbl_tabCopybook);

    JLabel lblCopybook = new JLabel(Language.txtFilePds);
    GridBagConstraints gbc_lblCopybook = new GridBagConstraints();
    gbc_lblCopybook.anchor = GridBagConstraints.EAST;
    gbc_lblCopybook.insets = new Insets(0, 0, 5, 5);
    gbc_lblCopybook.gridx = 1;
    gbc_lblCopybook.gridy = 1;
    tabCopybook.add(lblCopybook, gbc_lblCopybook);

    txtPath = new JTextField();
    GridBagConstraints gbc_txtPath = new GridBagConstraints();
    gbc_txtPath.gridwidth = 4;
    gbc_txtPath.insets = new Insets(0, 0, 5, 5);
    gbc_txtPath.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtPath.gridx = 2;
    gbc_txtPath.gridy = 1;
    tabCopybook.add(txtPath, gbc_txtPath);
    txtPath.setColumns(10);

    JButton btnDiretorio = new JButton("");
    btnDiretorio.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/folder.png")));
    btnDiretorio.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            openDirectory();
        }
    });
    GridBagConstraints gbc_btnDiretorio = new GridBagConstraints();
    gbc_btnDiretorio.insets = new Insets(0, 0, 5, 5);
    gbc_btnDiretorio.gridx = 6;
    gbc_btnDiretorio.gridy = 1;
    tabCopybook.add(btnDiretorio, gbc_btnDiretorio);

    btnClearCopy = new JButton("");
    btnClearCopy.setEnabled(false);
    btnClearCopy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            tableCopy = new JTable();
            scrCopy.setViewportView(tableCopy);
            tableString = new JTable();
            scrTableString.setViewportView(tableString);

            btnExcelString.setEnabled(false);
            btnClearString.setEnabled(false);
            textAreaString.setText("");

            console.removeAllElements();
            btnExcel.setEnabled(false);
            btnClearCopy.setEnabled(false);
            grpFontes.setEnabledAt(1, false);

            tableFile = new JTable();
            scrFile.setViewportView(tableFile);
            btnExcelFile.setEnabled(false);
            btnClearFile.setEnabled(false);
            grpFontes.setEnabledAt(2, false);

        }
    });
    btnClearCopy.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png")));
    GridBagConstraints gbc_btnLimpar = new GridBagConstraints();
    gbc_btnLimpar.fill = GridBagConstraints.BOTH;
    gbc_btnLimpar.insets = new Insets(0, 0, 5, 5);
    gbc_btnLimpar.gridx = 9;
    gbc_btnLimpar.gridy = 1;
    tabCopybook.add(btnClearCopy, gbc_btnLimpar);

    JButton btnProcessarBook = new JButton("");
    btnProcessarBook.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            loadData();
            btnClearCopy.setEnabled(true);
            grpFontes.setEnabledAt(1, true);
            grpFontes.setEnabledAt(2, true);
        }
    });
    btnProcessarBook.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png")));
    GridBagConstraints gbc_btnProcessarBook = new GridBagConstraints();
    gbc_btnProcessarBook.fill = GridBagConstraints.VERTICAL;
    gbc_btnProcessarBook.insets = new Insets(0, 0, 5, 5);
    gbc_btnProcessarBook.gridx = 7;
    gbc_btnProcessarBook.gridy = 1;
    tabCopybook.add(btnProcessarBook, gbc_btnProcessarBook);

    btnExcel = new JButton("");
    btnExcel.setEnabled(false);
    btnExcel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            expExcelBook();
            // exportarExcelBook(tableCopy, txtPath.getText(),
            // "Horizontal");
        }
    });
    btnExcel.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png")));
    GridBagConstraints gbc_btnExcel = new GridBagConstraints();
    gbc_btnExcel.insets = new Insets(0, 0, 5, 5);
    gbc_btnExcel.gridx = 8;
    gbc_btnExcel.gridy = 1;
    tabCopybook.add(btnExcel, gbc_btnExcel);

    // JScrollPane scrCopy = new JScrollPane();
    gbc_scrCopy = new GridBagConstraints();
    gbc_scrCopy.gridwidth = 9;
    gbc_scrCopy.insets = new Insets(0, 0, 0, 5);
    gbc_scrCopy.fill = GridBagConstraints.BOTH;
    gbc_scrCopy.gridx = 1;
    gbc_scrCopy.gridy = 2;
    // tabCopybook.add(scrCopy, gbc_scrCopy);

    panelConsole = new Panel();
    GridBagConstraints gbc_panelConsole = new GridBagConstraints();
    gbc_panelConsole.insets = new Insets(0, 0, 5, 0);
    gbc_panelConsole.fill = GridBagConstraints.BOTH;
    gbc_panelConsole.gridx = 0;
    gbc_panelConsole.gridy = 1;
    getContentPane().add(panelConsole, gbc_panelConsole);
    panelConsole.setLayout(new BorderLayout(0, 0));

    listTerminal = new JList<String>();
    listTerminal.setFont(new Font("Courier New", Font.PLAIN, 11));
    listTerminal.setModel(console);

    scrConsole = new JScrollPane(listTerminal);
    panelConsole.add(scrConsole);

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnNewMenu = new JMenu(Language.menuParam);
    menuBar.add(mnNewMenu);

    JMenuItem mnItemUsuario = new JMenuItem(Language.menuParamUser);
    mnItemUsuario.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FrmUser frmUsuar = new FrmUser();
            frmUsuar.setLocationRelativeTo(null);
            frmUsuar.setVisible(true);
            setUser();
        }
    });
    mnNewMenu.add(mnItemUsuario);

    JMenuItem mnItemFtp = new JMenuItem(Language.menuParamFtp);
    mnItemFtp.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FrmFtp frmFtp = new FrmFtp();
            frmFtp.setLocationRelativeTo(null);
            frmFtp.setVisible(true);
            setFtp();
        }
    });

    mnNewMenu.add(mnItemFtp);

    JMenu mnAjuda = new JMenu(Language.menuHelp);
    menuBar.add(mnAjuda);

    JMenuItem mntmNewMenuItem = new JMenuItem(Language.menuHelpAbout);
    mntmNewMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            FrmAbout frmSobre = new FrmAbout();
            frmSobre.setLocationRelativeTo(null);
            frmSobre.setVisible(true);
        }
    });
    mnAjuda.add(mntmNewMenuItem);

    tabCopybook.setFont(new Font("Arial", Font.PLAIN, 12));
    tabCopybook.add(scrCopy, gbc_scrCopy);

    tabString = new JPanel();
    tabString.setFont(new Font("Arial", Font.PLAIN, 12));
    tabString.setBackground(Color.WHITE);
    grpFontes.addTab(Language.tabString, null, tabString, null);
    grpFontes.setEnabledAt(1, false);
    GridBagLayout gbl_tabString = new GridBagLayout();
    gbl_tabString.columnWidths = new int[] { 10, 1, 346, 349, 0, 0, 62, 28, 71, 0, 0, 0 };
    gbl_tabString.rowHeights = new int[] { 1, 0, 0, 17, 22, 0, 259, 0 };
    gbl_tabString.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            Double.MIN_VALUE };
    gbl_tabString.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE };
    tabString.setLayout(gbl_tabString);

    JLabel lblString = new JLabel("String:");
    GridBagConstraints gbc_lblString = new GridBagConstraints();
    gbc_lblString.anchor = GridBagConstraints.WEST;
    gbc_lblString.insets = new Insets(0, 0, 5, 5);
    gbc_lblString.gridx = 1;
    gbc_lblString.gridy = 1;
    tabString.add(lblString, gbc_lblString);

    textAreaString = new JTextArea();

    JScrollPane scrStringData = new JScrollPane(textAreaString);
    GridBagConstraints gbc_scrString = new GridBagConstraints();
    gbc_scrString.gridheight = 3;
    gbc_scrString.gridwidth = 8;
    gbc_scrString.insets = new Insets(0, 0, 5, 5);
    gbc_scrString.fill = GridBagConstraints.BOTH;
    gbc_scrString.gridx = 1;
    gbc_scrString.gridy = 2;
    tabString.add(scrStringData, gbc_scrString);

    btnClearString = new JButton("");
    btnClearString.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            scrTableString.setViewportView(tableString);
            btnExcelString.setEnabled(false);
            btnClearString.setEnabled(false);
            textAreaString.setText("");
            tableString = new JTable();
            scrTableString.setViewportView(tableString);
        }
    });

    btnExcelString = new JButton("");
    btnExcelString.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            expExcelString();
        }
    });

    JButton btnProcessarArq = new JButton("");
    btnProcessarArq.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            processString();
        }
    });
    btnProcessarArq.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png")));
    GridBagConstraints gbc_btnProcessarArq = new GridBagConstraints();
    gbc_btnProcessarArq.fill = GridBagConstraints.VERTICAL;
    gbc_btnProcessarArq.insets = new Insets(0, 0, 5, 5);
    gbc_btnProcessarArq.gridx = 9;
    gbc_btnProcessarArq.gridy = 2;
    tabString.add(btnProcessarArq, gbc_btnProcessarArq);
    btnExcelString.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png")));
    btnExcelString.setEnabled(false);
    GridBagConstraints gbc_btnExcelString = new GridBagConstraints();
    gbc_btnExcelString.fill = GridBagConstraints.VERTICAL;
    gbc_btnExcelString.insets = new Insets(0, 0, 5, 5);
    gbc_btnExcelString.gridx = 9;
    gbc_btnExcelString.gridy = 3;
    tabString.add(btnExcelString, gbc_btnExcelString);
    btnClearString.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png")));
    btnClearString.setEnabled(false);
    GridBagConstraints gbc_btnClearString = new GridBagConstraints();
    gbc_btnClearString.fill = GridBagConstraints.VERTICAL;
    gbc_btnClearString.insets = new Insets(0, 0, 5, 5);
    gbc_btnClearString.gridx = 9;
    gbc_btnClearString.gridy = 4;
    tabString.add(btnClearString, gbc_btnClearString);

    JLabel lblSaida = new JLabel(Language.txtOutput);
    GridBagConstraints gbc_lblSaida = new GridBagConstraints();
    gbc_lblSaida.insets = new Insets(0, 0, 5, 5);
    gbc_lblSaida.gridx = 1;
    gbc_lblSaida.gridy = 5;
    tabString.add(lblSaida, gbc_lblSaida);

    GridBagConstraints gbc_scrArquivo = new GridBagConstraints();
    gbc_scrArquivo.fill = GridBagConstraints.BOTH;
    gbc_scrArquivo.gridwidth = 9;
    gbc_scrArquivo.insets = new Insets(0, 0, 0, 5);
    gbc_scrArquivo.gridx = 1;
    gbc_scrArquivo.gridy = 6;
    tabString.add(scrTableString, gbc_scrArquivo);

    tabFile = new JPanel();
    tabFile.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
            // TODO Auto-generated method stub
            if (isProcessStarted) {
                int key = e.getKeyCode();
                if (key == KeyEvent.VK_ESCAPE) {
                    int opc = JOptionPane.showConfirmDialog(null, Language.msgCancelProcess, Language.msgInf,
                            JOptionPane.OK_CANCEL_OPTION);
                    if (opc == JOptionPane.OK_OPTION) {
                        escProcessFile();
                    }
                }
            }

        }

        @Override
        public void keyReleased(KeyEvent arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void keyTyped(KeyEvent arg0) {
            // TODO Auto-generated method stub

        }

    });

    tabFile.setFont(new Font("Arial", Font.PLAIN, 12));
    tabFile.setBackground(Color.WHITE);
    grpFontes.addTab(Language.tabFile, null, tabFile, null);
    grpFontes.setEnabledAt(2, false);
    GridBagLayout gbl_tabFile = new GridBagLayout();
    gbl_tabFile.columnWidths = new int[] { 10, 1, 49, 459, 0, 0, 62, 28, 0, 71, 0, 0, 0, 0 };
    gbl_tabFile.rowHeights = new int[] { 1, 0, 0, 17, 22, 0, 259, 0, 0 };
    gbl_tabFile.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            Double.MIN_VALUE };
    gbl_tabFile.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE };
    tabFile.setLayout(gbl_tabFile);

    JLabel lblFile = new JLabel(Language.txtFilePds);
    GridBagConstraints gbc_lblFile = new GridBagConstraints();
    gbc_lblFile.anchor = GridBagConstraints.EAST;
    gbc_lblFile.insets = new Insets(0, 0, 5, 5);
    gbc_lblFile.gridx = 1;
    gbc_lblFile.gridy = 1;
    tabFile.add(lblFile, gbc_lblFile);

    txtFile = new JTextField();
    txtFile.setColumns(10);
    GridBagConstraints gbc_txtFile = new GridBagConstraints();
    gbc_txtFile.gridwidth = 5;
    gbc_txtFile.insets = new Insets(0, 0, 5, 5);
    gbc_txtFile.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtFile.gridx = 2;
    gbc_txtFile.gridy = 1;
    tabFile.add(txtFile, gbc_txtFile);

    btnClearFile = new JButton("");
    btnClearFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {

            tableFile = new JTable();
            scrFile.setViewportView(tableFile);
            btnExcelFile.setEnabled(false);
            btnClearFile.setEnabled(false);
            progressBar.setStringPainted(true);
            progressBar.setValue(0);
            progressBar.setString("");

        }
    });

    btnExcelFile = new JButton("");
    btnExcelFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            expExcelFile();
        }
    });

    btnProcFile = new JButton("");
    btnProcFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            loadFile();
        }
    });

    btnDirFile = new JButton("");
    btnDirFile.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            openDirFile();
        }
    });
    btnDirFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/folder.png")));
    GridBagConstraints gbc_btnDirFile = new GridBagConstraints();
    gbc_btnDirFile.fill = GridBagConstraints.VERTICAL;
    gbc_btnDirFile.insets = new Insets(0, 0, 5, 5);
    gbc_btnDirFile.gridx = 7;
    gbc_btnDirFile.gridy = 1;
    tabFile.add(btnDirFile, gbc_btnDirFile);
    btnProcFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/engine.png")));
    GridBagConstraints gbc_btnProcFile = new GridBagConstraints();
    gbc_btnProcFile.fill = GridBagConstraints.VERTICAL;
    gbc_btnProcFile.insets = new Insets(0, 0, 5, 5);
    gbc_btnProcFile.gridx = 8;
    gbc_btnProcFile.gridy = 1;
    tabFile.add(btnProcFile, gbc_btnProcFile);
    btnExcelFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/excel.png")));
    btnExcelFile.setEnabled(false);
    GridBagConstraints gbc_btnExcelFile = new GridBagConstraints();
    gbc_btnExcelFile.insets = new Insets(0, 0, 5, 5);
    gbc_btnExcelFile.gridx = 9;
    gbc_btnExcelFile.gridy = 1;
    tabFile.add(btnExcelFile, gbc_btnExcelFile);
    btnClearFile.setIcon(new ImageIcon(FrmJInSync.class.getResource("/resources/cancel.png")));
    btnClearFile.setEnabled(false);
    GridBagConstraints gbc_btnLimparFile = new GridBagConstraints();
    gbc_btnLimparFile.fill = GridBagConstraints.VERTICAL;
    gbc_btnLimparFile.insets = new Insets(0, 0, 5, 5);
    gbc_btnLimparFile.gridx = 10;
    gbc_btnLimparFile.gridy = 1;
    tabFile.add(btnClearFile, gbc_btnLimparFile);

    JLabel lblTamanho = new JLabel(Language.txtFileLength);
    GridBagConstraints gbc_lblTamanho = new GridBagConstraints();
    gbc_lblTamanho.anchor = GridBagConstraints.WEST;
    gbc_lblTamanho.insets = new Insets(0, 0, 5, 5);
    gbc_lblTamanho.gridx = 1;
    gbc_lblTamanho.gridy = 2;
    tabFile.add(lblTamanho, gbc_lblTamanho);

    txtLength = new JTextField();
    GridBagConstraints gbc_txtTamanho = new GridBagConstraints();
    gbc_txtTamanho.fill = GridBagConstraints.HORIZONTAL;
    gbc_txtTamanho.insets = new Insets(0, 0, 5, 5);
    gbc_txtTamanho.gridx = 2;
    gbc_txtTamanho.gridy = 2;
    tabFile.add(txtLength, gbc_txtTamanho);
    txtLength.setColumns(10);

    JLabel label_1 = new JLabel(Language.txtOutput);
    GridBagConstraints gbc_label_1 = new GridBagConstraints();
    gbc_label_1.anchor = GridBagConstraints.WEST;
    gbc_label_1.insets = new Insets(0, 0, 5, 5);
    gbc_label_1.gridx = 1;
    gbc_label_1.gridy = 3;
    tabFile.add(label_1, gbc_label_1);

    GridBagConstraints gbc_scrFile = new GridBagConstraints();
    gbc_scrFile.gridheight = 3;
    gbc_scrFile.fill = GridBagConstraints.BOTH;
    gbc_scrFile.gridwidth = 10;
    gbc_scrFile.insets = new Insets(0, 0, 5, 5);
    gbc_scrFile.gridx = 1;
    gbc_scrFile.gridy = 4;
    tabFile.add(scrFile, gbc_scrFile);

    progressBar = new JProgressBar();
    GridBagConstraints gbc_progressBar = new GridBagConstraints();
    gbc_progressBar.fill = GridBagConstraints.HORIZONTAL;
    gbc_progressBar.gridwidth = 10;
    gbc_progressBar.insets = new Insets(0, 0, 0, 5);
    gbc_progressBar.gridx = 1;
    gbc_progressBar.gridy = 7;
    tabFile.add(progressBar, gbc_progressBar);

    JLabel lblNewLabel = new JLabel(Language.txtDeveloped + " Rodrigo Augusto Silva dos Santos - 2016");
    GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
    gbc_lblNewLabel.gridx = 0;
    gbc_lblNewLabel.gridy = 2;
    getContentPane().add(lblNewLabel, gbc_lblNewLabel);

    loadParameters();

}

From source file:statechum.analysis.learning.Visualiser.java

public void construct(Graph g, LayoutOptions options) {
    if (!globalConfig.isAssertEnabled()
            && Boolean.getBoolean(globalConfig.getProperty(G_PROPERTIES.ASSERT_ENABLED))) {
        System.err.println("Pass the -ea argument to JVM to enable assertions");
    }//  ww  w  .  j  a v a  2 s .  c om

    //
    if (Boolean.valueOf(GlobalConfiguration.getConfiguration()
            .getProperty(GlobalConfiguration.G_PROPERTIES.CLOSE_TERMINATE)))
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    else if (Boolean.valueOf(
            GlobalConfiguration.getConfiguration().getProperty(GlobalConfiguration.G_PROPERTIES.ESC_TERMINATE)))
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    else
        this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

    this.addWindowListener(new WindowEventHandler());
    /*
    this.addComponentListener(new ComponentListener() {
             
     @Override
     public void componentShown(@SuppressWarnings("unused") ComponentEvent e) {}
             
     @Override
     public void componentResized(@SuppressWarnings("unused") ComponentEvent e) {
    if (viewer != null) viewer.getModel().getGraphLayout().resize(getSize());
     }
             
     @Override
     public void componentMoved(@SuppressWarnings("unused") ComponentEvent e) {}
             
     @Override
     public void componentHidden(@SuppressWarnings("unused") ComponentEvent e) {}
    });*/
    this.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent arg0) {
            Action act = keyToActionMap.get(arg0.getKeyCode());
            if (act != null) {
                act.actionPerformed(null);
            }
        }

        @Override
        public void keyReleased(@SuppressWarnings("unused") KeyEvent arg0) {// this method is intentionally left blank - keypresses/releases are handled by the keyPressed method.
        }

        @Override
        public void keyTyped(@SuppressWarnings("unused") KeyEvent key) {// this method is intentionally left blank - keypresses/releases are handled by the keyPressed method.
        }
    });

    popupMenu = new JPopupMenu();
    // Icon loading is from http://www.javaworld.com/javaworld/javaqa/2000-06/03-qa-0616-icon.html
    Image icon = Toolkit.getDefaultToolkit()
            .getImage(GlobalConfiguration.getConfiguration().getProperty(G_PROPERTIES.RESOURCES)
                    + File.separator + "icon.jpg");
    if (icon != null) {
        setIconImage(icon);
    }

    setVisualiserKeyBindings();
    setStateChumKeyBindings(this, propName, keyToActionMap);
    updatePopupMenu(popupMenu, keyToActionMap);
    //getContentPane().removeAll();
    WindowPosition framePosition = globalConfig.loadFrame(propName);

    viewer = new VisualizationViewer(
            new DefaultVisualizationModel(
                    new XMLPersistingLayout(propName >= 0 ? new FRLayout(g) : new KKLayout(g))),
            constructRenderer(g, options));

    viewer.setBackground(Color.WHITE);
    final DefaultModalGraphMouse graphMouse = new XMLModalGraphMouse();
    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
    graphMouse.add(new PickingGraphMousePlugin());
    viewer.setGraphMouse(graphMouse);
    viewer.setPickSupport(new ShapePickSupport());
    viewer.addMouseListener(this);

    final GraphZoomScrollPane panel = new GraphZoomScrollPane(viewer);
    getContentPane().add(panel);
    pack();
    viewer.setPreferredSize(getSize());
    //viewer.getModel().getGraphLayout().initialize(getSize());

    restoreLayout(true, currentGraph);
    setBounds(framePosition.getRect());
    framesVisible.add(this);// register as an active frame.
    setVisible(true);
}

From source file:net.minelord.gui.panes.IRCPane.java

public void startClient(final String nick) {
    IRCLog = new ArrayList<String>();
    SwingUtilities.invokeLater(new Runnable() {
        @Override//w ww. j  a v  a  2s.  c  o m
        public void run() {
            text = new JEditorPane("text/html", "<HTML>");
            text.setEditable(false);
            kit = new HTMLEditorKit();
            text.setEditorKit(kit);
            client.connect("irc.liberty-unleashed.co.uk", "#moomoohk", nick, instance);
            scroller = new JScrollPane(text);
            text.setEditable(false);
            connect();
            scroller.setBounds(20, 20, 810, 250);
            add(scroller);
            input = new JTextField();
            input.setBounds(20, 270, 810, 30);
            Color bgColor = Color.gray.darker().darker();
            UIDefaults defaults = new UIDefaults();
            defaults.put("EditorPane[Enabled].backgroundPainter", bgColor);
            text.putClientProperty("Nimbus.Overrides", defaults);
            text.putClientProperty("Nimbus.Overrides.InheritDefaults", true);
            text.setBackground(bgColor);
            input.setBackground(Color.gray);
            input.setForeground(Color.gray.darker().darker().darker());
            input.setEnabled(false);
            text.addHyperlinkListener(new HyperlinkListener() {
                @Override
                public void hyperlinkUpdate(HyperlinkEvent event) {
                    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                        if (event.getDescription().charAt(0) == '#') {
                            String[] params = { event.getDescription() };
                            IRCCommand.getCommand("/join").execute(client, params);
                        } else
                            OSUtils.browse(event.getURL().toString());
                    }
                }
            });
            text.addFocusListener(new FocusListener() {

                @Override
                public void focusLost(FocusEvent paramFocusEvent) {
                }

                @Override
                public void focusGained(FocusEvent paramFocusEvent) {
                    input.requestFocus();
                }
            });
            scroller.setViewportView(text);
            add(input);
            input.addKeyListener(new KeyListener() {

                @Override
                public void keyTyped(KeyEvent arg0) {
                }

                @Override
                public void keyReleased(KeyEvent arg0) {
                    if (arg0.getKeyCode() == 10) {
                        if (input.getText().length() > 0) {
                            lastCommandSelector = lastCommands.size();
                            lastCommands.add(input.getText());
                        }
                        sendMessage(input.getText());
                        input.setText("");
                    }
                    if (arg0.getKeyCode() == 27)
                        input.setText("");
                    if (arg0.getKeyCode() == 17) {
                        int before = input.getText().length();
                        if (input.getText().charAt(0) == '/') {
                            input.setText(completeNick(input.getText()));
                            input.select(
                                    input.getText().length() - completeNick(input.getText()).length() + before,
                                    input.getText().length());
                        } else {
                            input.setText(completeCommand(input.getText()));
                            input.select(input.getText().length() - completeCommand(input.getText()).length()
                                    + before, input.getText().length());
                        }
                    }
                    if (arg0.getKeyCode() == 38)
                        if (lastCommandSelector > 0) {
                            lastCommandSelector--;
                            input.setText(lastCommands.get(lastCommandSelector));
                        }
                    if (arg0.getKeyCode() == 40)
                        if (lastCommandSelector < lastCommands.size()) {
                            lastCommandSelector++;
                            if (lastCommandSelector == lastCommands.size())
                                input.setText("");
                            if (lastCommandSelector < lastCommands.size())
                                input.setText(lastCommands.get(lastCommandSelector));
                            return;
                        }
                }

                @Override
                public void keyPressed(KeyEvent arg0) {
                }
            });
        }
    });
}

From source file:com.mirth.connect.client.ui.editors.filter.FilterPane.java

public void makeFilterTable() {
    filterTable = new MirthTable();

    filterTable.setModel(new DefaultTableModel(new String[] { "#", "Operator", "Name", "Type", "Data" }, 0) {

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            boolean[] canEdit;
            FilterRulePlugin plugin;/* w w  w .  j  av  a2 s  . co m*/
            try {
                plugin = getPlugin((String) filterTableModel.getValueAt(rowIndex, RULE_TYPE_COL));
                canEdit = new boolean[] { false, true, plugin.isNameEditable(), true, true };
            } catch (Exception e) {
                canEdit = new boolean[] { false, true, true, true, true };
            }
            return canEdit[columnIndex];
        }
    });

    filterTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

    filterTableModel = (DefaultTableModel) filterTable.getModel();

    filterTable.getColumnModel().getColumn(RULE_NAME_COL).setCellEditor(new EditorTableCellEditor(this));
    filterTable.setCustomEditorControls(true);

    // Set the combobox editor on the operator column, and add action
    // listener
    MirthComboBoxTableCellEditor comboBoxOp = new MirthComboBoxTableCellEditor(filterTable, comboBoxValues, 2,
            true, new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    modified = true;
                    updateOperations();
                }
            });

    // Set the combobox editor on the type column, and add action listener
    String[] defaultComboBoxValues = new String[LoadedExtensions.getInstance().getFilterRulePlugins().size()];
    FilterRulePlugin[] pluginArray = LoadedExtensions.getInstance().getFilterRulePlugins().values()
            .toArray(new FilterRulePlugin[0]);
    for (int i = 0; i < pluginArray.length; i++) {
        defaultComboBoxValues[i] = pluginArray[i].getPluginPointName();
    }

    MirthComboBoxTableCellEditor comboBoxType = new MirthComboBoxTableCellEditor(filterTable,
            defaultComboBoxValues, 2, true, new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent evt) {
                    if (filterTable.getEditingRow() != -1) {
                        int row = getSelectedRow();
                        String selectedType = ((JComboBox) evt.getSource()).getSelectedItem().toString();
                        String previousType = (String) filterTable.getValueAt(row, RULE_TYPE_COL);

                        if (selectedType.equalsIgnoreCase(previousType)) {
                            return;
                        }

                        modified = true;
                        FilterRulePlugin plugin;
                        try {
                            if (rulePanel.isModified() && !PlatformUI.MIRTH_FRAME.alertOption(
                                    PlatformUI.MIRTH_FRAME,
                                    "Are you sure you would like to change this filter rule and lose all of the current filter data?")) {
                                ((JComboBox) evt.getSource()).getModel().setSelectedItem(previousType);
                                return;
                            }

                            plugin = getPlugin(selectedType);
                            plugin.initData();
                            filterTableModel.setValueAt(plugin.getNewName(), row, RULE_NAME_COL);
                            rulePanel.showCard(selectedType);
                            updateTaskPane(selectedType);
                            updateCodePanel(selectedType);
                        } catch (Exception e) {
                            parent.alertThrowable(parent, e);
                        }

                    }
                }
            });

    filterTable.setSelectionMode(0); // only select one row at a time

    filterTable.getColumnExt(RULE_NUMBER_COL).setMaxWidth(UIConstants.MAX_WIDTH);
    filterTable.getColumnExt(RULE_OP_COL).setMaxWidth(UIConstants.MAX_WIDTH);

    filterTable.getColumnExt(RULE_NUMBER_COL).setPreferredWidth(30);
    filterTable.getColumnExt(RULE_OP_COL).setPreferredWidth(60);

    filterTable.getColumnExt(RULE_NUMBER_COL).setCellRenderer(new CenterCellRenderer());
    filterTable.getColumnExt(RULE_OP_COL).setCellEditor(comboBoxOp);
    filterTable.getColumnExt(RULE_OP_COL).setCellRenderer(new MirthComboBoxTableCellRenderer(comboBoxValues) {
        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            if (value instanceof String && value.equals("")) {
                value = null;
            } else if (value != null) {
                value = value.toString();
            }

            return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        }
    });

    filterTable.getColumnExt(RULE_TYPE_COL).setMaxWidth(UIConstants.MAX_WIDTH);
    filterTable.getColumnExt(RULE_TYPE_COL).setMinWidth(120);
    filterTable.getColumnExt(RULE_TYPE_COL).setPreferredWidth(120);
    filterTable.getColumnExt(RULE_TYPE_COL).setCellEditor(comboBoxType);
    filterTable.getColumnExt(RULE_TYPE_COL)
            .setCellRenderer(new MirthComboBoxTableCellRenderer(defaultComboBoxValues));

    filterTable.getColumnExt(RULE_DATA_COL).setVisible(false);

    filterTable.setRowHeight(UIConstants.ROW_HEIGHT);
    filterTable.packTable(UIConstants.COL_MARGIN);
    filterTable.setSortable(false);
    filterTable.setOpaque(true);
    filterTable.setRowSelectionAllowed(true);
    filterTable.setDragEnabled(false);
    filterTable.getTableHeader().setReorderingAllowed(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR);
        filterTable.setHighlighters(highlighter);
    }

    filterTable.setDropTarget(dropTarget);
    filterTablePane.setDropTarget(dropTarget);

    filterTable.setBorder(BorderFactory.createEmptyBorder());
    filterTablePane.setBorder(BorderFactory.createEmptyBorder());

    filterTablePane.setViewportView(filterTable);

    filterTable.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }

        public void mouseReleased(MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }
    });

    filterTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            if (!updating && !evt.getValueIsAdjusting()) {
                FilterListSelected(evt);
                updateCodePanel(null);
            }
        }
    });
    filterTable.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                deleteRule();
            }
        }

        public void keyReleased(KeyEvent e) {
        }

        public void keyTyped(KeyEvent e) {
        }
    });
}

From source file:com.mirth.connect.client.ui.editors.transformer.TransformerPane.java

public void makeTransformerTable() {
    transformerTable = new MirthTable();
    transformerTable.setBorder(BorderFactory.createEmptyBorder());

    // Data Column is hidden
    transformerTable.setModel(new DefaultTableModel(new String[] { "#", "Name", "Type", "Data" }, 0) {

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            boolean[] canEdit;
            TransformerStepPlugin plugin;
            try {
                plugin = getPlugin((String) transformerTableModel.getValueAt(rowIndex, STEP_TYPE_COL));
                canEdit = new boolean[] { false, plugin.isNameEditable(), true, true };
            } catch (Exception e) {
                canEdit = new boolean[] { false, false, true, true };
            }//from w w w .j a va2 s.c  om
            return canEdit[columnIndex];
        }
    });

    transformerTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

    transformerTableModel = (DefaultTableModel) transformerTable.getModel();

    transformerTable.getColumnModel().getColumn(STEP_NAME_COL).setCellEditor(new EditorTableCellEditor(this));
    transformerTable.setCustomEditorControls(true);

    // Set the combobox editor on the type column, and add action listener
    String[] defaultComboBoxValues = new String[LoadedExtensions.getInstance().getTransformerStepPlugins()
            .size()];
    TransformerStepPlugin[] pluginArray = LoadedExtensions.getInstance().getTransformerStepPlugins().values()
            .toArray(new TransformerStepPlugin[0]);
    for (int i = 0; i < pluginArray.length; i++) {
        defaultComboBoxValues[i] = pluginArray[i].getPluginPointName();
    }

    MirthComboBoxTableCellEditor comboBox = new MirthComboBoxTableCellEditor(transformerTable,
            defaultComboBoxValues, 2, true, new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent evt) {
                    if (transformerTable.getEditingRow() != -1) {
                        int row = getSelectedRow();
                        String selectedType = ((JComboBox) evt.getSource()).getSelectedItem().toString();
                        String previousType = (String) transformerTable.getValueAt(row, STEP_TYPE_COL);

                        if (selectedType.equalsIgnoreCase(previousType)) {
                            return;
                        }

                        modified = true;
                        invalidVar = false;
                        TransformerStepPlugin plugin = null;
                        try {

                            if (stepPanel.isModified() && !PlatformUI.MIRTH_FRAME.alertOption(
                                    PlatformUI.MIRTH_FRAME,
                                    "Are you sure you would like to change this transformer step and lose all of the current transformer data?")) {
                                ((JComboBox) evt.getSource()).getModel().setSelectedItem(previousType);
                                return;
                            }

                            plugin = getPlugin(selectedType);
                            plugin.initData();
                            transformerTableModel.setValueAt(plugin.getNewName(), row, STEP_NAME_COL);
                            stepPanel.showCard(selectedType);
                            updateTaskPane(selectedType);
                            updateCodePanel(selectedType);
                        } catch (Exception e) {
                            parent.alertThrowable(PlatformUI.MIRTH_FRAME, e);
                        }
                    }
                }
            });

    transformerTable.setSelectionMode(0); // only select one row at a time

    transformerTable.getColumnExt(STEP_NUMBER_COL).setMaxWidth(UIConstants.MAX_WIDTH);
    transformerTable.getColumnExt(STEP_TYPE_COL).setMaxWidth(UIConstants.MAX_WIDTH);
    transformerTable.getColumnExt(STEP_TYPE_COL).setMinWidth(120);

    transformerTable.getColumnExt(STEP_NUMBER_COL).setPreferredWidth(30);
    transformerTable.getColumnExt(STEP_TYPE_COL).setPreferredWidth(120);

    transformerTable.getColumnExt(STEP_NUMBER_COL).setCellRenderer(new CenterCellRenderer());
    transformerTable.getColumnExt(STEP_TYPE_COL).setCellEditor(comboBox);
    transformerTable.getColumnExt(STEP_TYPE_COL)
            .setCellRenderer(new MirthComboBoxTableCellRenderer(defaultComboBoxValues));

    transformerTable.getColumnExt(STEP_DATA_COL).setVisible(false);

    transformerTable.setRowHeight(UIConstants.ROW_HEIGHT);
    transformerTable.packTable(UIConstants.COL_MARGIN);
    transformerTable.setSortable(false);
    transformerTable.setOpaque(true);
    transformerTable.setRowSelectionAllowed(true);
    transformerTable.setDragEnabled(false);
    transformerTable.getTableHeader().setReorderingAllowed(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR);
        transformerTable.setHighlighters(highlighter);
    }

    transformerTable.setDropTarget(dropTarget);
    transformerTablePane.setDropTarget(dropTarget);

    transformerTable.setBorder(BorderFactory.createEmptyBorder());
    transformerTablePane.setBorder(BorderFactory.createEmptyBorder());
    transformerTablePane.setViewportView(transformerTable);

    // listen for mouse clicks on the actual table
    transformerTable.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }

        public void mouseReleased(MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }
    });

    transformerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            if (!updating && !evt.getValueIsAdjusting()) {
                TransformerListSelected(evt);
                updateCodePanel(null);
            }
        }
    });
    transformerTable.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                deleteStep();
            }
        }

        public void keyReleased(KeyEvent e) {
        }

        public void keyTyped(KeyEvent e) {
        }
    });
}

From source file:com.mirth.connect.client.ui.ChannelSetup.java

/**
 * Makes the destination table with a parameter that is true if a new destination should be
 * added as well.//from w ww  .  j a v a 2 s  .  co m
 */
public void makeDestinationTable(boolean addNew) {
    List<Connector> destinationConnectors;
    Object[][] tableData;
    int tableSize;

    destinationConnectors = currentChannel.getDestinationConnectors();
    tableSize = destinationConnectors.size();

    if (addNew) {
        tableSize++;
    }

    int chain = 1;

    tableData = new Object[tableSize][5];

    for (int i = 0; i < tableSize; i++) {
        if (tableSize - 1 == i && addNew) {
            Connector connector = makeNewConnector(true);

            // Set the default inbound and outbound dataType and properties
            String dataType = currentChannel.getSourceConnector().getTransformer().getOutboundDataType();
            // Use a different properties object for the inbound and outbound
            DataTypeProperties defaultInboundProperties = LoadedExtensions.getInstance().getDataTypePlugins()
                    .get(dataType).getDefaultProperties();
            DataTypeProperties defaultOutboundProperties = LoadedExtensions.getInstance().getDataTypePlugins()
                    .get(dataType).getDefaultProperties();
            DataTypeProperties defaultResponseInboundProperties = LoadedExtensions.getInstance()
                    .getDataTypePlugins().get(dataType).getDefaultProperties();
            DataTypeProperties defaultResponseOutboundProperties = LoadedExtensions.getInstance()
                    .getDataTypePlugins().get(dataType).getDefaultProperties();

            connector.getTransformer().setInboundDataType(dataType);
            connector.getTransformer().setInboundProperties(defaultInboundProperties);
            connector.getTransformer().setOutboundDataType(dataType);
            connector.getTransformer().setOutboundProperties(defaultOutboundProperties);
            connector.getResponseTransformer().setInboundDataType(dataType);
            connector.getResponseTransformer().setInboundProperties(defaultResponseInboundProperties);
            connector.getResponseTransformer().setOutboundDataType(dataType);
            connector.getResponseTransformer().setOutboundProperties(defaultResponseOutboundProperties);

            connector.setName(getNewDestinationName(tableSize));
            connector.setTransportName(DESTINATION_DEFAULT);

            // We need to add the destination first so that the metadata ID is initialized.
            currentChannel.addDestination(connector);

            if (connector.isEnabled()) {
                tableData[i][0] = new CellData(
                        new ImageIcon(
                                com.mirth.connect.client.ui.Frame.class.getResource("images/bullet_blue.png")),
                        UIConstants.ENABLED_STATUS);
            } else {
                tableData[i][0] = new CellData(
                        new ImageIcon(
                                com.mirth.connect.client.ui.Frame.class.getResource("images/bullet_black.png")),
                        UIConstants.DISABLED_STATUS);
            }
            tableData[i][1] = connector.getName();
            tableData[i][2] = connector.getMetaDataId();
            tableData[i][3] = new ConnectorTypeData(destinationConnectors.get(i).getTransportName());

            if (i > 0 && !connector.isWaitForPrevious()) {
                chain++;
            }

            tableData[i][4] = chain;
        } else {

            if (destinationConnectors.get(i).isEnabled()) {
                tableData[i][0] = new CellData(
                        new ImageIcon(
                                com.mirth.connect.client.ui.Frame.class.getResource("images/bullet_blue.png")),
                        UIConstants.ENABLED_STATUS);
            } else {
                tableData[i][0] = new CellData(
                        new ImageIcon(
                                com.mirth.connect.client.ui.Frame.class.getResource("images/bullet_black.png")),
                        UIConstants.DISABLED_STATUS);
            }
            tableData[i][1] = destinationConnectors.get(i).getName();
            tableData[i][2] = destinationConnectors.get(i).getMetaDataId();
            tableData[i][3] = new ConnectorTypeData(destinationConnectors.get(i).getTransportName());

            if (i > 0 && !destinationConnectors.get(i).isWaitForPrevious()) {
                chain++;
            }

            tableData[i][4] = chain;
        }
    }

    destinationTable = new MirthTable();

    destinationTable.setModel(new javax.swing.table.DefaultTableModel(tableData,
            new String[] { STATUS_COLUMN_NAME, DESTINATION_COLUMN_NAME, METADATA_COLUMN_NAME,
                    CONNECTOR_TYPE_COLUMN_NAME, DESTINATION_CHAIN_COLUMN_NAME }) {

        boolean[] canEdit = new boolean[] { false, true, false, false, false };

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        }
    });

    destinationTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

    // Set the custom cell editor for the Destination Name column.
    destinationTable.getColumnModel()
            .getColumn(destinationTable.getColumnModel().getColumnIndex(DESTINATION_COLUMN_NAME))
            .setCellEditor(new DestinationTableCellEditor());
    destinationTable.setCustomEditorControls(true);

    // Must set the maximum width on columns that should be packed.
    destinationTable.getColumnExt(STATUS_COLUMN_NAME).setMaxWidth(UIConstants.MAX_WIDTH);
    destinationTable.getColumnExt(STATUS_COLUMN_NAME).setMinWidth(UIConstants.MIN_WIDTH);

    // Set the cell renderer for the status column.
    destinationTable.getColumnExt(STATUS_COLUMN_NAME).setCellRenderer(new ImageCellRenderer());

    // Set the maximum width and cell renderer for the metadata ID column
    destinationTable.getColumnExt(METADATA_COLUMN_NAME).setMaxWidth(UIConstants.METADATA_ID_COLUMN_WIDTH);
    destinationTable.getColumnExt(METADATA_COLUMN_NAME).setMinWidth(UIConstants.METADATA_ID_COLUMN_WIDTH);
    destinationTable.getColumnExt(METADATA_COLUMN_NAME)
            .setCellRenderer(new NumberCellRenderer(SwingConstants.CENTER, false));

    // Set the cell renderer for the destination connector type
    destinationTable.getColumnExt(CONNECTOR_TYPE_COLUMN_NAME).setCellRenderer(new ConnectorTypeCellRenderer());

    // Set the cell renderer and the max width for the destination chain column
    destinationTable.getColumnExt(DESTINATION_CHAIN_COLUMN_NAME)
            .setCellRenderer(new NumberCellRenderer(SwingConstants.CENTER, false));
    destinationTable.getColumnExt(DESTINATION_CHAIN_COLUMN_NAME).setMaxWidth(50);

    destinationTable.setSelectionMode(0);
    destinationTable.setRowSelectionAllowed(true);
    destinationTable.setRowHeight(UIConstants.ROW_HEIGHT);
    destinationTable.setFocusable(true);
    destinationTable.setSortable(false);
    destinationTable.getTableHeader().setReorderingAllowed(false);

    destinationTable.setOpaque(true);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        Highlighter highlighter = HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR);
        destinationTable.setHighlighters(highlighter);
    }

    // This action is called when a new selection is made on the destination
    // table.
    destinationTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                if (lastModelIndex != -1 && lastModelIndex != destinationTable.getRowCount() && !isDeleting) {
                    Connector destinationConnector = currentChannel.getDestinationConnectors()
                            .get(lastModelIndex);

                    ConnectorProperties props = destinationConnectorPanel.getProperties();
                    ((DestinationConnectorPropertiesInterface) props).getDestinationConnectorProperties()
                            .setResourceIds(resourceIds.get(destinationConnector.getMetaDataId()));
                    destinationConnector.setProperties(props);
                }

                if (!loadConnector()) {
                    if (lastModelIndex == destinationTable.getRowCount()) {
                        destinationTable.setRowSelectionInterval(lastModelIndex - 1, lastModelIndex - 1);
                    } else {
                        destinationTable.setRowSelectionInterval(lastModelIndex, lastModelIndex);
                    }
                } else {
                    lastModelIndex = destinationTable.getSelectedModelIndex();
                }

                /*
                 * Loading the connector may have updated the current destination with incorrect
                 * properties, so after updating lastModelIndex we need to update the
                 * destination panel again.
                 */
                saveDestinationPanel();
                checkVisibleDestinationTasks();
            }
        }
    });

    destinationTable.requestFocus();

    // Mouse listener for trigger-button popup on the table.
    destinationTable.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mousePressed(java.awt.event.MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
            checkSelectionAndPopupMenu(evt);
        }
    });

    // Checks to see what to set the new row selection to based on
    // last index and if a new destination was added.
    int last = lastModelIndex;

    // Select each destination in turn so that the connector types can be decorated
    for (int row = 0; row < destinationTable.getRowCount(); row++) {
        destinationTable.setRowSelectionInterval(row, row);
        destinationConnectorPanel.decorateConnectorType();
    }

    if (addNew) {
        destinationTable.setRowSelectionInterval(destinationTable.getRowCount() - 1,
                destinationTable.getRowCount() - 1);
    } else if (last == -1) {
        destinationTable.setRowSelectionInterval(0, 0); // Makes sure the
    } // event is called
      // when the table is
      // created.
    else if (last == destinationTable.getRowCount()) {
        destinationTable.setRowSelectionInterval(last - 1, last - 1);
    } else {
        destinationTable.setRowSelectionInterval(last, last);
    }

    destinationTablePane.setViewportView(destinationTable);
    destinationTablePane.setWheelScrollingEnabled(true);

    // Key Listener trigger for DEL
    destinationTable.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_DELETE) {
                parent.doDeleteDestination();
            }
        }

        public void keyReleased(KeyEvent e) {
        }

        public void keyTyped(KeyEvent e) {
        }
    });

    destinationTable.addMouseWheelListener(new MouseWheelListener() {

        public void mouseWheelMoved(MouseWheelEvent e) {
            destinationTablePane.getMouseWheelListeners()[0].mouseWheelMoved(e);
        }
    });
}

From source file:ca.phon.ipamap.IpaMap.java

public void showSearchFrame(ActionEvent ae) {
    if (searchFrame == null) {
        searchFrame = new JFrame("IPA Map : Search");
        searchFrame.setAlwaysOnTop(true);
        searchFrame.setUndecorated(true);
        searchFrame.getRootPane().putClientProperty("Window.shadow", Boolean.FALSE);

        searchField = createSearchField();
        searchFrame.add(searchField);/*w  w  w.j av a2 s. c o  m*/

        searchField.getTextField().addKeyListener(new KeyListener() {

            @Override
            public void keyTyped(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                    searchFrame.setVisible(false);
                }
            }

            @Override
            public void keyReleased(KeyEvent e) {

            }

            @Override
            public void keyPressed(KeyEvent e) {
                if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                    searchFrame.setVisible(false);
                }
            }
        });
        searchField.getEndButton().addActionListener(evt -> {
            searchFrame.setVisible(false);
        });

        searchFrame.addWindowFocusListener(new WindowFocusListener() {

            @Override
            public void windowLostFocus(WindowEvent e) {
                searchFrame.setVisible(false);
            }

            @Override
            public void windowGainedFocus(WindowEvent e) {

            }
        });

    }

    final JComponent source = (JComponent) ae.getSource();
    searchFrame.setSize(source.getWidth(), source.getHeight());

    Point sourcePt = ((JComponent) ae.getSource()).getLocationOnScreen();
    searchFrame.setLocation(sourcePt.x, sourcePt.y);
    searchFrame.setVisible(true);

    searchFrame.requestFocus();
    searchField.getTextField().requestFocus();
}

From source file:com.rapidminer.gui.new_plotter.gui.ColorSchemeDialog.java

/**
 * @return//w  w w .  j a va2  s .  c  om
 */
private JPanel createColorCategoriesPanel() {
    JPanel categoryColorsConfigurationPanel = new JPanel(new GridBagLayout());
    categoryColorsConfigurationPanel.setPreferredSize(new Dimension(180, 200));

    GridBagConstraints itemConstraint = new GridBagConstraints();

    JLabel categoryColorsLabel = new ResourceLabel(
            "plotter.configuration_dialog.color_scheme_dialog.category_colors");
    {

        itemConstraint.fill = GridBagConstraints.HORIZONTAL;
        itemConstraint.anchor = GridBagConstraints.WEST;
        itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
        itemConstraint.insets = new Insets(0, 5, 5, 5);
        itemConstraint.weightx = 1.0;

        categoryColorsConfigurationPanel.add(categoryColorsLabel, itemConstraint);
    }

    // add button panel
    {
        JPanel buttonPanel = new JPanel(new GridBagLayout());

        // remove scheme button
        {
            removeCategoryColorButton = new JButton(new ResourceAction(true,
                    "plotter.configuration_dialog.color_scheme_dialog.remove_category_color_button") {

                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    removeSelectedColorAction();
                }

            });

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
            itemConstraint.fill = GridBagConstraints.NONE;

            buttonPanel.add(removeCategoryColorButton, itemConstraint);
        }

        {
            addCategoryButton = new JButton(new ResourceAction(true,
                    "plotter.configuration_dialog.color_scheme_dialog.add_category_color_button") {

                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    Color oldColor = Color.white;
                    Color newSchemeColor = createColorDialog(oldColor);
                    if (newSchemeColor != null && !newSchemeColor.equals(oldColor)) {
                        addColorAction(newSchemeColor);
                    }
                }

            });

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
            itemConstraint.fill = GridBagConstraints.NONE;

            buttonPanel.add(addCategoryButton, itemConstraint);

        }

        itemConstraint = new GridBagConstraints();
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        itemConstraint.fill = GridBagConstraints.NONE;
        itemConstraint.anchor = GridBagConstraints.EAST;
        itemConstraint.insets = new Insets(0, 5, 5, 5);

        categoryColorsConfigurationPanel.add(buttonPanel, itemConstraint);
    }

    {

        JPanel categoryListPanel = new JPanel(new GridBagLayout());

        // add list of categorie colors
        {

            colorList = new JList<Color>(nominalColorListModel);
            categoryColorsLabel.setLabelFor(colorList);
            colorList.setCellRenderer(new ColorListCellRenderer());
            colorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

            MouseAdapter ma = new MouseAdapter() {

                private void myPopupEvent(MouseEvent e) {
                    int x = e.getX();
                    int y = e.getY();
                    JList<?> list = (JList<?>) e.getSource();
                    list.setSelectedIndex(list.locationToIndex(e.getPoint()));
                    Color selectedColor = (Color) list.getSelectedValue();
                    if (selectedColor == null) {
                        return;
                    }

                    removeMenuItem.setEnabled(nominalColorListModel.getSize() > 2);

                    popupMenu.show(list, x, y);
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        myPopupEvent(e);
                    }
                }

                @Override
                public void mouseReleased(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        myPopupEvent(e);
                    }
                }
            };

            colorList.addMouseListener(ma);
            colorList.addKeyListener(new KeyListener() {

                @Override
                public void keyTyped(KeyEvent e) {
                    return; // Nothing to be done
                }

                @Override
                public void keyReleased(KeyEvent e) {
                    return; // Nothing to be done
                }

                @Override
                public void keyPressed(KeyEvent e) {
                    int key = e.getKeyCode();
                    if (key == KeyEvent.VK_DELETE) {
                        if (nominalColorListModel.getSize() > 2) {
                            removeSelectedColorAction();
                        }
                    }
                    if (key == KeyEvent.VK_F2) {
                        replaceSelectedColorAction();
                    }
                    if (key == KeyEvent.VK_UP && SwingTools.isControlOrMetaDown(e)) {
                        moveSelectedColorUpAction();
                    }
                    if (key == KeyEvent.VK_DOWN && SwingTools.isControlOrMetaDown(e)) {
                        moveSelectedColorDownAction();
                    }
                }
            });

            colorListScrollPane = new JScrollPane(colorList);
            colorListScrollPane.setPreferredSize(new Dimension(170, 200));
            colorListScrollPane.setMaximumSize(new Dimension(170, 200));
            colorListScrollPane.setMinimumSize(new Dimension(170, 180));
            colorListScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            colorListScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

            itemConstraint = new GridBagConstraints();
            itemConstraint.fill = GridBagConstraints.BOTH;
            itemConstraint.weightx = 0.0;
            itemConstraint.weighty = 0.5;
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;

            categoryListPanel.add(colorListScrollPane, itemConstraint);
        }

        // add up/down button panel
        {

            JPanel upAndDownButtonPanel = new JPanel(new GridBagLayout());

            // add up button
            {
                JButton upButton = new JButton(
                        new ResourceAction(true, "plotter.configuration_dialog.move_color_up") {

                            private static final long serialVersionUID = 1L;

                            @Override
                            public void actionPerformed(ActionEvent e) {
                                moveSelectedColorUpAction();
                            }
                        });

                itemConstraint = new GridBagConstraints();
                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.weightx = 0;
                itemConstraint.weighty = 0;
                itemConstraint.fill = GridBagConstraints.NONE;
                itemConstraint.insets = new Insets(0, 2, 0, 12);

                upAndDownButtonPanel.add(upButton, itemConstraint);
            }

            // add down button
            {
                JButton downButton = new JButton(
                        new ResourceAction(true, "plotter.configuration_dialog.move_color_down") {

                            private static final long serialVersionUID = 1L;

                            @Override
                            public void actionPerformed(ActionEvent e) {
                                moveSelectedColorDownAction();
                            }
                        });

                itemConstraint = new GridBagConstraints();
                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.weightx = 0;
                itemConstraint.weighty = 0;
                itemConstraint.fill = GridBagConstraints.NONE;
                itemConstraint.insets = new Insets(0, 2, 0, 12);

                upAndDownButtonPanel.add(downButton, itemConstraint);
            }

            // add spacer panel
            {
                JPanel spacer = new JPanel();

                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.weightx = 0;
                itemConstraint.weighty = 1;
                itemConstraint.fill = GridBagConstraints.VERTICAL;

                upAndDownButtonPanel.add(spacer, itemConstraint);

            }

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
            itemConstraint.weightx = 1;
            itemConstraint.weighty = 1;
            itemConstraint.fill = GridBagConstraints.VERTICAL;

            categoryListPanel.add(upAndDownButtonPanel, itemConstraint);

        }

        itemConstraint = new GridBagConstraints();
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        itemConstraint.weightx = 1;
        itemConstraint.weighty = 1;
        itemConstraint.fill = GridBagConstraints.BOTH;

        categoryColorsConfigurationPanel.add(categoryListPanel, itemConstraint);
    }

    return categoryColorsConfigurationPanel;
}

From source file:org.nuclos.client.wizard.steps.NuclosEntityAttributeCommonPropertiesStep.java

@Override
protected void initComponents() {
    double size[][] = { { 150, 20, TableLayout.FILL },
            { 20, 20, 20, 20, 20, 20, 20, 20, 90, TableLayout.FILL } };

    TableLayout layout = new TableLayout(size);
    layout.setVGap(3);//from w  w  w  .ja v  a2  s.  c  o m
    layout.setHGap(5);
    this.setLayout(layout);

    final LabeledComponentSupport support = new LabeledComponentSupport();

    lbLabel = new JLabel(
            SpringLocaleDelegate.getInstance().getMessage("wizard.step.attributeproperties.10", "Feldname")
                    + ": ");
    tfLabel = new JTextField();
    tfLabel.addFocusListener(NuclosWizardUtils.createWizardFocusAdapter());
    tfLabel.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.10", "Feldname"));

    lbDefaultValue = new JLabel(
            SpringLocaleDelegate.getInstance().getMessage("wizard.step.attributeproperties.11", "Standardwert")
                    + ": ");
    tfDefaultValue = new JTextField();
    tfDefaultValue.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.11", "Standardwert"));
    tfDefaultValue.addFocusListener(NuclosWizardUtils.createWizardFocusAdapter());

    cbxDefaultValue = new JComboBox();
    cbxDefaultValue.setVisible(false);
    cbxDefaultValue.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.11", "Standardwert"));

    lovDefaultValue = new ListOfValues();
    lovDefaultValue.setVisible(false);
    lovDefaultValue.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.11", "Standardwert"));

    dateDefaultValue = new DateChooser(support, true);
    dateDefaultValue.setVisible(false);
    dateDefaultValue.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.11", "Standardwert"));

    cbDefaultValue = new JCheckBox();
    cbDefaultValue.setVisible(false);
    cbDefaultValue.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.11", "Standardwert"));

    lbDistinct = new JLabel(
            SpringLocaleDelegate.getInstance().getMessage("wizard.step.attributeproperties.7", "Eindeutig")
                    + ": ");
    cbDistinct = new JCheckBox();
    cbDistinct.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.7", "Eindeutig"));

    lbLogBook = new JLabel(
            SpringLocaleDelegate.getInstance().getMessage("wizard.step.attributeproperties.8", "Logbuch")
                    + ": ");
    cbLogBook = new JCheckBox();
    cbLogBook.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.8", "Logbuch"));

    lbMandatory = new JLabel(
            SpringLocaleDelegate.getInstance().getMessage("wizard.step.attributeproperties.9", "Pflichtfeld")
                    + ": ");
    cbMandatory = new JCheckBox();
    cbMandatory.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.9", "Pflichtfeld"));

    tfMandatory = new JTextField();
    tfMandatory.addFocusListener(NuclosWizardUtils.createWizardFocusAdapter());
    tfMandatory.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.27", "Defaultwert fr Pflichtfeld"));

    cbxMandatory = new JComboBox();
    cbxMandatory.setVisible(false);
    cbxMandatory.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.27", "Defaultwert fr Pflichtfeld"));

    lovMandatory = new ListOfValues();
    lovMandatory.setVisible(false);
    lovMandatory.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.27", "Defaultwert fr Pflichtfeld"));

    dateMandatory = new DateChooser(support);
    dateMandatory.setVisible(false);
    dateMandatory.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.27", "Defaultwert fr Pflichtfeld"));

    cbMandatoryValue = new JCheckBox();
    cbMandatoryValue.setVisible(false);
    cbMandatoryValue.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.27", "Defaultwert fr Pflichtfeld"));

    lbDBFieldName = new JLabel(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.12", "DB-Spaltename"));
    tfDBFieldName = new JTextField();
    tfDBFieldName.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.12", "DB-Spaltename"));
    tfDBFieldName.addFocusListener(NuclosWizardUtils.createWizardFocusAdapter());

    lbDBFieldNameComplete = new JLabel(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.18", "Vollst\u00e4ndiger Spaltenname"));
    tfDBFieldNameComplete = new JTextField();
    tfDBFieldNameComplete.setEnabled(false);

    lbAttributeGroup = new JLabel(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.19", "Attributegruppe"));
    cbxAttributeGroup = new JComboBox();
    cbxAttributeGroup.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.19", "Attributegruppe"));

    lbCalcFunction = new JLabel(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.20", "Berechungsvorschrift"));
    cbxCalcFunction = new JComboBox();
    cbxCalcFunction.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.20", "Berechungsvorschrift"));

    lbCalculationScript = new JLabel(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.calculationscript.label", "Berechnungsausdruck"));
    lbCalculationScript.setToolTipText(SpringLocaleDelegate.getInstance().getMessage(
            "wizard.step.attributeproperties.calculationscript.description", "Berechnungsausdruck"));
    btCalculationScript = new JButton("...");
    btCalculationScript.setToolTipText(SpringLocaleDelegate.getInstance().getMessage(
            "wizard.step.attributeproperties.calculationscript.description", "Berechnungsausdruck"));
    btCalculationScript.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ScriptEditor editor = new ScriptEditor();
            if (getModel().getAttribute().getCalculationScript() != null) {
                editor.setScript(getModel().getAttribute().getCalculationScript());
            }
            editor.run();
            NuclosScript script = editor.getScript();
            if (org.nuclos.common2.StringUtils.isNullOrEmpty(script.getSource())) {
                script = null;
            }
            getModel().getAttribute().setCalculationScript(script);
        }
    });

    lbIndexed = new JLabel(
            SpringLocaleDelegate.getInstance().getMessage("wizard.step.attributeproperties.26", "Indiziert"));
    cbIndexed = new JCheckBox();
    cbIndexed.setToolTipText(SpringLocaleDelegate.getInstance()
            .getMessage("wizard.step.attributeproperties.tooltip.26", "Indiziert"));

    pnlMoreOptions = new JPanel();

    double sizeMoreOptions[][] = { { 150, TableLayout.FILL }, { 20, 20, 20, TableLayout.FILL } };

    TableLayout tlMoreOptions = new TableLayout(sizeMoreOptions);
    tlMoreOptions.setVGap(3);
    tlMoreOptions.setHGap(5);

    pnlMoreOptions.setLayout(tlMoreOptions);
    pnlMoreOptions.add(lbDBFieldName, "0,0");
    pnlMoreOptions.add(tfDBFieldName, "1,0");
    pnlMoreOptions.add(lbDBFieldNameComplete, "0,1");
    pnlMoreOptions.add(tfDBFieldNameComplete, "1,1");
    pnlMoreOptions.add(lbIndexed, "0,2");
    pnlMoreOptions.add(cbIndexed, "1,2");

    MoreOptionPanel optionPanel = new MoreOptionPanel(pnlMoreOptions);

    this.add(lbLabel, "0,0");
    this.add(tfLabel, "1,0 , 2,0");
    this.add(lbDefaultValue, "0,1");
    this.add(tfDefaultValue, "1,1 , 2,1");
    this.add(cbxDefaultValue, "1,1 , 2,1");
    this.add(lovDefaultValue, "1,1 , 2,1");
    this.add(dateDefaultValue, "1,1 , 2,1");
    this.add(cbDefaultValue, "1,1");
    this.add(lbDistinct, "0,2");
    this.add(cbDistinct, "1,2");
    this.add(lbLogBook, "0,3");
    this.add(cbLogBook, "1,3");
    this.add(lbMandatory, "0,4");
    this.add(cbMandatory, "1,4");
    this.add(tfMandatory, "2,4");
    this.add(cbxMandatory, "2,4");
    this.add(lovMandatory, "2,4");
    this.add(dateMandatory, "2,4");
    this.add(cbMandatoryValue, "2,4");

    this.add(lbAttributeGroup, "0,5");
    this.add(cbxAttributeGroup, "1,5 , 2,5");
    this.add(lbCalcFunction, "0,6");
    this.add(cbxCalcFunction, "1,6 , 2,6");
    this.add(lbCalculationScript, "0,7");
    this.add(btCalculationScript, "1,7");

    this.add(optionPanel, "0,8, 2,8");

    tfLabel.addKeyListener(new KeyListener() {

        @Override
        public void keyTyped(KeyEvent e) {
            doSomeWork();
        }

        @Override
        public void keyReleased(KeyEvent e) {
            doSomeWork();
        }

        @Override
        public void keyPressed(KeyEvent e) {
            doSomeWork();
        }

        protected void doSomeWork() {
            blnLabelModified = true;
        }

    });

    tfLabel.setDocument(new SpecialCharacterDocument());
    tfLabel.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        protected void doSomeWork(DocumentEvent e) {
            int size = e.getDocument().getLength();
            if (size > 0) {
                NuclosEntityAttributeCommonPropertiesStep.this.setComplete(true);
            } else {
                NuclosEntityAttributeCommonPropertiesStep.this.setComplete(false);
            }
            try {
                NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute()
                        .setInternalName(e.getDocument().getText(0, e.getDocument().getLength()));
                if (!NuclosEntityAttributeCommonPropertiesStep.this.getModel().isEditMode()) {
                    String sPrefix = Attribute.getDBPrefix(
                            NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute());
                    tfDBFieldName.setText(sPrefix + e.getDocument().getText(0, e.getDocument().getLength()));
                }

            } catch (BadLocationException ex) {
                Errors.getInstance().showExceptionDialog(NuclosEntityAttributeCommonPropertiesStep.this, ex);
            }
        }
    });

    tfDefaultValue.getDocument().addDocumentListener(new DefaultValueDocumentListener());

    tfMandatory.getDocument().addDocumentListener(new MandatoryValueDocumentListener());
    tfMandatory.setLocale(SpringLocaleDelegate.getInstance().getLocale());

    tfDBFieldName.setDocument(new LimitCharacterDocument());
    tfDBFieldName.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        protected void doSomeWork(DocumentEvent e) {
            try {
                NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute()
                        .setDbName(e.getDocument().getText(0, e.getDocument().getLength()));

                String s = e.getDocument().getText(0, e.getDocument().getLength());
                if (getModel().getAttribute().getMetaVO() != null
                        && getModel().getAttribute().getField() != null) {
                    s = "STRVALUE_" + s;
                } else if (getModel().getAttribute().getMetaVO() != null
                        && getModel().getAttribute().getField() == null) {
                    s = "INTID_" + s;
                }
                tfDBFieldNameComplete.setText(s);

            } catch (BadLocationException ex) {
                Errors.getInstance().showExceptionDialog(NuclosEntityAttributeCommonPropertiesStep.this, ex);
            }
        }
    });

    cbDistinct.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            final JCheckBox cb = (JCheckBox) e.getItem();
            NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute()
                    .setDistinct(cb.isSelected());
            if (!cb.isSelected()) {
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        cbMandatory.setEnabled(true);
                    }
                });
            }
        }
    });

    cbLogBook.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            JCheckBox cb = (JCheckBox) e.getItem();
            NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute()
                    .setLogBook(cb.isSelected());
        }
    });

    cbMandatory.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            final JCheckBox cb = (JCheckBox) e.getItem();
            NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute()
                    .setMandatory(cb.isSelected());
            if (NuclosEntityAttributeCommonPropertiesStep.this.parentWizardModel.isEditMode() && cb.isSelected()
                    && !parentWizardModel.isVirtual()) {
                if (NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute()
                        .getMandatoryValue() == null) {
                    (new Bubble(cb,
                            SpringLocaleDelegate.getInstance().getMessage(
                                    "wizard.step.attributeproperties.tooltip.28",
                                    "Bitte tragen Sie einen Wert ein mit dem das Feld vorbelegt werden kann!"),
                            3, Position.UPPER)).setVisible(true);
                }

            }
        }
    });

    cbIndexed.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            JCheckBox cb = (JCheckBox) e.getItem();
            NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute()
                    .setIndexed(cb.isSelected());
        }
    });

    cbxDefaultValue.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                getModel().getAttribute().setIdDefaultValue((DefaultValue) e.getItem());
            }
        }
    });

    cbxMandatory.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                getModel().getAttribute().setMandatoryValue(((DefaultValue) e.getItem()).getId());
            }
        }
    });

    dateDefaultValue.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            doSomeWork(e);
        }

        protected void doSomeWork(DocumentEvent e) {
            try {
                String value = e.getDocument().getText(0, e.getDocument().getLength());
                if ("Heute".equalsIgnoreCase(value)) {
                    value = RelativeDate.today().toString();
                }
                NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute().setDefaultValue(value);
            } catch (BadLocationException ex) {
                Errors.getInstance().showExceptionDialog(NuclosEntityAttributeCommonPropertiesStep.this, ex);
            }
        }

    });

    cbDefaultValue.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            JCheckBox cb = (JCheckBox) e.getItem();
            if (cb.isSelected()) {
                NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute().setDefaultValue("ja");
            } else {
                NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute()
                        .setDefaultValue("nein");
            }
        }
    });

    cbMandatoryValue.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            JCheckBox cb = (JCheckBox) e.getItem();
            if (cb.isSelected()) {
                NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute()
                        .setMandatoryValue(Boolean.TRUE);
            } else {
                NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute()
                        .setMandatoryValue(Boolean.FALSE);
            }
        }
    });

    cbxAttributeGroup.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute()
                        .setAttributeGroup((String) e.getItem());
                NuclosEntityAttributeCommonPropertiesStep.this.setComplete(true);
            }
        }
    });

    cbxCalcFunction.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                NuclosEntityAttributeCommonPropertiesStep.this.getModel().getAttribute()
                        .setCalcFunction((String) e.getItem());
            }
        }
    });

}