Example usage for javax.swing BorderFactory createEtchedBorder

List of usage examples for javax.swing BorderFactory createEtchedBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createEtchedBorder.

Prototype

public static Border createEtchedBorder() 

Source Link

Document

Creates a border with an "etched" look using the component's current background color for highlighting and shading.

Usage

From source file:jp.massbank.spectrumsearch.SearchPage.java

/**
 * ?//from   w  w w . j a va2s.  c  o m
 */
private void createWindow() {

    // ??
    ToolTipManager ttm = ToolTipManager.sharedInstance();
    ttm.setInitialDelay(50);
    ttm.setDismissDelay(8000);

    // Search?
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(),
            new EmptyBorder(1, 1, 1, 1));
    mainPanel.setBorder(border);

    // *********************************************************************
    // User File Query
    // *********************************************************************
    DefaultTableModel fileDm = new DefaultTableModel();
    fileSorter = new TableSorter(fileDm, TABLE_QUERY_FILE);
    queryFileTable = new JTable(fileSorter) {
        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    queryFileTable.addMouseListener(new TblMouseListener());
    fileSorter.setTableHeader(queryFileTable.getTableHeader());
    queryFileTable.setRowSelectionAllowed(true);
    queryFileTable.setColumnSelectionAllowed(false);
    queryFileTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col = { COL_LABEL_NO, COL_LABEL_NAME, COL_LABEL_ID };
    ((DefaultTableModel) fileSorter.getTableModel()).setColumnIdentifiers(col);
    (queryFileTable.getColumn(queryFileTable.getColumnName(0))).setPreferredWidth(44);
    (queryFileTable.getColumn(queryFileTable.getColumnName(1))).setPreferredWidth(LEFT_PANEL_WIDTH - 44);
    (queryFileTable.getColumn(queryFileTable.getColumnName(2))).setPreferredWidth(70);

    ListSelectionModel lm = queryFileTable.getSelectionModel();
    lm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lm.addListSelectionListener(new LmFileListener());
    queryFilePane = new JScrollPane(queryFileTable);
    queryFilePane.addMouseListener(new PaneMouseListener());
    queryFilePane.setPreferredSize(new Dimension(300, 300));

    // *********************************************************************
    // Result
    // *********************************************************************
    DefaultTableModel resultDm = new DefaultTableModel();
    resultSorter = new TableSorter(resultDm, TABLE_RESULT);
    resultTable = new JTable(resultSorter) {
        @Override
        public String getToolTipText(MouseEvent me) {
            //            super.getToolTipText(me);
            // ?????
            Point pt = me.getPoint();
            int row = rowAtPoint(pt);
            if (row < 0) {
                return null;
            } else {
                int nameCol = getColumnModel().getColumnIndex(COL_LABEL_NAME);
                return " " + getValueAt(row, nameCol) + " ";
            }
        }

        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    resultTable.addMouseListener(new TblMouseListener());
    resultSorter.setTableHeader(resultTable.getTableHeader());

    JPanel dbPanel = new JPanel();
    dbPanel.setLayout(new BorderLayout());
    resultPane = new JScrollPane(resultTable);
    resultPane.addMouseListener(new PaneMouseListener());

    resultTable.setRowSelectionAllowed(true);
    resultTable.setColumnSelectionAllowed(false);
    resultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col2 = { COL_LABEL_NAME, COL_LABEL_SCORE, COL_LABEL_HIT, COL_LABEL_ID, COL_LABEL_ION,
            COL_LABEL_CONTRIBUTOR, COL_LABEL_NO };

    resultDm.setColumnIdentifiers(col2);
    (resultTable.getColumn(resultTable.getColumnName(0))).setPreferredWidth(LEFT_PANEL_WIDTH - 180);
    (resultTable.getColumn(resultTable.getColumnName(1))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(2))).setPreferredWidth(20);
    (resultTable.getColumn(resultTable.getColumnName(3))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(4))).setPreferredWidth(20);
    (resultTable.getColumn(resultTable.getColumnName(5))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(6))).setPreferredWidth(50);

    ListSelectionModel lm2 = resultTable.getSelectionModel();
    lm2.addListSelectionListener(new LmResultListener());

    resultPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, 200));
    dbPanel.add(resultPane, BorderLayout.CENTER);

    // *********************************************************************
    // DB Query
    // *********************************************************************
    DefaultTableModel dbDm = new DefaultTableModel();
    querySorter = new TableSorter(dbDm, TABLE_QUERY_DB);
    queryDbTable = new JTable(querySorter) {
        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    queryDbTable.addMouseListener(new TblMouseListener());
    querySorter.setTableHeader(queryDbTable.getTableHeader());
    queryDbPane = new JScrollPane(queryDbTable);
    queryDbPane.addMouseListener(new PaneMouseListener());

    int h = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
    queryDbPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, h));
    queryDbTable.setRowSelectionAllowed(true);
    queryDbTable.setColumnSelectionAllowed(false);
    queryDbTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col3 = { COL_LABEL_ID, COL_LABEL_NAME, COL_LABEL_CONTRIBUTOR, COL_LABEL_NO };
    DefaultTableModel model = (DefaultTableModel) querySorter.getTableModel();
    model.setColumnIdentifiers(col3);

    // 
    queryDbTable.getColumn(queryDbTable.getColumnName(0)).setPreferredWidth(70);
    queryDbTable.getColumn(queryDbTable.getColumnName(1)).setPreferredWidth(LEFT_PANEL_WIDTH - 70);
    queryDbTable.getColumn(queryDbTable.getColumnName(2)).setPreferredWidth(70);
    queryDbTable.getColumn(queryDbTable.getColumnName(3)).setPreferredWidth(50);

    ListSelectionModel lm3 = queryDbTable.getSelectionModel();
    lm3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lm3.addListSelectionListener(new LmQueryDbListener());

    // ?
    JPanel btnPanel = new JPanel();
    btnName.addActionListener(new BtnSearchNameListener());
    btnAll.addActionListener(new BtnAllListener());
    btnPanel.add(btnName);
    btnPanel.add(btnAll);

    parentPanel2 = new JPanel();
    parentPanel2.setLayout(new BoxLayout(parentPanel2, BoxLayout.PAGE_AXIS));
    parentPanel2.add(btnPanel);
    parentPanel2.add(queryDbPane);

    // ?
    JPanel dispModePanel = new JPanel();
    isDispSelected = dispSelected.isSelected();
    isDispRelated = dispRelated.isSelected();
    if (isDispSelected) {
        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    } else if (isDispRelated) {
        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
    Object[] retRadio = new Object[] { dispSelected, dispRelated };
    for (int i = 0; i < retRadio.length; i++) {
        ((JRadioButton) retRadio[i]).addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if (isDispSelected != dispSelected.isSelected() || isDispRelated != dispRelated.isSelected()) {

                    isDispSelected = dispSelected.isSelected();
                    isDispRelated = dispRelated.isSelected();

                    // ??
                    resultTable.clearSelection();
                    resultPlot.clear();
                    compPlot.setPeaks(null, 1);
                    resultPlot.setPeaks(null, 0);
                    setAllPlotAreaRange();
                    pkgView.initResultRecInfo();

                    if (isDispSelected) {
                        resultTable.getSelectionModel()
                                .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
                    } else if (isDispRelated) {
                        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                    }
                }
            }
        });
    }
    ButtonGroup disGroup = new ButtonGroup();
    disGroup.add(dispSelected);
    disGroup.add(dispRelated);
    dispModePanel.add(lbl2);
    dispModePanel.add(dispSelected);
    dispModePanel.add(dispRelated);

    JPanel paramPanel = new JPanel();
    paramPanel.add(etcPropertyButton);
    etcPropertyButton.setMargin(new Insets(0, 10, 0, 10));
    etcPropertyButton.addActionListener(new ActionListener() {
        private ParameterSetWindow ps = null;

        public void actionPerformed(ActionEvent e) {
            // ??????????
            if (!isSubWindow) {
                ps = new ParameterSetWindow(getParentFrame());
            } else {
                ps.requestFocus();
            }
        }
    });

    JPanel optionPanel = new JPanel();
    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
    optionPanel.add(dispModePanel);
    optionPanel.add(paramPanel);

    // PackageView?????
    pkgView = new PackageViewPanel();
    pkgView.initAllRecInfo();

    queryTabPane.addTab("DB", parentPanel2);
    queryTabPane.setToolTipTextAt(TAB_ORDER_DB, "Query from DB.");
    queryTabPane.addTab("File", queryFilePane);
    queryTabPane.setToolTipTextAt(TAB_ORDER_FILE, "Query from user file.");
    queryTabPane.setSelectedIndex(TAB_ORDER_DB);
    queryTabPane.setFocusable(false);
    queryTabPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {

            // ?
            queryPlot.clear();
            compPlot.clear();
            resultPlot.clear();
            queryPlot.setPeaks(null, 0);
            compPlot.setPeaks(null, 1);
            resultPlot.setPeaks(null, 0);

            // PackageView?
            pkgView.initAllRecInfo();

            // DB Hit?
            if (resultTabPane.getTabCount() > 0) {
                resultTabPane.setSelectedIndex(0);
            }
            DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel();
            dataModel.setRowCount(0);
            hitLabel.setText(" ");

            // DB?User File??????
            queryTabPane.update(queryTabPane.getGraphics());
            if (queryTabPane.getSelectedIndex() == TAB_ORDER_DB) {
                parentPanel2.update(parentPanel2.getGraphics());
                updateSelectQueryTable(queryDbTable);
            } else if (queryTabPane.getSelectedIndex() == TAB_ORDER_FILE) {
                queryFilePane.update(queryFilePane.getGraphics());
                updateSelectQueryTable(queryFileTable);
            }
        }
    });

    //       
    JPanel queryPanel = new JPanel();
    queryPanel.setLayout(new BorderLayout());
    queryPanel.add(queryTabPane, BorderLayout.CENTER);
    queryPanel.add(optionPanel, BorderLayout.SOUTH);
    queryPanel.setMinimumSize(new Dimension(0, 170));

    JPanel jtp2Panel = new JPanel();
    jtp2Panel.setLayout(new BorderLayout());
    jtp2Panel.add(dbPanel, BorderLayout.CENTER);
    jtp2Panel.add(hitLabel, BorderLayout.SOUTH);
    jtp2Panel.setMinimumSize(new Dimension(0, 70));
    Color colorGreen = new Color(0, 128, 0);
    hitLabel.setForeground(colorGreen);

    resultTabPane.addTab("Result", jtp2Panel);
    resultTabPane.setToolTipTextAt(TAB_RESULT_DB, "Result of DB hit.");
    resultTabPane.setFocusable(false);

    queryPlot.setMinimumSize(new Dimension(0, 100));
    compPlot.setMinimumSize(new Dimension(0, 120));
    resultPlot.setMinimumSize(new Dimension(0, 100));
    int height = initAppletHight / 3;
    JSplitPane jsp_cmp2db = new JSplitPane(JSplitPane.VERTICAL_SPLIT, compPlot, resultPlot);
    JSplitPane jsp_qry2cmp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPlot, jsp_cmp2db);
    jsp_cmp2db.setDividerLocation(height);
    jsp_qry2cmp.setDividerLocation(height - 25);
    jsp_qry2cmp.setMinimumSize(new Dimension(190, 0));

    viewTabPane.addTab("Compare View", jsp_qry2cmp);
    viewTabPane.addTab("Package View", pkgView);
    viewTabPane.setToolTipTextAt(TAB_VIEW_COMPARE, "Comparison of query and result spectrum.");
    viewTabPane.setToolTipTextAt(TAB_VIEW_PACKAGE, "Package comparison of query and result spectrum.");
    viewTabPane.setSelectedIndex(TAB_VIEW_COMPARE);
    viewTabPane.setFocusable(false);

    JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPanel, resultTabPane);
    jsp.setDividerLocation(310);
    jsp.setMinimumSize(new Dimension(180, 0));
    jsp.setOneTouchExpandable(true);

    JSplitPane jsp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jsp, viewTabPane);
    int divideSize = (int) (initAppletWidth * 0.4);
    divideSize = (divideSize >= 180) ? divideSize : 180;
    jsp2.setDividerLocation(divideSize);
    jsp2.setOneTouchExpandable(true);

    mainPanel.add(jsp2, BorderLayout.CENTER);
    add(mainPanel);

    queryPlot.setSearchPage(this);
    compPlot.setSearchPage(this);
    resultPlot.setSearchPage(this);

    setJMenuBar(MenuBarGenerator.generateMenuBar(this));
}

