Search in sources :

Example 11 with CustomJButton

use of net.pms.newgui.components.CustomJButton in project UniversalMediaServer by UniversalMediaServer.

the class RendererPanel method customizeButton.

public JButton customizeButton() {
    final CustomJButton open = new CustomJButton("+", MetalIconFactory.getTreeLeafIcon());
    open.setHorizontalTextPosition(JButton.CENTER);
    open.setForeground(Color.lightGray);
    open.setToolTipText(Messages.getString("RendererPanel.5"));
    open.setFocusPainted(false);
    open.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            DeviceConfiguration d = (DeviceConfiguration) renderer;
            File f = chooseConf(d.getDeviceDir(), d.getDefaultFilename(d));
            if (f != null) {
                File file = DeviceConfiguration.createDeviceFile(d, f.getName(), true);
                buildEditBar(true);
                try {
                    java.awt.Desktop.getDesktop().open(file);
                } catch (IOException ioe) {
                    LOGGER.debug("Failed to open default desktop application: " + ioe);
                }
            }
        }
    });
    return open;
}
Also used : CustomJButton(net.pms.newgui.components.CustomJButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) IOException(java.io.IOException) DeviceConfiguration(net.pms.configuration.DeviceConfiguration) File(java.io.File)

Example 12 with CustomJButton

use of net.pms.newgui.components.CustomJButton in project UniversalMediaServer by UniversalMediaServer.

the class RendererPanel method editButton.

public JButton editButton(final boolean create) {
    final File file = create ? renderer.getUsableFile() : renderer.getFile();
    final CustomJButton open = new CustomJButton(((file != null && file.exists() || !create) ? "<html>" : "<html><font color=blue>" + Messages.getString("RendererPanel.2") + ":</font> ") + file.getName() + "</html>", MetalIconFactory.getTreeLeafIcon());
    open.setToolTipText(file.getAbsolutePath());
    open.setFocusPainted(false);
    open.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            boolean exists = file.isFile() && file.exists();
            File f = file;
            if (!exists && create) {
                f = chooseConf(file.getParentFile(), file.getName());
                if (f != null) {
                    File ref = chooseReferenceConf();
                    if (ref != null) {
                        renderer.createNewFile(renderer, f, true, ref);
                        open.setText(f.getName());
                        exists = true;
                    }
                }
            }
            if (exists) {
                try {
                    java.awt.Desktop.getDesktop().open(f);
                } catch (IOException ioe) {
                    LOGGER.debug("Failed to open default desktop application: " + ioe);
                }
            } else {
                // Conf no longer exists, repair the edit bar
                buildEditBar(true);
            }
        }
    });
    return open;
}
Also used : CustomJButton(net.pms.newgui.components.CustomJButton) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) IOException(java.io.IOException) File(java.io.File)

Example 13 with CustomJButton

use of net.pms.newgui.components.CustomJButton in project UniversalMediaServer by UniversalMediaServer.

the class TranscodingTab method buildSubtitlesSetupPanel.

