Example usage for javax.swing JSplitPane setDividerLocation

List of usage examples for javax.swing JSplitPane setDividerLocation

Introduction

In this page you can find the example usage for javax.swing JSplitPane setDividerLocation.

Prototype

@BeanProperty(description = "The location of the divider.")
public void setDividerLocation(int location) 

Source Link

Document

Sets the location of the divider.

Usage

From source file:org.tinymediamanager.ui.movies.dialogs.MovieExporterDialog.java

/**
 * Create the dialog./*  w w  w.j  a  va  2s .  c  om*/
 * 
 * @param moviesToExport
 *          the movies to export
 */
public MovieExporterDialog(List<Movie> moviesToExport) {
    super(BUNDLE.getString("movie.export"), "movieExporter"); //$NON-NLS-1$
    setBounds(5, 5, 600, 300);

    getContentPane().setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("300dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, }));

    JSplitPane splitPane = new JSplitPane();
    splitPane.setResizeWeight(0.7);
    getContentPane().add(splitPane, "2, 2, fill, fill");

    JScrollPane scrollPane = new JScrollPane();
    splitPane.setLeftComponent(scrollPane);

    list = new JList();
    scrollPane.setViewportView(list);

    JPanel panelExporterDetails = new JPanel();
    splitPane.setRightComponent(panelExporterDetails);
    panelExporterDetails.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("default:grow"), }));

    lblTemplateName = new JLabel("");
    panelExporterDetails.add(lblTemplateName, "2, 2, 3, 1");

    lblUrl = new JLabel("");
    panelExporterDetails.add(lblUrl, "2, 4, 3, 1");

    chckbxTemplateWithDetail = new JCheckBox("");
    chckbxTemplateWithDetail.setEnabled(false);
    panelExporterDetails.add(chckbxTemplateWithDetail, "2, 6");

    JLabel lblDetails = new JLabel(BUNDLE.getString("export.detail")); //$NON-NLS-1$
    panelExporterDetails.add(lblDetails, "4, 6");

    JScrollPane scrollPaneDescription = new JScrollPane();
    panelExporterDetails.add(scrollPaneDescription, "2, 8, 3, 1, fill, fill");

    tpDescription = new JTextPane();
    scrollPaneDescription.setViewportView(tpDescription);
    splitPane.setDividerLocation(300);

    JPanel panelDestination = new JPanel();
    getContentPane().add(panelDestination, "2, 4, fill, fill");
    panelDestination
            .setLayout(
                    new FormLayout(
                            new ColumnSpec[] { ColumnSpec.decode("150dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                                    FormSpecs.DEFAULT_COLSPEC, },
                            new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, }));

    tfExportDir = new JTextField();
    panelDestination.add(tfExportDir, "1, 1, fill, default");
    tfExportDir.setColumns(10);

    JButton btnSetDestination = new JButton(BUNDLE.getString("export.setdestination")); //$NON-NLS-1$
    panelDestination.add(btnSetDestination, "3, 1");
    btnSetDestination.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("export.selectdirectory")); //$NON-NLS-1$
            if (file != null) {
                tfExportDir.setText(file.toAbsolutePath().toString());
            }
        }
    });

    JPanel panelButtons = new JPanel();
    panelButtons.setLayout(new EqualsLayout(5));
    getContentPane().add(panelButtons, "2, 6, fill, fill");

    JButton btnExport = new JButton("Export");
    btnExport.setIcon(IconManager.EXPORT);
    btnExport.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (StringUtils.isBlank(tfExportDir.getText())) {
                return;
            }
            // check selected template
            int index = list.getSelectedIndex();
            if (index < 0) {
                return;
            }

            ExportTemplate selectedTemplate = templatesFound.get(index);
            if (selectedTemplate != null) {
                try {
                    MovieExporter exporter = new MovieExporter(Paths.get(selectedTemplate.getPath()));
                    exporter.export(movies, Paths.get(tfExportDir.getText()));
                } catch (Exception e) {
                    LOGGER.error("Error exporting movies: ", e);
                }
                setVisible(false);
            }
        }
    });
    panelButtons.add(btnExport);

    JButton btnCancel = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$
    btnCancel.setIcon(IconManager.CANCEL);
    btnCancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            setVisible(false);
        }
    });
    panelButtons.add(btnCancel);

    movies = moviesToExport;
    templatesFound = MovieExporter.findTemplates(TemplateType.MOVIE);
    initDataBindings();
}

From source file:org.tinymediamanager.ui.tvshows.dialogs.TvShowEpisodeChooserDialog.java