From source file:it.staiger.jmeter.protocol.http.config.gui.DynamicFilePanel.java

/**
 * Create a panel containing the source files Mime-Type and relative path.
 *
 * @return a panel containing the source files parameters.
 *///from   w  w w. j ava2 s  .com
private JPanel getImportInfo() {
    JPanel panel = new HorizontalPanel();
    panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Source:")); // $NON-NLS-1$

    attachmentsCT = new JTextField(10);
    folder = new JTextField(10);
    folder.setToolTipText("leave Empty for relative path to ${base.dir}");// $NON-NLS-1$
    browseFolder = new JButton("Browse"); // $NON-NLS-1$
    browseFolder.setActionCommand(BROWSE_IMPORT_PATH);
    browseFolder.addActionListener(this);

    panel.add(StaigerUtils.getInputPanel("MIME Type:", attachmentsCT));// $NON-NLS-1$
    panel.add(StaigerUtils.getInputPanel("set Path Relative to:", folder, browseFolder));// $NON-NLS-1$

    return panel;
}

From source file:com.mirth.connect.connectors.file.FileWriter.java

private void initComponents() {
    schemeLabel = new JLabel();
    schemeLabel.setText("Method:");
    schemeComboBox = new MirthComboBox();
    schemeComboBox.setModel(new DefaultComboBoxModel(new String[] { "file", "ftp", "sftp", "smb", "webdav" }));
    schemeComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            schemeComboBoxActionPerformed(evt);
        }//w w  w . jav a  2 s.  co  m
    });

    testConnectionButton = new JButton();
    testConnectionButton.setText("Test Write");
    testConnectionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            testConnectionActionPerformed(evt);
        }
    });

    advancedSettingsButton = new JButton(new ImageIcon(Frame.class.getResource("images/wrench.png")));
    advancedSettingsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            advancedFileSettingsActionPerformed();
        }
    });

    summaryLabel = new JLabel("Advanced Options:");
    summaryField = new JLabel("");

    directoryLabel = new JLabel();
    directoryLabel.setText("Directory:");
    directoryField = new MirthTextField();

    hostLabel = new JLabel();
    hostLabel.setText("ftp://");
    hostField = new MirthTextField();
    pathLabel = new JLabel();
    pathLabel.setText("/");
    pathField = new MirthTextField();

    fileNameLabel = new JLabel();
    fileNameLabel.setText("File Name:");

    fileNameField = new MirthTextField();

    anonymousLabel = new JLabel();
    anonymousLabel.setText("Anonymous:");

    anonymousYesRadio = new MirthRadioButton();
    anonymousYesRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    anonymousYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    anonymousYesRadio.setText("Yes");
    anonymousYesRadio.setMargin(new Insets(0, 0, 0, 0));
    anonymousYesRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            anonymousYesActionPerformed(evt);
        }
    });

    anonymousNoRadio = new MirthRadioButton();
    anonymousNoRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    anonymousNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    anonymousNoRadio.setSelected(true);
    anonymousNoRadio.setText("No");
    anonymousNoRadio.setMargin(new Insets(0, 0, 0, 0));
    anonymousNoRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            anonymousNoActionPerformed(evt);
        }
    });

    anonymousButtonGroup = new ButtonGroup();
    anonymousButtonGroup.add(anonymousYesRadio);
    anonymousButtonGroup.add(anonymousNoRadio);

    usernameLabel = new JLabel();
    usernameLabel.setText("Username:");
    usernameField = new MirthTextField();

    passwordLabel = new JLabel();
    passwordLabel.setText("Password:");
    passwordField = new MirthPasswordField();

    timeoutLabel = new JLabel();
    timeoutLabel.setText("Timeout (ms):");
    timeoutField = new MirthTextField();

    secureModeLabel = new JLabel();
    secureModeLabel.setText("Secure Mode:");

    secureModeYesRadio = new MirthRadioButton();
    secureModeYesRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    secureModeYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    secureModeYesRadio.setText("Yes");
    secureModeYesRadio.setMargin(new Insets(0, 0, 0, 0));
    secureModeYesRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            secureModeYesActionPerformed(evt);
        }
    });

    secureModeNoRadio = new MirthRadioButton();
    secureModeNoRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    secureModeNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    secureModeNoRadio.setSelected(true);
    secureModeNoRadio.setText("No");
    secureModeNoRadio.setMargin(new Insets(0, 0, 0, 0));
    secureModeNoRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            secureModeNoActionPerformed(evt);
        }
    });

    secureModeButtonGroup = new ButtonGroup();
    secureModeButtonGroup.add(secureModeYesRadio);
    secureModeButtonGroup.add(secureModeNoRadio);

    passiveModeLabel = new JLabel();
    passiveModeLabel.setText("Passive Mode:");

    passiveModeYesRadio = new MirthRadioButton();
    passiveModeYesRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    passiveModeYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    passiveModeYesRadio.setText("Yes");
    passiveModeYesRadio.setMargin(new Insets(0, 0, 0, 0));

    passiveModeNoRadio = new MirthRadioButton();
    passiveModeNoRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    passiveModeNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    passiveModeNoRadio.setSelected(true);
    passiveModeNoRadio.setText("No");
    passiveModeNoRadio.setMargin(new Insets(0, 0, 0, 0));

    passiveModeButtonGroup = new ButtonGroup();
    passiveModeButtonGroup.add(passiveModeYesRadio);
    passiveModeButtonGroup.add(passiveModeNoRadio);

    validateConnectionLabel = new JLabel();
    validateConnectionLabel.setText("Validate Connection:");

    validateConnectionYesRadio = new MirthRadioButton();
    validateConnectionYesRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    validateConnectionYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    validateConnectionYesRadio.setText("Yes");
    validateConnectionYesRadio.setMargin(new Insets(0, 0, 0, 0));

    validateConnectionNoRadio = new MirthRadioButton();
    validateConnectionNoRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    validateConnectionNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    validateConnectionNoRadio.setText("No");
    validateConnectionNoRadio.setMargin(new Insets(0, 0, 0, 0));

    validateConnectionButtonGroup = new ButtonGroup();
    validateConnectionButtonGroup.add(validateConnectionYesRadio);
    validateConnectionButtonGroup.add(validateConnectionNoRadio);

    fileExistsLabel = new JLabel();
    fileExistsLabel.setText("File Exists:");

    fileExistsAppendRadio = new MirthRadioButton();
    fileExistsAppendRadio.setBackground(new java.awt.Color(255, 255, 255));
    fileExistsAppendRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    fileExistsAppendRadio.setText("Append");
    fileExistsAppendRadio.setMargin(new java.awt.Insets(0, 0, 0, 0));
    fileExistsAppendRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            fileExistsAppendRadioActionPerformed(evt);
        }
    });

    fileExistsOverwriteRadio = new MirthRadioButton();
    fileExistsOverwriteRadio.setBackground(new java.awt.Color(255, 255, 255));
    fileExistsOverwriteRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    fileExistsOverwriteRadio.setText("Overwrite");
    fileExistsOverwriteRadio.setMargin(new java.awt.Insets(0, 0, 0, 0));
    fileExistsOverwriteRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            fileExistsOverwriteRadioActionPerformed(evt);
        }
    });

    fileExistsErrorRadio = new MirthRadioButton();
    fileExistsErrorRadio.setBackground(new java.awt.Color(255, 255, 255));
    fileExistsErrorRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    fileExistsErrorRadio.setSelected(true);
    fileExistsErrorRadio.setText("Error");
    fileExistsErrorRadio.setMargin(new java.awt.Insets(0, 0, 0, 0));
    fileExistsErrorRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            fileExistsErrorRadioActionPerformed(evt);
        }
    });

    fileExistsButtonGroup = new ButtonGroup();
    fileExistsButtonGroup.add(fileExistsAppendRadio);
    fileExistsButtonGroup.add(fileExistsOverwriteRadio);
    fileExistsButtonGroup.add(fileExistsErrorRadio);

    tempFileLabel = new JLabel();
    tempFileLabel.setText("Create Temp File:");

    tempFileYesRadio = new MirthRadioButton();
    tempFileYesRadio.setBackground(new java.awt.Color(255, 255, 255));
    tempFileYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    tempFileYesRadio.setText("Yes");
    tempFileYesRadio.setMargin(new java.awt.Insets(0, 0, 0, 0));

    tempFileNoRadio = new MirthRadioButton();
    tempFileNoRadio.setBackground(new java.awt.Color(255, 255, 255));
    tempFileNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    tempFileNoRadio.setSelected(true);
    tempFileNoRadio.setText("No");
    tempFileNoRadio.setMargin(new java.awt.Insets(0, 0, 0, 0));

    tempFileButtonGroup = new ButtonGroup();
    tempFileButtonGroup.add(tempFileYesRadio);
    tempFileButtonGroup.add(tempFileNoRadio);

    fileTypeLabel = new JLabel();
    fileTypeLabel.setText("File Type:");

    fileTypeBinary = new MirthRadioButton();
    fileTypeBinary.setBackground(UIConstants.BACKGROUND_COLOR);
    fileTypeBinary.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    fileTypeBinary.setText("Binary");
    fileTypeBinary.setMargin(new Insets(0, 0, 0, 0));
    fileTypeBinary.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            fileTypeBinaryActionPerformed(evt);
        }
    });

    fileTypeText = new MirthRadioButton();
    fileTypeText.setBackground(UIConstants.BACKGROUND_COLOR);
    fileTypeText.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    fileTypeText.setSelected(true);
    fileTypeText.setText("Text");
    fileTypeText.setMargin(new Insets(0, 0, 0, 0));
    fileTypeText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            fileTypeASCIIActionPerformed(evt);
        }
    });

    fileTypeButtonGroup = new ButtonGroup();
    fileTypeButtonGroup.add(fileTypeBinary);
    fileTypeButtonGroup.add(fileTypeText);

    encodingLabel = new JLabel();
    encodingLabel.setText("Encoding:");

    charsetEncodingComboBox = new MirthComboBox();
    charsetEncodingComboBox.setModel(new DefaultComboBoxModel(new String[] { "Default", "UTF-8", "ISO-8859-1",
            "UTF-16 (le)", "UTF-16 (be)", "UTF-16 (bom)", "US-ASCII" }));

    templateLabel = new JLabel();
    templateLabel.setText("Template:");

    fileContentsTextPane = new MirthSyntaxTextArea();
    fileContentsTextPane.setBorder(BorderFactory.createEtchedBorder());
}

