Example usage for javax.swing BorderFactory createMatteBorder

List of usage examples for javax.swing BorderFactory createMatteBorder

Introduction

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

Prototype

public static MatteBorder createMatteBorder(int top, int left, int bottom, int right, Icon tileIcon) 

Source Link

Document

Creates a matte-look border that consists of multiple tiles of a specified icon.

Usage

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

private void initLayout() {
    JPanel propertiesPanel = new JPanel(
            new MigLayout("insets 12, novisualpadding, hidemode 3, fillx", "[right][left]"));
    propertiesPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    propertiesPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 1, 1, 1, new Color(204, 204, 204)), "SFTP Settings",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));

    propertiesPanel.add(authenticationLabel);
    propertiesPanel.add(usePasswordRadio, "split 3");
    propertiesPanel.add(usePrivateKeyRadio);
    propertiesPanel.add(useBothRadio, "push, wrap");

    propertiesPanel.add(keyLocationLabel);
    propertiesPanel.add(keyLocationField, "w 200!, wrap");

    propertiesPanel.add(passphraseLabel);
    propertiesPanel.add(passphraseField, "w 125!, wrap");

    propertiesPanel.add(useKnownHostsLabel);
    propertiesPanel.add(useKnownHostsYesRadio, "split 3");
    propertiesPanel.add(useKnownHostsAskRadio);
    propertiesPanel.add(useKnownHostsNoRadio, "push, wrap");

    propertiesPanel.add(knownHostsLocationLabel);
    propertiesPanel.add(knownHostsField, "w 200!, wrap");

    propertiesPanel.add(configurationsLabel, "aligny top");
    propertiesPanel.add(configurationsScrollPane, "span, grow, split 2");

    JPanel configurationsButtonPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill"));
    configurationsButtonPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    configurationsButtonPanel.add(newButton, "w 50!, wrap");
    configurationsButtonPanel.add(deleteButton, "w 50!");

    propertiesPanel.add(configurationsButtonPanel, "top");

    add(propertiesPanel, "grow, push, top, wrap");

    JPanel buttonPanel = new JPanel(new MigLayout("insets 0 8 8 8, novisualpadding, hidemode 3, fill"));
    buttonPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    buttonPanel.add(new JSeparator(), "growx, sx, wrap");
    buttonPanel.add(okButton, "newline, w 50!, sx, right, split");
    buttonPanel.add(cancelButton, "w 50!");

    add(buttonPanel, "south, span");
}

From source file:eu.europa.ec.markt.dss.applet.util.ComponentFactory.java

/**
 * //  w w w.j a  v a  2s  .c  o  m
 * @param applet
 * @param container
 */
public static void updateDisplay(final JApplet applet, final Container container) {
    if (container != null) {

        final PanelBuilder builder = createBuilder(new String[] { "5dlu", "fill:default:grow", "5dlu" },
                new String[] { "5dlu", "fill:default:grow", "5dlu" });
        final CellConstraints cc = new CellConstraints();
        builder.add(container, cc.xy(2, 2));

        final JPanel panel = createPanel(builder);
        panel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.GRAY));

        applet.getContentPane().removeAll();
        applet.getContentPane().add(panel);
        applet.getContentPane().validate();
        applet.getContentPane().repaint();

    }
}

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

private void initComponents() {
    setLayout(new MigLayout("insets 12, novisualpadding, hidemode 3, fill"));
    setBackground(UIConstants.BACKGROUND_COLOR);

    JPanel resourceListPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill"));
    resourceListPanel.setBackground(getBackground());
    resourceListPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Resources",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));

    resourceTable = new MirthTable();
    resourceTable.setModel(/*from   w  ww. jav  a 2  s.  c om*/
            new RefreshTableModel(new Object[] { "Properties", "Name", "Type", "Global Scripts" }, 0) {
                @Override
                public boolean isCellEditable(int row, int column) {
                    if (row == 0) {
                        return column == GLOBAL_SCRIPTS_COLUMN;
                    } else {
                        return column == NAME_COLUMN || column == TYPE_COLUMN
                                || column == GLOBAL_SCRIPTS_COLUMN;
                    }
                }
            });
    resourceTable.setDragEnabled(false);
    resourceTable.setRowSelectionAllowed(true);
    resourceTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    resourceTable.setRowHeight(UIConstants.ROW_HEIGHT);
    resourceTable.setFocusable(true);
    resourceTable.setOpaque(true);
    resourceTable.getTableHeader().setReorderingAllowed(false);
    resourceTable.setEditable(true);
    resourceTable.setSortable(false);

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

    for (ResourceClientPlugin plugin : LoadedExtensions.getInstance().getResourceClientPlugins().values()) {
        propertiesPanelMap.put(plugin.getType(), plugin.getPropertiesPanel());
    }

    resourceTable.getColumnModel().getColumn(NAME_COLUMN).setCellEditor(new NameEditor());
    resourceTable.getColumnExt(NAME_COLUMN).setToolTipText("The unique name of the resource.");

    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMinWidth(100);
    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMaxWidth(200);
    resourceTable.getColumnModel().getColumn(TYPE_COLUMN)
            .setCellRenderer(new ComboBoxRenderer(propertiesPanelMap.keySet().toArray()));
    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setCellEditor(new ComboBoxEditor(resourceTable,
            propertiesPanelMap.keySet().toArray(), 1, true, new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent evt) {
                    typeComboBoxActionPerformed(evt);
                }
            }));
    resourceTable.getColumnExt(TYPE_COLUMN).setToolTipText("The type of resource.");

    resourceTable.getColumnModel().getColumn(GLOBAL_SCRIPTS_COLUMN).setMinWidth(80);
    resourceTable.getColumnModel().getColumn(GLOBAL_SCRIPTS_COLUMN).setMaxWidth(80);
    resourceTable.getColumnModel().getColumn(GLOBAL_SCRIPTS_COLUMN).setCellRenderer(new CheckBoxRenderer());
    resourceTable.getColumnModel().getColumn(GLOBAL_SCRIPTS_COLUMN).setCellEditor(new CheckBoxEditor());
    resourceTable.getColumnExt(GLOBAL_SCRIPTS_COLUMN).setToolTipText(
            "<html>If checked, libraries associated with the corresponding<br/>resource will be included in global script contexts.</html>");

    resourceTable.removeColumn(resourceTable.getColumnModel().getColumn(PROPERTIES_COLUMN));

    resourceTable.getSelectionModel().addListSelectionListener(this);

    resourceTable
            .setToolTipText("<html>Add or remove resources to use<br/>in specific channels/connectors.</html>");

    resourceTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "selectNextColumnCell");

    resourceListPanel.add(new JScrollPane(resourceTable), "grow, push");

    add(resourceListPanel, "grow, h 20%");

    for (ResourcePropertiesPanel panel : propertiesPanelMap.values()) {
        add(panel, "newline, grow, h 80%");
    }

    fillerPanel = new JPanel(new MigLayout("insets 5, novisualpadding, hidemode 3, fill", "", "[][grow]"));
    fillerPanel.setBackground(getBackground());
    fillerPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Resource Settings",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));
    fillerLabel = new JLabel("Select a resource from the table above.");
    fillerPanel.add(fillerLabel);

    exceptionTextPane = new JTextPane();
    exceptionTextPane.setBackground(new Color(224, 223, 227));
    exceptionTextPane.setEditable(false);
    exceptionScrollPane = new JScrollPane(exceptionTextPane);
    fillerPanel.add(exceptionScrollPane, "newline, grow");

    add(fillerPanel, "newline, grow, h 80%");
}

From source file:com.amitycoin.enterprisetool.diagramInputServlet.java