public TvShowEpisodeChooserDialog(TvShowEpisode ep, MediaScraper mediaScraper) {
    super(BUNDLE.getString("tvshowepisode.choose"), "episodeChooser"); //$NON-NLS-1$
    setBounds(5, 5, 600, 400);/*from w w  w . j  a  v a  2s.c om*/

    this.episode = ep;
    this.mediaScraper = mediaScraper;
    this.metadata = new MediaEpisode(mediaScraper.getId());
    episodeEventList = new ObservableElementList<>(
            GlazedLists.threadSafeList(new BasicEventList<TvShowEpisodeChooserModel>()),
            GlazedLists.beanConnector(TvShowEpisodeChooserModel.class));
    sortedEpisodes = new SortedList<>(GlazedListsSwing.swingThreadProxyList(episodeEventList),
            new EpisodeComparator());

    getContentPane().setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("590px:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("200dlu:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:37px"),
                    FormSpecs.RELATED_GAP_ROWSPEC, }));
    {
        JSplitPane splitPane = new JSplitPane();
        getContentPane().add(splitPane, "2, 2, fill, fill");

        JPanel panelLeft = new JPanel();
        panelLeft.setLayout(new FormLayout(
                new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150dlu:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormSpecs.RELATED_GAP_ROWSPEC, }));

        textField = EnhancedTextField.createSearchTextField();
        panelLeft.add(textField, "2, 2, fill, default");
        textField.setColumns(10);

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setMinimumSize(new Dimension(200, 23));
        panelLeft.add(scrollPane, "2, 4, fill, fill");
        splitPane.setLeftComponent(panelLeft);

        MatcherEditor<TvShowEpisodeChooserModel> textMatcherEditor = new TextComponentMatcherEditor<>(textField,
                new TvShowEpisodeChooserModelFilterator());
        FilterList<TvShowEpisodeChooserModel> textFilteredEpisodes = new FilterList<>(sortedEpisodes,
                textMatcherEditor);
        AdvancedTableModel<TvShowEpisodeChooserModel> episodeTableModel = GlazedListsSwing
                .eventTableModelWithThreadProxyList(textFilteredEpisodes, new EpisodeTableFormat());
        DefaultEventSelectionModel<TvShowEpisodeChooserModel> selectionModel = new DefaultEventSelectionModel<>(
                textFilteredEpisodes);
        selectedEpisodes = selectionModel.getSelected();

        selectionModel.addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting()) {
                    return;
                }
                // display first selected episode
                if (!selectedEpisodes.isEmpty()) {
                    TvShowEpisodeChooserModel episode = selectedEpisodes.get(0);
                    taPlot.setText(episode.getOverview());
                } else {
                    taPlot.setText("");
                }
                taPlot.setCaretPosition(0);
            }
        });

        table = new JTable(episodeTableModel);
        table.setSelectionModel(selectionModel);
        scrollPane.setViewportView(table);

        JPanel panelRight = new JPanel();
        panelRight.setLayout(new FormLayout(
                new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150dlu:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.LINE_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormSpecs.RELATED_GAP_ROWSPEC, }));
        JScrollPane scrollPane_1 = new JScrollPane();
        panelRight.add(scrollPane_1, "2, 2, fill, fill");
        splitPane.setRightComponent(panelRight);

        taPlot = new JTextArea();
        taPlot.setEditable(false);
        taPlot.setWrapStyleWord(true);
        taPlot.setLineWrap(true);
        scrollPane_1.setViewportView(taPlot);
        splitPane.setDividerLocation(300);

    }
    JPanel bottomPanel = new JPanel();
    getContentPane().add(bottomPanel, "2, 4, fill, top");

    bottomPanel.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("25px"),
                    FormFactory.RELATED_GAP_ROWSPEC, }));

    JPanel buttonPane = new JPanel();
    bottomPanel.add(buttonPane, "5, 2, fill, fill");
    EqualsLayout layout = new EqualsLayout(5);
    layout.setMinWidth(100);
    buttonPane.setLayout(layout);
    final JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$
    okButton.setToolTipText(BUNDLE.getString("tvshow.change"));
    okButton.setIcon(IconManager.APPLY);
    buttonPane.add(okButton);
    okButton.setActionCommand("OK");
    okButton.addActionListener(this);

    JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$
    cancelButton.setToolTipText(BUNDLE.getString("edit.discard"));
    cancelButton.setIcon(IconManager.CANCEL);
    buttonPane.add(cancelButton);
    cancelButton.setActionCommand("Cancel");
    cancelButton.addActionListener(this);

    // column widths
    table.getColumnModel().getColumn(0).setMaxWidth(50);
    table.getColumnModel().getColumn(1).setMaxWidth(50);

    SearchTask task = new SearchTask();
    task.execute();

    MouseListener mouseListener = new MouseListener() {

        @Override
        public void mouseReleased(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2 && !e.isConsumed() && e.getButton() == MouseEvent.BUTTON1) {
                actionPerformed(new ActionEvent(okButton, ActionEvent.ACTION_PERFORMED, "OK"));
            }
        }

    };
    table.addMouseListener(mouseListener);
}

From source file:org.tinymediamanager.ui.tvshows.dialogs.TvShowExporterDialog.java

/**
 * Create the dialog./* w  ww. j  a  v  a2s .  c  o  m*/
 * 
 * @param tvShowsToExport
 *          the movies to export
 */
