Example usage for javax.swing JButton setActionCommand

List of usage examples for javax.swing JButton setActionCommand

Introduction

In this page you can find the example usage for javax.swing JButton setActionCommand.

Prototype

public void setActionCommand(String actionCommand) 

Source Link

Document

Sets the action command for this button.

Usage

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

/**
 * Instantiates a new tv show editor dialog.
 * //from   ww  w  .jav  a  2  s .  c  o m
 * @param tvShow
 *          the tv show
 * @param inQueue
 *          the in queue
 */
public TvShowEditorDialog(TvShow tvShow, boolean inQueue) {
    super(BUNDLE.getString("tvshow.edit"), "tvShowEditor"); //$NON-NLS-1$
    setBounds(5, 5, 950, 700);

    tvShowToEdit = tvShow;
    ids = MediaIdTable.convertIdMapToEventList(tvShowToEdit.getIds());

    getContentPane().setLayout(new BorderLayout());
    {
        JPanel panelPath = new JPanel();
        getContentPane().add(panelPath, BorderLayout.NORTH);
        panelPath.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("15px"),
                        FormFactory.RELATED_GAP_ROWSPEC, }));

        JLabel lblTvShowPathT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$
        panelPath.add(lblTvShowPathT, "2, 2, left, top");

        lvlTvShowPath = new JLabel("");
        TmmFontHelper.changeFont(lblTvShowPathT, 1.166, Font.BOLD);
        panelPath.add(lvlTvShowPath, "5, 2, left, top");
    }

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.NORTH);
    tabbedPane.addTab(BUNDLE.getString("metatag.details"), details1Panel); //$NON-NLS-1$
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    details1Panel.setBorder(new EmptyBorder(5, 5, 5, 5));
    details1Panel.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(40dlu;default)"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("30dlu"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("250px:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("15dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("top:max(30dlu;default)"), FormSpecs.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("20dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:30px:grow(2)"), }));

    {
        JLabel lblTitle = new JLabel(BUNDLE.getString("metatag.title")); //$NON-NLS-1$
        details1Panel.add(lblTitle, "2, 2, right, default");
    }
    {
        tfTitle = new JTextField();
        details1Panel.add(tfTitle, "4, 2, 15, 1, fill, default");
        tfTitle.setColumns(10);
    }
    {
        lblPoster = new ImageLabel();
        lblPoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); //$NON-NLS-1$
        lblPoster.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(), ImageType.POSTER,
                        tvShowList.getAvailableArtworkScrapers(), lblPoster, null, null, MediaType.TV_SHOW);
                dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                dialog.setVisible(true);
            }
        });
        lblPoster.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        details1Panel.add(lblPoster, "22, 2, 3, 19, fill, fill");
    }
    {
        JLabel lblSortTitle = new JLabel(BUNDLE.getString("metatag.sorttitle")); //$NON-NLS-1$
        details1Panel.add(lblSortTitle, "2, 4, right, default");
    }
    {
        tfSorttitle = new JTextField();
        details1Panel.add(tfSorttitle, "4, 4, 15, 1, fill, default");
        tfSorttitle.setColumns(10);
    }
    {
        JLabel lblYear = new JLabel(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
        details1Panel.add(lblYear, "2, 6, right, default");
    }
    {
        spYear = new YearSpinner();
        details1Panel.add(spYear, "4, 6, fill, top");
    }
    {
        JLabel lblpremiered = new JLabel(BUNDLE.getString("metatag.premiered")); //$NON-NLS-1$
        details1Panel.add(lblpremiered, "8, 6, right, default");
    }
    {
        dpPremiered = new DatePicker(tvShow.getFirstAired());
        details1Panel.add(dpPremiered, "10, 6, fill, default");
    }
    {
        JLabel lblRuntime = new JLabel(BUNDLE.getString("metatag.runtime")); //$NON-NLS-1$
        details1Panel.add(lblRuntime, "14, 6, right, default");
    }
    {
        spRuntime = new JSpinner();
        details1Panel.add(spRuntime, "16, 6, fill, default");
    }
    spRuntime.setValue(tvShow.getRuntime());

    {
        JLabel lblMin = new JLabel(BUNDLE.getString("metatag.minutes")); //$NON-NLS-1$
        details1Panel.add(lblMin, "18, 6");
    }
    {
        JLabel lblRating = new JLabel(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$
        details1Panel.add(lblRating, "2, 8, right, default");
    }
    {
        spRating = new JSpinner();
        details1Panel.add(spRating, "4, 8");
    }
    spRating.setModel(new SpinnerNumberModel(tvShow.getRating(), 0.0, 10.0, 0.1));
    {
        {
            JLabel lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$
            details1Panel.add(lblCertification, "8, 8, right, default");
        }
    }
    cbCertification = new JComboBox();
    for (Certification cert : Certification
            .getCertificationsforCountry(TvShowModuleManager.SETTINGS.getCertificationCountry())) {
        cbCertification.addItem(cert);
    }
    details1Panel.add(cbCertification, "10, 8, fill, default");
    cbCertification.setSelectedItem(tvShow.getCertification());
    {
        JLabel lblStatus = new JLabel(BUNDLE.getString("metatag.status")); //$NON-NLS-1$
        details1Panel.add(lblStatus, "14, 8, right, default");
    }
    {
        cbStatus = new JComboBox(new String[] { "", "Continuing", "Ended" });
        details1Panel.add(cbStatus, "16, 8, 3, 1, fill, default");
    }
    cbStatus.setSelectedItem(tvShow.getStatus());
    {
        JLabel lblDateAdded = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$
        details1Panel.add(lblDateAdded, "2, 10, right, default");
    }
    {
        spDateAdded = new JSpinner(new SpinnerDateModel());
        details1Panel.add(spDateAdded, "4, 10");
    }

    {
        JLabel lblIds = new JLabel("Ids");
        details1Panel.add(lblIds, "2, 12, right, default");
    }
    {
        JScrollPane scrollPaneIds = new JScrollPane();
        details1Panel.add(scrollPaneIds, "4, 12, 9, 5, fill, fill");
        {
            tableIds = new MediaIdTable(ids, ScraperType.TV_SHOW);
            scrollPaneIds.setViewportView(tableIds);
        }
    }
    {
        JButton btnAddId = new JButton("");
        btnAddId.setAction(new AddIdAction());
        btnAddId.setIcon(IconManager.LIST_ADD);
        btnAddId.setMargin(new Insets(2, 2, 2, 2));
        details1Panel.add(btnAddId, "2, 14, right, top");
    }
    {
        JButton btnRemoveId = new JButton("RemoveId");
        btnRemoveId.setAction(new RemoveIdAction());
        btnRemoveId.setIcon(IconManager.LIST_REMOVE);
        btnRemoveId.setMargin(new Insets(2, 2, 2, 2));
        details1Panel.add(btnRemoveId, "2, 16, right, top");
    }
    {
        JLabel lblPlot = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$
        details1Panel.add(lblPlot, "2, 18, right, top");
    }
    {
        JScrollPane scrollPanePlot = new JScrollPane();
        details1Panel.add(scrollPanePlot, "4, 18, 15, 3, fill, fill");
        {
            tpPlot = new JTextPane();
            scrollPanePlot.setViewportView(tpPlot);
        }
    }
    {
        JLabel lblStudio = new JLabel(BUNDLE.getString("metatag.studio")); //$NON-NLS-1$
        details1Panel.add(lblStudio, "2, 22, right, top");
    }
    {
        tfStudio = new JTextField();
        details1Panel.add(tfStudio, "4, 22, 15, 1");
    }

    /**
     * DetailsPanel 2
     */
    tabbedPane.addTab(BUNDLE.getString("metatag.details2"), details2Panel); //$NON-NLS-1$
    details2Panel.setBorder(new EmptyBorder(5, 5, 5, 5));
    details2Panel.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(40dlu;default)"),
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("100px:grow(2)"),
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("100px:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:30px:grow"),
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow(2)"), }));
    {
        JLabel lblActors = new JLabel(BUNDLE.getString("metatag.actors")); //$NON-NLS-1$
        details2Panel.add(lblActors, "2, 2, right, default");
    }
    {
        JScrollPane scrollPane = new JScrollPane();
        details2Panel.add(scrollPane, "4, 2, 1, 7");
        {
            tableActors = new JTable();
            tableActors.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            scrollPane.setViewportView(tableActors);
        }
    }
    {
        JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$
        details2Panel.add(lblGenres, "6, 2");
    }
    {
        JButton btnAddActor = new JButton("Add Actor");
        btnAddActor.setMargin(new Insets(2, 2, 2, 2));
        btnAddActor.setAction(new AddActorAction());
        btnAddActor.setIcon(IconManager.LIST_ADD);
        details2Panel.add(btnAddActor, "2, 4, right, top");
    }
    {
        JScrollPane scrollPaneGenres = new JScrollPane();
        details2Panel.add(scrollPaneGenres, "8, 2, 1, 5");
        {
            listGenres = new JList();
            scrollPaneGenres.setViewportView(listGenres);
        }
    }
    {
        JButton btnAddGenre = new JButton("");
        btnAddGenre.setAction(new AddGenreAction());
        btnAddGenre.setIcon(IconManager.LIST_ADD);
        btnAddGenre.setMargin(new Insets(2, 2, 2, 2));
        details2Panel.add(btnAddGenre, "6, 4, right, top");
    }
    {
        JButton btnRemoveActor = new JButton(BUNDLE.getString("cast.actor.remove")); //$NON-NLS-1$
        btnRemoveActor.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveActor.setAction(new RemoveActorAction());
        btnRemoveActor.setIcon(IconManager.LIST_REMOVE);
        details2Panel.add(btnRemoveActor, "2,6, right, top");
    }

    {
        JButton btnRemoveGenre = new JButton("");
        btnRemoveGenre.setAction(new RemoveGenreAction());
        btnRemoveGenre.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveGenre.setIcon(IconManager.LIST_REMOVE);
        details2Panel.add(btnRemoveGenre, "6, 6, right, top");
    }
    {
        cbGenres = new AutocompleteComboBox(MediaGenres.values());
        cbGenres.setEditable(true);
        details2Panel.add(cbGenres, "8,8");
    }
    {
        JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$
        details2Panel.add(lblTags, "2, 10, right, default");
    }
    {
        JScrollPane scrollPaneTags = new JScrollPane();
        details2Panel.add(scrollPaneTags, "4, 10, 1, 5");
        listTags = new JList();
        scrollPaneTags.setViewportView(listTags);
    }
    {
        JButton btnAddTag = new JButton("");
        btnAddTag.setAction(new AddTagAction());
        btnAddTag.setIcon(IconManager.LIST_ADD);
        btnAddTag.setMargin(new Insets(2, 2, 2, 2));
        details2Panel.add(btnAddTag, "2, 12, right, top");
    }
    {
        JButton btnRemoveTag = new JButton("");
        btnRemoveTag.setAction(new RemoveTagAction());
        btnRemoveTag.setIcon(IconManager.LIST_REMOVE);
        btnRemoveTag.setMargin(new Insets(2, 2, 2, 2));
        details2Panel.add(btnRemoveTag, "2, 14, right, top");
    }
    {
        cbTags = new AutocompleteComboBox(tvShowList.getTagsInTvShows().toArray());
        cbTags.setEditable(true);
        details2Panel.add(cbTags, "4, 16");
    }

    /**
     * extra artwork pane
     */
    {
        JPanel artworkPanel = new JPanel();
        tabbedPane.addTab(BUNDLE.getString("metatag.extraartwork"), null, artworkPanel, null); //$NON-NLS-1$
        artworkPanel.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"),
                        FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"),
                        FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("50px:grow(2)"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("200px:grow(2)"),
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), }));
        {
            JLabel lblLogoT = new JLabel(BUNDLE.getString("mediafiletype.logo")); //$NON-NLS-1$
            artworkPanel.add(lblLogoT, "2, 2");
        }
        {
            lblLogo = new ImageLabel();
            lblLogo.setAlternativeText(BUNDLE.getString("image.notfound.logo")); //$NON-NLS-1$
            lblLogo.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(), ImageType.LOGO,
                            tvShowList.getAvailableArtworkScrapers(), lblLogo, null, null, MediaType.TV_SHOW);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            {
                final JLabel lblClearlogoT = new JLabel(BUNDLE.getString("mediafiletype.clearlogo")); //$NON-NLS-1$
                artworkPanel.add(lblClearlogoT, "4, 2");
            }
            lblLogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblLogo, "2, 4, fill, fill");
        }
        {
            lblClearlogo = new ImageLabel();
            lblClearlogo.setAlternativeText(BUNDLE.getString("image.notfound.clearlogo")); //$NON-NLS-1$
            lblClearlogo.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(),
                            ImageType.CLEARLOGO, tvShowList.getAvailableArtworkScrapers(), lblClearlogo, null,
                            null, MediaType.TV_SHOW);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblClearlogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblClearlogo, "4, 4, fill, fill");
        }
        {
            JLabel lblClearartT = new JLabel(BUNDLE.getString("mediafiletype.clearart")); //$NON-NLS-1$
            artworkPanel.add(lblClearartT, "2, 6");
        }
        {
            lblClearart = new ImageLabel();
            lblClearart.setAlternativeText(BUNDLE.getString("image.notfound.clearart")); //$NON-NLS-1$
            lblClearart.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(),
                            ImageType.CLEARART, tvShowList.getAvailableArtworkScrapers(), lblClearart, null,
                            null, MediaType.TV_SHOW);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblClearart.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblClearart, "2, 8, fill, fill");
        }
        {
            JLabel lblThumbT = new JLabel(BUNDLE.getString("mediafiletype.thumb")); //$NON-NLS-1$
            artworkPanel.add(lblThumbT, "4, 6");
        }
        {
            lblThumb = new ImageLabel();
            lblThumb.setAlternativeText(BUNDLE.getString("image.notfound.thumb")); //$NON-NLS-1$
            lblThumb.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(), ImageType.THUMB,
                            tvShowList.getAvailableArtworkScrapers(), lblThumb, null, null, MediaType.TV_SHOW);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblThumb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblThumb, "4, 8, fill, fill");
        }

    }
    tabbedPane.addTab(BUNDLE.getString("metatag.episodes"), episodesPanel); //$NON-NLS-1$
    episodesPanel.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), }));
    {
        JButton btnCloneEpisode = new JButton("");
        btnCloneEpisode.setAction(new CloneEpisodeAction());
        episodesPanel.add(btnCloneEpisode, "2, 2");
    }
    {
        JScrollPane scrollPaneEpisodes = new JScrollPane();
        episodesPanel.add(scrollPaneEpisodes, "4, 2, 1, 3, fill, fill");
        {
            tableEpisodes = new JTable();
            scrollPaneEpisodes.setViewportView(tableEpisodes);
        }
    }
    {
        JButton btnRemoveEpisode = new JButton("");
        btnRemoveEpisode.setAction(new RemoveEpisodeAction());
        btnRemoveEpisode.setIcon(IconManager.LIST_REMOVE);
        episodesPanel.add(btnRemoveEpisode, "2, 4, default, top");
    }

    /**
     * Button pane
     */
    {
        JPanel bottomPane = new JPanel();
        getContentPane().add(bottomPane, BorderLayout.SOUTH);
        bottomPane.setLayout(new FormLayout(
                new ColumnSpec[] { ColumnSpec.decode("371px: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();
        bottomPane.add(buttonPane, "2, 2, left, top");
        EqualsLayout layout = new EqualsLayout(5);
        layout.setMinWidth(100);
        buttonPane.setLayout(layout);
        {
            JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$
            buttonPane.add(okButton);
            okButton.setAction(new OKAction());
            okButton.setActionCommand("OK");
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$
            buttonPane.add(cancelButton);
            cancelButton.setAction(new CancelAction());
            cancelButton.setActionCommand("Cancel");
        }
        if (inQueue) {
            JButton btnAbort = new JButton(BUNDLE.getString("Button.abortqueue")); //$NON-NLS-1$
            btnAbort.setAction(new AbortAction());
            buttonPane.add(btnAbort);
        }

    }

    initDataBindings();

    {
        lvlTvShowPath.setText(tvShow.getPath());
        tfTitle.setText(tvShow.getTitle());
        tfSorttitle.setText(tvShow.getSortTitle());
        tpPlot.setText(tvShow.getPlot());
        lblPoster.setImagePath(tvShow.getArtworkFilename(MediaFileType.POSTER));
        lblThumb.setImagePath(tvShowToEdit.getArtworkFilename(MediaFileType.THUMB));
        lblLogo.setImagePath(tvShowToEdit.getArtworkFilename(MediaFileType.LOGO));
        lblClearlogo.setImagePath(tvShowToEdit.getArtworkFilename(MediaFileType.CLEARLOGO));
        lblClearart.setImagePath(tvShowToEdit.getArtworkFilename(MediaFileType.CLEARART));
        tfStudio.setText(tvShow.getProductionCompany());

        int year = 0;
        try {
            year = Integer.parseInt(tvShow.getYear());
        } catch (Exception e) {
        }
        spYear.setValue(year);
        spDateAdded.setValue(tvShow.getDateAdded());

        for (TvShowActor origCast : tvShow.getActors()) {
            TvShowActor actor = new TvShowActor();
            actor.setName(origCast.getName());
            actor.setCharacter(origCast.getCharacter());
            actor.setThumbUrl(origCast.getThumbUrl());
            actors.add(actor);
        }

        for (MediaGenres genre : tvShow.getGenres()) {
            genres.add(genre);
        }

        // for (MediaTrailer trailer : tvShow.getTrailers()) {
        // trailers.add(trailer);
        // }

        for (String tag : tvShowToEdit.getTags()) {
            tags.add(tag);
        }

        List<TvShowEpisode> epl = new ArrayList<>(tvShowToEdit.getEpisodes());
        // custom sort per filename (just this time)
        // for unknown EPs (-1/-1) this is extremely useful to sort like on filesystem
        // and for already renamed ones, it makes no difference
        Collections.sort(epl, new Comparator<TvShowEpisode>() {
            public int compare(TvShowEpisode s1, TvShowEpisode s2) {
                return s1.getMediaFiles(MediaFileType.VIDEO).get(0).getFile()
                        .compareTo(s2.getMediaFiles(MediaFileType.VIDEO).get(0).getFile());
            }
        });

        for (TvShowEpisode episode : epl) {
            TvShowEpisodeEditorContainer container = new TvShowEpisodeEditorContainer();
            container.tvShowEpisode = episode;
            container.dvdOrder = episode.isDvdOrder();
            container.season = episode.getSeason();
            container.episode = episode.getEpisode();
            episodes.add(container);
        }

        if (((DefaultComboBoxModel) cbCertification.getModel()).getIndexOf(tvShow.getCertification()) == -1) {
            cbCertification.addItem(tvShow.getCertification());
        }

    }
    lblBanner = new ImageLabel();
    lblBanner.setAlternativeText(BUNDLE.getString("image.notfound.banner")); //$NON-NLS-1$
    lblBanner.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lblBanner.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(), ImageType.BANNER,
                    tvShowList.getAvailableArtworkScrapers(), lblBanner, null, null, MediaType.TV_SHOW);
            dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
            dialog.setVisible(true);
        }
    });
    details1Panel.add(lblBanner, "4, 24, 15, 3, fill, fill");
    lblBanner.setImagePath(tvShow.getArtworkFilename(MediaFileType.BANNER));
    {
        // JLabel lblFanart = new JLabel("");
        lblFanart = new ImageLabel();
        lblFanart.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); //$NON-NLS-1$
        lblFanart.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        lblFanart.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(), ImageType.FANART,
                        tvShowList.getAvailableArtworkScrapers(), lblFanart, null, null, MediaType.TV_SHOW);
                dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                dialog.setVisible(true);
            }
        });
        details1Panel.add(lblFanart, "22, 22, 3, 5, fill, fill");
    }
    lblFanart.setImagePath(tvShow.getArtworkFilename(MediaFileType.FANART));

    // adjust columnn titles - we have to do it this way - thx to windowbuilder pro
    tableActors.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableActors.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$

    tableEpisodes.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.title")); //$NON-NLS-1$
    tableEpisodes.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.filename")); //$NON-NLS-1$
    tableEpisodes.getColumnModel().getColumn(2).setHeaderValue(BUNDLE.getString("metatag.season")); //$NON-NLS-1$
    tableEpisodes.getColumnModel().getColumn(3).setHeaderValue(BUNDLE.getString("metatag.episode")); //$NON-NLS-1$
    tableEpisodes.getColumnModel().getColumn(4).setHeaderValue(BUNDLE.getString("metatag.dvdorder")); //$NON-NLS-1$
    tableEpisodes.getColumnModel().getColumn(2).setMaxWidth(150);
    tableEpisodes.getColumnModel().getColumn(3).setMaxWidth(150);
    tableEpisodes.getColumnModel().getColumn(2).setCellEditor(new TableSpinnerEditor());
    tableEpisodes.getColumnModel().getColumn(3).setCellEditor(new TableSpinnerEditor());

    // adjust table columns
    TableColumnResizer.adjustColumnPreferredWidths(tableActors, 6);
    // TableColumnResizer.adjustColumnPreferredWidths(tableTrailer, 6);
    TableColumnResizer.adjustColumnPreferredWidths(tableEpisodes, 6);
}

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);/*  w ww.  j  a  v a  2  s.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.TvShowEpisodeEditorDialog.java

/**
 * Instantiates a new tv show episode scrape dialog.
 * /*w  ww. j  a  v a  2s .  c om*/
 * @param episode
 *          the episode
 * @param inQueue
 *          the in queue
 */