From source file:com.mirth.connect.connectors.http.HttpListener.java

private void initComponentsManual() {
    staticResourcesTable.setModel(new RefreshTableModel(StaticResourcesColumn.getNames(), 0) {
        @Override//from w  w w .ja  v a  2s .com
        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return true;
        }
    });

    staticResourcesTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    staticResourcesTable.setRowHeight(UIConstants.ROW_HEIGHT);
    staticResourcesTable.setFocusable(true);
    staticResourcesTable.setSortable(false);
    staticResourcesTable.setOpaque(true);
    staticResourcesTable.setDragEnabled(false);
    staticResourcesTable.getTableHeader().setReorderingAllowed(false);
    staticResourcesTable.setShowGrid(true, true);
    staticResourcesTable.setAutoCreateColumnsFromModel(false);
    staticResourcesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    staticResourcesTable.setRowSelectionAllowed(true);
    staticResourcesTable.setCustomEditorControls(true);

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

    class ContextPathCellEditor extends TextFieldCellEditor {
        public ContextPathCellEditor() {
            getTextField().setDocument(new MirthFieldConstraints("^\\S*$"));
        }

        @Override
        protected boolean valueChanged(String value) {
            if (StringUtils.isEmpty(value) || value.equals("/")) {
                return false;
            }

            if (value.equals(getOriginalValue())) {
                return false;
            }

            for (int i = 0; i < staticResourcesTable.getRowCount(); i++) {
                if (value.equals(fixContentPath((String) staticResourcesTable.getValueAt(i,
                        StaticResourcesColumn.CONTEXT_PATH.getIndex())))) {
                    return false;
                }
            }

            parent.setSaveEnabled(true);
            return true;
        }

        @Override
        public Object getCellEditorValue() {
            String value = fixContentPath((String) super.getCellEditorValue());
            String baseContextPath = getBaseContextPath();
            if (value.equals(baseContextPath)) {
                return null;
            } else {
                return fixContentPath(StringUtils.removeStartIgnoreCase(value, baseContextPath + "/"));
            }
        }

        @Override
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row,
                int column) {
            String resourceContextPath = fixContentPath((String) value);
            setOriginalValue(resourceContextPath);
            getTextField().setText(getBaseContextPath() + resourceContextPath);
            return getTextField();
        }
    }
    ;

    staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTEXT_PATH.getIndex())
            .setCellEditor(new ContextPathCellEditor());
    staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTEXT_PATH.getIndex())
            .setCellRenderer(new DefaultTableCellRenderer() {
                @Override
                protected void setValue(Object value) {
                    super.setValue(getBaseContextPath() + fixContentPath((String) value));
                }
            });

    class ResourceTypeCellEditor extends MirthComboBoxTableCellEditor implements ActionListener {
        private Object originalValue;

        public ResourceTypeCellEditor(JTable table, Object[] items, int clickCount, boolean focusable) {
            super(table, items, clickCount, focusable, null);
            for (ActionListener actionListener : comboBox.getActionListeners()) {
                comboBox.removeActionListener(actionListener);
            }
            comboBox.addActionListener(this);
        }

        @Override
        public boolean stopCellEditing() {
            if (ObjectUtils.equals(getCellEditorValue(), originalValue)) {
                cancelCellEditing();
            } else {
                parent.setSaveEnabled(true);
            }
            return super.stopCellEditing();
        }

        @Override
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row,
                int column) {
            originalValue = value;
            return super.getTableCellEditorComponent(table, value, isSelected, row, column);
        }

        @Override
        public void actionPerformed(ActionEvent evt) {
            ((AbstractTableModel) staticResourcesTable.getModel()).fireTableCellUpdated(
                    staticResourcesTable.getSelectedRow(), StaticResourcesColumn.VALUE.getIndex());
            stopCellEditing();
            fireEditingStopped();
        }
    }

    String[] resourceTypes = ResourceType.stringValues();
    staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex()).setMinWidth(100);
    staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex()).setMaxWidth(100);
    staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex())
            .setCellEditor(new ResourceTypeCellEditor(staticResourcesTable, resourceTypes, 1, false));
    staticResourcesTable.getColumnExt(StaticResourcesColumn.RESOURCE_TYPE.getIndex())
            .setCellRenderer(new MirthComboBoxTableCellRenderer(resourceTypes));

    class ValueCellEditor extends AbstractCellEditor implements TableCellEditor {

        private JPanel panel;
        private JLabel label;
        private JTextField textField;
        private String text;
        private String originalValue;

        public ValueCellEditor() {
            panel = new JPanel(new MigLayout("insets 0 1 0 0, novisualpadding, hidemode 3"));
            panel.setBackground(UIConstants.BACKGROUND_COLOR);

            label = new JLabel();
            label.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent evt) {
                    new ValueDialog();
                    stopCellEditing();
                }
            });
            panel.add(label, "grow, pushx, h 19!");

            textField = new JTextField();
            panel.add(textField, "grow, pushx, h 19!");
        }

        @Override
        public boolean isCellEditable(EventObject evt) {
            if (evt == null) {
                return false;
            }
            if (evt instanceof MouseEvent) {
                return ((MouseEvent) evt).getClickCount() >= 2;
            }
            return true;
        }

        @Override
        public Object getCellEditorValue() {
            if (label.isVisible()) {
                return text;
            } else {
                return textField.getText();
            }
        }

        @Override
        public boolean stopCellEditing() {
            if (ObjectUtils.equals(getCellEditorValue(), originalValue)) {
                cancelCellEditing();
            } else {
                parent.setSaveEnabled(true);
            }
            return super.stopCellEditing();
        }

        @Override
        public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row,
                int column) {
            boolean custom = table.getValueAt(row, StaticResourcesColumn.RESOURCE_TYPE.getIndex())
                    .equals(ResourceType.CUSTOM.toString());
            label.setVisible(custom);
            textField.setVisible(!custom);

            panel.setBackground(table.getSelectionBackground());
            label.setBackground(panel.getBackground());
            label.setMaximumSize(new Dimension(table.getColumnModel().getColumn(column).getWidth(), 19));

            String text = (String) value;
            this.text = text;
            originalValue = text;
            label.setText(text);
            textField.setText(text);

            return panel;
        }

        class ValueDialog extends MirthDialog {

            public ValueDialog() {
                super(parent, true);
                setTitle("Custom Value");
                setPreferredSize(new Dimension(600, 500));
                setLayout(new MigLayout("insets 12, novisualpadding, hidemode 3, fill", "", "[grow]7[]"));
                setBackground(UIConstants.BACKGROUND_COLOR);
                getContentPane().setBackground(getBackground());

                final MirthSyntaxTextArea textArea = new MirthSyntaxTextArea();
                textArea.setSaveEnabled(false);
                textArea.setText(text);
                textArea.setBorder(BorderFactory.createEtchedBorder());
                add(textArea, "grow");

                add(new JSeparator(), "newline, grow");

                JPanel buttonPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3"));
                buttonPanel.setBackground(getBackground());

                JButton openFileButton = new JButton("Open File...");
                openFileButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        String content = parent.browseForFileString(null);
                        if (content != null) {
                            textArea.setText(content);
                        }
                    }
                });
                buttonPanel.add(openFileButton);

                JButton okButton = new JButton("OK");
                okButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        text = textArea.getText();
                        label.setText(text);
                        textField.setText(text);
                        staticResourcesTable.getModel().setValueAt(text, staticResourcesTable.getSelectedRow(),
                                StaticResourcesColumn.VALUE.getIndex());
                        parent.setSaveEnabled(true);
                        dispose();
                    }
                });
                buttonPanel.add(okButton);

                JButton cancelButton = new JButton("Cancel");
                cancelButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        dispose();
                    }
                });
                buttonPanel.add(cancelButton);

                add(buttonPanel, "newline, right");

                pack();
                setLocationRelativeTo(parent);
                setVisible(true);
            }
        }
    }
    ;

    staticResourcesTable.getColumnExt(StaticResourcesColumn.VALUE.getIndex())
            .setCellEditor(new ValueCellEditor());

    staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTENT_TYPE.getIndex()).setMinWidth(100);
    staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTENT_TYPE.getIndex()).setMaxWidth(150);
    staticResourcesTable.getColumnExt(StaticResourcesColumn.CONTENT_TYPE.getIndex())
            .setCellEditor(new TextFieldCellEditor() {
                @Override
                protected boolean valueChanged(String value) {
                    if (value.equals(getOriginalValue())) {
                        return false;
                    }
                    parent.setSaveEnabled(true);
                    return true;
                }
            });

    staticResourcesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (getSelectedRow(staticResourcesTable) != -1) {
                staticResourcesLastIndex = getSelectedRow(staticResourcesTable);
                staticResourcesDeleteButton.setEnabled(true);
            } else {
                staticResourcesDeleteButton.setEnabled(false);
            }
        }
    });

    contextPathField.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void insertUpdate(DocumentEvent evt) {
            changedUpdate(evt);
        }

        @Override
        public void removeUpdate(DocumentEvent evt) {
            changedUpdate(evt);
        }

        @Override
        public void changedUpdate(DocumentEvent evt) {
            ((AbstractTableModel) staticResourcesTable.getModel()).fireTableDataChanged();
        }
    });

    staticResourcesDeleteButton.setEnabled(false);
}