public TvShowExporterDialog(List<TvShow> tvShowsToExport) {
    super(BUNDLE.getString("tvshow.export"), "tvShowExporter"); //$NON-NLS-1$
    setBounds(5, 5, 600, 300);

    getContentPane().setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("300dlu:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, }));

    JSplitPane splitPane = new JSplitPane();
    splitPane.setResizeWeight(0.7);
    getContentPane().add(splitPane, "2, 2, fill, fill");

    JScrollPane scrollPane = new JScrollPane();
    splitPane.setLeftComponent(scrollPane);

    list = new JList();
    scrollPane.setViewportView(list);

    JPanel panelExporterDetails = new JPanel();
    splitPane.setRightComponent(panelExporterDetails);
    panelExporterDetails.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("default:grow"), }));

    lblTemplateName = new JLabel("");
    panelExporterDetails.add(lblTemplateName, "2, 2, 3, 1");

    lblUrl = new JLabel("");
    panelExporterDetails.add(lblUrl, "2, 4, 3, 1");

    chckbxTemplateWithDetail = new JCheckBox("");
    chckbxTemplateWithDetail.setEnabled(false);
    panelExporterDetails.add(chckbxTemplateWithDetail, "2, 6");

    JLabel lblDetails = new JLabel(BUNDLE.getString("export.detail")); //$NON-NLS-1$
    panelExporterDetails.add(lblDetails, "4, 6");

    JScrollPane scrollPaneDescription = new JScrollPane();
    panelExporterDetails.add(scrollPaneDescription, "2, 8, 3, 1, fill, fill");

    tpDescription = new JTextPane();
    scrollPaneDescription.setViewportView(tpDescription);
    splitPane.setDividerLocation(300);

    JPanel panel = new JPanel();
    getContentPane().add(panel, "2, 4, fill, fill");
    panel.setLayout(
            new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                    FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, }));

    tfExportDir = new JTextField();
    panel.add(tfExportDir, "1, 1, fill, default");
    tfExportDir.setColumns(10);

    JButton btnSetDestination = new JButton(BUNDLE.getString("export.setdestination")); //$NON-NLS-1$
    panel.add(btnSetDestination, "3, 1");
    btnSetDestination.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("export.selectdirectory")); //$NON-NLS-1$
            if (file != null) {
                tfExportDir.setText(file.toAbsolutePath().toString());
            }
        }
    });

    JPanel panelButtons = new JPanel();
    panelButtons.setLayout(new EqualsLayout(5));
    getContentPane().add(panelButtons, "2, 6, fill, fill");

    JButton btnExport = new JButton("Export");
    btnExport.setIcon(IconManager.EXPORT);
    btnExport.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (StringUtils.isBlank(tfExportDir.getText())) {
                return;
            }
            // check selected template
            int index = list.getSelectedIndex();
            if (index < 0) {
                return;
            }

            ExportTemplate selectedTemplate = templatesFound.get(index);
            if (selectedTemplate != null) {
                try {
                    TvShowExporter exporter = new TvShowExporter(Paths.get(selectedTemplate.getPath()));
                    exporter.export(tvShows, Paths.get(tfExportDir.getText()));
                } catch (Exception e) {
                    LOGGER.error("Error exporting tv shows: ", e);
                }
                setVisible(false);
            }
        }
    });
    panelButtons.add(btnExport);

    JButton btnCancel = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$
    btnCancel.setIcon(IconManager.CANCEL);
    btnCancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            setVisible(false);
        }
    });
    panelButtons.add(btnCancel);

    tvShows = tvShowsToExport;
    templatesFound = TvShowExporter.findTemplates(TemplateType.TV_SHOW);
    initDataBindings();
}

From source file:org.tros.torgo.ControllerBase.java

/**
 * Initialize the window. This is called here from run() and not the
 * constructor so that the Service Provider doesn't load up all of the
 * necessary resources when the application loads.
 *///  w w  w . j ava  2  s .c  o m
private void initSwing() {
    this.torgoPanel = createConsole((Controller) this);
    this.torgoCanvas = createCanvas(torgoPanel);

    //init the GUI w/ the components...
    Container contentPane = window.getContentPane();
    JToolBar tb = createToolBar();
    if (tb != null) {
        contentPane.add(tb, BorderLayout.NORTH);
    }

    final java.util.prefs.Preferences prefs = java.util.prefs.Preferences.userNodeForPackage(NamedWindow.class);
    if (torgoCanvas != null) {
        final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, torgoCanvas.getComponent(),
                torgoPanel.getComponent());
        int dividerLocation = prefs.getInt(this.getClass().getName() + "divider-location",
                window.getWidth() - 300);
        splitPane.setDividerLocation(dividerLocation);
        splitPane.addPropertyChangeListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent pce) {
                prefs.putInt(this.getClass().getName() + "divider-location", splitPane.getDividerLocation());
            }
        });

        contentPane.add(splitPane);
    } else {
        contentPane.add(torgoPanel.getComponent());
    }

    JMenuBar mb = createMenuBar();
    if (mb == null) {
        mb = new TorgoMenuBar(window, this);
    }
    window.setJMenuBar(mb);
    JMenu helpMenu = new JMenu("Help");
    JMenuItem aboutMenu = new JMenuItem("About Torgo");
    try {
        java.util.Enumeration<URL> resources = ClassLoader.getSystemClassLoader()
                .getResources(ABOUT_MENU_TORGO_ICON);
        ImageIcon ico = new ImageIcon(resources.nextElement());
        aboutMenu.setIcon(ico);
    } catch (IOException ex) {
        Logger.getLogger(ControllerBase.class.getName()).log(Level.SEVERE, null, ex);
    }

    aboutMenu.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            AboutWindow aw = new AboutWindow();
            aw.setVisible(true);
        }
    });
    helpMenu.add(aboutMenu);

    JMenu vizMenu = new JMenu("Visualization");
    for (String name : TorgoToolkit.getVisualizers()) {
        JCheckBoxMenuItem item = new JCheckBoxMenuItem(name);
        viz.add(item);
        vizMenu.add(item);
    }
    if (vizMenu.getItemCount() > 0) {
        mb.add(vizMenu);
    }

    mb.add(helpMenu);
    window.setJMenuBar(mb);

    window.addWindowListener(new WindowListener() {

        @Override
        public void windowOpened(WindowEvent e) {
        }

        /**
         * We only care if the window is closing so we can kill the
         * interpreter thread.
         *
         * @param e
         */
        @Override
        public void windowClosing(WindowEvent e) {
            stopInterpreter();
        }

        @Override
        public void windowClosed(WindowEvent e) {
        }

        @Override
        public void windowIconified(WindowEvent e) {
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
        }

        @Override
        public void windowActivated(WindowEvent e) {
        }

        @Override
        public void windowDeactivated(WindowEvent e) {
        }
    });
}