public TvShowEpisodeEditorDialog(TvShowEpisode episode, boolean inQueue) {
    super(BUNDLE.getString("tvshowepisode.scrape"), "tvShowEpisodeScraper"); //$NON-NLS-1$
    setBounds(5, 5, 964, 632);

    for (MediaFile mf : episode.getMediaFiles()) {
        mediaFiles.add(new MediaFile(mf));
    }

    this.episodeToEdit = episode;
    getContentPane().setLayout(new BorderLayout());

    {
        JPanel panelFilename = new JPanel();
        getContentPane().add(panelFilename, BorderLayout.NORTH);
        panelFilename.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("15px"),
                        FormFactory.RELATED_GAP_ROWSPEC, }));

        JLabel lblFilenameT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$
        panelFilename.add(lblFilenameT, "2, 2, left, top");

        lblFilename = new JLabel("");
        TmmFontHelper.changeFont(lblFilename, 1.166, Font.BOLD);
        panelFilename.add(lblFilename, "5, 2, left, top");
    }

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.NORTH);
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    /**
     * DetailsPanel
     */
    {
        JPanel detailsPanel = new JPanel();
        tabbedPane.addTab(BUNDLE.getString("metatag.details"), detailsPanel); //$NON-NLS-1$
        detailsPanel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("40dlu:grow"),
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("20dlu"),
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("30dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"),
                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("35dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, }));

        JLabel lblTitle = new JLabel(BUNDLE.getString("metatag.title")); //$NON-NLS-1$
        detailsPanel.add(lblTitle, "2, 4, right, default");

        tfTitle = new JTextField();
        detailsPanel.add(tfTitle, "4, 4, 19, 1");
        tfTitle.setColumns(10);

        JLabel lblSeason = new JLabel(BUNDLE.getString("metatag.season")); //$NON-NLS-1$
        detailsPanel.add(lblSeason, "2, 6, right, default");

        spSeason = new JSpinner();
        detailsPanel.add(spSeason, "4, 6");

        JLabel lblEpisode = new JLabel(BUNDLE.getString("metatag.episode")); //$NON-NLS-1$
        detailsPanel.add(lblEpisode, "8, 6, right, default");

        spEpisode = new JSpinner();
        detailsPanel.add(spEpisode, "10, 6");

        JLabel lblDvdSeason = new JLabel(BUNDLE.getString("metatag.dvdseason")); //$NON-NLS-1$
        detailsPanel.add(lblDvdSeason, "2, 8, right, default");

        spDvdSeason = new JSpinner();
        detailsPanel.add(spDvdSeason, "4, 8");

        JLabel lblDvdEpisode = new JLabel(BUNDLE.getString("metatag.dvdepisode")); //$NON-NLS-1$
        detailsPanel.add(lblDvdEpisode, "8, 8, right, default");

        spDvdEpisode = new JSpinner();
        detailsPanel.add(spDvdEpisode, "10, 8");

        JLabel lblDvdOrder = new JLabel(BUNDLE.getString("metatag.dvdorder")); //$NON-NLS-1$
        detailsPanel.add(lblDvdOrder, "14, 8, right, default");

        cbDvdOrder = new JCheckBox("");
        detailsPanel.add(cbDvdOrder, "16, 8");
        cbDvdOrder.setSelected(episodeToEdit.isDvdOrder());

        JLabel lblDisplaySeason = new JLabel(BUNDLE.getString("metatag.displayseason")); //$NON-NLS-1$
        detailsPanel.add(lblDisplaySeason, "2, 10, right, default");

        spDisplaySeason = new JSpinner();
        detailsPanel.add(spDisplaySeason, "4, 10");

        JLabel lblDisplayEpisode = new JLabel(BUNDLE.getString("metatag.displayepisode")); //$NON-NLS-1$
        detailsPanel.add(lblDisplayEpisode, "8, 10, right, default");

        spDisplayEpisode = new JSpinner();
        detailsPanel.add(spDisplayEpisode, "10, 10");

        JLabel lblRating = new JLabel(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$
        detailsPanel.add(lblRating, "2, 12, right, default");

        spRating = new JSpinner();
        detailsPanel.add(spRating, "4, 12");

        JLabel lblFirstAired = new JLabel(BUNDLE.getString("metatag.aired")); //$NON-NLS-1$
        detailsPanel.add(lblFirstAired, "8, 12, right, default");

        dpFirstAired = new DatePicker(episode.getFirstAired());
        detailsPanel.add(dpFirstAired, "10, 12, 3, 1, fill, default");

        JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$
        detailsPanel.add(lblWatched, "2, 14, right, default");

        chckbxWatched = new JCheckBox("");
        detailsPanel.add(chckbxWatched, "4, 14");

        JLabel lblDateAdded = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$
        detailsPanel.add(lblDateAdded, "8, 14, right, default");

        spDateAdded = new JSpinner(new SpinnerDateModel());
        detailsPanel.add(spDateAdded, "10, 14, 3, 1, fill, default");

        JLabel lblMediasource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
        detailsPanel.add(lblMediasource, "2, 16, right, default");

        cbMediaSource = new JComboBox(MediaSource.values());
        detailsPanel.add(cbMediaSource, "4, 16, 4, 1, fill, default");

        JLabel lblPlot = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$
        detailsPanel.add(lblPlot, "2, 18, right, top");

        JScrollPane scrollPane = new JScrollPane();
        detailsPanel.add(scrollPane, "4, 18, 13, 1, fill, fill");

        taPlot = new JTextArea();
        taPlot.setLineWrap(true);
        taPlot.setWrapStyleWord(true);
        scrollPane.setViewportView(taPlot);

        lblThumb = new ImageLabel();
        lblThumb.setAlternativeText(BUNDLE.getString("image.notfound.thumb")); //$NON-NLS-1$
        lblThumb.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                Path file = TmmUIHelper.selectFile(BUNDLE.getString("image.choose")); //$NON-NLS-1$
                if (file != null && Utils.isRegularFile(file)) {
                    String fileName = file.toAbsolutePath().toString();
                    lblThumb.setImageUrl("file:/" + fileName);
                }
            }
        });
        lblThumb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        detailsPanel.add(lblThumb, "20, 6, 3, 13");

        JLabel lblDirector = new JLabel(BUNDLE.getString("metatag.director")); //$NON-NLS-1$
        detailsPanel.add(lblDirector, "2, 20, right, default");

        tfDirector = new JTextField();
        tfDirector.setText((String) null);
        tfDirector.setColumns(10);
        detailsPanel.add(tfDirector, "4, 20, 13, 1, fill, default");

        JLabel lblWriter = new JLabel(BUNDLE.getString("metatag.writer")); //$NON-NLS-1$
        detailsPanel.add(lblWriter, "2, 22, right, default");

        tfWriter = new JTextField();
        tfWriter.setText((String) null);
        tfWriter.setColumns(10);
        detailsPanel.add(tfWriter, "4, 22, 13, 1, fill, default");

        JLabel lblGuests = new JLabel(BUNDLE.getString("metatag.guests")); //$NON-NLS-1$
        detailsPanel.add(lblGuests, "2, 24, right, top");

        JScrollPane scrollPaneGuests = new JScrollPane();
        detailsPanel.add(scrollPaneGuests, "4, 24, 13, 7, fill, fill");

        tableGuests = new JTable();
        tableGuests.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
        scrollPaneGuests.setViewportView(tableGuests);

        JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$
        detailsPanel.add(lblTags, "20, 24, default, top");

        JScrollPane scrollPaneTags = new JScrollPane();
        detailsPanel.add(scrollPaneTags, "22, 24, 1, 5, fill, fill");

        listTags = new JList();
        scrollPaneTags.setViewportView(listTags);

        JButton btnAddActor = new JButton("");
        btnAddActor.setMargin(new Insets(2, 2, 2, 2));
        btnAddActor.setAction(new AddActorAction());
        btnAddActor.setIcon(IconManager.LIST_ADD);
        detailsPanel.add(btnAddActor, "2, 26, right, top");

        JButton btnAddTag = new JButton("");
        btnAddTag.setMargin(new Insets(2, 2, 2, 2));
        btnAddTag.setAction(new AddTagAction());
        btnAddTag.setIcon(IconManager.LIST_ADD);
        detailsPanel.add(btnAddTag, "20, 26, right, top");

        JButton btnRemoveActor = new JButton("");
        btnRemoveActor.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveActor.setAction(new RemoveActorAction());
        btnRemoveActor.setIcon(IconManager.LIST_REMOVE);
        detailsPanel.add(btnRemoveActor, "2, 28, right, top");

        JButton btnRemoveTag = new JButton("");
        btnRemoveTag.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveTag.setAction(new RemoveTagAction());
        btnRemoveTag.setIcon(IconManager.LIST_REMOVE);
        detailsPanel.add(btnRemoveTag, "20, 28, right, top");

        cbTags = new AutocompleteComboBox(tvShowList.getTagsInEpisodes().toArray());
        cbTags.setEditable(true);
        detailsPanel.add(cbTags, "22, 30, fill, default");
    }

    /**
     * Media Files panel
     */
    {
        mediaFilesPanel = new MediaFileEditorPanel(mediaFiles);
        tabbedPane.addTab(BUNDLE.getString("metatag.mediafiles"), null, mediaFilesPanel, null); //$NON-NLS-1$
    }

    {
        JPanel bottomPanel = new JPanel();
        getContentPane().add(bottomPanel, BorderLayout.SOUTH);

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

        cbScraper = new MediaScraperComboBox(tvShowList.getAvailableMediaScrapers());
        MediaScraper defaultScraper = tvShowList.getDefaultMediaScraper();
        cbScraper.setSelectedItem(defaultScraper);
        bottomPanel.add(cbScraper, "2, 2, fill, default");

        JButton btnScrape = new JButton(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$
        btnScrape.setPreferredSize(new Dimension(100, 23));
        btnScrape.setMaximumSize(new Dimension(0, 0));
        btnScrape.setMinimumSize(new Dimension(100, 23));
        btnScrape.setActionCommand("Scrape");
        btnScrape.addActionListener(this);
        bottomPanel.add(btnScrape, "4, 2, left, fill");

        JButton btnSearch = new JButton(BUNDLE.getString("tvshowepisodechooser.search")); //$NON-NLS-1$
        btnSearch.setActionCommand("Search");
        btnSearch.addActionListener(this);
        btnSearch.setIcon(IconManager.SEARCH);
        bottomPanel.add(btnSearch, "6, 2, left, fill");
        {
            JPanel buttonPane = new JPanel();
            bottomPanel.add(buttonPane, "8, 2, fill, fill");
            EqualsLayout layout = new EqualsLayout(5);
            layout.setMinWidth(100);
            buttonPane.setLayout(layout);
            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);

            if (inQueue) {
                JButton abortButton = new JButton(BUNDLE.getString("Button.abortqueue")); //$NON-NLS-1$
                abortButton.setToolTipText(BUNDLE.getString("tvshow.edit.abortqueue.desc")); //$NON-NLS-1$
                abortButton.setIcon(IconManager.PROCESS_STOP);
                buttonPane.add(abortButton);
                abortButton.setActionCommand("Abort");
                abortButton.addActionListener(this);
            }
        }
    }

    initDataBindings();

    // fill data
    {
        MediaFile mediaFile = episodeToEdit.getMediaFiles().get(0);
        lblFilename.setText(mediaFile.getFileAsPath().toString());
        tfTitle.setText(episodeToEdit.getTitle());

        spSeason.setModel(new SpinnerNumberModel(episodeToEdit.getAiredSeason(), -1, Integer.MAX_VALUE, 1));
        spEpisode.setModel(new SpinnerNumberModel(episodeToEdit.getAiredEpisode(), -1, Integer.MAX_VALUE, 1));
        spDvdSeason.setModel(new SpinnerNumberModel(episodeToEdit.getDvdSeason(), -1, Integer.MAX_VALUE, 1));
        spDvdEpisode.setModel(new SpinnerNumberModel(episodeToEdit.getDvdEpisode(), -1, Integer.MAX_VALUE, 1));
        spDisplaySeason
                .setModel(new SpinnerNumberModel(episodeToEdit.getDisplaySeason(), -1, Integer.MAX_VALUE, 1));
        spDisplayEpisode
                .setModel(new SpinnerNumberModel(episodeToEdit.getDisplayEpisode(), -1, Integer.MAX_VALUE, 1));
        spDateAdded.setValue(episodeToEdit.getDateAdded());

        lblThumb.setImagePath(episodeToEdit.getArtworkFilename(MediaFileType.THUMB));
        spRating.setModel(new SpinnerNumberModel(episodeToEdit.getRating(), 0.0, 10.0, 0.1));
        spRating.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                voteCount = 1;
            }
        });
        voteCount = episodeToEdit.getVotes();
        chckbxWatched.setSelected(episodeToEdit.isWatched());
        taPlot.setText(episodeToEdit.getPlot());
        taPlot.setCaretPosition(0);
        tfDirector.setText(episodeToEdit.getDirector());
        tfWriter.setText(episodeToEdit.getWriter());
        cbMediaSource.setSelectedItem(episodeToEdit.getMediaSource());

        for (TvShowActor origCast : episodeToEdit.getGuests()) {
            TvShowActor actor = new TvShowActor();
            actor.setName(origCast.getName());
            actor.setCharacter(origCast.getCharacter());
            actor.setThumbUrl(origCast.getThumbUrl());
            cast.add(actor);
        }

        for (String tag : episodeToEdit.getTags()) {
            tags.add(tag);
        }
    }

    // adjust table columns
    tableGuests.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableGuests.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$

}