From source file:com.hp.alm.ali.idea.content.taskboard.TaskBoardPanel.java

private JComponent columnHeader(String name) {
    BoldLabel label = new BoldLabel(name);
    label.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 1, 0, 0),
            BorderFactory.createEtchedBorder()));
    label.setPreferredSize(new Dimension(MIN_COLUMN_WIDTH, 26));
    return label;
}

From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java

/**
 * Initializes the layout for the visible components in this menu. A
 * {@link GridBagLayout} is used.//from   w  w w  . ja  v  a  2s.c  o  m
 */
private void initLayout() {

    GridBagLayout gbl = new GridBagLayout();

    panelDirectory.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            Localization.lang("Select directory")));
    panelFiles.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            Localization.lang("Select files")));
    panelEntryTypesSelection.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            Localization.lang("BibTeX entry creation")));

    Insets basicInsets = new Insets(6, 6, 6, 6);
    Insets smallInsets = new Insets(3, 2, 3, 1);
    Insets noInsets = new Insets(0, 0, 0, 0);

    //       x, y, w, h, wx,wy,ix,iy
    FindUnlinkedFilesDialog.addComponent(gbl, panelSearchArea, buttonScan, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.EAST, noInsets, 0, 1, 1, 1, 1, 1, 40, 10);
    FindUnlinkedFilesDialog.addComponent(gbl, panelSearchArea, labelSearchingDirectoryInfo,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST, noInsets, 0, 2, 1, 1, 0, 0, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelSearchArea, progressBarSearching,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.EAST, noInsets, 0, 3, 1, 1, 0, 0, 0, 0);

    FindUnlinkedFilesDialog.addComponent(gbl, panelDirectory, labelDirectoryDescription, null,
            GridBagConstraints.WEST, new Insets(6, 6, 0, 6), 0, 0, 3, 1, 0, 0, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelDirectory, textfieldDirectoryPath,
            GridBagConstraints.HORIZONTAL, null, basicInsets, 0, 1, 2, 1, 1, 1, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelDirectory, buttonBrowse, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.EAST, basicInsets, 2, 1, 1, 1, 0, 0, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelDirectory, labelFileTypesDescription,
            GridBagConstraints.NONE, GridBagConstraints.WEST, new Insets(18, 6, 18, 3), 0, 3, 1, 1, 0, 0, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelDirectory, comboBoxFileTypeSelection,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, new Insets(18, 3, 18, 6), 1, 3, 1, 1, 1, 0,
            0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelDirectory, panelSearchArea, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.EAST, new Insets(18, 6, 18, 6), 2, 3, 1, 1, 0, 0, 0, 0);

    FindUnlinkedFilesDialog.addComponent(gbl, panelFiles, labelFilesDescription, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST, new Insets(6, 6, 0, 6), 0, 0, 1, 1, 0, 0, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelFiles, scrollpaneTree, GridBagConstraints.BOTH,
            GridBagConstraints.CENTER, basicInsets, 0, 1, 1, 1, 1, 1, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelFiles, panelOptions, GridBagConstraints.NONE,
            GridBagConstraints.NORTHEAST, basicInsets, 1, 1, 1, 1, 0, 0, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelOptions, buttonOptionSelectAll,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH, noInsets, 0, 0, 1, 1, 1, 0, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelOptions, buttonOptionUnselectAll,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH, noInsets, 0, 1, 1, 1, 0, 0, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelOptions, buttonOptionExpandAll,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH, new Insets(6, 0, 0, 0), 0, 2, 1, 1, 0, 0,
            0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelOptions, buttonOptionCollapseAll,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH, noInsets, 0, 3, 1, 1, 0, 0, 0, 0);

    FindUnlinkedFilesDialog.addComponent(gbl, panelEntryTypesSelection, labelEntryTypeDescription,
            GridBagConstraints.NONE, GridBagConstraints.WEST, basicInsets, 0, 0, 1, 1, 0, 0, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelEntryTypesSelection, comboBoxEntryTypeSelection,
            GridBagConstraints.NONE, GridBagConstraints.WEST, basicInsets, 1, 0, 1, 1, 1, 0, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelEntryTypesSelection, checkboxCreateKeywords,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, basicInsets, 0, 1, 2, 1, 0, 0, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelImportArea, labelImportingInfo,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(6, 6, 0, 6), 0, 1, 1, 1, 1, 0,
            0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelImportArea, progressBarImporting,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, new Insets(0, 6, 6, 6), 0, 2, 1, 1, 1, 0,
            0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, panelButtons, panelImportArea, GridBagConstraints.NONE,
            GridBagConstraints.EAST, smallInsets, 1, 0, 1, 1, 0, 0, 0, 0);

    FindUnlinkedFilesDialog.addComponent(gbl, getContentPane(), panelDirectory, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.CENTER, basicInsets, 0, 0, 1, 1, 0, 0, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, getContentPane(), panelFiles, GridBagConstraints.BOTH,
            GridBagConstraints.NORTHWEST, new Insets(12, 6, 2, 2), 0, 1, 1, 1, 1, 1, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, getContentPane(), panelEntryTypesSelection,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.SOUTHWEST, new Insets(12, 6, 2, 2), 0, 2, 1, 1, 0,
            0, 0, 0);
    FindUnlinkedFilesDialog.addComponent(gbl, getContentPane(), panelButtons, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.CENTER, new Insets(10, 6, 10, 6), 0, 3, 1, 1, 0, 0, 0, 0);

    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(buttonApply);
    bb.addButton(buttonClose);
    bb.addGlue();

    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panelImportArea.add(bb.getPanel(), GridBagConstraints.NONE);
    pack();

}

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);/*from  w  ww.j  av a 2 s. c o  m*/
    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.mirth.connect.connectors.file.FileReader.java