From source file:org.zaproxy.zap.extension.ascan.CustomScanDialog.java

private JPanel getCustomPanel() {
    if (customPanel == null) {
        customPanel = new JPanel(new GridBagLayout());

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
        scrollPane.setViewportView(getRequestField());

        JPanel buttonPanel = new JPanel(new GridBagLayout());

        getRequestField().addCaretListener(new CaretListener() {
            @Override/*  ww w  .  java2  s  .c o m*/
            public void caretUpdate(CaretEvent event) {
                setFieldStates();
            }
        });

        buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(0, 0, 1, 0.5)); // Spacer
        buttonPanel.add(getAddCustomButton(), LayoutHelper.getGBC(1, 0, 1, 1, 0.0D, 0.0D,
                GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST, new Insets(5, 5, 5, 5)));

        buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(2, 0, 1, 0.5)); // Spacer

        buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(0, 1, 1, 0.5)); // Spacer
        buttonPanel.add(getRemoveCustomButton(), LayoutHelper.getGBC(1, 1, 1, 1, 0.0D, 0.0D,
                GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST, new Insets(5, 5, 5, 5)));

        buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(2, 1, 1, 0.5)); // Spacer

        JScrollPane scrollPane2 = new JScrollPane(getInjectionPointList());
        scrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

        buttonPanel.add(new JLabel(Constant.messages.getString("ascan.custom.label.vectors")),
                LayoutHelper.getGBC(0, 2, 3, 0.0D, 0.0D));

        buttonPanel.add(scrollPane2, LayoutHelper.getGBC(0, 3, 3, 1.0D, 1.0D));

        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPane, buttonPanel);
        splitPane.setDividerLocation(550);
        customPanel.add(splitPane, LayoutHelper.getGBC(0, 0, 1, 1, 1.0D, 1.0D));
        customPanel.add(customPanelStatus, LayoutHelper.getGBC(0, 1, 1, 1, 1.0D, 0.0D));
        customPanel.add(getDisableNonCustomVectors(), LayoutHelper.getGBC(0, 2, 1, 1, 1.0D, 0.0D));
    }

    return customPanel;
}

From source file:org.zaproxy.zap.extension.customFire.CustomFireDialog.java

/**
 * //from w w  w . java 2  s  .c o m
 * @param highlightList
 * @param httpReq
 * @return JPanel 
 * Returns CustomPanel with saved injectionList 
 */
private JPanel getSavedCustomPanel(ArrayList highlightList, String httpReq) {

    customPanel = new JPanel(new GridBagLayout());

    JScrollPane scrollPane = new JScrollPane(); //gT
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setViewportView(getRequestField());

    JPanel buttonPanel = new JPanel(new GridBagLayout());

    getRequestField().addCaretListener(new CaretListener() {
        @Override
        public void caretUpdate(CaretEvent event) {
            setFieldStates();

        }
    });

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(0, 0, 1, 0.5)); // Spacer
    buttonPanel.add(getAddCustomButton(), LayoutHelper.getGBC(1, 0, 1, 1, 0.0D, 0.0D, GridBagConstraints.BOTH,
            GridBagConstraints.NORTHWEST, new Insets(5, 5, 5, 5)));

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(2, 0, 1, 0.5)); // Spacer

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(0, 1, 1, 0.5)); // Spacer
    buttonPanel.add(getRemoveCustomButton(), LayoutHelper.getGBC(1, 1, 1, 1, 0.0D, 0.0D,
            GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST, new Insets(5, 5, 5, 5)));

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(2, 1, 1, 0.5)); // Spacer

    JScrollPane scrollPane2 = new JScrollPane(getSavedInjectionPointList(highlightList, httpReq));

    scrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

    buttonPanel.add(new JLabel(Constant.messages.getString("customFire.custom.label.vectors")),
            LayoutHelper.getGBC(0, 2, 3, 0.0D, 0.0D));

    buttonPanel.add(scrollPane2, LayoutHelper.getGBC(0, 3, 3, 1.0D, 1.0D)); //gT

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPane, buttonPanel);
    splitPane.setDividerLocation(550);

    customPanel.add(splitPane, LayoutHelper.getGBC(0, 0, 1, 1, 1.0D, 1.0D));
    customPanel.add(customPanelStatus, LayoutHelper.getGBC(0, 1, 1, 1, 1.0D, 0.0D));
    customPanel.add(getDisableNonCustomVectors(), LayoutHelper.getGBC(0, 2, 1, 1, 1.0D, 0.0D));

    return customPanel;
}

From source file:org.zaproxy.zap.extension.customFire.CustomFireDialog.java

/**
 * //from   w w  w.  j  a  va2 s.c  om
 * @return JPanel `
 */