private JComponent buildSubtitlesSetupPanel() {
    String colSpec = FormLayoutUtil.getColSpec("left:pref, 3dlu, p:grow, 3dlu, right:p:grow, 3dlu, p:grow, 3dlu, right:p:grow,3dlu, p:grow, 3dlu, right:p:grow,3dlu, pref:grow", orientation);
    FormLayout layout = new FormLayout(colSpec, "$lgap, 11*(pref, 3dlu), pref");
    final PanelBuilder builder = new PanelBuilder(layout);
    builder.border(Borders.DLU4);
    CellConstraints cc = new CellConstraints();
    builder.addLabel(Messages.getString("MEncoderVideo.9"), FormLayoutUtil.flip(cc.xy(1, 2), colSpec, orientation));
    defaultsubs = new CustomJTextField(configuration.getSubtitlesLanguages());
    defaultsubs.setToolTipText(Messages.getString("TrTab2.76"));
    defaultsubs.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setSubtitlesLanguages(defaultsubs.getText());
        }
    });
    builder.add(defaultsubs, FormLayoutUtil.flip(cc.xyw(3, 2, 5), colSpec, orientation));
    builder.addLabel(Messages.getString("MEncoderVideo.94"), FormLayoutUtil.flip(cc.xy(9, 2, CellConstraints.RIGHT, CellConstraints.CENTER), colSpec, orientation));
    forcedsub = new JTextField(configuration.getForcedSubtitleLanguage());
    forcedsub.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setForcedSubtitleLanguage(forcedsub.getText());
        }
    });
    builder.add(forcedsub, FormLayoutUtil.flip(cc.xy(11, 2), colSpec, orientation));
    builder.addLabel(Messages.getString("MEncoderVideo.95"), FormLayoutUtil.flip(cc.xy(13, 2, CellConstraints.RIGHT, CellConstraints.CENTER), colSpec, orientation));
    forcedtags = new JTextField(configuration.getForcedSubtitleTags());
    forcedtags.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setForcedSubtitleTags(forcedtags.getText());
        }
    });
    builder.add(forcedtags, FormLayoutUtil.flip(cc.xy(15, 2), colSpec, orientation));
    builder.addLabel(Messages.getString("MEncoderVideo.10"), FormLayoutUtil.flip(cc.xy(1, 4), colSpec, orientation));
    defaultaudiosubs = new JTextField(configuration.getAudioSubLanguages());
    defaultaudiosubs.setToolTipText(Messages.getString("TrTab2.77"));
    defaultaudiosubs.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setAudioSubLanguages(defaultaudiosubs.getText());
        }
    });
    builder.add(defaultaudiosubs, FormLayoutUtil.flip(cc.xyw(3, 4, 13), colSpec, orientation));
    builder.addLabel(Messages.getString("MEncoderVideo.37"), FormLayoutUtil.flip(cc.xyw(1, 6, 2), colSpec, orientation));
    alternateSubFolder = new JTextField(configuration.getAlternateSubtitlesFolder());
    alternateSubFolder.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setAlternateSubtitlesFolder(alternateSubFolder.getText());
        }
    });
    builder.add(alternateSubFolder, FormLayoutUtil.flip(cc.xyw(3, 6, 12), colSpec, orientation));
    folderSelectButton = new JButton("...");
    folderSelectButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser;
            try {
                chooser = new JFileChooser();
            } catch (Exception ee) {
                chooser = new JFileChooser(new RestrictedFileSystemView());
            }
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = chooser.showDialog((Component) e.getSource(), Messages.getString("FoldTab.28"));
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                alternateSubFolder.setText(chooser.getSelectedFile().getAbsolutePath());
                configuration.setAlternateSubtitlesFolder(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });
    builder.add(folderSelectButton, FormLayoutUtil.flip(cc.xy(15, 6), colSpec, orientation));
    builder.addLabel(Messages.getString("TrTab2.95"), FormLayoutUtil.flip(cc.xy(1, 8), colSpec, orientation));
    String[] keys = new String[] { "", "cp874", "cp932", "cp936", "cp949", "cp950", "cp1250", "cp1251", "cp1252", "cp1253", "cp1254", "cp1255", "cp1256", "cp1257", "cp1258", "ISO-2022-CN", "ISO-2022-JP", "ISO-2022-KR", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-10", "ISO-8859-11", "ISO-8859-13", "ISO-8859-14", "ISO-8859-15", "ISO-8859-16", "Big5", "EUC-JP", "EUC-KR", "GB18030", "IBM420", "IBM424", "KOI8-R", "Shift_JIS", "TIS-620" };
    String[] values = new String[] { Messages.getString("General.2"), Messages.getString("CharacterSet.874"), Messages.getString("CharacterSet.932"), Messages.getString("CharacterSet.936"), Messages.getString("CharacterSet.949"), Messages.getString("CharacterSet.950"), Messages.getString("CharacterSet.1250"), Messages.getString("CharacterSet.1251"), Messages.getString("CharacterSet.1252"), Messages.getString("CharacterSet.1253"), Messages.getString("CharacterSet.1254"), Messages.getString("CharacterSet.1255"), Messages.getString("CharacterSet.1256"), Messages.getString("CharacterSet.1257"), Messages.getString("CharacterSet.1258"), Messages.getString("CharacterSet.2022-CN"), Messages.getString("CharacterSet.2022-JP"), Messages.getString("CharacterSet.2022-KR"), Messages.getString("CharacterSet.8859-1"), Messages.getString("CharacterSet.8859-2"), Messages.getString("CharacterSet.8859-3"), Messages.getString("CharacterSet.8859-4"), Messages.getString("CharacterSet.8859-5"), Messages.getString("CharacterSet.8859-6"), Messages.getString("CharacterSet.8859-7"), Messages.getString("CharacterSet.8859-8"), Messages.getString("CharacterSet.8859-9"), Messages.getString("CharacterSet.8859-10"), Messages.getString("CharacterSet.8859-11"), Messages.getString("CharacterSet.8859-13"), Messages.getString("CharacterSet.8859-14"), Messages.getString("CharacterSet.8859-15"), Messages.getString("CharacterSet.8859-16"), Messages.getString("CharacterSet.Big5"), Messages.getString("CharacterSet.EUC-JP"), Messages.getString("CharacterSet.EUC-KR"), Messages.getString("CharacterSet.GB18030"), Messages.getString("CharacterSet.IBM420"), Messages.getString("CharacterSet.IBM424"), Messages.getString("CharacterSet.KOI8-R"), Messages.getString("CharacterSet.ShiftJIS"), Messages.getString("CharacterSet.TIS-620") };
    final KeyedComboBoxModel<String, String> subtitleCodePageModel = new KeyedComboBoxModel<>(keys, values);
    subtitleCodePage = new CustomJComboBox<>(subtitleCodePageModel);
    subtitleCodePage.setToolTipText(Messages.getString("TrTab2.94"));
    subtitleCodePageModel.setSelectedKey(configuration.getSubtitlesCodepage());
    subtitleCodePage.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setSubtitlesCodepage(subtitleCodePageModel.getSelectedKey());
            }
        }
    });
    subtitleCodePage.setEditable(false);
    builder.add(subtitleCodePage, FormLayoutUtil.flip(cc.xyw(3, 8, 7), colSpec, orientation));
    fribidi = new JCheckBox(Messages.getString("MEncoderVideo.23"), configuration.isMencoderSubFribidi());
    fribidi.setContentAreaFilled(false);
    fribidi.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderSubFribidi(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(fribidi), FormLayoutUtil.flip(cc.xyw(11, 8, 4), colSpec, orientation));
    builder.addLabel(Messages.getString("MEncoderVideo.24"), FormLayoutUtil.flip(cc.xy(1, 10), colSpec, orientation));
    defaultfont = new JTextField(configuration.getFont());
    defaultfont.setToolTipText(Messages.getString("TrTab2.97"));
    defaultfont.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setFont(defaultfont.getText());
        }
    });
    builder.add(defaultfont, FormLayoutUtil.flip(cc.xyw(3, 10, 12), colSpec, orientation));
    fontselect = new CustomJButton("...");
    fontselect.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser();
            chooser.setFileFilter(new FontFileFilter());
            int returnVal = chooser.showDialog((Component) e.getSource(), Messages.getString("MEncoderVideo.25"));
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                defaultfont.setText(chooser.getSelectedFile().getAbsolutePath());
                configuration.setFont(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });
    builder.add(fontselect, FormLayoutUtil.flip(cc.xy(15, 10), colSpec, orientation));
    builder.addLabel(Messages.getString("MEncoderVideo.12"), FormLayoutUtil.flip(cc.xy(1, 12), colSpec, orientation));
    builder.addLabel(Messages.getString("MEncoderVideo.133"), FormLayoutUtil.flip(cc.xy(1, 12, CellConstraints.RIGHT, CellConstraints.CENTER), colSpec, orientation));
    ass_scale = new JTextField(configuration.getAssScale());
    ass_scale.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setAssScale(ass_scale.getText());
        }
    });
    builder.addLabel(Messages.getString("MEncoderVideo.13"), FormLayoutUtil.flip(cc.xy(5, 12), colSpec, orientation));
    ass_outline = new JTextField(configuration.getAssOutline());
    ass_outline.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setAssOutline(ass_outline.getText());
        }
    });
    builder.addLabel(Messages.getString("MEncoderVideo.14"), FormLayoutUtil.flip(cc.xy(9, 12), colSpec, orientation));
    ass_shadow = new JTextField(configuration.getAssShadow());
    ass_shadow.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setAssShadow(ass_shadow.getText());
        }
    });
    builder.addLabel(Messages.getString("MEncoderVideo.15"), FormLayoutUtil.flip(cc.xy(13, 12), colSpec, orientation));
    ass_margin = new JTextField(configuration.getAssMargin());
    ass_margin.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setAssMargin(ass_margin.getText());
        }
    });
    builder.add(ass_scale, FormLayoutUtil.flip(cc.xy(3, 12), colSpec, orientation));
    builder.add(ass_outline, FormLayoutUtil.flip(cc.xy(7, 12), colSpec, orientation));
    builder.add(ass_shadow, FormLayoutUtil.flip(cc.xy(11, 12), colSpec, orientation));
    builder.add(ass_margin, FormLayoutUtil.flip(cc.xy(15, 12), colSpec, orientation));
    autoloadExternalSubtitles = new JCheckBox(Messages.getString("MEncoderVideo.22"), configuration.isAutoloadExternalSubtitles());
    autoloadExternalSubtitles.setToolTipText(Messages.getString("TrTab2.78"));
    autoloadExternalSubtitles.setContentAreaFilled(false);
    autoloadExternalSubtitles.setEnabled(!configuration.isForceExternalSubtitles());
    autoloadExternalSubtitles.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setAutoloadExternalSubtitles((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(autoloadExternalSubtitles), FormLayoutUtil.flip(cc.xyw(1, 14, 11), colSpec, orientation));
    subColor = new JButton();
    subColor.setText(Messages.getString("MEncoderVideo.31"));
    subColor.setBackground(configuration.getSubsColor());
    subColor.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final JColorChooser jColorChooser = new JColorChooser(subColor.getBackground());
            Locale locale = PMS.getLocale();
            jColorChooser.setLocale(locale);
            jColorChooser.setComponentOrientation(ComponentOrientation.getOrientation(locale));
            JDialog dialog = JColorChooser.createDialog(looksFrame, Messages.getString("MEncoderVideo.125"), true, jColorChooser, new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    Color newColor = jColorChooser.getColor();
                    if (newColor != null) {
                        subColor.setBackground(newColor);
                        configuration.setSubsColor(newColor);
                        // Subtitle color has been changed so all temporary subtitles must be deleted
                        SubtitleUtils.deleteSubs();
                    }
                }
            }, null);
            dialog.setVisible(true);
            dialog.dispose();
        }
    });
    builder.add(subColor, FormLayoutUtil.flip(cc.xyw(13, 14, 3), colSpec, orientation));
    forceExternalSubtitles = new JCheckBox(Messages.getString("TrTab2.87"), configuration.isForceExternalSubtitles());
    forceExternalSubtitles.setToolTipText(Messages.getString("TrTab2.88"));
    forceExternalSubtitles.setContentAreaFilled(false);
    forceExternalSubtitles.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setForceExternalSubtitles((e.getStateChange() == ItemEvent.SELECTED));
            if (configuration.isForceExternalSubtitles()) {
                autoloadExternalSubtitles.setSelected(true);
            }
            autoloadExternalSubtitles.setEnabled(!configuration.isForceExternalSubtitles());
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(forceExternalSubtitles), FormLayoutUtil.flip(cc.xyw(1, 16, 11), colSpec, orientation));
    useEmbeddedSubtitlesStyle = new JCheckBox(Messages.getString("MEncoderVideo.36"), configuration.isUseEmbeddedSubtitlesStyle());
    useEmbeddedSubtitlesStyle.setToolTipText(Messages.getString("TrTab2.89"));
    useEmbeddedSubtitlesStyle.setContentAreaFilled(false);
    useEmbeddedSubtitlesStyle.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setUseEmbeddedSubtitlesStyle(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(useEmbeddedSubtitlesStyle), FormLayoutUtil.flip(cc.xyw(1, 18, 11), colSpec, orientation));
    Integer[] depth = { -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 };
    builder.addLabel(Messages.getString("TrTab2.90"), FormLayoutUtil.flip(cc.xy(1, 20), colSpec, orientation));
    depth3D = new JComboBox<>(depth);
    depth3D.setSelectedItem(configuration.getDepth3D());
    depth3D.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setDepth3D((int) e.getItem());
            }
        }
    });
    builder.add(depth3D, FormLayoutUtil.flip(cc.xy(3, 20), colSpec, orientation));
    final JPanel panel = builder.getPanel();
    GuiUtil.enableContainer(panel, !configuration.isDisableSubtitles());
    disableSubs.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            // If "Disable Subtitles" is not selected, subtitles are enabled
            GuiUtil.enableContainer(panel, e.getStateChange() != ItemEvent.SELECTED);
        }
    });
    panel.applyComponentOrientation(orientation);
    return panel;
}
Also used : Locale(java.util.Locale) CustomJButton(net.pms.newgui.components.CustomJButton) CustomJTextField(net.pms.newgui.components.CustomJTextField) CellConstraints(com.jgoodies.forms.layout.CellConstraints) FormLayout(com.jgoodies.forms.layout.FormLayout) PanelBuilder(com.jgoodies.forms.builder.PanelBuilder) KeyedComboBoxModel(net.pms.util.KeyedComboBoxModel) CustomJButton(net.pms.newgui.components.CustomJButton) CustomJTextField(net.pms.newgui.components.CustomJTextField)