From source file:pcgen.gui.sources.SourceSelectionDialog.java

/**
 * This method is called from within the constructor to
 * initialize the form.//from   w  w  w . ja v a  2  s.  co  m
 */
private void initComponents() {
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    getContentPane().setLayout(new java.awt.GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(4, 4, 4, 4);

    JLabel jLabel1 = new JLabel(LanguageBundle.getString("in_qsrc_intro"));
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0.0, 0.0);
    getContentPane().add(jLabel1, gbc);

    sourceList = new javax.swing.JList();
    sourceModel = new DefaultListModel();
    List<String> strings = getSourceNames();
    for (String string : strings) {
        sourceModel.addElement(string);
    }
    sourceList.setModel(sourceModel);
    sourceList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    sourceList.setLayoutOrientation(JList.VERTICAL_WRAP);
    sourceList.setVisibleRowCount(2);
    sourceList.setCellRenderer(new SourceListCellRenderer());
    JScrollPane listScrollPane = new JScrollPane(sourceList);
    listScrollPane.setPreferredSize(new Dimension(480, 260));
    if (lastLoadedCollection != null && lastLoadedCollection.length() > 0) {
        sourceList.setSelectedValue(lastLoadedCollection, true);
    }

    Utility.buildRelativeConstraints(gbc, 2, 5, 100, 100, GridBagConstraints.BOTH, GridBagConstraints.WEST);
    getContentPane().add(listScrollPane, gbc);

    JButton addButton = new JButton(LanguageBundle.getString("in_add"));
    addButton.setActionCommand(ACTION_ADD);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST);
    getContentPane().add(addButton, gbc);

    modifyButton = new JButton(LanguageBundle.getString("in_modify"));
    modifyButton.setActionCommand(ACTION_MODIFY);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST);
    getContentPane().add(modifyButton, gbc);

    JButton hideButton = new JButton(LanguageBundle.getString("in_hide"));
    hideButton.setActionCommand(ACTION_HIDE);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.NORTH);
    getContentPane().add(hideButton, gbc);

    JButton unhideButton = new JButton(LanguageBundle.getString("in_unhide"));
    unhideButton.setActionCommand(ACTION_UNHIDE);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.NORTH);
    getContentPane().add(unhideButton, gbc);

    deleteButton = new JButton(LanguageBundle.getString("in_delete"));
    deleteButton.setActionCommand(ACTION_DELETE);
    Utility.buildRelativeConstraints(gbc, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.NORTH);
    getContentPane().add(deleteButton, gbc);

    JButton advancedButton = new JButton(LanguageBundle.getString("in_qsrc_advanced"));
    advancedButton.setActionCommand(ACTION_ADVANCED);
    getRootPane().setDefaultButton(advancedButton);
    Utility.buildRelativeConstraints(gbc, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST);
    getContentPane().add(advancedButton, gbc);

    JButton loadButton = new JButton(LanguageBundle.getString("in_load"));
    loadButton.setActionCommand(ACTION_LOAD);
    getRootPane().setDefaultButton(loadButton);
    Utility.buildRelativeConstraints(gbc, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.EAST);
    getContentPane().add(loadButton, gbc);

    JButton cancelButton = new JButton(LanguageBundle.getString("in_cancel"));
    cancelButton.setActionCommand(ACTION_CANCEL);
    Utility.buildRelativeConstraints(gbc, 1, 1, 0, 0);
    getContentPane().add(cancelButton, gbc);

    //Listen for actions on the buttons
    addButton.addActionListener(this);
    modifyButton.addActionListener(this);
    deleteButton.addActionListener(this);
    hideButton.addActionListener(this);
    unhideButton.addActionListener(this);
    advancedButton.addActionListener(this);
    loadButton.addActionListener(this);
    cancelButton.addActionListener(this);
    sourceList.addListSelectionListener(this);
    valueChanged(null);

    //Listen for actions on the list
    sourceList.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent evt) {
            sourceListMouseClicked(evt);
        }
    });

    pack();
}