private JPanel getCustomPanel() {

    customPanel = new JPanel(new GridBagLayout());

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setViewportView(getRequestField());

    JPanel buttonPanel = new JPanel(new GridBagLayout());

    getRequestField().addCaretListener(new CaretListener() {
        @Override
        public void caretUpdate(CaretEvent event) {
            setFieldStates();

        }
    });

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(0, 0, 1, 0.5)); // Spacer
    buttonPanel.add(getAddCustomButton(), LayoutHelper.getGBC(1, 0, 1, 1, 0.0D, 0.0D, GridBagConstraints.BOTH,
            GridBagConstraints.NORTHWEST, new Insets(5, 5, 5, 5)));

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(2, 0, 1, 0.5)); // Spacer

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(0, 1, 1, 0.5)); // Spacer
    buttonPanel.add(getRemoveCustomButton(), LayoutHelper.getGBC(1, 1, 1, 1, 0.0D, 0.0D,
            GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST, new Insets(5, 5, 5, 5)));

    buttonPanel.add(new JLabel(""), LayoutHelper.getGBC(2, 1, 1, 0.5)); // Spacer

    JScrollPane scrollPane2 = new JScrollPane(getInjectionPointList());
    scrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);

    buttonPanel.add(new JLabel(Constant.messages.getString("customFire.custom.label.vectors")),
            LayoutHelper.getGBC(0, 2, 3, 0.0D, 0.0D));

    buttonPanel.add(scrollPane2, LayoutHelper.getGBC(0, 3, 3, 1.0D, 1.0D)); //gT

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPane, buttonPanel);
    splitPane.setDividerLocation(550);

    customPanel.add(splitPane, LayoutHelper.getGBC(0, 0, 1, 1, 1.0D, 1.0D));
    customPanel.add(customPanelStatus, LayoutHelper.getGBC(0, 1, 1, 1, 1.0D, 0.0D));
    customPanel.add(getDisableNonCustomVectors(), LayoutHelper.getGBC(0, 2, 1, 1, 1.0D, 0.0D));
    //}

    return customPanel;
}

From source file:pl.otros.logview.gui.Log4jPatternParserEditor.java

private void createGui() {
    this.setLayout(new BorderLayout());
    heading1Font = new JLabel().getFont().deriveFont(20f).deriveFont(Font.BOLD);
    heading2Font = new JLabel().getFont().deriveFont(14f).deriveFont(Font.BOLD);

    loadLog = new JButton("Load log", Icons.FOLDER_OPEN);
    testParser = new JButton("Test parser", Icons.WRENCH_ARROW);
    saveParser = new JButton("Save", Icons.DISK);
    logFileContent = new JTextArea();
    DefaultSyntaxKit.initKit();//  ww  w  . j a v  a 2s.  c om
    propertyEditor = new JEditorPane();

    logFileContent = new JTextArea();
    logViewPanel = new LogViewPanel(new LogDataTableModel(), TableColumns.ALL_WITHOUT_LOG_SOURCE,
            otrosApplication);
    JPanel panelEditorActions = new JPanel(new BorderLayout(5, 5));
    JToolBar actionsToolBar = new JToolBar("Actions");
    actionsToolBar.setFloatable(false);
    actionsToolBar.add(testParser);
    actionsToolBar.add(saveParser);

    JToolBar propertyEditorToolbar = new JToolBar();
    JLabel labelEditProperties = new JLabel("Edit your properties: and test parser");
    labelEditProperties.setFont(heading2Font);
    propertyEditorToolbar.add(labelEditProperties);
    panelEditorActions.add(propertyEditorToolbar, BorderLayout.NORTH);
    panelEditorActions.add(actionsToolBar, BorderLayout.SOUTH);
    panelEditorActions.add(new JScrollPane(propertyEditor));

    logFileContentLabel = new JLabel(" Load your log file, paste from clipboard or drag and drop file. ");
    JToolBar loadToolbar = new JToolBar();
    loadToolbar.add(logFileContentLabel);
    loadToolbar.add(loadLog);
    logFileContentLabel.setFont(heading2Font);
    JPanel logContentPanel = new JPanel(new BorderLayout(5, 5));
    logContentPanel.add(new JScrollPane(logFileContent));
    logContentPanel.add(loadToolbar, BorderLayout.NORTH);

    JSplitPane northSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    northSplit.setOneTouchExpandable(true);
    northSplit.add(logContentPanel);
    northSplit.add(panelEditorActions);

    JPanel southPanel = new JPanel(new BorderLayout(5, 5));
    JLabel labelParsingResult = new JLabel(" Parsing result:");
    labelParsingResult.setFont(heading1Font);
    southPanel.add(labelParsingResult, BorderLayout.NORTH);
    southPanel.add(logViewPanel);

    JSplitPane mainSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    mainSplit.setOneTouchExpandable(true);
    mainSplit.add(northSplit);
    mainSplit.add(southPanel);
    mainSplit.setDividerLocation(0.5f);

    add(mainSplit);

    propertyEditor.setContentType("text/properties");

}

From source file:pl.otros.logview.gui.LogViewPanel.java