@Override
@SuppressWarnings({ "null", "ValueOfIncrementOrDecrementUsed", "UnusedAssignment" })
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String filePath;//from   ww  w  .  j  ava 2s .c  o  m
    String docids;
    String userid;
    String a[][];
    a = new String[200][200];
    // database connection settings
    String dbURL = "jdbc:mysql://localhost:3306/enterprisedb";
    String dbUser = "root";
    String dbPass = "sandy";

    @SuppressWarnings("UnusedAssignment")
    Connection conn = null; // connection to the database
    userid = (String) request.getAttribute("uidM");
    String fname = (String) request.getAttribute("fnameM");
    int docid = (Integer) request.getAttribute("docidM");

    docids = "" + docid;
    String pathToWeb;
    pathToWeb = getServletContext().getRealPath(File.separator);
    System.out.println("pathtoweb:\t" + pathToWeb);
    filePath = pathToWeb + "readFiles\\";
    filePath = filePath + docids + userid + fname; //+.xls
    File myFile = new File(filePath);

    //boolean newExcel;
    //boolean oldExcel;
    String ext = FilenameUtils.getExtension(filePath);
    System.out.println("Extension: " + ext);

    FileInputStream fis = new FileInputStream(myFile);
    Workbook wb = null;
    if ("xls".equals(ext)) {
        // Finds the workbook instance for the file
        wb = new HSSFWorkbook(fis);

    } else if ("xlsx".equals(ext)) {
        wb = new XSSFWorkbook(fis);

    }

    @SuppressWarnings("null")
    Sheet mySheet;
    mySheet = wb.getSheetAt(0);

    // Get iterator to all the rows in current sheet
    Iterator<Row> rowIterator = mySheet.iterator();

    @SuppressWarnings("UnusedAssignment")
    int rowct = 0, colct = 0, colit = 0, ci = 0, ri = 0;

    // Traversing over each row of XLSX file
    while (rowIterator.hasNext()) {
        ri++;
        System.out.println("\nRi:\t" + ri);
        //Iterate over Rows
        Row row = rowIterator.next();

        if (1 == rowct) {
            colct = colit;
        }
        // For each row, iterate through each columns
        Iterator<Cell> cellIterator = row.cellIterator();
        ci = 0;
        while (cellIterator.hasNext()) {

            ci++;

            System.out.println("\nCi:\t" + ci);
            //Iterate over Columns
            Cell cell = cellIterator.next();

            switch (cell.getCellType()) {
            case Cell.CELL_TYPE_STRING:
                System.out.print(cell.getStringCellValue() + "\t");
                a[ri][ci] = cell.getStringCellValue();
                break;
            case Cell.CELL_TYPE_NUMERIC:
                System.out.print(cell.getNumericCellValue() + "\t");
                double temp = cell.getNumericCellValue();
                String dblValue = "" + temp;
                a[ri][ci] = dblValue;
                break;
            case Cell.CELL_TYPE_BOOLEAN:
                System.out.print(cell.getBooleanCellValue() + "\t");
                String tmp = "" + cell.getBooleanCellValue();
                a[ri][ci] = tmp;
                break;
            default:

            }
            colit++;

        }
        //rowit++;
        rowct++;
        //increase row count
    }

    System.out.println("Row Count:\t" + rowct);
    System.out.println("Column Count:\t" + colct);
    for (int i = 1; i <= rowct; i++) {
        for (int j = 1; j <= colct; j++) {
            System.out.println("a[" + i + "][" + j + "]=" + a[i][j] + "\n");
        }
    }
    try {
        DriverManager.registerDriver(new com.mysql.jdbc.Driver());
        conn = DriverManager.getConnection(dbURL, dbUser, dbPass);
        String append = "?, ?";
        String quest = ", ?";

        for (int j = 1; j <= colct; j++) {
            append += quest;
        }

        String crsql;
        String cappend = "`uid`,`doc_id`";
        for (int j = 1; j <= colct; j++) {
            cappend = cappend + ",`" + j + "`";
        }
        crsql = "CREATE TABLE IF NOT EXISTS `data" + userid + docid + "` (\n"
                + "`row_id` INT(11) NOT NULL AUTO_INCREMENT,\n" + "`uid` VARCHAR(50) NOT NULL,\n"
                + "`doc_id` INT(11) NOT NULL";
        System.out.println(crsql);

        for (int j = 1; j <= colct; j++) {
            System.out.println("j:\t" + (j));
            crsql = crsql + ",\n`" + (j) + "` VARCHAR(50)";
        }
        crsql += ",\nPRIMARY KEY (`row_id`)\n)";

        System.out.println(crsql);

        PreparedStatement cstmt = conn.prepareStatement(crsql);
        int c = cstmt.executeUpdate();

        String sql = "INSERT INTO data" + userid + docid + "(" + cappend + ")" + " values (" + append + ")";
        System.out.println("Append=\t" + append);
        PreparedStatement statement = conn.prepareStatement(sql);
        statement.setString(1, userid);
        statement.setInt(2, docid);
        for (int i = 1; i <= rowct; i++) {
            for (int j = 1; j <= (colct); j++) {
                statement.setString(j + 2, a[i][j]);
                System.out.println("j=" + (j) + "\ta[" + i + "][" + (j) + "]=" + a[i][j] + "\n");
            }
            System.out.println("\n");
            System.out.println("\nstatement:\t" + statement);
            int res = statement.executeUpdate();
        }
    } catch (SQLException ex) {
        Logger.getLogger(diagramInputServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
    for (int i = 1; i <= rowct; i++) {
        for (int j = 1; j <= colct; j++) {
            System.out.println("a[" + i + "][" + j + "]=" + a[i][j] + "\n");
        }
    }
    System.out.println("Rowct:\t" + rowct + "\nColct:\t" + colct);
    @SuppressWarnings("UseOfObsoleteCollectionType")
    Hashtable<String, Object> style = new Hashtable<String, Object>();
    style.put(mxConstants.STYLE_FILLCOLOR, mxUtils.getHexColorString(Color.WHITE));
    style.put(mxConstants.STYLE_STROKEWIDTH, 1.5);
    style.put(mxConstants.STYLE_STROKECOLOR, mxUtils.getHexColorString(new Color(0, 0, 170)));
    style.put(mxConstants.STYLE_SHAPE, mxConstants.SHAPE_ELLIPSE);
    style.put(mxConstants.STYLE_PERIMETER, mxConstants.PERIMETER_ELLIPSE);

    graph = new mxGraph();

    mxStylesheet stylesheet = graph.getStylesheet();
    stylesheet.putCellStyle("process", createProcessStyle());
    stylesheet.putCellStyle("object", createObjectStyle());
    stylesheet.putCellStyle("state", createStateStyle());
    stylesheet.putCellStyle("agent", createAgentLinkStyle());
    fr = new JFrame("Enterprise Architecture Diagram");

    fr.setSize(2000, 2000);
    graph.setMinimumGraphSize(new mxRectangle(0, 0, 1000, 1500));
    graph.setMaximumGraphBounds(new mxRectangle(0, 0, 2000, 2000));
    graph.setMinimumGraphSize(new mxRectangle(0, 0, 1000, 1000));

    double rech1 = 200;
    double rech2 = 200;
    double rech3 = 170;
    double rech3e = 180;
    double rech4 = 120;
    Object defaultParent = graph.getDefaultParent();

    graph.setConstrainChildren(true);
    graph.setExtendParents(true);
    graph.setExtendParentsOnAdd(true);
    graph.setDefaultOverlap(0);
    graph.setCellsMovable(true); // Moving cells in the graph. Note that an edge is also a cell.
    graph.setCellsEditable(true);
    graph.setCellsResizable(true); // Inhibit cell re-sizing.

    graph.getModel().beginUpdate();

    Object[] obj = new Object[100];
    int k = 1;
    for (int i = 2; i <= rowct; i++) {
        for (int j = 1; j <= 2; j++) {
            obj[k] = a[i][j];
            k++;
        }

    }

    //print debug info
    for (int l = 1; l <= (rowct * 2) - 2; l++) {
        System.out.println("obj[" + l + "]:\t" + obj[l]);
    }

    List<Object> list = new ArrayList<Object>();
    for (Object val : obj) {
        if (!list.contains(val)) {
            list.add(val);
        }
    }

    list.remove(null);
    list.toArray(new Object[0]);
    System.out.println("list:" + list);

    Object[] array = new Object[list.size()];
    list.toArray(array); // fill the array
    System.out.println("Array:\t" + Arrays.toString(array));

    Object[] gArray = new Object[array.length];
    String[] sArray = new String[array.length];

    for (int i = 0; i < array.length; i++) {
        sArray[i] = array[i].toString();
        if (sArray[i].contains("Database") || sArray[i].contains("Server") || sArray[i].contains("DATABASE")
                || sArray[i].contains("SERVER") || sArray[i].contains("DB")) {
            System.out.println("Object type");
            gArray[i] = graph.insertVertex(defaultParent, null, sArray[i], rech1, rech2, rech3, rech4,
                    "object");

        } else {
            System.out.println("Process type");
            gArray[i] = graph.insertVertex(defaultParent, null, sArray[i], rech1, rech2, rech3e, rech4,
                    "process");
        }
        rech1 += 100;
        rech2 += 100;
    }

    for (int i = 2; i <= rowct; i++) {

        if (a[i][3].equals("Two Way") || a[i][3].equals("TWO WAY") || a[i][3].equals("TwoWay")
                || a[i][3].equals("TWOWAY") || a[i][3].equals("2 Way") || a[i][3].equals("Two way")) {
            System.out.println("Double Edges");
            int l1 = 0, l2 = 0;
            for (int l = 1; l < gArray.length; l++) {
                System.out.println("gArray.toString=\t" + sArray[l]);
                System.out.println("gArray.length=\t" + sArray.length);
                if (sArray[l].equals(a[i][1])) {
                    l1 = l;
                    System.out.println("l2:\t" + l1);
                }
                if (sArray[l].equals(a[i][2])) {
                    l2 = l;
                    System.out.println("l2:\t" + l2);
                }
            }
            graph.insertEdge(defaultParent, null, a[i][4], gArray[l1], gArray[l2], "agent");
            graph.insertEdge(defaultParent, null, a[i][4], gArray[l2], gArray[l1], "agent");

        } else {
            System.out.println("Single Edges");
            int l1 = 0, l2 = 0;
            for (int l = 1; l < gArray.length; l++) {
                System.out.println("gArray.toString=\t" + sArray[l]);
                System.out.println("gArray.length=\t" + sArray.length);
                if (sArray[l].equals(a[i][1])) {
                    l1 = l;
                    System.out.println("l2:\t" + l2);
                }
                if (sArray[l].equals(a[i][2])) {
                    l2 = l;
                    System.out.println("l2:\t" + l2);
                }
            }
            graph.insertEdge(defaultParent, null, a[i][4], gArray[l1], gArray[l2], "agent");
        }
    }

    graph.setEnabled(true);

    graph.setAutoSizeCells(true);

    graph.getModel().endUpdate();

    graphComponent = new mxGraphComponent(graph);
    mxFastOrganicLayout layout = new mxFastOrganicLayout(graph);
    // define layout

    //set all properties
    layout.setMinDistanceLimit(1);
    //layout.setInitialTemp(5);
    //layout.setInitialTemp(10);
    //layout.setForceConstant(10);
    //layout.setDisableEdgeStyle(true);
    //layout graph
    //layout.execute(graph.getDefaultParent());
    // layout using morphing
    String fileWPath;

    graph.getModel().beginUpdate();
    try {
        layout.execute(graph.getDefaultParent());
    } finally {
        mxMorphing morph = new mxMorphing(graphComponent, 20, 1.2, 20);

        morph.addListener(mxEvent.DONE, new mxIEventListener() {

            @Override
            public void invoke(Object arg0, mxEventObject arg1) {
                graph.getModel().endUpdate();
                // fitViewport();
            }

        });

        BufferedImage image;
        image = mxCellRenderer.createBufferedImage(graph, null, 2, Color.WHITE, true, null);
        Document d = mxCellRenderer.createVmlDocument(graph, null, 1, Color.WHITE, null);
        pathToWeb = getServletContext().getRealPath(File.separator);
        System.out.println("pathtoweb:\t" + pathToWeb);
        fileWPath = pathToWeb + "genImg\\" + userid + docid + ".png";
        System.out.println("filewpath:\t" + fileWPath);
        //System.out.println(pathToWeb + userid + docid + ".svg");
        ImageIO.write(image, "PNG", new File(fileWPath));
        XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
                new FileOutputStream(new File(pathToWeb + "genXML\\" + userid + docid + ".xml"))));
        encoder.writeObject(graph);
        encoder.close();
        morph.startAnimation();
    }

    graphComponent.setConnectable(false);
    fr.getRootPane().setBorder(BorderFactory.createMatteBorder(4, 4, 4, 4, Color.WHITE));
    // Inhibit edge creation in the graph.
    fr.getContentPane().add(graphComponent);

    //fr.setVisible(true);

    request.setAttribute("docidM", docid);
    request.setAttribute("useridM", userid);
    request.setAttribute("colCountM", colct);
    request.setAttribute("rowCountM", rowct);
    request.setAttribute("fileLinkM", fileWPath);
    request.setAttribute("pathToWebM", pathToWeb);
    System.out.println("Iteration Complete");

    getServletContext().getRequestDispatcher("/success.jsp").forward(request, response);

}