From source file:pcgen.gui2.dialog.CharacterHPDialog.java

private void initComponents() {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    JTable table = new JTable(tableModel) {

        @Override//from  w ww. ja  v a 2 s  .  c o  m
        public TableCellEditor getCellEditor(int row, int column) {
            if (column == 5) {//TODO: the max roll should be calculated in a different manner
                String hd = levels.getClassTaken(levels.getElementAt(row)).getHD();
                int max = NumberUtils.toInt(hd);
                return new IntegerEditor(1, max);
            } else {
                return super.getCellEditor(row, column);
            }
        }

    };
    table.setDefaultRenderer(JButton.class, new Renderer());
    table.setDefaultEditor(JButton.class, new Editor());
    table.setCellSelectionEnabled(false);
    table.setRowHeight(new IntegerEditor(1, 10).getPreferredSize().height);
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);

    JScrollPane scrollPane = new JScrollPane(table);
    pane.add(scrollPane, BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    box.add(new JLabel("Total Hp:"));
    box.add(Box.createHorizontalStrut(3));

    final ReferenceListener<Integer> hpListener = new ReferenceListener<Integer>() {

        @Override
        public void referenceChanged(ReferenceEvent<Integer> e) {
            totalHp.setText(e.getNewReference().toString());
        }

    };
    ReferenceFacade<Integer> hpRef = character.getTotalHPRef();
    totalHp.setText(hpRef.get().toString());
    hpRef.addReferenceListener(hpListener);
    box.add(totalHp);
    box.add(Box.createHorizontalStrut(5));

    JButton button = new JButton("Reroll All");
    button.setActionCommand("Reroll");
    button.addActionListener(this);
    box.add(button);

    box.add(Box.createHorizontalGlue());
    button = new JButton("Close");
    button.setActionCommand("Close");
    button.addActionListener(this);
    box.add(button);
    pane.add(box, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            //Make sure to remove the listeners so that the garbage collector can
            //dispose of this dialog and prevent a memory leak
            levels.removeHitPointListener(tableModel);
            character.getTotalHPRef().removeReferenceListener(hpListener);
        }

    });

    Utility.installEscapeCloseOperation(this);
}