public LogViewPanel(final LogDataTableModel dataTableModel, TableColumns[] visibleColumns,
        final OtrosApplication otrosApplication) {
    super();/*from  w  w w .j a v  a 2  s .  co m*/
    this.dataTableModel = dataTableModel;
    this.otrosApplication = otrosApplication;
    this.statusObserver = otrosApplication.getStatusObserver();
    configuration = otrosApplication.getConfiguration();

    AllPluginables allPluginable = AllPluginables.getInstance();
    markersContainer = allPluginable.getMarkersContainser();
    markersContainer.addListener(new MarkersMenuReloader());
    logFiltersContainer = allPluginable.getLogFiltersContainer();
    messageColorizersContainer = allPluginable.getMessageColorizers();
    messageFormattersContainer = allPluginable.getMessageFormatters();
    selectedMessageColorizersContainer = new PluginableElementsContainer<MessageColorizer>();
    selectedMessageFormattersContainer = new PluginableElementsContainer<MessageFormatter>();
    for (MessageColorizer messageColorizer : messageColorizersContainer.getElements()) {
        selectedMessageColorizersContainer.addElement(messageColorizer);
    }
    for (MessageFormatter messageFormatter : messageFormattersContainer.getElements()) {
        selectedMessageFormattersContainer.addElement(messageFormatter);
    }
    messageColorizersContainer.addListener(
            new SynchronizePluginableContainerListener<MessageColorizer>(selectedMessageColorizersContainer));
    messageFormattersContainer.addListener(
            new SynchronizePluginableContainerListener<MessageFormatter>(selectedMessageFormattersContainer));

    menuLabelFont = new JLabel().getFont().deriveFont(Font.BOLD);
    filtersPanel = new JPanel();
    logsTablePanel = new JPanel();
    logsMarkersPanel = new JPanel();
    leftPanel = new JPanel(new MigLayout());
    logDetailTextArea = new JTextPane();
    logDetailTextArea.setEditable(false);
    MouseAdapter locationInfo = new LocationClickMouseAdapter(otrosApplication, logDetailTextArea);
    logDetailTextArea.addMouseMotionListener(locationInfo);
    logDetailTextArea.addMouseListener(locationInfo);
    logDetailTextArea.setBorder(BorderFactory.createTitledBorder("Details"));
    logDetailWithRulerScrollPane = RulerBarHelper.wrapTextComponent(logDetailTextArea);
    table = new JTableWith2RowHighliting(dataTableModel);

    // Initialize default column visible before creating context menu
    table.setColumnControlVisible(true);
    final ColumnControlButton columnControlButton = new ColumnControlButton(table) {

        @Override
        public void togglePopup() {
            populatePopup();
            super.togglePopup();
        }

        @Override
        protected List<Action> getAdditionalActions() {
            final List<Action> additionalActions = super.getAdditionalActions();
            final AbstractAction saveLayout = new AbstractAction("Save current to new column layout",
                    Icons.DISK) {
                @Override
                public void actionPerformed(ActionEvent actionEvent) {
                    String newLayoutName = JOptionPane.showInputDialog(table, "New Layout name");
                    if (newLayoutName == null) {
                        return;
                    }
                    newLayoutName = newLayoutName.trim();
                    LOGGER.info(String.format("Saving New column layout '%s'", newLayoutName));
                    ArrayList<String> visibleColNames = new ArrayList<String>();
                    for (TableColumn tc : table.getColumns()) {
                        Object o = tc.getIdentifier();
                        if (!(o instanceof TableColumns)) {
                            LOGGER.severe("TableColumn identifier of unexpected type: "
                                    + tc.getIdentifier().getClass().getName());
                            LOGGER.warning("Throw up a pop-up");
                            return;
                        }
                        TableColumns tcs = (TableColumns) o;
                        visibleColNames.add(tcs.getName());
                    }
                    ColumnLayout columnLayout = new ColumnLayout(newLayoutName, visibleColNames);
                    final List<ColumnLayout> columnLayouts = LogTableFormatConfigView
                            .loadColumnLayouts(configuration);
                    columnLayouts.add(columnLayout);
                    LogTableFormatConfigView.saveColumnLayouts(columnLayouts, configuration);
                    populatePopup();
                }
            };
            additionalActions.add(saveLayout);

            final List<ColumnLayout> columnLayoutNames = LogTableFormatConfigView
                    .loadColumnLayouts(configuration);
            for (final ColumnLayout columnLayout : columnLayoutNames) {
                final String name = columnLayout.getName();
                final AbstractAction applyColumnLayout = new ApplyColumnLayoutAction(name, Icons.EDIT_COLUMNS,
                        columnLayout, table);
                additionalActions.add(applyColumnLayout);
            }
            return additionalActions;
        }
    };
    table.setColumnControl(columnControlButton);

    List<TableColumn> columns = table.getColumns(true);
    for (int i = 0; i < columns.size(); i++) {
        columns.get(i).setIdentifier(TableColumns.getColumnById(i));
    }
    for (TableColumn tableColumn : columns) {
        table.getColumnExt(tableColumn.getIdentifier()).setVisible(false);
    }
    for (TableColumns tableColumns : visibleColumns) {
        table.getColumnExt(tableColumns).setVisible(true);
    }

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    updateColumnsSize();
    table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
    final Renderers renderers = Renderers.getInstance(otrosApplication);
    table.setDefaultRenderer(String.class, new TableMarkDecoratorRenderer(renderers.getStringRenderer()));
    table.setDefaultRenderer(Object.class,
            new TableMarkDecoratorRenderer(table.getDefaultRenderer(Object.class)));
    table.setDefaultRenderer(Integer.class,
            new TableMarkDecoratorRenderer(table.getDefaultRenderer(Object.class)));
    table.setDefaultRenderer(Level.class, new TableMarkDecoratorRenderer(renderers.getLevelRenderer()));
    table.setDefaultRenderer(Date.class, new TableMarkDecoratorRenderer(renderers.getDateRenderer()));
    final TimeDeltaRenderer timeDeltaRenderer = new TimeDeltaRenderer();
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent listSelectionEvent) {
            final int[] selectedRows = table.getSelectedRows();
            if (selectedRows.length > 0) {
                final int selectedRow = selectedRows[selectedRows.length - 1];
                final Date selectedDate = dataTableModel.getLogData(table.convertRowIndexToModel(selectedRow))
                        .getDate();
                timeDeltaRenderer.setSelectedTimestamp(selectedDate);
                table.repaint();
            }
        }
    });
    table.setDefaultRenderer(TimeDelta.class, new TableMarkDecoratorRenderer(timeDeltaRenderer));

    ((EventSource) configuration.getConfiguration()).addConfigurationListener(new ConfigurationListener() {
        @Override
        public void configurationChanged(ConfigurationEvent ce) {
            if (ce.getType() == AbstractConfiguration.EVENT_SET_PROPERTY && !ce.isBeforeUpdate()) {
                if (ce.getPropertyName().equals(ConfKeys.LOG_TABLE_FORMAT_DATE_FORMAT)) {
                    table.setDefaultRenderer(Date.class, new TableMarkDecoratorRenderer(new DateRenderer(
                            configuration.getString(ConfKeys.LOG_TABLE_FORMAT_DATE_FORMAT, "HH:mm:ss.SSS"))));
                    updateTimeColumnSize();
                } else if (ce.getPropertyName().equals(ConfKeys.LOG_TABLE_FORMAT_LEVEL_RENDERER)) {
                    table.setDefaultRenderer(Level.class,
                            new TableMarkDecoratorRenderer(new LevelRenderer(configuration.get(
                                    LevelRenderer.Mode.class, ConfKeys.LOG_TABLE_FORMAT_LEVEL_RENDERER,
                                    LevelRenderer.Mode.IconsOnly))));
                    updateLevelColumnSize();
                }
            }
        }
    });

    table.setDefaultRenderer(Boolean.class,
            new TableMarkDecoratorRenderer(table.getDefaultRenderer(Boolean.class)));
    table.setDefaultRenderer(Note.class, new TableMarkDecoratorRenderer(new NoteRenderer()));
    table.setDefaultRenderer(MarkerColors.class, new TableMarkDecoratorRenderer(new MarkTableRenderer()));
    table.setDefaultEditor(Note.class, new NoteTableEditor());
    table.setDefaultEditor(MarkerColors.class, new MarkTableEditor(otrosApplication));
    table.setDefaultRenderer(ClassWrapper.class,
            new TableMarkDecoratorRenderer(renderers.getClassWrapperRenderer()));
    sorter = new TableRowSorter<LogDataTableModel>(dataTableModel);
    for (int i = 0; i < dataTableModel.getColumnCount(); i++) {
        sorter.setSortable(i, false);
    }
    sorter.setSortable(TableColumns.ID.getColumn(), true);
    sorter.setSortable(TableColumns.TIME.getColumn(), true);
    table.setRowSorter(sorter);

    messageDetailListener = new MessageDetailListener(this, dateFormat, selectedMessageFormattersContainer,
            selectedMessageColorizersContainer);
    table.getSelectionModel().addListSelectionListener(messageDetailListener);
    dataTableModel.addNoteObserver(messageDetailListener);

    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            boolean hasFocus = otrosApplication.getApplicationJFrame().isFocused();
            final boolean enabled = otrosApplication.getConfiguration()
                    .getBoolean(ConfKeys.JUMP_TO_CODE_AUTO_JUMP_ENABLED, false);
            if (hasFocus && enabled && !e.getValueIsAdjusting()) {
                try {
                    final LogData logData = dataTableModel
                            .getLogData(table.convertRowIndexToModel(e.getFirstIndex()));
                    LocationInfo li = new LocationInfo(logData.getClazz(), logData.getMethod(),
                            logData.getFile(), Integer.valueOf(logData.getLine()));
                    final JumpToCodeService jumpToCodeService = otrosApplication.getServices()
                            .getJumpToCodeService();
                    final boolean ideAvailable = jumpToCodeService.isIdeAvailable();
                    if (ideAvailable) {
                        LOGGER.fine("Jumping to " + li);
                        jumpToCodeService.jump(li);
                    }
                } catch (Exception e1) {
                    LOGGER.warning("Can't perform jump to code " + e1.getMessage());
                }

            }
        }
    });

    notes = new JTextArea();
    notes.setEditable(false);
    NoteObserver allNotesObserver = new AllNotesTextAreaObserver(notes);
    dataTableModel.addNoteObserver(allNotesObserver);

    addFiltersGUIsToPanel(filtersPanel);
    logsTablePanel.setLayout(new BorderLayout());
    logsTablePanel.add(new JScrollPane(table));
    JPanel messageDetailsPanel = new JPanel(new BorderLayout());
    messageDetailToolbar = new JToolBar("MessageDetail");
    messageDetailsPanel.add(messageDetailToolbar, BorderLayout.NORTH);
    messageDetailsPanel.add(logDetailWithRulerScrollPane);
    initMessageDetailsToolbar();

    jTabbedPane = new JTabbedPane();
    jTabbedPane.add("Message detail", messageDetailsPanel);
    jTabbedPane.add("All notes", new JScrollPane(notes));

    leftPanel.add(filtersPanel, "wrap, growx");
    leftPanel.add(new JSeparator(SwingConstants.HORIZONTAL), "wrap,growx");
    leftPanel.add(logsMarkersPanel, "wrap,growx");

    JSplitPane splitPaneLogsTableAndDetails = new JSplitPane(JSplitPane.VERTICAL_SPLIT, logsTablePanel,
            jTabbedPane);
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftPanel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED),
            splitPaneLogsTableAndDetails);
    splitPane.setOneTouchExpandable(true);
    this.setLayout(new BorderLayout());
    this.add(splitPane);

    splitPaneLogsTableAndDetails.setDividerLocation(0.5d);
    splitPaneLogsTableAndDetails.setOneTouchExpandable(true);
    splitPane.setDividerLocation(leftPanel.getPreferredSize().width + 10);

    PopupListener popupListener = new PopupListener(new Callable<JPopupMenu>() {
        @Override
        public JPopupMenu call() throws Exception {
            return initTableContextMenu();
        }
    });
    table.addMouseListener(popupListener);
    table.addKeyListener(popupListener);

    PopupListener popupListenerMessageDetailMenu = new PopupListener(new Callable<JPopupMenu>() {
        @Override
        public JPopupMenu call() throws Exception {
            return initMessageDetailPopupMenu();
        }
    });
    logDetailTextArea.addMouseListener(popupListenerMessageDetailMenu);
    logDetailTextArea.addKeyListener(popupListenerMessageDetailMenu);

    dataTableModel.notifyAllNoteObservers(new NoteEvent(EventType.CLEAR, dataTableModel, null, 0));

    table.addKeyListener(new MarkRowBySpaceKeyListener(otrosApplication));
    initAcceptConditions();
}