From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java

/**
 * Initializes the GUI./*from  w ww . j  a v a  2  s .  c o  m*/
 *
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void initGUI() {
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    // add attribute name
    panelAttName = new JPanel();
    panelAttName.setLayout(new BoxLayout(panelAttName, BoxLayout.PAGE_AXIS));
    panelAttName.setOpaque(false);
    // this border is to visualize that the name column can be enlarged/shrinked
    panelAttName.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.LIGHT_GRAY));

    labelAttHeader = new JLabel(LABEL_DOTS);
    labelAttHeader.setFont(labelAttHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelAttHeader.setForeground(Color.GRAY);
    panelAttName.add(labelAttHeader);

    labelAttName = new JLabel(LABEL_DOTS);
    labelAttName.setFont(labelAttName.getFont().deriveFont(Font.BOLD, FONT_SIZE_LABEL_VALUE));
    labelAttName.setMinimumSize(DIMENSION_LABEL_ATTRIBUTE);
    labelAttName.setPreferredSize(DIMENSION_LABEL_ATTRIBUTE);
    panelAttName.add(labelAttName);

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.insets = new Insets(3, 20, 3, 10);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 0.0;
    gbc.weighty = 1.0;
    gbc.gridheight = 2;
    add(panelAttName, gbc);

    // create value type name and bring it to a nice to read format (aka uppercase first letter
    // and replace '_' with ' '
    gbc.gridx += 1;
    gbc.insets = new Insets(5, 15, 5, 10);
    labelAttType = new JLabel(LABEL_DOTS);
    labelAttType.setMinimumSize(DIMENSION_LABEL_TYPE);
    labelAttType.setPreferredSize(DIMENSION_LABEL_TYPE);
    add(labelAttType, gbc);

    // missings panel
    JPanel panelStatsMissing = new JPanel();
    panelStatsMissing.setLayout(new BoxLayout(panelStatsMissing, BoxLayout.PAGE_AXIS));
    panelStatsMissing.setOpaque(false);

    labelStatsMissing = new JLabel(LABEL_DOTS);
    labelStatsMissing.setMinimumSize(DIMENSION_LABEL_MISSINGS);
    labelStatsMissing.setPreferredSize(DIMENSION_LABEL_MISSINGS);
    panelStatsMissing.add(labelStatsMissing);

    gbc.gridx += 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0.0;
    add(panelStatsMissing, gbc);

    // chart panel(s) (only visible when enlarged)
    JPanel chartPanel = new JPanel(new BorderLayout());
    chartPanel.setBackground(COLOR_TRANSPARENT);
    chartPanel.setOpaque(false);
    listOfChartPanels.add(chartPanel);
    updateVisibilityOfChartPanels();

    gbc.fill = GridBagConstraints.NONE;
    gbc.weighty = 0.0;
    gbc.insets = new Insets(0, 10, 0, 10);
    for (JPanel panel : listOfChartPanels) {
        gbc.gridx += 1;
        add(panel, gbc);
    }

    // (hidden) construction panel
    String constructionLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.construction.label");
    panelStatsConstruction = new JPanel();
    panelStatsConstruction.setLayout(new BoxLayout(panelStatsConstruction, BoxLayout.PAGE_AXIS));
    panelStatsConstruction.setOpaque(false);
    panelStatsConstruction.setVisible(false);

    JLabel labelConstructionHeader = new JLabel(constructionLabel);
    labelConstructionHeader.setFont(labelConstructionHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelConstructionHeader.setForeground(Color.GRAY);
    panelStatsConstruction.add(labelConstructionHeader);

    labelStatsConstruction = new JLabel(LABEL_DOTS);
    labelStatsConstruction.setFont(labelStatsConstruction.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    labelStatsConstruction.setMinimumSize(DIMENSION_LABEL_CONSTRUCTION);
    labelStatsConstruction.setPreferredSize(DIMENSION_LABEL_CONSTRUCTION);
    panelStatsConstruction.add(labelStatsConstruction);

    gbc.gridx += 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 0.0;
    add(panelStatsConstruction, gbc);

    // statistics panel, contains different statistics panels for numerical/nominal/date_time on
    // a card layout
    // needed to switch between for model swapping
    cardStatsPanel = new JPanel();
    cardStatsPanel.setOpaque(false);
    cardLayout = new CardLayout();
    cardStatsPanel.setLayout(cardLayout);

    // numerical version
    JPanel statsNumPanel = new JPanel();
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints gbcStatPanel = new GridBagConstraints();
    statsNumPanel.setLayout(layout);
    statsNumPanel.setOpaque(false);

    String avgLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.avg.label");
    String devianceLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.variance.label");
    String minLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.min.label");
    String maxLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.max.label");

    // min value panel
    JPanel panelStatsMin = new JPanel();
    panelStatsMin.setLayout(new BoxLayout(panelStatsMin, BoxLayout.PAGE_AXIS));
    panelStatsMin.setOpaque(false);

    JLabel labelMinHeader = new JLabel(minLabel);
    labelMinHeader.setFont(labelMinHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelMinHeader.setForeground(Color.GRAY);
    panelStatsMin.add(labelMinHeader);

    labelStatsMin = new JLabel(LABEL_DOTS);
    labelStatsMin.setFont(labelStatsMin.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsMin.add(labelStatsMin);

    // max value panel
    JPanel panelStatsMax = new JPanel();
    panelStatsMax.setLayout(new BoxLayout(panelStatsMax, BoxLayout.PAGE_AXIS));
    panelStatsMax.setOpaque(false);

    JLabel labelMaxHeader = new JLabel(maxLabel);
    labelMaxHeader.setFont(labelMaxHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelMaxHeader.setForeground(Color.GRAY);
    panelStatsMax.add(labelMaxHeader);

    labelStatsMax = new JLabel(LABEL_DOTS);
    labelStatsMax.setFont(labelStatsMax.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsMax.add(labelStatsMax);

    // average value panel
    JPanel panelStatsAvg = new JPanel();
    panelStatsAvg.setLayout(new BoxLayout(panelStatsAvg, BoxLayout.PAGE_AXIS));
    panelStatsAvg.setOpaque(false);

    JLabel labelAvgHeader = new JLabel(avgLabel);
    labelAvgHeader.setFont(labelAvgHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelAvgHeader.setForeground(Color.GRAY);
    panelStatsAvg.add(labelAvgHeader);

    labelStatsAvg = new JLabel(LABEL_DOTS);
    labelStatsAvg.setFont(labelStatsAvg.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsAvg.add(labelStatsAvg);

    // deviance value panel
    JPanel panelStatsDeviance = new JPanel();
    panelStatsDeviance.setLayout(new BoxLayout(panelStatsDeviance, BoxLayout.PAGE_AXIS));
    panelStatsDeviance.setOpaque(false);

    JLabel labelDevianceHeader = new JLabel(devianceLabel);
    labelDevianceHeader.setFont(labelDevianceHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelDevianceHeader.setForeground(Color.GRAY);
    panelStatsDeviance.add(labelDevianceHeader);

    labelStatsDeviation = new JLabel(LABEL_DOTS);
    labelStatsDeviation.setFont(labelStatsDeviation.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsDeviance.add(labelStatsDeviation);

    // add sub panels to stats panel
    gbcStatPanel.gridx = 0;
    gbcStatPanel.weightx = 0.0;
    gbcStatPanel.fill = GridBagConstraints.NONE;
    gbcStatPanel.insets = new Insets(0, 0, 0, 4);
    panelStatsMin.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE);
    statsNumPanel.add(panelStatsMin, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsMax.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE);
    statsNumPanel.add(panelStatsMax, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsAvg.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE);
    statsNumPanel.add(panelStatsAvg, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsDeviance.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE);
    statsNumPanel.add(panelStatsDeviance, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    gbcStatPanel.weightx = 1.0;
    gbcStatPanel.fill = GridBagConstraints.HORIZONTAL;
    statsNumPanel.add(new JLabel(), gbcStatPanel);
    cardStatsPanel.add(statsNumPanel, CARD_NUMERICAL);

    // nominal version
    JPanel statsNomPanel = new JPanel();
    statsNomPanel.setLayout(layout);
    statsNomPanel.setOpaque(false);
    String leastLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.least.label");
    String mostLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.most.label");
    String valuesLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.values.label");

    // least panel
    JPanel panelStatsLeast = new JPanel();
    panelStatsLeast.setLayout(new BoxLayout(panelStatsLeast, BoxLayout.PAGE_AXIS));
    panelStatsLeast.setOpaque(false);

    JLabel labelLeastHeader = new JLabel(leastLabel);
    labelLeastHeader.setFont(labelLeastHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelLeastHeader.setForeground(Color.GRAY);
    labelLeastHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    panelStatsLeast.add(labelLeastHeader);

    labelStatsLeast = new JLabel(LABEL_DOTS);
    labelStatsLeast.setFont(labelStatsLeast.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsLeast.add(labelStatsLeast);

    // most panel
    JPanel panelStatsMost = new JPanel();
    panelStatsMost.setLayout(new BoxLayout(panelStatsMost, BoxLayout.PAGE_AXIS));
    panelStatsMost.setOpaque(false);

    JLabel labelMostHeader = new JLabel(mostLabel);
    labelMostHeader.setFont(labelMostHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelMostHeader.setForeground(Color.GRAY);
    labelMostHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    panelStatsMost.add(labelMostHeader);

    labelStatsMost = new JLabel(LABEL_DOTS);
    labelStatsMost.setFont(labelStatsMost.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsMost.add(labelStatsMost);

    // values panel
    JPanel panelStatsValues = new JPanel();
    panelStatsValues.setLayout(new BoxLayout(panelStatsValues, BoxLayout.PAGE_AXIS));
    panelStatsValues.setOpaque(false);

    JLabel labelValuesHeader = new JLabel(valuesLabel);
    labelValuesHeader.setFont(labelValuesHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelValuesHeader.setForeground(Color.GRAY);
    labelValuesHeader.setAlignmentX(Component.LEFT_ALIGNMENT);
    panelStatsValues.add(labelValuesHeader);

    labelStatsValues = new JLabel(LABEL_DOTS);
    labelStatsValues.setFont(labelStatsValues.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsValues.add(labelStatsValues);

    detailsButton = new JButton(new ShowNomValueAction(this));
    detailsButton.setVisible(false);
    detailsButton.setOpaque(false);
    detailsButton.setContentAreaFilled(false);
    detailsButton.setBorderPainted(false);
    detailsButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
    detailsButton.setHorizontalAlignment(SwingConstants.LEFT);
    detailsButton.setHorizontalTextPosition(SwingConstants.LEFT);
    detailsButton.setIcon(null);
    Font font = detailsButton.getFont();
    Map attributes = font.getAttributes();
    attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    detailsButton.setFont(font.deriveFont(attributes));
    panelStatsValues.add(detailsButton);

    // add sub panel to stats panel
    gbcStatPanel.gridx = 0;
    gbcStatPanel.weightx = 0.0;
    gbcStatPanel.fill = GridBagConstraints.NONE;
    gbcStatPanel.insets = new Insets(0, 0, 0, 6);
    panelStatsLeast.setPreferredSize(DIMENSION_PANEL_NOMINAL_PREF_SIZE);
    statsNomPanel.add(panelStatsLeast, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsMost.setPreferredSize(DIMENSION_PANEL_NOMINAL_PREF_SIZE);
    statsNomPanel.add(panelStatsMost, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    statsNomPanel.add(panelStatsValues, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    gbcStatPanel.weightx = 1.0;
    gbcStatPanel.fill = GridBagConstraints.HORIZONTAL;
    statsNomPanel.add(new JLabel(), gbcStatPanel);
    cardStatsPanel.add(statsNomPanel, CARD_NOMINAL);

    // date_time version
    JPanel statsDateTimePanel = new JPanel();
    statsDateTimePanel.setLayout(layout);
    statsDateTimePanel.setOpaque(false);

    String durationLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.duration.label");
    String fromLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.from.label");
    String untilLabel = I18N.getMessage(I18N.getGUIBundle(),
            "gui.label.attribute_statistics.statistics.until.label");

    // min value panel
    JPanel panelStatsFrom = new JPanel();
    panelStatsFrom.setLayout(new BoxLayout(panelStatsFrom, BoxLayout.PAGE_AXIS));
    panelStatsFrom.setOpaque(false);

    JLabel labelFromHeader = new JLabel(fromLabel);
    labelFromHeader.setFont(labelFromHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelFromHeader.setForeground(Color.GRAY);
    panelStatsFrom.add(labelFromHeader);

    labelStatsFrom = new JLabel(LABEL_DOTS);
    labelStatsFrom.setFont(labelStatsFrom.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsFrom.add(labelStatsFrom);

    // until value panel
    JPanel panelStatsUntil = new JPanel();
    panelStatsUntil.setLayout(new BoxLayout(panelStatsUntil, BoxLayout.PAGE_AXIS));
    panelStatsUntil.setOpaque(false);

    JLabel labelUntilHeader = new JLabel(untilLabel);
    labelUntilHeader.setFont(labelUntilHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelUntilHeader.setForeground(Color.GRAY);
    panelStatsUntil.add(labelUntilHeader);

    labelStatsUntil = new JLabel(LABEL_DOTS);
    labelStatsUntil.setFont(labelStatsUntil.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsUntil.add(labelStatsUntil);

    // duration value panel
    JPanel panelStatsDuration = new JPanel();
    panelStatsDuration.setLayout(new BoxLayout(panelStatsDuration, BoxLayout.PAGE_AXIS));
    panelStatsDuration.setOpaque(false);

    JLabel labelDurationHeader = new JLabel(durationLabel);
    labelDurationHeader.setFont(labelDurationHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER));
    labelDurationHeader.setForeground(Color.GRAY);
    panelStatsDuration.add(labelDurationHeader);

    labelStatsDuration = new JLabel(LABEL_DOTS);
    labelStatsDuration.setFont(labelStatsDuration.getFont().deriveFont(FONT_SIZE_LABEL_VALUE));
    panelStatsDuration.add(labelStatsDuration);

    // add sub panels to stats panel
    gbcStatPanel.gridx = 0;
    gbcStatPanel.weightx = 0.0;
    gbcStatPanel.fill = GridBagConstraints.NONE;
    gbcStatPanel.insets = new Insets(0, 0, 0, 6);
    panelStatsFrom.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE);
    statsDateTimePanel.add(panelStatsFrom, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsUntil.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE);
    statsDateTimePanel.add(panelStatsUntil, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    panelStatsDuration.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE);
    statsDateTimePanel.add(panelStatsDuration, gbcStatPanel);
    gbcStatPanel.gridx += 1;
    gbcStatPanel.weightx = 1.0;
    gbcStatPanel.fill = GridBagConstraints.HORIZONTAL;
    statsDateTimePanel.add(new JLabel(), gbcStatPanel);
    cardStatsPanel.add(statsDateTimePanel, CARD_DATE_TIME);

    // add stats panel to main gui
    gbc.gridx += 1;
    gbc.insets = new Insets(5, 10, 5, 10);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.anchor = GridBagConstraints.WEST;
    add(cardStatsPanel, gbc);

    // needed so we can draw our own background
    setOpaque(false);

    // handle mouse events for hover effect and enlarging/shrinking
    addMouseListener(enlargeAndHoverAndPopupMouseAdapter);

    // change cursor to indicate this component can be clicked
    setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}

From source file:com.mirth.connect.plugins.datapruner.DataPrunerPanel.java

private void initComponents() {
    setBackground(UIConstants.BACKGROUND_COLOR);

    statusPanel = new JPanel();
    statusPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    statusPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Status",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));

    currentStateLabel = new JLabel("Current State:");
    currentStateTextLabel = new JLabel("Unknown");

    currentProcessLabel = new JLabel("Current Process:");
    currentProcessTextLabel = new JLabel("Unknown");

    lastProcessLabel = new JLabel("Last Process:");
    lastProcessTextLabel = new JLabel("Unknown");

    nextProcessLabel = new JLabel("Next Process:");
    nextProcessTextLabel = new JLabel("Unknown");

    pruningSchedulePanel = new JPanel();
    pruningSchedulePanel.setBackground(UIConstants.BACKGROUND_COLOR);
    pruningSchedulePanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Schedule",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            new java.awt.Font("Tahoma", 1, 11)));

    enabledLabel = new JLabel("Enable:");

    yesEnabledRadio = new MirthRadioButton("Yes");
    yesEnabledRadio.setFocusable(false);
    yesEnabledRadio.setBackground(Color.white);
    yesEnabledRadio.addActionListener(new ActionListener() {
        @Override//from w  w w .  ja  va  2  s. co m
        public void actionPerformed(ActionEvent event) {
            enabledActionPerformed();
        }
    });

    noEnabledRadio = new MirthRadioButton("No");
    noEnabledRadio.setFocusable(false);
    noEnabledRadio.setBackground(Color.white);
    noEnabledRadio.setSelected(true);
    noEnabledRadio.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            enabledActionPerformed();
        }
    });

    enabledButtonGroup = new ButtonGroup();
    enabledButtonGroup.add(yesEnabledRadio);
    enabledButtonGroup.add(noEnabledRadio);

    pollingSettingsPanel = new PollingSettingsPanel(false);

    pruneSettingsPanel = new JPanel();
    pruneSettingsPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    pruneSettingsPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Prune Settings",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); // NOI18N

    blockSizeLabel = new JLabel("Block Size:");
    blockSizeTextField = new MirthTextField();
    blockSizeTextField.setToolTipText(
            "<html>The number of messages that will be pruned at a time. This value must<br/>be between 50 and 10000. The recommended value for most servers is 1000.</html>");

    pruneEventsLabel = new JLabel("Prune Events:");

    pruneEventsYes = new MirthRadioButton("Yes");
    pruneEventsYes.setBackground(UIConstants.BACKGROUND_COLOR);
    pruneEventsYes.setToolTipText(
            "<html>If Yes, event records older than the Event Age will be pruned. If No, event records will not be pruned.</html>");
    pruneEventsYes.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pruneEventsActionPerformed(evt);
        }
    });

    pruneEventsNo = new MirthRadioButton("No");
    pruneEventsNo.setBackground(UIConstants.BACKGROUND_COLOR);
    pruneEventsNo.setToolTipText(
            "<html>If Yes, event records will be pruned in addition to messages. If No, event records will not be pruned.</html>");
    pruneEventsNo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pruneEventsActionPerformed(evt);
        }
    });

    pruneEventsButtonGroup = new ButtonGroup();
    pruneEventsButtonGroup.add(pruneEventsYes);
    pruneEventsButtonGroup.add(pruneEventsNo);

    pruneEventAgeLabel = new JLabel("Prune Event Age:");

    pruneEventAgeTextField = new MirthTextField();
    pruneEventAgeTextField.setToolTipText(
            "<html>Events older than this number of days will be pruned if Prune Events is set to Yes.</html>");

    eventDaysLabel = new JLabel("days");
    eventDaysLabel.setEnabled(false);

    archiverContainerPanel = new JPanel();
    archiverContainerPanel.setBackground(UIConstants.BACKGROUND_COLOR);
    archiverContainerPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Archive Settings",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11))); // NOI18N
    archiverContainerPanel.setLayout(null);

    archiverPanel = new MessageExportPanel(Frame.userPreferences, true, false);
    archiverPanel.setBackground(archiverContainerPanel.getBackground());
    archiverContainerPanel.setLayout(new MigLayout("fillx, insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
    archiverContainerPanel.add(archiverPanel, "height 195!, aligny top");

    enabledActionPerformed();
}

From source file:com.rapidminer.gui.properties.RegexpPropertyDialog.java

public RegexpPropertyDialog(final Collection<String> items, String predefinedRegexp, String description) {
    super(ApplicationFrame.getApplicationFrame(), "parameter.regexp", ModalityType.APPLICATION_MODAL,
            new Object[] {});
    this.items = items;
    this.supportsItems = items != null;
    this.infoText = "<html>" + I18N.getMessage(I18N.getGUIBundle(), getKey() + ".title") + ": <br/>"
            + description + "</html>";
    Dimension size = new Dimension(420, 500);
    this.setMinimumSize(size);
    this.setPreferredSize(size);

    JPanel panel = new JPanel(createGridLayout(1, supportsItems ? 2 : 1));

    // create regexp text field
    regexpTextField = new JTextField(predefinedRegexp);
    regexpTextField.setToolTipText(/*from  w  ww .j  a  va2s. c  o  m*/
            I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.tip"));
    regexpTextField.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

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

        @Override
        public void keyTyped(KeyEvent e) {
        }

    });
    regexpTextField.requestFocus();

    // create replacement text field
    replacementTextField = new JTextField();
    replacementTextField.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.replacement.tip"));
    replacementTextField.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

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

        @Override
        public void keyTyped(KeyEvent e) {
        }

    });

    // create inline search documents
    inlineSearchDocument = new RegexpSearchStyledDocument();
    inlineReplaceDocument = new RegexpReplaceStyledDocument();

    // create search results list
    DefaultListCellRenderer resultCellRenderer = new DefaultListCellRenderer() {

        private static final long serialVersionUID = 1L;

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            setBackground(list.getBackground());
            setForeground(list.getForeground());
            setBorder(getNoFocusBorder());
            return this;
        }

        private Border getNoFocusBorder() {
            Border border = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray);
            return border;
        }
    };

    JList<RegExpResult> regexpFindingsList = new JList<RegExpResult>(resultsListModel);
    regexpFindingsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    regexpFindingsList.setLayoutOrientation(JList.VERTICAL);
    regexpFindingsList.setCellRenderer(resultCellRenderer);

    // regexp panel on left side of dialog
    JPanel regexpPanel = new JPanel(new GridBagLayout());
    regexpPanel.setBorder(createTitledBorder(
            I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.border")));
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(4, 4, 4, 0);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.fill = GridBagConstraints.BOTH;
    regexpPanel.add(regexpTextField, c);

    // make shortcut button
    final Action nullAction = new DefaultAction();
    PlainArrowDropDownButton autoWireDropDownButton = PlainArrowDropDownButton.makeDropDownButton(nullAction);

    for (String[] popupItem : (String[][]) ArrayUtils.addAll(regexpConstructs, regexpShortcuts)) {
        String shortcut = popupItem[0].length() > 14 ? popupItem[0].substring(0, 14) + "..." : popupItem[0];
        autoWireDropDownButton
                .add(new InsertionAction("<html><table border=0 cellpadding=0 cellspacing=0><tr><td width=100>"
                        + shortcut + "</td><td>" + popupItem[1] + "</td></tr></table></html>", popupItem[0]));
    }
    c.insets = new Insets(4, 0, 4, 0);
    c.gridx = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    regexpPanel.add(autoWireDropDownButton.getDropDownArrowButton(), c);

    // make delete button
    c.insets = new Insets(4, 0, 4, 4);
    c.gridx = 2;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    JButton clearRegexpTextFieldButton = new JButton(SwingTools.createIcon("16/delete2.png"));
    clearRegexpTextFieldButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            regexpTextField.setText("");
            fireRegularExpressionUpdated();
            regexpTextField.requestFocusInWindow();
        }
    });

    regexpPanel.add(clearRegexpTextFieldButton, c);

    errorMessage = new JLabel(NO_ERROR_MESSAGE, NO_ERROR_ICON, SwingConstants.LEFT);
    errorMessage.setFocusable(false);
    c.insets = new Insets(4, 8, 4, 4);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    regexpPanel.add(errorMessage, c);

    // create replacement panel
    JPanel replacementPanel = new JPanel(new GridBagLayout());
    replacementPanel.setBorder(createTitledBorder(
            I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.replacement.border")));

    JPanel testerPanel = new JPanel(new GridBagLayout());

    c.insets = new Insets(4, 4, 4, 0);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    replacementPanel.add(replacementTextField, c);

    // create inline search panel
    JPanel inlineSearchPanel = new JPanel(new GridBagLayout());

    c.insets = new Insets(8, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    inlineSearchPanel.add(
            new JLabel(
                    I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.inline_search.search")),
            c);

    c.insets = new Insets(0, 0, 0, 0);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    inlineSearchPanel.add(new JScrollPane(new JTextPane(inlineSearchDocument)), c);

    c.insets = new Insets(8, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    inlineSearchPanel.add(
            new JLabel(
                    I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.inline_search.replaced")),
            c);

    c.insets = new Insets(0, 0, 0, 0);
    c.gridx = 0;
    c.gridy = 3;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    JTextPane replaceTextPane = new JTextPane(inlineReplaceDocument);
    replaceTextPane.setEditable(false);
    inlineSearchPanel.add(new JScrollPane(replaceTextPane), c);

    // create regexp options panel
    ItemListener defaultOptionListener = new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            fireRegexpOptionsChanged();
        }
    };

    cbCaseInsensitive = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.case_insensitive"));
    cbCaseInsensitive.setToolTipText(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.case_insensitive.tip"));
    cbCaseInsensitive.addItemListener(defaultOptionListener);

    cbMultiline = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.multiline_mode"));
    cbMultiline.setToolTipText(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.multiline_mode.tip"));
    cbMultiline.addItemListener(defaultOptionListener);

    cbDotall = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.dotall_mode"));
    cbDotall.setToolTipText(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.dotall_mode.tip"));
    cbDotall.addItemListener(defaultOptionListener);

    cbUnicodeCase = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.unicode_case"));
    cbUnicodeCase.setToolTipText(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.unicode_case.tip"));
    cbUnicodeCase.addItemListener(defaultOptionListener);

    JPanel regexpOptionsPanelWrapper = new JPanel(new BorderLayout());
    JPanel regexpOptionsPanel = new JPanel(new GridBagLayout());
    regexpOptionsPanelWrapper.add(regexpOptionsPanel, BorderLayout.NORTH);

    c.insets = new Insets(12, 4, 0, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    regexpOptionsPanel.add(cbMultiline, c);
    c.insets = new Insets(8, 4, 0, 4);
    c.gridy = 1;
    regexpOptionsPanel.add(cbCaseInsensitive, c);
    c.gridy = 2;
    regexpOptionsPanel.add(cbUnicodeCase, c);
    c.gridy = 3;
    regexpOptionsPanel.add(cbDotall, c);

    // create tabbed panel
    c.insets = new Insets(8, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    testExp = new JTabbedPane();
    testExp.add(
            I18N.getMessage(I18N.getGUIBundle(),
                    "gui.dialog.parameter.regexp.regular_expression.inline_search.title"),
            new JScrollPane(inlineSearchPanel));
    testExp.add(
            I18N.getMessage(I18N.getGUIBundle(),
                    "gui.dialog.parameter.regexp.regular_expression.result_list.title"),
            new JScrollPane(regexpFindingsList));
    testExp.add(
            I18N.getMessage(I18N.getGUIBundle(),
                    "gui.dialog.parameter.regexp.regular_expression.regexp_options.title"),
            regexpOptionsPanelWrapper);
    testerPanel.add(testExp, c);

    JPanel groupPanel = new JPanel(new GridBagLayout());
    c.insets = new Insets(4, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    groupPanel.add(regexpPanel, c);

    c.insets = new Insets(4, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    groupPanel.add(replacementPanel, c);

    c.insets = new Insets(4, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    groupPanel.add(testerPanel, c);

    panel.add(groupPanel, 1, 0);

    if (supportsItems) {
        // item shortcuts list
        itemShortcutsList = new JList<String>(items.toArray(new String[items.size()]));
        itemShortcutsList.setToolTipText(
                I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.item_shortcuts.tip"));
        itemShortcutsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        itemShortcutsList.addMouseListener(new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    String text = regexpTextField.getText();
                    int cursorPosition = regexpTextField.getCaretPosition();
                    int index = itemShortcutsList.getSelectedIndex();
                    if (index > -1 && index < itemShortcutsList.getModel().getSize()) {
                        String insertionString = itemShortcutsList.getModel().getElementAt(index).toString();
                        String newText = text.substring(0, cursorPosition) + insertionString
                                + (cursorPosition < text.length() ? text.substring(cursorPosition) : "");
                        regexpTextField.setText(newText);
                        regexpTextField.setCaretPosition(cursorPosition + insertionString.length());
                        regexpTextField.requestFocus();
                        fireRegularExpressionUpdated();
                    }
                }
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }
        });
        JScrollPane itemShortcutsPane = new JScrollPane(itemShortcutsList);
        itemShortcutsPane.setBorder(createTitledBorder(
                I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.item_shortcuts.border")));

        // matched items list
        matchedItemsListModel = new DefaultListModel<String>();
        JList<String> matchedItemsList = new JList<String>(matchedItemsListModel);
        matchedItemsList.setToolTipText(
                I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.matched_items.tip"));
        // add custom cell renderer to disallow selections
        matchedItemsList.setCellRenderer(new DefaultListCellRenderer() {

            private static final long serialVersionUID = -5795848004756768378L;

            @Override
            public Component getListCellRendererComponent(JList list, Object value, int index,
                    boolean isSelected, boolean cellHasFocus) {
                return super.getListCellRendererComponent(list, value, index, false, false);
            }
        });
        JScrollPane matchedItemsPanel = new JScrollPane(matchedItemsList);
        matchedItemsPanel.setBorder(createTitledBorder(
                I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.matched_items.border")));

        // item panel on right side of dialog
        JPanel itemPanel = new JPanel(createGridLayout(1, 2));
        itemPanel.add(itemShortcutsPane, 0, 0);
        itemPanel.add(matchedItemsPanel, 0, 1);

        panel.add(itemPanel, 0, 1);
    }

    okButton = makeOkButton("regexp_property_dialog_apply");
    fireRegularExpressionUpdated();

    layoutDefault(panel, supportsItems ? NORMAL : NARROW, okButton, makeCancelButton());
}

From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplateImportDialog.java

private void initComponents() {
    setBackground(UIConstants.BACKGROUND_COLOR);
    getContentPane().setBackground(getBackground());

    topPanel = new JPanel();
    topPanel.setBackground(getBackground());

    linkPanel = new JPanel();
    linkPanel.setBackground(topPanel.getBackground());

    linkLeftPanel = new JPanel();
    linkLeftPanel.setBackground(linkPanel.getBackground());

    linkLeftSelectAllLabel = new JLabel("<html><u>All</u></html>");
    linkLeftSelectAllLabel.setForeground(Color.BLUE);
    linkLeftSelectAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    linkLeftSelectAllLabel.addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent evt) {
            for (int row = 0; row < importTreeTable.getRowCount(); row++) {
                importTreeTable.getModel().setValueAt(true, row, IMPORT_SELECTED_COLUMN);
            }//from w w  w  .  j  ava 2s. c om
        }
    });

    linkLeftDeselectAllLabel = new JLabel("<html><u>None</u></html>");
    linkLeftDeselectAllLabel.setForeground(Color.BLUE);
    linkLeftDeselectAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    linkLeftDeselectAllLabel.addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent evt) {
            for (int row = 0; row < importTreeTable.getRowCount(); row++) {
                importTreeTable.getModel().setValueAt(false, row, IMPORT_SELECTED_COLUMN);
            }
        }
    });

    linkRightPanel = new JPanel();
    linkRightPanel.setBackground(linkPanel.getBackground());

    linkRightOverwriteAllLabel = new JLabel("<html><u>All</u></html>");
    linkRightOverwriteAllLabel.setForeground(Color.BLUE);
    linkRightOverwriteAllLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    linkRightOverwriteAllLabel.addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent evt) {
            for (int row = 0; row < importTreeTable.getRowCount(); row++) {
                TreePath path = importTreeTable.getPathForRow(row);
                if (path != null) {
                    ImportTreeTableNode node = (ImportTreeTableNode) path.getLastPathComponent();
                    if (node instanceof ImportLibraryTreeTableNode) {
                        ImportLibraryTreeTableNode libraryNode = (ImportLibraryTreeTableNode) node;
                        if (libraryNode.getConflicts().getMatchingLibrary() != null) {
                            importTreeTable.getModel().setValueAt(true, row, IMPORT_OVERWRITE_COLUMN);
                        }
                    } else if (node instanceof ImportCodeTemplateTreeTableNode) {
                        ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) node;
                        if (codeTemplateNode.getConflicts().getMatchingCodeTemplate() != null) {
                            importTreeTable.getModel().setValueAt(true, row, IMPORT_OVERWRITE_COLUMN);
                        }
                    }
                }
            }
        }
    });

    linkRightOverwriteNoneLabel = new JLabel("<html><u>None</u></html>");
    linkRightOverwriteNoneLabel.setForeground(Color.BLUE);
    linkRightOverwriteNoneLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
    linkRightOverwriteNoneLabel.addMouseListener(new MouseAdapter() {
        public void mouseReleased(MouseEvent evt) {
            for (int row = 0; row < importTreeTable.getRowCount(); row++) {
                TreePath path = importTreeTable.getPathForRow(row);
                if (path != null) {
                    ImportTreeTableNode node = (ImportTreeTableNode) path.getLastPathComponent();
                    if (node instanceof ImportLibraryTreeTableNode) {
                        ImportLibraryTreeTableNode libraryNode = (ImportLibraryTreeTableNode) node;
                        if (libraryNode.getConflicts().getMatchingLibrary() != null) {
                            importTreeTable.getModel().setValueAt(false, row, IMPORT_OVERWRITE_COLUMN);
                        }
                    } else if (node instanceof ImportCodeTemplateTreeTableNode) {
                        ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) node;
                        if (codeTemplateNode.getConflicts().getMatchingCodeTemplate() != null) {
                            importTreeTable.getModel().setValueAt(false, row, IMPORT_OVERWRITE_COLUMN);
                        }
                    }
                }
            }
        }
    });

    final TableCellEditor templateCellEditor = new NameCellEditor();

    importTreeTable = new JXTreeTable() {
        @Override
        public boolean isCellEditable(int row, int column) {
            return (column == IMPORT_OVERWRITE_COLUMN || column == IMPORT_SELECTED_COLUMN
                    || column == IMPORT_NAME_COLUMN);
        }

        @Override
        public TableCellEditor getCellEditor(int row, int column) {
            if (isHierarchical(column)) {
                return templateCellEditor;
            } else {
                return super.getCellEditor(row, column);
            }
        }
    };

    importTreeTable.setLargeModel(true);
    DefaultTreeTableModel model = new ImportTreeTableModel();
    model.setColumnIdentifiers(Arrays.asList(new String[] { "", "Name", "Overwrite", "Conflicts", "Id" }));

    DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode();
    model.setRoot(rootNode);
    importTreeTable.setTreeTableModel(model);

    Set<String> addedCodeTemplateIds = new HashSet<String>();

    if (unassignedCodeTemplates) {
        ImportTreeTableNode libraryNode = new ImportUnassignedLibraryTreeTableNode("Select a library", "");
        CodeTemplateLibrary library = importLibraries.get(0);

        for (CodeTemplate codeTemplate : library.getCodeTemplates()) {
            if (!addedCodeTemplateIds.contains(codeTemplate.getId())) {
                libraryNode
                        .add(new ImportCodeTemplateTreeTableNode(codeTemplate.getName(), codeTemplate.getId()));
                addedCodeTemplateIds.add(codeTemplate.getId());
                importCodeTemplateMap.put(codeTemplate.getId(), codeTemplate);
            }
        }

        rootNode.add(libraryNode);
    } else {
        Set<String> addedLibraryIds = new HashSet<String>();

        for (CodeTemplateLibrary library : importLibraries) {
            if (!addedLibraryIds.contains(library.getId())) {
                ImportTreeTableNode libraryNode = new ImportLibraryTreeTableNode(library.getName(),
                        library.getId());
                importLibraryMap.put(library.getId(), library);

                for (CodeTemplate codeTemplate : library.getCodeTemplates()) {
                    if (!addedCodeTemplateIds.contains(codeTemplate.getId())) {
                        libraryNode.add(new ImportCodeTemplateTreeTableNode(codeTemplate.getName(),
                                codeTemplate.getId()));
                        addedCodeTemplateIds.add(codeTemplate.getId());
                        importCodeTemplateMap.put(codeTemplate.getId(), codeTemplate);
                    }
                }

                rootNode.add(libraryNode);
                addedLibraryIds.add(library.getId());
            }
        }
    }

    importTreeTable.setOpenIcon(null);
    importTreeTable.setClosedIcon(null);
    importTreeTable.setLeafIcon(null);
    importTreeTable.setRootVisible(false);
    importTreeTable.setDoubleBuffered(true);
    importTreeTable.setDragEnabled(false);
    importTreeTable.setRowSelectionAllowed(true);
    importTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    importTreeTable.setRowHeight(UIConstants.ROW_HEIGHT);
    importTreeTable.setFocusable(true);
    importTreeTable.setOpaque(true);
    importTreeTable.getTableHeader().setReorderingAllowed(false);
    importTreeTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    importTreeTable.setEditable(true);
    importTreeTable.setSortable(false);
    importTreeTable.setAutoCreateColumnsFromModel(false);
    importTreeTable.setShowGrid(true, true);

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

    importTreeTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent evt) {
            checkSelection(evt);
        }

        @Override
        public void mouseReleased(MouseEvent evt) {
            checkSelection(evt);
        }

        private void checkSelection(MouseEvent evt) {
            int row = importTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY()));

            if (row < 0) {
                importTreeTable.clearSelection();
            }
        }
    });

    importTreeTable.addTreeWillExpandListener(new TreeWillExpandListener() {
        @Override
        public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
        }

        @Override
        public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
            throw new ExpandVetoException(event);
        }
    });

    importTreeTable.setTreeCellRenderer(new NameCellRenderer());

    importTreeTable.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent evt) {
            if (evt.getColumn() != IMPORT_CONFLICTS_COLUMN) {
                for (int row = evt.getFirstRow(); row <= evt.getLastRow()
                        && row < importTreeTable.getRowCount(); row++) {
                    TreePath path = importTreeTable.getPathForRow(row);
                    if (path != null) {
                        ImportTreeTableNode node = (ImportTreeTableNode) path.getLastPathComponent();

                        if (path.getPathCount() == 2) {
                            if (node instanceof ImportUnassignedLibraryTreeTableNode) {
                                String libraryName = (String) node.getValueAt(IMPORT_NAME_COLUMN);
                                String libraryId = null;
                                for (CodeTemplateLibrary library : PlatformUI.MIRTH_FRAME.codeTemplatePanel
                                        .getCachedCodeTemplateLibraries().values()) {
                                    if (library.getName().equals(libraryName)) {
                                        libraryId = library.getId();
                                        break;
                                    }
                                }
                                node.setValueAt(libraryId, IMPORT_ID_COLUMN);
                            } else if (node instanceof ImportLibraryTreeTableNode) {
                                ImportLibraryTreeTableNode libraryNode = (ImportLibraryTreeTableNode) node;
                                libraryNode.setConflicts(getLibraryConflicts(node));
                            }

                            for (Enumeration<? extends TreeTableNode> codeTemplateNodes = node
                                    .children(); codeTemplateNodes.hasMoreElements();) {
                                ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) codeTemplateNodes
                                        .nextElement();
                                codeTemplateNode.setConflicts(getCodeTemplateConflicts(codeTemplateNode));
                            }

                            importTreeTable.updateUI();
                        } else if (path.getPathCount() == 3) {
                            ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) node;
                            codeTemplateNode.setConflicts(getCodeTemplateConflicts(node));
                        }
                    }
                }
            }

            updateImportButton();
            updateErrorsAndWarnings();
        }
    });

    importTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                updateImportButton();
                updateErrorsAndWarnings();
            }
        }
    });

    importTreeTable.expandAll();

    importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN).setMinWidth(20);
    importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN).setMaxWidth(20);
    importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN)
            .setCellRenderer(new ImportSelectedCellRenderer());
    importTreeTable.getColumnModel().getColumn(IMPORT_SELECTED_COLUMN)
            .setCellEditor(new ImportSelectedCellEditor());

    importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN).setMinWidth(60);
    importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN).setMaxWidth(60);
    importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN)
            .setCellRenderer(new OverwriteCellRenderer());
    importTreeTable.getColumnModel().getColumn(IMPORT_OVERWRITE_COLUMN)
            .setCellEditor(new OverwriteCellEditor());

    importTreeTable.getColumnModel().getColumn(IMPORT_CONFLICTS_COLUMN).setMinWidth(60);
    importTreeTable.getColumnModel().getColumn(IMPORT_CONFLICTS_COLUMN).setMaxWidth(60);
    importTreeTable.getColumnModel().getColumn(IMPORT_CONFLICTS_COLUMN).setCellRenderer(new IconCellRenderer());

    importTreeTable.getColumnModel().removeColumn(importTreeTable.getColumnModel().getColumn(IMPORT_ID_COLUMN));

    importTreeTableScrollPane = new JScrollPane(importTreeTable);
    importTreeTableScrollPane.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new Color(0x6E6E6E)));

    warningsPanel = new JPanel();
    warningsPanel.setBackground(getBackground());
    warningsPanel.setVisible(false);

    warningsLabel = new JLabel(UIConstants.ICON_WARNING);

    warningsTextArea = new JTextArea();
    warningsTextArea.setLineWrap(true);
    warningsTextArea.setWrapStyleWord(true);

    errorsPanel = new JPanel();
    errorsPanel.setBackground(getBackground());
    errorsPanel.setVisible(false);

    errorsLabel = new JLabel(UIConstants.ICON_ERROR);

    errorsTextArea = new JTextArea();
    errorsTextArea.setLineWrap(true);
    errorsTextArea.setWrapStyleWord(true);

    separator = new JSeparator();

    buttonPanel = new JPanel();
    buttonPanel.setBackground(getBackground());

    importButton = new JButton("Import");
    importButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                boolean warnings = false;
                for (Enumeration<? extends TreeTableNode> libraryNodes = ((TreeTableNode) importTreeTable
                        .getTreeTableModel().getRoot()).children(); libraryNodes.hasMoreElements();) {
                    for (Enumeration<? extends TreeTableNode> codeTemplateNodes = libraryNodes.nextElement()
                            .children(); codeTemplateNodes.hasMoreElements();) {
                        ImportCodeTemplateTreeTableNode codeTemplateNode = (ImportCodeTemplateTreeTableNode) codeTemplateNodes
                                .nextElement();

                        if ((boolean) codeTemplateNode.getValueAt(IMPORT_SELECTED_COLUMN)) {
                            CodeTemplateConflicts conflicts = codeTemplateNode.getConflicts();
                            if (conflicts.getMatchingCodeTemplate() != null) {
                                warnings = true;
                                break;
                            }
                        }
                    }

                    if (warnings) {
                        break;
                    }
                }

                if (!warnings || PlatformUI.MIRTH_FRAME.alertOption(CodeTemplateImportDialog.this,
                        "Some selected rows have warnings. Are you sure you wish to continue?")) {
                    save();
                    dispose();
                }
            } catch (Exception e) {
                PlatformUI.MIRTH_FRAME.alertThrowable(CodeTemplateImportDialog.this, e,
                        "Unable to import: " + e.getMessage());
            }
        }
    });

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

    updateImportButton();
}