private void initComponents() {
    schemeLabel = new JLabel();
    schemeLabel.setText("Method:");
    schemeComboBox = new MirthComboBox();
    schemeComboBox.setModel(new DefaultComboBoxModel(new String[] { "file", "ftp", "sftp", "smb", "webdav" }));
    schemeComboBox.setToolTipText(//from  ww w . j  ava  2s.  com
            "The basic method used to access files to be read - file (local filesystem), FTP, SFTP, Samba share, or WebDAV");
    schemeComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            schemeComboBoxActionPerformed(evt);
        }
    });

    testConnectionButton = new JButton();
    testConnectionButton.setText("Test Read");
    testConnectionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            testConnectionActionPerformed(evt);
        }
    });

    advancedSettingsButton = new JButton(new ImageIcon(Frame.class.getResource("images/wrench.png")));
    advancedSettingsButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            advancedFileSettingsActionPerformed();
        }
    });

    summaryLabel = new JLabel("Advanced Options:");
    summaryField = new JLabel("");

    directoryLabel = new JLabel();
    directoryLabel.setText("Directory:");
    directoryField = new MirthTextField();
    directoryField.setToolTipText("The directory (folder) in which the files to be read can be found.");

    hostLabel = new JLabel();
    hostLabel.setText("ftp://");
    hostField = new MirthTextField();
    hostField.setToolTipText(
            "The name or IP address of the host (computer) on which the files to be read can be found.");
    pathLabel = new JLabel();
    pathLabel.setText("/");
    pathField = new MirthTextField();
    pathField.setToolTipText("The directory (folder) in which the files to be read can be found.");

    filenameFilterLabel = new JLabel();
    filenameFilterLabel.setText("Filename Filter Pattern:");
    fileNameFilterField = new MirthTextField();
    fileNameFilterField.setToolTipText(
            "<html>The pattern which names of files must match in order to be read.<br>Files with names that do not match the pattern will be ignored.</html>");
    filenameFilterRegexCheckBox = new MirthCheckBox();
    filenameFilterRegexCheckBox.setBackground(UIConstants.BACKGROUND_COLOR);
    filenameFilterRegexCheckBox.setText("Regular Expression");
    filenameFilterRegexCheckBox.setToolTipText(
            "<html>If Regex is checked, the pattern is treated as a regular expression.<br>If Regex is not checked, it is treated as a pattern that supports wildcards and a comma separated list.</html>");

    directoryRecursionLabel = new JLabel();
    directoryRecursionLabel.setText("Include All Subdirectories:");

    directoryRecursionYesRadio = new MirthRadioButton();
    directoryRecursionYesRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    directoryRecursionYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    directoryRecursionYesRadio.setText("Yes");
    directoryRecursionYesRadio.setToolTipText(
            "<html>Select Yes to traverse directories recursively and search for files in each one.</html>");
    directoryRecursionYesRadio.setMargin(new Insets(0, 0, 0, 0));
    directoryRecursionYesRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            directoryRecursionYesRadioActionPerformed(evt);
        }
    });

    directoryRecursionNoRadio = new MirthRadioButton();
    directoryRecursionNoRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    directoryRecursionNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    directoryRecursionNoRadio.setSelected(true);
    directoryRecursionNoRadio.setText("No");
    directoryRecursionNoRadio.setToolTipText(
            "<html>Select No to only search for files in the selected directory/location, ignoring subdirectories.</html>");
    directoryRecursionNoRadio.setMargin(new Insets(0, 0, 0, 0));

    directoryRecursionButtonGroup = new ButtonGroup();
    directoryRecursionButtonGroup.add(directoryRecursionYesRadio);
    directoryRecursionButtonGroup.add(directoryRecursionNoRadio);

    ignoreDotFilesLabel = new JLabel();
    ignoreDotFilesLabel.setText("Ignore . files:");

    ignoreDotFilesYesRadio = new MirthRadioButton();
    ignoreDotFilesYesRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    ignoreDotFilesYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    ignoreDotFilesYesRadio.setText("Yes");
    ignoreDotFilesYesRadio.setToolTipText("Select Yes to ignore all files starting with a period.");
    ignoreDotFilesYesRadio.setMargin(new Insets(0, 0, 0, 0));

    ignoreDotFilesNoRadio = new MirthRadioButton();
    ignoreDotFilesNoRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    ignoreDotFilesNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    ignoreDotFilesNoRadio.setText("No");
    ignoreDotFilesNoRadio.setToolTipText("Select No to process files starting with a period.");
    ignoreDotFilesNoRadio.setMargin(new Insets(0, 0, 0, 0));

    ignoreDotFilesButtonGroup = new ButtonGroup();
    ignoreDotFilesButtonGroup.add(ignoreDotFilesYesRadio);
    ignoreDotFilesButtonGroup.add(ignoreDotFilesNoRadio);

    anonymousLabel = new JLabel();
    anonymousLabel.setText("Anonymous:");

    anonymousYesRadio = new MirthRadioButton();
    anonymousYesRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    anonymousYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    anonymousYesRadio.setText("Yes");
    anonymousYesRadio
            .setToolTipText("Connects to the file anonymously instead of using a username and password.");
    anonymousYesRadio.setMargin(new Insets(0, 0, 0, 0));
    anonymousYesRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            anonymousYesActionPerformed(evt);
        }
    });

    anonymousNoRadio = new MirthRadioButton();
    anonymousNoRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    anonymousNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    anonymousNoRadio.setSelected(true);
    anonymousNoRadio.setText("No");
    anonymousNoRadio
            .setToolTipText("Connects to the file using a username and password instead of anonymously.");
    anonymousNoRadio.setMargin(new Insets(0, 0, 0, 0));
    anonymousNoRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            anonymousNoActionPerformed(evt);
        }
    });

    anonymousButtonGroup = new ButtonGroup();
    anonymousButtonGroup.add(anonymousYesRadio);
    anonymousButtonGroup.add(anonymousNoRadio);

    usernameLabel = new JLabel();
    usernameLabel.setText("Username:");
    usernameField = new MirthTextField();
    usernameField.setToolTipText("The user name used to gain access to the server.");

    passwordLabel = new JLabel();
    passwordLabel.setText("Password:");
    passwordField = new MirthPasswordField();
    passwordField.setToolTipText("The password used to gain access to the server.");

    timeoutLabel = new JLabel();
    timeoutLabel.setText("Timeout (ms):");
    timeoutField = new MirthTextField();
    timeoutField.setToolTipText("The socket timeout (in ms) for connecting to the server.");

    secureModeLabel = new JLabel();
    secureModeLabel.setText("Secure Mode:");

    secureModeYesRadio = new MirthRadioButton();
    secureModeYesRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    secureModeYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    secureModeYesRadio.setText("Yes");
    secureModeYesRadio.setToolTipText(
            "<html>Select Yes to connect to the server via HTTPS.<br>Select No to connect via HTTP.</html>");
    secureModeYesRadio.setMargin(new Insets(0, 0, 0, 0));
    secureModeYesRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            secureModeYesActionPerformed(evt);
        }
    });

    secureModeNoRadio = new MirthRadioButton();
    secureModeNoRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    secureModeNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    secureModeNoRadio.setSelected(true);
    secureModeNoRadio.setText("No");
    secureModeNoRadio.setToolTipText(
            "<html>Select Yes to connect to the server via HTTPS.<br>Select No to connect via HTTP.</html>");
    secureModeNoRadio.setMargin(new Insets(0, 0, 0, 0));
    secureModeNoRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            secureModeNoActionPerformed(evt);
        }
    });

    secureModeButtonGroup = new ButtonGroup();
    secureModeButtonGroup.add(secureModeYesRadio);
    secureModeButtonGroup.add(secureModeNoRadio);

    passiveModeLabel = new JLabel();
    passiveModeLabel.setText("Passive Mode:");

    passiveModeYesRadio = new MirthRadioButton();
    passiveModeYesRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    passiveModeYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    passiveModeYesRadio.setText("Yes");
    passiveModeYesRadio.setToolTipText(
            "<html>Select Yes to connect to the server in \"passive mode\".<br>Passive mode sometimes allows a connection through a firewall that normal mode does not.</html>");
    passiveModeYesRadio.setMargin(new Insets(0, 0, 0, 0));

    passiveModeNoRadio = new MirthRadioButton();
    passiveModeNoRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    passiveModeNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    passiveModeNoRadio.setSelected(true);
    passiveModeNoRadio.setText("No");
    passiveModeNoRadio.setToolTipText(
            "Select Yes to connect to the server in \"normal mode\" as opposed to passive mode.");
    passiveModeNoRadio.setMargin(new Insets(0, 0, 0, 0));

    passiveModeButtonGroup = new ButtonGroup();
    passiveModeButtonGroup.add(passiveModeYesRadio);
    passiveModeButtonGroup.add(passiveModeNoRadio);

    validateConnectionLabel = new JLabel();
    validateConnectionLabel.setText("Validate Connection:");

    validateConnectionYesRadio = new MirthRadioButton();
    validateConnectionYesRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    validateConnectionYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    validateConnectionYesRadio.setText("Yes");
    validateConnectionYesRadio
            .setToolTipText("Select Yes to test the connection to the server before each operation.");
    validateConnectionYesRadio.setMargin(new Insets(0, 0, 0, 0));

    validateConnectionNoRadio = new MirthRadioButton();
    validateConnectionNoRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    validateConnectionNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    validateConnectionNoRadio.setText("No");
    validateConnectionNoRadio
            .setToolTipText("Select No to skip testing the connection to the server before each operation.");
    validateConnectionNoRadio.setMargin(new Insets(0, 0, 0, 0));

    validateConnectionButtonGroup = new ButtonGroup();
    validateConnectionButtonGroup.add(validateConnectionYesRadio);
    validateConnectionButtonGroup.add(validateConnectionNoRadio);

    afterProcessingActionLabel = new JLabel();
    afterProcessingActionLabel.setText("After Processing Action:");

    afterProcessingActionComboBox = new MirthComboBox();
    afterProcessingActionComboBox.setModel(new DefaultComboBoxModel(new String[] { "None", "Move", "Delete" }));
    afterProcessingActionComboBox.setToolTipText(
            "<html>Select Move to move and/or rename the file after successful processing.<br/>Select Delete to delete the file after successful processing.</html>");
    afterProcessingActionComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            afterProcessingActionComboBoxActionPerformed(evt);
        }
    });

    moveToDirectoryLabel = new JLabel();
    moveToDirectoryLabel.setText("Move-to Directory:");
    moveToDirectoryField = new MirthTextField();
    moveToDirectoryField.setToolTipText(
            "<html>If successfully processed files should be moved to a different directory (folder), enter that directory here.<br>The directory name specified may include template substitutions from the list to the right.<br>If this field is left empty, successfully processed files will not be moved to a different directory.</html>");

    moveToFileNameLabel = new JLabel();
    moveToFileNameLabel.setText("Move-to File Name:");
    moveToFileNameField = new MirthTextField();
    moveToFileNameField.setToolTipText(
            "<html>If successfully processed files should be renamed, enter the new name here.<br>The filename specified may include template substitutions from the list to the right.<br>If this field is left empty, successfully processed files will not be renamed.</html>");

    errorReadingActionLabel = new JLabel();
    errorReadingActionLabel.setText("Error Reading Action:");

    errorReadingActionComboBox = new MirthComboBox();
    errorReadingActionComboBox.setModel(new DefaultComboBoxModel(new String[] { "None", "Move", "Delete" }));
    errorReadingActionComboBox.setToolTipText(
            "<html>Select Move to move and/or rename files that have failed to be read in.<br/>Select Delete to delete files that have failed to be read in.</html>");
    errorReadingActionComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            errorReadingActionComboBoxActionPerformed(evt);
        }
    });

    errorResponseActionLabel = new JLabel();
    errorResponseActionLabel.setText("Error in Response Action:");

    errorResponseActionComboBox = new MirthComboBox();
    errorResponseActionComboBox
            .setModel(new DefaultComboBoxModel(new String[] { "After Processing Action", "Move", "Delete" }));
    errorResponseActionComboBox.setToolTipText(
            "<html>Select Move to move and/or rename the file if an ERROR response is returned.<br/>Select Delete to delete the file if an ERROR response is returned.<br/>If After Processing Action is selected, the After Processing Action will apply.<br/>This action is only available if Process Batch Files is disabled.</html>");
    errorResponseActionComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            errorResponseActionComboBoxActionPerformed(evt);
        }
    });

    errorMoveToDirectoryLabel = new JLabel();
    errorMoveToDirectoryLabel.setText("Error Move-to Directory:");
    errorMoveToDirectoryField = new MirthTextField();
    errorMoveToDirectoryField.setToolTipText(
            "<html>If files which cause processing errors should be moved to a different directory (folder), enter that directory here.<br>The directory name specified may include template substitutions from the list to the right.<br>If this field is left empty, files which cause processing errors will not be moved to a different directory.</html>");

    errorMoveToFileNameLabel = new JLabel();
    errorMoveToFileNameLabel.setText("Error Move-to File Name:");
    errorMoveToFileNameField = new MirthTextField();
    errorMoveToFileNameField.setToolTipText(
            "<html>If files which cause processing errors should be renamed, enter the new name here.<br/>The filename specified may include template substitutions from the list to the right.<br/>If this field is left empty, files which cause processing errors will not be renamed.</html>");

    variableListScrollPane = new JScrollPane();
    variableListScrollPane.setBorder(null);
    variableListScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    variableListScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

    mirthVariableList = new MirthVariableList();
    mirthVariableList.setBorder(BorderFactory.createEtchedBorder());
    mirthVariableList.setModel(new AbstractListModel() {
        String[] strings = { "channelName", "channelId", "DATE", "COUNT", "UUID", "SYSTIME",
                "originalFilename" };

        public int getSize() {
            return strings.length;
        }

        public Object getElementAt(int i) {
            return strings[i];
        }
    });
    variableListScrollPane.setViewportView(mirthVariableList);

    checkFileAgeLabel = new JLabel();
    checkFileAgeLabel.setText("Check File Age:");

    checkFileAgeYesRadio = new MirthRadioButton();
    checkFileAgeYesRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    checkFileAgeYesRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    checkFileAgeYesRadio.setText("Yes");
    checkFileAgeYesRadio
            .setToolTipText("Select Yes to skip files that are created within the specified age below.");
    checkFileAgeYesRadio.setMargin(new Insets(0, 0, 0, 0));
    checkFileAgeYesRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            checkFileAgeYesActionPerformed(evt);
        }
    });

    checkFileAgeNoRadio = new MirthRadioButton();
    checkFileAgeNoRadio.setBackground(UIConstants.BACKGROUND_COLOR);
    checkFileAgeNoRadio.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    checkFileAgeNoRadio.setSelected(true);
    checkFileAgeNoRadio.setText("No");
    checkFileAgeNoRadio.setToolTipText("Select No to process files regardless of age.");
    checkFileAgeNoRadio.setMargin(new Insets(0, 0, 0, 0));
    checkFileAgeNoRadio.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            checkFileAgeNoActionPerformed(evt);
        }
    });

    checkFileAgeButtonGroup = new ButtonGroup();
    checkFileAgeButtonGroup.add(checkFileAgeYesRadio);
    checkFileAgeButtonGroup.add(checkFileAgeNoRadio);

    fileAgeLabel = new JLabel();
    fileAgeLabel.setText("File Age (ms):");
    fileAgeField = new MirthTextField();
    fileAgeField.setToolTipText(
            "If Check File Age Yes is selected, only the files created that are older than the specified value in milliseconds will be processed.");

    fileSizeLabel = new JLabel();
    fileSizeLabel.setText("File Size (bytes):");
    fileSizeMinimumField = new MirthTextField();
    fileSizeMinimumField.setToolTipText("<html>The minimum size (in bytes) of files to be accepted.</html>");
    fileSizeDashLabel = new JLabel();
    fileSizeDashLabel.setText("-");
    fileSizeMaximumField = new MirthTextField();
    fileSizeMaximumField.setToolTipText(
            "<html>The maximum size (in bytes) of files to be accepted.<br/>This option has no effect if Ignore Maximum is checked.</html>");
    ignoreFileSizeMaximumCheckBox = new MirthCheckBox();
    ignoreFileSizeMaximumCheckBox.setBackground(UIConstants.BACKGROUND_COLOR);
    ignoreFileSizeMaximumCheckBox.setText("Ignore Maximum");
    ignoreFileSizeMaximumCheckBox.setToolTipText(
            "<html>If checked, only the minimum file size will be checked against incoming files.</html>");
    ignoreFileSizeMaximumCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            ignoreFileSizeMaximumCheckBoxActionPerformed(evt);
        }
    });

    sortFilesByLabel = new JLabel();
    sortFilesByLabel.setText("Sort Files By:");
    sortByComboBox = new MirthComboBox();
    sortByComboBox.setModel(new DefaultComboBoxModel(new String[] { "Date", "Name", "Size" }));
    sortByComboBox.setToolTipText(
            "<html>Selects the order in which files should be processed, if there are multiple files available to be processed.<br>Files can be processed by Date (oldest last modification date first), Size (smallest first) or name (a before z, etc.).</html>");

    fileTypeLabel = new JLabel();
    fileTypeLabel.setText("File Type:");

    fileTypeBinary = new MirthRadioButton();
    fileTypeBinary.setBackground(UIConstants.BACKGROUND_COLOR);
    fileTypeBinary.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    fileTypeBinary.setText("Binary");
    fileTypeBinary.setToolTipText(
            "<html>Select Binary if files contain binary data; the contents will be Base64 encoded before processing.<br>Select Text if files contain text data; the contents will be encoded using the specified character set encoding.</html>");
    fileTypeBinary.setMargin(new Insets(0, 0, 0, 0));
    fileTypeBinary.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            fileTypeBinaryActionPerformed(evt);
        }
    });

    fileTypeText = new MirthRadioButton();
    fileTypeText.setBackground(UIConstants.BACKGROUND_COLOR);
    fileTypeText.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    fileTypeText.setSelected(true);
    fileTypeText.setText("Text");
    fileTypeText.setToolTipText(
            "<html>Select Binary if files contain binary data; the contents will be Base64 encoded before processing.<br>Select Text if files contain text data; the contents will be encoded using the specified character set encoding.</html>");
    fileTypeText.setMargin(new Insets(0, 0, 0, 0));
    fileTypeText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            fileTypeASCIIActionPerformed(evt);
        }
    });

    fileTypeButtonGroup = new ButtonGroup();
    fileTypeButtonGroup.add(fileTypeBinary);
    fileTypeButtonGroup.add(fileTypeText);

    encodingLabel = new JLabel();
    encodingLabel.setText("Encoding:");

    charsetEncodingComboBox = new MirthComboBox();
    charsetEncodingComboBox.setModel(new DefaultComboBoxModel(new String[] { "Default", "UTF-8", "ISO-8859-1",
            "UTF-16 (le)", "UTF-16 (be)", "UTF-16 (bom)", "US-ASCII" }));
    charsetEncodingComboBox.setToolTipText(
            "If File Type Text is selected, select the character set encoding (ASCII, UTF-8, etc.) to be used in reading the contents of each file.");
}