From source file:pcgen.gui2.dialog.ChooserDialog.java

private void initComponents() {
    setTitle(chooser.getName());/*from   ww w . j av a 2s .c  o  m*/
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            //detach listeners from the chooser
            treeViewModel.setDelegate(null);
            listModel.setListFacade(null);
            chooser.getRemainingSelections().removeReferenceListener(ChooserDialog.this);
        }

    });
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());

    JSplitPane split = new JSplitPane();
    JPanel leftPane = new JPanel(new BorderLayout());
    if (availTable != null) {
        availTable.setAutoCreateRowSorter(true);
        availTable.setTreeViewModel(treeViewModel);
        availTable.getRowSorter().toggleSortOrder(0);
        availTable.addActionListener(this);
        leftPane.add(new JScrollPane(availTable), BorderLayout.CENTER);
    } else {
        availInput.addActionListener(this);
        Dimension maxDim = new Dimension(Integer.MAX_VALUE, availInput.getPreferredSize().height);
        availInput.setMaximumSize(maxDim);
        JPanel availPanel = new JPanel();
        availPanel.setLayout(new BoxLayout(availPanel, BoxLayout.PAGE_AXIS));
        availPanel.add(Box.createRigidArea(new Dimension(10, 30)));
        availPanel.add(Box.createVerticalGlue());
        availPanel.add(new JLabel(LanguageBundle.getString("in_uichooser_value")));
        availPanel.add(availInput);
        availPanel.add(Box.createVerticalGlue());
        leftPane.add(availPanel, BorderLayout.WEST);
    }

    JPanel buttonPane1 = new JPanel(new FlowLayout());
    JButton addButton = new JButton(chooser.getAddButtonName());
    addButton.setActionCommand("ADD");
    addButton.addActionListener(this);
    buttonPane1.add(addButton);
    buttonPane1.add(new JLabel(Icons.Forward16.getImageIcon()));
    leftPane.add(buttonPane1, BorderLayout.SOUTH);

    split.setLeftComponent(leftPane);

    JPanel rightPane = new JPanel(new BorderLayout());
    JPanel labelPane = new JPanel(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    labelPane.add(new JLabel(chooser.getSelectionCountName()), new GridBagConstraints());
    remainingLabel.setText(chooser.getRemainingSelections().get().toString());
    labelPane.add(remainingLabel, gbc);
    labelPane.add(new JLabel(chooser.getSelectedTableTitle()), gbc);
    rightPane.add(labelPane, BorderLayout.NORTH);

    list.setModel(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.addActionListener(this);
    rightPane.add(new JScrollPane(list), BorderLayout.CENTER);

    JPanel buttonPane2 = new JPanel(new FlowLayout());
    buttonPane2.add(new JLabel(Icons.Back16.getImageIcon()));
    JButton removeButton = new JButton(chooser.getRemoveButtonName());
    removeButton.setActionCommand("REMOVE");
    removeButton.addActionListener(this);
    buttonPane2.add(removeButton);
    rightPane.add(buttonPane2, BorderLayout.SOUTH);

    split.setRightComponent(rightPane);

    if (chooser.isInfoAvailable()) {
        JSplitPane infoSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        infoSplit.setTopComponent(split);
        infoSplit.setBottomComponent(infoPane);
        infoSplit.setResizeWeight(0.8);
        pane.add(infoSplit, BorderLayout.CENTER);
        if (availTable != null) {
            availTable.getSelectionModel().addListSelectionListener(this);
        }
    } else {
        pane.add(split, BorderLayout.CENTER);
    }
    JPanel bottomPane = new JPanel(new FlowLayout());
    JButton button = new JButton(LanguageBundle.getString("in_ok")); //$NON-NLS-1$
    button.setMnemonic(LanguageBundle.getMnemonic("in_mn_ok")); //$NON-NLS-1$
    button.setActionCommand("OK");
    button.addActionListener(this);
    bottomPane.add(button);
    button = new JButton(LanguageBundle.getString("in_cancel")); //$NON-NLS-1$
    button.setMnemonic(LanguageBundle.getMnemonic("in_mn_cancel")); //$NON-NLS-1$
    button.setActionCommand("CANCEL");
    button.addActionListener(this);
    bottomPane.add(button);
    pane.add(bottomPane, BorderLayout.SOUTH);
}

From source file:pcgen.gui2.dialog.OptionsPathDialog.java

private void initComponents() {
    setResizable(false);// ww  w .ja  v a  2s.c  om
    setTitle("Directory for options.ini location");
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

    getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints gridBagConstraints = new GridBagConstraints();

    JLabel label = new JLabel("Select a directory to store PCGen options in:");
    gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.insets = new Insets(4, 4, 0, 4);
    getContentPane().add(label, gridBagConstraints);

    gridBagConstraints.insets = new Insets(2, 0, 2, 0);
    getContentPane().add(new JSeparator(), gridBagConstraints);

    label = new JLabel(
            "If you have an existing options.ini file," + "then select the directory containing that file");
    gridBagConstraints.insets = new Insets(4, 4, 4, 4);
    getContentPane().add(label, gridBagConstraints);

    ActionListener handler = new ActionHandler();
    ButtonGroup group = new ButtonGroup();

    gridBagConstraints.insets = new Insets(0, 4, 0, 4);
    addRadioButton("<html><b>PCGen Dir</b>: This is the directory that PCGen is installed into",
            SettingsFilesPath.pcgen.name(), group, handler, gridBagConstraints);
    // Remark: do mac user really need to be able to put the file either in a specific mac dir or home?
    if (SystemUtils.IS_OS_MAC_OSX) {
        addRadioButton("<html><b>Mac User Dir</b>", SettingsFilesPath.mac_user.name(), group, handler,
                gridBagConstraints);
    } else if (SystemUtils.IS_OS_UNIX) {
        // putting it the same way as mac. merging all and using a system config dir instead would be better IMHO.
        addRadioButton("<html><b>Freedesktop configuration sub-directory</b> Use for most Linux/BSD",
                SettingsFilesPath.FD_USER.name(), group, handler, gridBagConstraints);
    }
    addRadioButton("<html><b>Home Dir</b>: This is your home directory", SettingsFilesPath.user.name(), group,
            handler, gridBagConstraints);
    addRadioButton("Select a directory to use", "select", group, handler, gridBagConstraints);

    dirField.setText(ConfigurationSettings.getSettingsDirFromFilePath(selectedDir));
    dirField.setEditable(false);

    gridBagConstraints.gridwidth = GridBagConstraints.RELATIVE;
    gridBagConstraints.weightx = 1;
    gridBagConstraints.insets = new Insets(0, 4, 0, 0);
    getContentPane().add(dirField, gridBagConstraints);

    dirButton.setText("...");
    dirButton.setEnabled(false);
    dirButton.addActionListener(handler);
    dirButton.setActionCommand("custom");
    dirButton.setMargin(new Insets(2, 2, 2, 2));

    GridBagConstraints bagConstraints = new GridBagConstraints();
    bagConstraints.gridwidth = GridBagConstraints.REMAINDER;
    bagConstraints.insets = new Insets(0, 0, 0, 4);
    getContentPane().add(dirButton, bagConstraints);

    JButton okButton = new JButton("OK");
    okButton.setPreferredSize(new Dimension(75, 23));
    okButton.setActionCommand("ok");
    okButton.addActionListener(handler);

    bagConstraints.insets = new Insets(4, 0, 4, 0);
    getContentPane().add(okButton, bagConstraints);
    getRootPane().setDefaultButton(okButton);

    pack();
    setLocationRelativeTo(null);
}

From source file:pcgen.gui2.dialog.PostLevelUpDialog.java

private void initComponents() {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    JTable table = new JTable(tableModel) {

        @Override/*from   ww  w .j  av  a 2s .  c  o  m*/
        public TableCellEditor getCellEditor(int row, int column) {
            if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {//TODO: the max roll should be calculated in a different manner
                String hd = levels.getClassTaken(levels.getElementAt(row + oldLevel)).getHD();
                int max = NumberUtils.toInt(hd);
                return new SpinnerEditor(new SpinnerNumberModel(1, 1, max, 1));
            }
            return super.getCellEditor(row, column);
        }

        @Override
        public TableCellRenderer getCellRenderer(int row, int column) {
            if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {
                return new SpinnerRenderer();
            }
            return super.getCellRenderer(row, column);
        }

    };
    table.setCellSelectionEnabled(false);
    table.setRowHeight(new JSpinner().getPreferredSize().height);
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);

    JScrollPane scrollPane = new JScrollPane(table);
    pane.add(scrollPane, BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    JButton button = new JButton(LanguageBundle.getString("in_close")); //$NON-NLS-1$
    button.setMnemonic(LanguageBundle.getMnemonic("in_mn_close")); //$NON-NLS-1$
    button.setActionCommand("Close"); //$NON-NLS-1$
    button.addActionListener(this);
    box.add(button);
    pane.add(box, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            //Make sure to remove the listeners so that the garbage collector can
            //dispose of this dialog and prevent a memory leak
            levels.removeHitPointListener(tableModel);
        }

    });

    Utility.installEscapeCloseOperation(this);
}