From source file:com.rapidminer.gui.properties.OperatorPropertyPanel.java

@Override
public Component getComponent() {
    if (dockableComponent == null) {
        JScrollPane scrollPane = new ExtendedJScrollPane(this);
        scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        scrollPane.setBorder(null);//from   www . j  a v a  2s.co m

        dockableComponent = new JPanel(new BorderLayout());

        JPanel toolBarPanel = new JPanel(new BorderLayout());
        ViewToolBar toolBar = new ViewToolBar();
        JToggleButton toggleExpertModeButton = mainFrame.TOGGLE_EXPERT_MODE_ACTION.createToggleButton();
        toggleExpertModeButton.setText(null);
        toolBar.add(toggleExpertModeButton);

        showHelpAction.setSelected(isShowParameterHelp());
        JToggleButton helpToggleButton = showHelpAction.createToggleButton();
        helpToggleButton.setText(null);
        toolBar.add(helpToggleButton);

        Action infoOperatorAction = new InfoOperatorAction() {

            private static final long serialVersionUID = 6758272768665592429L;

            @Override
            protected Operator getOperator() {
                return mainFrame.getFirstSelectedOperator();
            }
        };
        toolBar.add(infoOperatorAction);
        JToggleButton enableOperatorButton = new ToggleActivationItem(mainFrame.getActions())
                .createToggleButton();
        enableOperatorButton.setText(null);
        toolBar.add(enableOperatorButton);
        Action renameOperatorAction = new ResourceAction(true, "rename_in_processrenderer") {

            {
                setCondition(OPERATOR_SELECTED, MANDATORY);
            }

            private static final long serialVersionUID = -3104160320178045540L;

            @Override
            public void actionPerformed(ActionEvent e) {
                Operator operator = mainFrame.getFirstSelectedOperator();
                String name = SwingTools.showInputDialog("rename_operator", operator.getName());
                if (name != null && name.length() > 0) {
                    operator.rename(name);
                }
            }
        };
        toolBar.add(renameOperatorAction);
        toolBar.add(new DeleteOperatorAction());
        breakpointButton.addToToolBar(toolBar);

        // toolBar.add(mainFrame.getActions().MAKE_DIRTY_ACTION);
        toolBarPanel.add(toolBar, BorderLayout.NORTH);

        JPanel headerPanel = new JPanel();
        headerPanel.setBackground(SwingTools.LIGHTEST_BLUE);
        headerPanel.add(headerLabel);
        headerPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY));
        toolBarPanel.add(headerPanel, BorderLayout.SOUTH);

        dockableComponent.add(toolBarPanel, BorderLayout.NORTH);
        dockableComponent.add(scrollPane, BorderLayout.CENTER);

        // compatibility level and warnings
        JPanel southPanel = new JPanel(new BorderLayout());
        southPanel.add(expertModeHintLabel, BorderLayout.CENTER);
        compatibilityLabel.setLabelFor(compatibilityLevelSpinner);
        compatibilityLevelSpinner.setPreferredSize(
                new Dimension(80, (int) compatibilityLevelSpinner.getPreferredSize().getHeight()));
        compatibilityPanel.add(compatibilityLabel);
        compatibilityPanel.add(compatibilityLevelSpinner);
        southPanel.add(compatibilityPanel, BorderLayout.SOUTH);

        dockableComponent.add(southPanel, BorderLayout.SOUTH);
    }
    return dockableComponent;
}