From source file:it.imtech.metadata.MetaUtility.java

/**
 * Metodo adibito alla creazione dinamica ricorsiva dell'interfaccia dei
 * metadati/*from  w  ww  .j a  va  2 s  . c  om*/
 *
 * @param submetadatas Map contente i metadati e i sottolivelli di metadati
 * @param vocabularies Map contenente i dati contenuti nel file xml
 * vocabulary.xml
 * @param parent Jpanel nel quale devono venir inseriti i metadati
 * @param level Livello corrente
 */
public void create_metadata_view(Map<Object, Metadata> submetadatas, JPanel parent, int level,
        final String panelname) throws Exception {
    ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader);
    int lenght = submetadatas.size();
    int labelwidth = 220;
    int i = 0;
    JButton addcontribute = null;

    for (Map.Entry<Object, Metadata> kv : submetadatas.entrySet()) {
        ArrayList<Component> tabobjects = new ArrayList<Component>();

        if (kv.getValue().MID == 17 || kv.getValue().MID == 23 || kv.getValue().MID == 18
                || kv.getValue().MID == 137) {
            continue;
        }

        //Crea un jpanel nuovo e fa appen su parent
        JPanel innerPanel = new JPanel(new MigLayout("fillx, insets 1 1 1 1"));
        innerPanel.setName("pannello" + level + i);

        i++;
        String datatype = kv.getValue().datatype.toString();

        if (kv.getValue().MID == 45) {
            JPanel choice = new JPanel(new MigLayout());

            JComboBox combo = addClassificationChoice(choice, kv.getValue().sequence, panelname);

            JLabel labelc = new JLabel();
            labelc.setText(Utility.getBundleString("selectclassif", bundle));
            labelc.setPreferredSize(new Dimension(100, 20));

            choice.add(labelc);

            findLastClassification(panelname);
            if (last_classification != 0 && classificationRemoveButton == null) {
                logger.info("Removing last clasification");
                classificationRemoveButton = new JButton("-");

                classificationRemoveButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent event) {
                        BookImporter.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                        removeClassificationToMetadata(panelname);
                        BookImporter.getInstance().refreshMetadataTab(false, panelname);
                        findLastClassification(panelname); //update last_classification
                        BookImporter.getInstance().setCursor(null);
                    }
                });
                if (Integer.parseInt(kv.getValue().sequence) == last_classification) {
                    choice.add(classificationRemoveButton, "wrap, width :50:");
                }
            }

            if (classificationAddButton == null) {
                logger.info("Adding a new classification");
                choice.add(combo, "width 100:600:600");

                classificationAddButton = new JButton("+");

                classificationAddButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent event) {
                        BookImporter.getInstance().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                        addClassificationToMetadata(panelname);
                        BookImporter.getInstance().refreshMetadataTab(false, panelname);
                        BookImporter.getInstance().setCursor(null);
                    }
                });

                choice.add(classificationAddButton, "width :50:");
            } else {
                //choice.add(combo, "wrap,width 100:700:700");
                choice.add(combo, "width 100:700:700");
                if (Integer.parseInt(kv.getValue().sequence) == last_classification) {
                    choice.add(classificationRemoveButton, "wrap, width :50");
                }
            }
            parent.add(choice, "wrap,width 100:700:700");
            classificationMID = kv.getValue().MID;

            innerPanel.setName(panelname + "---ImPannelloClassif---" + kv.getValue().sequence);
            try {

                addClassification(innerPanel, classificationMID, kv.getValue().sequence, panelname);
            } catch (Exception ex) {
                logger.error("Errore nell'aggiunta delle classificazioni");
            }
            parent.add(innerPanel, "wrap, growx");
            BookImporter.policy.addIndexedComponent(combo);

            continue;
        }

        if (datatype.equals("Node")) {
            JLabel label = new JLabel();
            label.setText(kv.getValue().description);
            label.setPreferredSize(new Dimension(100, 20));

            int size = 16 - (level * 2);
            Font myFont = new Font("MS Sans Serif", Font.PLAIN, size);
            label.setFont(myFont);

            if (Integer.toString(kv.getValue().MID).equals("11")) {
                JPanel temppanel = new JPanel(new MigLayout());

                //update last_contribute
                findLastContribute(panelname);

                if (last_contribute != 0 && removeContribute == null) {
                    logger.info("Removing last contribute");
                    removeContribute = new JButton("-");

                    removeContribute.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent event) {
                            BookImporter.getInstance()
                                    .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                            removeContributorToMetadata(panelname);
                            BookImporter.getInstance().refreshMetadataTab(false, panelname);
                            BookImporter.getInstance().setCursor(null);
                        }
                    });

                    if (!kv.getValue().sequence.equals("")) {
                        if (Integer.parseInt(kv.getValue().sequence) == last_contribute) {
                            innerPanel.add(removeContribute, "width :50:");
                        }
                    }
                }

                if (addcontribute == null) {
                    logger.info("Adding a new contribute");
                    addcontribute = new JButton("+");

                    addcontribute.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent event) {
                            BookImporter.getInstance()
                                    .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                            addContributorToMetadata(panelname);
                            BookImporter.getInstance().refreshMetadataTab(false, panelname);
                            BookImporter.getInstance().setCursor(null);
                        }
                    });

                    temppanel.add(label, " width :200:");
                    temppanel.add(addcontribute, "width :50:");
                    innerPanel.add(temppanel, "wrap, growx");
                } else {
                    temppanel.add(label, " width :200:");
                    findLastContribute(panelname);
                    if (!kv.getValue().sequence.equals("")) {
                        if (Integer.parseInt(kv.getValue().sequence) == last_contribute) {
                            temppanel.add(removeContribute, "width :50:");
                        }
                    }
                    innerPanel.add(temppanel, "wrap, growx");
                }
            } else if (Integer.toString(kv.getValue().MID).equals("115")) {
                logger.info("Devo gestire una provenience!");
            }
        } else {
            String title = "";

            if (kv.getValue().mandatory.equals("Y") || kv.getValue().MID == 14 || kv.getValue().MID == 15) {
                title = kv.getValue().description + " *";
            } else {
                title = kv.getValue().description;
            }

            innerPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), title,
                    TitledBorder.LEFT, TitledBorder.TOP));

            if (datatype.equals("Vocabulary")) {
                TreeMap<String, String> entryCombo = new TreeMap<String, String>();
                int index = 0;
                String selected = null;

                if (!Integer.toString(kv.getValue().MID).equals("8"))
                    entryCombo.put(Utility.getBundleString("comboselect", bundle),
                            Utility.getBundleString("comboselect", bundle));

                for (Map.Entry<String, TreeMap<String, VocEntry>> vc : vocabularies.entrySet()) {
                    String tempmid = Integer.toString(kv.getValue().MID);

                    if (Integer.toString(kv.getValue().MID_parent).equals("11")
                            || Integer.toString(kv.getValue().MID_parent).equals("13")) {
                        String[] testmid = tempmid.split("---");
                        tempmid = testmid[0];
                    }

                    if (vc.getKey().equals(tempmid)) {
                        TreeMap<String, VocEntry> iEntry = vc.getValue();

                        for (Map.Entry<String, VocEntry> ivc : iEntry.entrySet()) {
                            entryCombo.put(ivc.getValue().description, ivc.getValue().ID);
                            if (kv.getValue().value != null) {
                                if (kv.getValue().value.equals(ivc.getValue().ID)) {
                                    selected = ivc.getValue().ID;
                                }
                            }
                            index++;
                        }
                    }
                }

                final ComboMapImpl model = new ComboMapImpl();
                model.setVocabularyCombo(true);
                model.putAll(entryCombo);

                final JComboBox voc = new javax.swing.JComboBox(model);
                model.specialRenderCombo(voc);

                if (Integer.toString(kv.getValue().MID_parent).equals("11")
                        || Integer.toString(kv.getValue().MID_parent).equals("13")) {
                    voc.setName("MID_" + Integer.toString(kv.getValue().MID) + "---" + kv.getValue().sequence);
                } else {
                    voc.setName("MID_" + Integer.toString(kv.getValue().MID));
                }

                if (Integer.toString(kv.getValue().MID).equals("8") && selected == null)
                    selected = "44";

                selected = (selected == null) ? Utility.getBundleString("comboselect", bundle) : selected;

                for (int k = 0; k < voc.getItemCount(); k++) {
                    Map.Entry<String, String> el = (Map.Entry<String, String>) voc.getItemAt(k);
                    if (el.getValue().equals(selected))
                        voc.setSelectedIndex(k);
                }

                voc.setPreferredSize(new Dimension(150, 30));
                innerPanel.add(voc, "wrap, width :400:");
                tabobjects.add(voc);
            } else if (datatype.equals("CharacterString") || datatype.equals("GPS")) {
                final JTextArea textField = new javax.swing.JTextArea();

                if (Integer.toString(kv.getValue().MID_parent).equals("11")
                        || Integer.toString(kv.getValue().MID_parent).equals("13")) {
                    textField.setName(
                            "MID_" + Integer.toString(kv.getValue().MID) + "---" + kv.getValue().sequence);
                } else {
                    textField.setName("MID_" + Integer.toString(kv.getValue().MID));
                }

                textField.setPreferredSize(new Dimension(230, 0));
                textField.setText(kv.getValue().value);
                textField.setLineWrap(true);
                textField.setWrapStyleWord(true);

                innerPanel.add(textField, "wrap, width :300:");

                textField.addKeyListener(new KeyAdapter() {
                    @Override
                    public void keyPressed(KeyEvent e) {
                        if (e.getKeyCode() == KeyEvent.VK_TAB) {
                            if (e.getModifiers() > 0) {
                                textField.transferFocusBackward();
                            } else {
                                textField.transferFocus();
                            }
                            e.consume();
                        }
                    }
                });

                tabobjects.add(textField);
            } else if (datatype.equals("LangString")) {
                JScrollPane inner_scroll = new javax.swing.JScrollPane();
                inner_scroll.setHorizontalScrollBarPolicy(
                        javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
                inner_scroll.setVerticalScrollBarPolicy(
                        javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
                inner_scroll.setPreferredSize(new Dimension(240, 80));
                inner_scroll.setName("langStringScroll");
                final JTextArea jTextArea1 = new javax.swing.JTextArea();
                jTextArea1.setName("MID_" + Integer.toString(kv.getValue().MID));
                jTextArea1.setText(kv.getValue().value);

                jTextArea1.setSize(new Dimension(350, 70));
                jTextArea1.setLineWrap(true);
                jTextArea1.setWrapStyleWord(true);

                inner_scroll.setViewportView(jTextArea1);
                innerPanel.add(inner_scroll, "width :300:");

                //Add combo language box
                JComboBox voc = getComboLangBox(kv.getValue().language);
                voc.setName("MID_" + Integer.toString(kv.getValue().MID) + "_lang");

                voc.setPreferredSize(new Dimension(200, 20));
                innerPanel.add(voc, "wrap, width :300:");

                jTextArea1.addKeyListener(new KeyAdapter() {
                    @Override
                    public void keyPressed(KeyEvent e) {
                        if (e.getKeyCode() == KeyEvent.VK_TAB) {
                            if (e.getModifiers() > 0) {
                                jTextArea1.transferFocusBackward();
                            } else {
                                jTextArea1.transferFocus();
                            }
                            e.consume();
                        }
                    }
                });
                tabobjects.add(jTextArea1);
                tabobjects.add(voc);
            } else if (datatype.equals("Language")) {
                final JComboBox voc = getComboLangBox(kv.getValue().value);
                voc.setName("MID_" + Integer.toString(kv.getValue().MID));

                voc.setPreferredSize(new Dimension(150, 20));
                voc.setBounds(5, 5, 150, 20);
                innerPanel.add(voc, "wrap, width :500:");

                //BookImporter.policy.addIndexedComponent(voc);
                tabobjects.add(voc);

            } else if (datatype.equals("Boolean")) {
                int selected = 0;
                TreeMap bin = new TreeMap<String, String>();
                bin.put("yes", Utility.getBundleString("voc1", bundle));
                bin.put("no", Utility.getBundleString("voc2", bundle));

                if (kv.getValue().value == null) {
                    switch (kv.getValue().MID) {
                    case 35:
                        selected = 0;
                        break;
                    case 36:
                        selected = 1;
                        break;
                    }
                } else if (kv.getValue().value.equals("yes")) {
                    selected = 1;
                } else {
                    selected = 0;
                }

                final ComboMapImpl model = new ComboMapImpl();
                model.putAll(bin);

                final JComboBox voc = new javax.swing.JComboBox(model);
                model.specialRenderCombo(voc);

                voc.setName("MID_" + Integer.toString(kv.getValue().MID));
                voc.setSelectedIndex(selected);

                voc.setPreferredSize(new Dimension(150, 20));
                voc.setBounds(5, 5, 150, 20);
                innerPanel.add(voc, "wrap, width :300:");
                //BookImporter.policy.addIndexedComponent(voc);
                tabobjects.add(voc);
            } else if (datatype.equals("License")) {
                String selectedIndex = null;
                int vindex = 0;
                int defaultIndex = 0;

                TreeMap<String, String> entryCombo = new TreeMap<String, String>();

                for (Map.Entry<String, TreeMap<String, VocEntry>> vc : vocabularies.entrySet()) {
                    if (vc.getKey().equals(Integer.toString(kv.getValue().MID))) {
                        TreeMap<String, VocEntry> iEntry = vc.getValue();

                        for (Map.Entry<String, VocEntry> ivc : iEntry.entrySet()) {
                            entryCombo.put(ivc.getValue().description, ivc.getValue().ID);

                            if (ivc.getValue().ID.equals("1"))
                                defaultIndex = vindex;

                            if (kv.getValue().value != null) {
                                if (ivc.getValue().ID.equals(kv.getValue().value)) {
                                    selectedIndex = Integer.toString(vindex);
                                }
                            }
                            vindex++;
                        }
                    }
                }

                if (selectedIndex == null)
                    selectedIndex = Integer.toString(defaultIndex);

                ComboMapImpl model = new ComboMapImpl();
                model.putAll(entryCombo);
                model.setVocabularyCombo(true);

                JComboBox voc = new javax.swing.JComboBox(model);
                model.specialRenderCombo(voc);

                voc.setName("MID_" + Integer.toString(kv.getValue().MID));
                voc.setSelectedIndex(Integer.parseInt(selectedIndex));
                voc.setPreferredSize(new Dimension(150, 20));

                voc.setBounds(5, 5, 150, 20);
                innerPanel.add(voc, "wrap, width :500:");
                //BookImporter.policy.addIndexedComponent(voc);
                tabobjects.add(voc);
            } else if (datatype.equals("DateTime")) {
                //final JXDatePicker datePicker = new JXDatePicker();
                JDateChooser datePicker = new JDateChooser();
                datePicker.setName("MID_" + Integer.toString(kv.getValue().MID));

                JPanel test = new JPanel(new MigLayout());
                JLabel lbefore = new JLabel(Utility.getBundleString("beforechristlabel", bundle));
                JCheckBox beforechrist = new JCheckBox();
                beforechrist.setName("MID_" + Integer.toString(kv.getValue().MID) + "_check");

                if (kv.getValue().value != null) {
                    try {
                        if (kv.getValue().value.charAt(0) == '-') {
                            beforechrist.setSelected(true);
                        }

                        Date date1 = new Date();
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        if (kv.getValue().value.charAt(0) == '-') {
                            date1 = sdf.parse(adjustDate(kv.getValue().value));
                        } else {
                            date1 = sdf.parse(kv.getValue().value);
                        }
                        datePicker.setDate(date1);
                    } catch (Exception e) {
                        //Console.WriteLine("ERROR import date:" + ex.Message);
                    }
                }

                test.add(datePicker, "width :200:");
                test.add(lbefore, "gapleft 30");
                test.add(beforechrist, "wrap");

                innerPanel.add(test, "wrap");
            }
        }

        //Recursive call
        create_metadata_view(kv.getValue().submetadatas, innerPanel, level + 1, panelname);

        if (kv.getValue().editable.equals("Y")
                || (datatype.equals("Node") && kv.getValue().hidden.equals("0"))) {
            parent.add(innerPanel, "wrap, growx");

            for (Component tabobject : tabobjects) {
                BookImporter.policy.addIndexedComponent(tabobject);
            }
        }
    }
}