From source file:pipeline.GUI_utils.ListOfPointsView.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override//from   w  w w .  j  av  a 2  s  .  co m
public void show() {
    if (frame != null)
        frame.toFront();
    if (table == null) {
        spreadsheetEngine = new DependencyEngine(new BasicEngineProvider());
        setupTableModel(points);
        silenceUpdates.incrementAndGet();
        table = new JXTablePerColumnFiltering(tableModel);

        table.setRolloverEnabled(true);
        // table.setDragEnabled(true);
        table.setFillsViewportHeight(false);
        table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        table.setShowGrid(true);
        table.setShowHorizontalLines(true);
        table.setColumnSelectionAllowed(true);
        table.setRowSelectionAllowed(true);
        table.setColumnControlVisible(true);
        table.setHighlighters(new Highlighter[] { HighlighterFactory.createAlternateStriping() });

        table.addPropertyChangeListener("horizontalScrollEnabled", new PropertyChangeListener() {

            JViewport viewPort, filteringViewPort, columnDescViewPort;
            int lastX;

            ChangeListener scrollListener = new ChangeListener() {

                @Override
                public void stateChanged(ChangeEvent e) {
                    if (viewPort == null || filteringViewPort == null) {
                        return;
                    }
                    Point position = viewPort.getViewPosition();
                    if (position.x == lastX) {
                        return;
                    }
                    filteringViewPort.setViewPosition(position);
                    columnDescViewPort.setViewPosition(position);
                    lastX = position.x;
                }

            };

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if (viewPort != null) {
                    viewPort.removeChangeListener(scrollListener);
                }
                if (evt.getNewValue().equals(true)) {
                    viewPort = getTableViewPort(table);
                    if (viewPort == null) {
                        return;
                    }
                    table.filteringTable.setHorizontalScrollEnabled(true);
                    table.tableForColumnDescriptions.setHorizontalScrollEnabled(true);
                    table.updateFilteringTableSetup();
                    filteringViewPort = getTableViewPort(table.filteringTable);
                    columnDescViewPort = getTableViewPort(table.tableForColumnDescriptions);
                    viewPort.addChangeListener(scrollListener);
                    scrollListener.stateChanged(null);
                } else {
                    table.filteringTable.setHorizontalScrollEnabled(false);
                    table.tableForColumnDescriptions.setHorizontalScrollEnabled(false);
                }
            }
        });

        modelForColumnDescriptions = new dataModelAllEditable(1, tableModel.getColumnCount());
        Vector<String> rowVector0 = (Vector<String>) modelForColumnDescriptions.getDataVector().get(0);
        for (int j = 0; j < tableModel.getColumnCount(); j++) {
            rowVector0.setElementAt(tableModel.getColumnName(j), j);
        }

        boolean done;
        do {
            done = true;
            for (TableColumn i : table.getColumns(true)) {
                TableColumnExt iCast = (TableColumnExt) i;
                if (iCast.getTitle().equals("Class") || iCast.getTitle().equals("c")
                        || iCast.getTitle().equals("t") || iCast.getTitle().equals("clusterID")
                        || iCast.getTitle().equals("userCell 2") || iCast.getTitle().equals("userCell 3")) {
                    if (iCast.isVisible()) {
                        iCast.setVisible(false);
                        done = false;
                        break;
                    }
                }
            }
        } while (!done);

        SwingUtilities.invokeLater(modelForColumnDescriptions::fireTableDataChanged);

        JScrollPane scrollPane = new JScrollPane(table);
        scrollPane.setPreferredSize(new Dimension(2000, 2000));

        updateColumnDescriptions();
        silenceUpdates.decrementAndGet();

        setSpreadsheetColumnEditorAndRenderer();

        tableForColumnDescriptions = new JXTable(modelForColumnDescriptions);
        table.tableForColumnDescriptions = tableForColumnDescriptions;

        JScrollPane jScrollPaneForNames = new JScrollPane(tableForColumnDescriptions);
        jScrollPaneForNames.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        JPanel controlPanel = new JPanel();
        controlPanel.setLayout(new FlowLayout());

        JButton createScatterPlotButton = new JButton("Scatter plot from selected columns");
        controlPanel.add(createScatterPlotButton);
        createScatterPlotButton.setActionCommand("Scatter plot from selected columns");
        createScatterPlotButton.addActionListener(this);

        realTimeUpdateCheckbox = new JCheckBox("Update display in real time");
        controlPanel.add(realTimeUpdateCheckbox);
        realTimeUpdateCheckbox.setActionCommand("Update display in real time");
        realTimeUpdateCheckbox.addActionListener(this);

        JButton forceUpdate = new JButton("Force display update");
        controlPanel.add(forceUpdate);
        forceUpdate.setActionCommand("Force display update");
        forceUpdate.addActionListener(this);

        JButton extendFormula = new JButton("Extend formula to column");
        controlPanel.add(extendFormula);
        extendFormula.setActionCommand("Extend formula to column");
        extendFormula.addActionListener(this);

        JButton saveFormulas = new JButton("Save user formulas...");
        saveFormulas.addActionListener(this);
        saveFormulas.setActionCommand("Save user formulas");
        controlPanel.add(saveFormulas);

        JButton reloadFormulas = new JButton("Reload user formulas...");
        reloadFormulas.addActionListener(this);
        reloadFormulas.setActionCommand("Reload user formulas");
        controlPanel.add(reloadFormulas);

        controlPanel.add(new JLabel("Color with:"));
        coloringComboBox = new JComboBox();
        controlPanel.add(coloringComboBox);
        DefaultComboBoxModel comboBoxModel = (DefaultComboBoxModel) coloringComboBox.getModel();
        coloringComboBox.addActionListener(this);

        for (int i = 0; i < tableModel.getColumnCount(); i++) {
            comboBoxModel.addElement(tableModel.getColumnName(i));
        }

        JButton saveTableToFile = new JButton("Save table to file");
        controlPanel.add(saveTableToFile);
        saveTableToFile.setActionCommand("Save table to file");
        saveTableToFile.addActionListener(this);

        /*
        final JCheckBox useCalibration = new JCheckBox("Use calibration");
        useCalibration.addActionListener(e -> {
           if (points == null)
              return;
           boolean selected = useCalibration.isSelected();
           if (selected && !(points instanceof PluginIOCalibrable)) {
              Utils.displayMessage("Type " + points.getClass().getName() + " does not have calibration", true,
             LogLevel.ERROR);
              return;
           }
           PluginIOCalibrable calibrable = (PluginIOCalibrable) points;
           if (selected && (calibrable.getCalibration() == null)) {
              Utils.displayMessage("Calibration information is not present in the segmentation; one "
             + "way of adding it is to give the source image (with calibration) as an input "
             + "to the active contour plugin", true, LogLevel.ERROR);
              return;
           }
           float xyCalibration = selected ? ((float) calibrable.getCalibration().pixelWidth) : 0;
           float zCalibration = selected ? ((float) calibrable.getCalibration().pixelDepth) : 0;
           updateCalibration(xyCalibration, zCalibration);
        });
        PluginIOCalibrable calibrable = null;
        if (points instanceof PluginIOCalibrable)
           calibrable = (PluginIOCalibrable) points;
        boolean calibrationPresent = calibrable != null && calibrable.getCalibration() != null;
        useCalibration.setSelected(calibrationPresent);
        if (calibrationPresent) {
           updateCalibration((float) calibrable.getCalibration().pixelWidth,
          (float) calibrable.getCalibration().pixelDepth);
        }
        controlPanel.add(useCalibration);
        */

        frame = new JFrame(points.getName());
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

        listener = new WindowListenerWeakRef(new WindowAdapter() {
            @Override
            public void windowClosed(WindowEvent e) {
                close();// So all references to data are nulled, to ensure garbage collection
            }

        });
        frame.addWindowListener(listener);

        frame.setLayout(new GridBagLayout());

        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.BOTH;
        c.gridx = 0;
        c.gridy = GridBagConstraints.RELATIVE;
        c.weighty = 0.75;
        c.weightx = 1.0;
        c.gridwidth = 1;
        c.gridheight = 1;

        frame.add(scrollPane, c);

        c.weighty = 0.0;
        JScrollPane scrollPane2 = new JScrollPane(table.filteringTable);
        scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scrollPane2.setMinimumSize(new Dimension(1, 250));
        frame.add(scrollPane2, c);

        c.weighty = 0.0;
        jScrollPaneForNames.setMinimumSize(new Dimension(1, 40));
        jScrollPaneForNames.setMaximumSize(new Dimension(9999999, 40));
        frame.add(jScrollPaneForNames, c);

        c.weighty = 0.0;
        c.fill = GridBagConstraints.HORIZONTAL;
        controlPanel.setMinimumSize(new Dimension(1, 80));
        frame.add(controlPanel, c);

        table.setHorizontalScrollEnabled(true);
        table.updateFilteringTableSetup();

        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        int height = screenSize.height;
        int width = screenSize.width;
        frame.setSize((int) (0.67 * width), height / 2);
        frame.setLocation((int) (0.33 * width), height / 2);
        frame.setVisible(true);
    }

    if ((tableUpdateThread == null) || (!tableUpdateThread.isAlive())) {
        tableUpdateThread = new Thread(() -> {
            try {
                checkForDirtiness();
            } catch (Exception e) {
                Utils.log("Exception in ListOfPointsView GUI update thread", LogLevel.ERROR);
                Utils.printStack(e);
            }
        }, "ListOfPointsView GUI update thread");

        tableUpdateThread.start();
    }
}