Example 14 with CustomJButton

use of net.pms.newgui.components.CustomJButton in project UniversalMediaServer by UniversalMediaServer.

the class TranscodingTab method buildLeft.

public JComponent buildLeft() {
    String colSpec = FormLayoutUtil.getColSpec(LEFT_COL_SPEC, orientation);
    FormLayout layout = new FormLayout(colSpec, LEFT_ROW_SPEC);
    PanelBuilder builder = new PanelBuilder(layout);
    builder.border(Borders.EMPTY);
    builder.opaque(false);
    CellConstraints cc = new CellConstraints();
    CustomJButton but = new CustomJButton(LooksFrame.readImageIcon("button-arrow-down.png"));
    but.setToolTipText(Messages.getString("TrTab2.6"));
    but.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            TreePath path = tree.getSelectionModel().getSelectionPath();
            if (path != null && path.getLastPathComponent() instanceof TreeNodeSettings) {
                TreeNodeSettings node = ((TreeNodeSettings) path.getLastPathComponent());
                if (node.getPlayer() != null) {
                    // get the tree model
                    DefaultTreeModel dtm = (DefaultTreeModel) tree.getModel();
                    // now get the index of the selected node in the DefaultTreeModel
                    int index = dtm.getIndexOfChild(node.getParent(), node);
                    // if selected node is first, return (can't move it up)
                    if (index < node.getParent().getChildCount() - 1) {
                        // move the node
                        dtm.insertNodeInto(node, (DefaultMutableTreeNode) node.getParent(), index + 1);
                        dtm.reload();
                        for (int i = 0; i < tree.getRowCount(); i++) {
                            tree.expandRow(i);
                        }
                        tree.getSelectionModel().setSelectionPath(new TreePath(node.getPath()));
                        updateEngineModel();
                    }
                }
            }
        }
    });
    builder.add(but, FormLayoutUtil.flip(cc.xy(2, 3), colSpec, orientation));
    CustomJButton but2 = new CustomJButton(LooksFrame.readImageIcon("button-arrow-up.png"));
    but2.setToolTipText(Messages.getString("TrTab2.6"));
    but2.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            TreePath path = tree.getSelectionModel().getSelectionPath();
            if (path != null && path.getLastPathComponent() instanceof TreeNodeSettings) {
                TreeNodeSettings node = ((TreeNodeSettings) path.getLastPathComponent());
                if (node.getPlayer() != null) {
                    // get the tree model
                    DefaultTreeModel dtm = (DefaultTreeModel) tree.getModel();
                    // now get the index of the selected node in the DefaultTreeModel
                    int index = dtm.getIndexOfChild(node.getParent(), node);
                    // if selected node is first, return (can't move it up)
                    if (index != 0) {
                        // move the node
                        dtm.insertNodeInto(node, (DefaultMutableTreeNode) node.getParent(), index - 1);
                        dtm.reload();
                        for (int i = 0; i < tree.getRowCount(); i++) {
                            tree.expandRow(i);
                        }
                        tree.getSelectionModel().setSelectionPath(new TreePath(node.getPath()));
                        updateEngineModel();
                    }
                }
            }
        }
    });
    builder.add(but2, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation));
    CustomJButton but3 = new CustomJButton(LooksFrame.readImageIcon("button-toggleengine.png"));
    but3.setToolTipText(Messages.getString("TrTab2.0"));
    but3.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            TreePath path = tree.getSelectionModel().getSelectionPath();
            if (path != null && path.getLastPathComponent() instanceof TreeNodeSettings && ((TreeNodeSettings) path.getLastPathComponent()).getPlayer() != null) {
                ((TreeNodeSettings) path.getLastPathComponent()).setEnable(!((TreeNodeSettings) path.getLastPathComponent()).isEnable());
                updateEngineModel();
                tree.updateUI();
            }
        }
    });
    builder.add(but3, FormLayoutUtil.flip(cc.xy(4, 3), colSpec, orientation));
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(Messages.getString("TrTab2.11"));
    TreeNodeSettings commonEnc = new TreeNodeSettings(Messages.getString("TrTab2.5"), null, buildCommon());
    commonEnc.getConfigPanel().addComponentListener(new ComponentAdapter() {

        @Override
        public void componentShown(ComponentEvent e) {
            handleCardComponentChange(e.getComponent());
        }
    });
    tabbedPanel.add(commonEnc.id(), commonEnc.getConfigPanel());
    root.add(commonEnc);
    parent = new DefaultMutableTreeNode[5];
    parent[0] = new DefaultMutableTreeNode(Messages.getString("TrTab2.14"));
    parent[1] = new DefaultMutableTreeNode(Messages.getString("TrTab2.15"));
    parent[2] = new DefaultMutableTreeNode(Messages.getString("TrTab2.16"));
    parent[3] = new DefaultMutableTreeNode(Messages.getString("TrTab2.17"));
    parent[4] = new DefaultMutableTreeNode(Messages.getString("TrTab2.18"));
    root.add(parent[0]);
    root.add(parent[1]);
    root.add(parent[2]);
    root.add(parent[3]);
    root.add(parent[4]);
    tree = new JTree(new DefaultTreeModel(root)) {

        private static final long serialVersionUID = -6703434752606636290L;
    };
    tree.setRootVisible(false);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            if (e.getNewLeadSelectionPath() != null && e.getNewLeadSelectionPath().getLastPathComponent() instanceof TreeNodeSettings) {
                TreeNodeSettings tns = (TreeNodeSettings) e.getNewLeadSelectionPath().getLastPathComponent();
                cl.show(tabbedPanel, tns.id());
            }
        }
    });
    tree.setRequestFocusEnabled(false);
    tree.setCellRenderer(new TreeRenderer());
    JScrollPane pane = new JScrollPane(tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    builder.add(pane, FormLayoutUtil.flip(cc.xyw(2, 1, 4), colSpec, orientation));
    builder.addLabel(Messages.getString("TrTab2.19"), FormLayoutUtil.flip(cc.xyw(2, 5, 4), colSpec, orientation));
    builder.addLabel(Messages.getString("TrTab2.20"), FormLayoutUtil.flip(cc.xyw(2, 7, 4), colSpec, orientation));
    JPanel panel = builder.getPanel();
    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);
    return panel;
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) PanelBuilder(com.jgoodies.forms.builder.PanelBuilder) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeSelectionListener(javax.swing.event.TreeSelectionListener) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) CustomJButton(net.pms.newgui.components.CustomJButton) TreePath(javax.swing.tree.TreePath) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Aggregations

CustomJButton (net.pms.newgui.components.CustomJButton)14 PanelBuilder (com.jgoodies.forms.builder.PanelBuilder)6 CellConstraints (com.jgoodies.forms.layout.CellConstraints)6 FormLayout (com.jgoodies.forms.layout.FormLayout)6 File (java.io.File)6 ActionEvent (java.awt.event.ActionEvent)5 ActionListener (java.awt.event.ActionListener)5 IOException (java.io.IOException)4 Component (java.awt.Component)3 JComponent (javax.swing.JComponent)3 KeyedComboBoxModel (net.pms.util.KeyedComboBoxModel)3 ComponentOrientation (java.awt.ComponentOrientation)2 Dimension (java.awt.Dimension)2 FontMetrics (java.awt.FontMetrics)2 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)2 TableColumn (javax.swing.table.TableColumn)2 BorderLayout (java.awt.BorderLayout)1 Font (java.awt.Font)1 GridLayout (java.awt.GridLayout)1 MouseEvent (java.awt.event.MouseEvent)1