From source file:it.iit.genomics.cru.igb.bundles.mi.business.MIWorker.java

/**
 * Adds a component to a JTabbedPane with a little close tab" button on the
 * right side of the tab./*from  ww w. j  a v  a  2  s .  com*/
 *
 * @param tabbedPane
 *            the JTabbedPane
 * @param c
 *            any JComponent
 * @param title
 *            the title for the tab
 */
public static void addClosableTab(final JTabbedPane tabbedPane, final JComponent c, final String title) {
    // Add the tab to the pane without any label
    tabbedPane.addTab(null, c);
    int pos = tabbedPane.indexOfComponent(c);

    // Create a FlowLayout that will space things 5px apart
    FlowLayout f = new FlowLayout(FlowLayout.CENTER, 5, 0);

    // Make a small JPanel with the layout and make it non-opaque
    JPanel pnlTab = new JPanel(f);
    pnlTab.setOpaque(false);

    // Add a JLabel with title and the left-side tab icon
    JLabel lblTitle = new JLabel(title);

    // Create a JButton for the close tab button
    JButton btnClose = new JButton("x");
    // btnClose.setOpaque(false);
    int size = 17;
    btnClose.setPreferredSize(new Dimension(size, size));
    btnClose.setToolTipText("close this tab");
    // Make the button looks the same for all Laf's
    btnClose.setUI(new BasicButtonUI());
    // Make it transparent
    btnClose.setContentAreaFilled(false);
    // No need to be focusable
    btnClose.setFocusable(false);
    btnClose.setBorder(BorderFactory.createEtchedBorder());
    btnClose.setBorderPainted(false);
    // Making nice rollover effect
    // we use the same listener for all buttons
    btnClose.setRolloverEnabled(true);
    // Close the proper tab by clicking the button

    // Configure icon and rollover icon for button
    btnClose.setRolloverEnabled(true);

    // Set border null so the button doesnt make the tab too big
    btnClose.setBorder(null);
    // Make sure the button cant get focus, otherwise it looks funny
    btnClose.setFocusable(false);

    // Put the panel together
    pnlTab.add(lblTitle);
    pnlTab.add(btnClose);

    // Add a thin border to keep the image below the top edge of the tab
    // when the tab is selected
    pnlTab.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
    // Now assign the component for the tab
    tabbedPane.setTabComponentAt(pos, pnlTab);

    // Add the listener that removes the tab
    ActionListener listener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (JOptionPane.showConfirmDialog(new JFrame(),
                    "Are you sure you want to remove this tab? All results will be lost!", "Remove tab",
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                tabbedPane.remove(c);
            }
        }
    };
    btnClose.addActionListener(listener);

    // Optionally bring the new tab to the front
    tabbedPane.setSelectedComponent(c);

}