From source file:pl.otros.logview.gui.message.editor.MessageColorizerBrowser.java

public MessageColorizerBrowser(OtrosApplication otrosApplication) {
    super(new BorderLayout());
    this.container = otrosApplication.getAllPluginables().getMessageColorizers();
    this.otrosApplication = otrosApplication;

    toolBar = new JToolBar();
    editor = new MessageColorizerEditor(container, otrosApplication.getStatusObserver());
    JLabel noEditable = new JLabel("Selected MessageColorizer is not editable.", SwingConstants.CENTER);
    JLabel nothingSelected = new JLabel("Nothing selected", SwingConstants.CENTER);

    listModel = new PluginableElementListModel<MessageColorizer>(container);
    jList = new JList(listModel);
    jList.setCellRenderer(new PluginableElementNameListRenderer());
    cardLayout = new CardLayout();
    contentPanel = new JPanel(cardLayout);
    contentPanel.add(editor, CARD_LAYOUT_EDITOR);
    contentPanel.add(noEditable, CARD_LAYOUT_NOT_EDITABLE);
    contentPanel.add(nothingSelected, CARD_LAYOUT_NO_SELECTED);
    cardLayout.show(contentPanel, CARD_LAYOUT_NOT_EDITABLE);
    JSplitPane mainSplitPane = new JSplitPane(SwingConstants.VERTICAL, new JScrollPane(jList), contentPanel);
    mainSplitPane.setDividerLocation(220);

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

        @Override/* w  w w  . ja v  a  2 s  .  co  m*/
        public void valueChanged(ListSelectionEvent e) {
            showSelected();
            enableDisableButtonsForSelectedColorizer();
        }

    });

    jList.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            int keyCode = e.getKeyCode();
            if (keyCode == KeyEvent.VK_DELETE) {
                ActionEvent actionEvent = new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, "");
                deleteAction.actionPerformed(actionEvent);
            }
        }
    });

    JButton createNew = new JButton("Create new", Icons.ADD);
    createNew.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveAsButton.setEnabled(false);
            createNew();
        }
    });

    saveButton = new JButton("Save and use", Icons.DISK);
    saveButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            try {
                PropertyPatternMessageColorizer mc = editor.createMessageColorizer();
                File selectedFile = null;
                String f = mc.getFile();
                if (StringUtils.isNotBlank(f)) {
                    selectedFile = new File(mc.getFile());
                } else {
                    int response = chooser.showSaveDialog(MessageColorizerBrowser.this);
                    if (response != JFileChooser.APPROVE_OPTION) {
                        return;
                    }
                    selectedFile = chooser.getSelectedFile();
                    if (!selectedFile.getName().endsWith(".pattern")) {
                        selectedFile = new File(selectedFile.getParentFile(),
                                selectedFile.getName() + ".pattern");
                    }
                }
                removeMessageColorizerWithNullFile();
                applyMessageColorizer(selectedFile);
                saveMessageColorizer(selectedFile);
                jList.setSelectedValue(mc, true);
            } catch (ConfigurationException e1) {
                String errorMessage = String.format("Can't save message colorizer: %s", e1.getMessage());
                LOGGER.severe(errorMessage);
                MessageColorizerBrowser.this.otrosApplication.getStatusObserver().updateStatus(errorMessage,
                        StatusObserver.LEVEL_ERROR);
            }
        }
    });

    saveAsButton = new JButton("Save as", Icons.DISK_PLUS);
    saveAsButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                int response = chooser.showSaveDialog(MessageColorizerBrowser.this);
                if (response != JFileChooser.APPROVE_OPTION) {
                    return;
                }
                File selectedFile = chooser.getSelectedFile();
                selectedFile = chooser.getSelectedFile();
                if (!selectedFile.getName().endsWith(".pattern")) {
                    selectedFile = new File(selectedFile.getParentFile(), selectedFile.getName() + ".pattern");
                }
                removeMessageColorizerWithNullFile();
                applyMessageColorizer(selectedFile);
                saveMessageColorizer(selectedFile);
                jList.setSelectedValue(editor.createMessageColorizer(), true);
            } catch (ConfigurationException e1) {
                String errorMessage = String.format("Can't save message colorizer: %s", e1.getMessage());
                LOGGER.severe(errorMessage);
                MessageColorizerBrowser.this.otrosApplication.getStatusObserver().updateStatus(errorMessage,
                        StatusObserver.LEVEL_ERROR);
            }
        }
    });

    useButton = new JButton("Use without saving");
    useButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            try {
                removeMessageColorizerWithNullFile();
                applyMessageColorizer(File.createTempFile("messageColorizer", "pattern"));
            } catch (Exception e) {
                LOGGER.severe("Cannot create message colorizer: " + e.getMessage());
            }

        }
    });

    deleteAction = new DeleteSelected(otrosApplication);
    deleteButton = new JButton(deleteAction);

    toolBar.setFloatable(false);
    toolBar.add(createNew);
    toolBar.add(saveButton);
    toolBar.add(saveAsButton);
    toolBar.add(useButton);
    toolBar.add(deleteButton);
    enableDisableButtonsForSelectedColorizer();
    initFileChooser();
    this.add(mainSplitPane);
    this.add(toolBar, BorderLayout.SOUTH);
}