From source file:playground.sergioo.facilitiesGenerator2012.gui.ClustersWindow.java

public ClustersWindow(String title, Map<Integer, Cluster<Double>> clusters, int numTotalPoints) {
    setTitle(title);/* w  w  w. j ava 2 s  .  c o  m*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setLocation(0, 0);
    this.setLayout(new BorderLayout());
    layersPanels.put(PanelIds.ONE, new ClustersPanel(this, clusters, numTotalPoints));
    this.add(layersPanels.get(PanelIds.ONE), BorderLayout.CENTER);
    option = Options.ZOOM;
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new GridLayout(Options.values().length, 1));
    for (Options option : Options.values()) {
        JButton optionButton = new JButton(option.getCaption());
        optionButton.setActionCommand(option.getCaption());
        optionButton.addActionListener(this);
        buttonsPanel.add(optionButton);
    }
    this.add(buttonsPanel, BorderLayout.EAST);
    JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new BorderLayout());
    readyButton = new JButton("Ready to exit");
    readyButton.addActionListener(this);
    readyButton.setActionCommand(READY_TO_EXIT);
    infoPanel.add(readyButton, BorderLayout.WEST);
    JPanel labelsPanel = new JPanel();
    labelsPanel.setLayout(new GridLayout(1, Labels.values().length));
    labelsPanel.setBorder(new TitledBorder("Information"));
    labels = new JTextField[Labels.values().length];
    for (int i = 0; i < Labels.values().length; i++) {
        labels[i] = new JTextField("");
        labels[i].setEditable(false);
        labels[i].setBackground(null);
        labels[i].setBorder(null);
        labelsPanel.add(labels[i]);
    }
    infoPanel.add(labelsPanel, BorderLayout.CENTER);
    JPanel coordsPanel = new JPanel();
    coordsPanel.setLayout(new GridLayout(1, 2));
    coordsPanel.setBorder(new TitledBorder("Coordinates"));
    coordsPanel.add(lblCoords[0]);
    coordsPanel.add(lblCoords[1]);
    infoPanel.add(coordsPanel, BorderLayout.EAST);
    this.add(infoPanel, BorderLayout.SOUTH);
    pack();
}