From source file:com.jvms.i18neditor.editor.Editor.java

private void setupUI() {
    Color borderColor = Colors.scale(UIManager.getColor("Panel.background"), .8f);

    setTitle(TITLE);/* w w  w .  ja va 2 s  .  c  om*/
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new EditorWindowListener());

    setIconImages(Lists.newArrayList("512", "256", "128", "64", "48", "32", "24", "20", "16").stream()
            .map(size -> Images.loadFromClasspath("images/icon-" + size + ".png").getImage())
            .collect(Collectors.toList()));

    translationTree = new TranslationTree();
    translationTree.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    translationTree.addTreeSelectionListener(new TranslationTreeNodeSelectionListener());
    translationTree.addMouseListener(new TranslationTreeMouseListener());

    translationField = new TranslationField();
    translationField.addKeyListener(new TranslationFieldKeyListener());
    translationField.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1, 0, 0, 1, borderColor),
                    ((CompoundBorder) translationField.getBorder()).getInsideBorder()));

    JScrollPane translationsScrollPane = new JScrollPane(translationTree);
    translationsScrollPane.getViewport().setOpaque(false);
    translationsScrollPane.setOpaque(false);
    translationsScrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, borderColor));

    translationsPanel = new JPanel(new BorderLayout());
    translationsPanel.add(translationsScrollPane);
    translationsPanel.add(translationField, BorderLayout.SOUTH);

    resourcesPanel = new JScrollablePanel(true, false);
    resourcesPanel.setLayout(new BoxLayout(resourcesPanel, BoxLayout.Y_AXIS));
    resourcesPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20));
    resourcesPanel.setOpaque(false);
    resourcesPanel.addMouseListener(new ResourcesPaneMouseListener());

    resourcesScrollPane = new JScrollPane(resourcesPanel);
    resourcesScrollPane.getViewport().setOpaque(false);
    resourcesScrollPane.setOpaque(false);
    resourcesScrollPane.setBorder(null);
    resourcesScrollPane.addMouseListener(new ResourcesPaneMouseListener());

    contentPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, translationsPanel, resourcesScrollPane);
    contentPane.setBorder(null);
    contentPane.setDividerSize(10);

    // Style the split pane divider if possible
    SplitPaneUI splitPaneUI = contentPane.getUI();
    if (splitPaneUI instanceof BasicSplitPaneUI) {
        BasicSplitPaneDivider divider = ((BasicSplitPaneUI) splitPaneUI).getDivider();
        divider.setBorder(null);
        resourcesPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 20));
    }

    introText = new JLabel("<html><body style=\"text-align:center; padding:30px;\">"
            + MessageBundle.get("core.intro.text") + "</body></html>");
    introText.setOpaque(true);
    introText.setFont(introText.getFont().deriveFont(28f));
    introText.setHorizontalTextPosition(JLabel.CENTER);
    introText.setVerticalTextPosition(JLabel.BOTTOM);
    introText.setHorizontalAlignment(JLabel.CENTER);
    introText.setVerticalAlignment(JLabel.CENTER);
    introText.setForeground(getBackground().darker());
    introText.setIcon(Images.loadFromClasspath("images/icon-intro.png"));

    Container container = getContentPane();
    container.add(introText);

    editorMenu = new EditorMenuBar(this, translationTree);
    setJMenuBar(editorMenu);
}