Search in sources :

Example 1 with PrefComboBox

use of com.mucommander.ui.dialog.pref.component.PrefComboBox in project mucommander by mucommander.

the class AppearancePanel method createLookAndFeelPanel.

/**
 * Creates the look and feel panel.
 *
 * @return the look and feel panel.
 */
private JPanel createLookAndFeelPanel() {
    JPanel lnfPanel;
    // Creates the panel.
    lnfPanel = new YBoxPanel();
    lnfPanel.setAlignmentX(LEFT_ALIGNMENT);
    lnfPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.look_and_feel")));
    // Creates the look and feel combo box.
    lookAndFeelComboBox = new PrefComboBox() {

        public boolean hasChanged() {
            int selectedIndex = getSelectedIndex();
            if (selectedIndex < 0)
                return false;
            return !lookAndFeels[selectedIndex].getClassName().equals(MuConfigurations.getPreferences().getVariable(MuPreference.LOOK_AND_FEEL));
        }
    };
    lookAndFeelComboBox.setRenderer(new BasicComboBoxRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            JLabel label;
            label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (index < 0)
                return label;
            // All look and feels that are not modifiable must be flagged with a lock icon.
            if (isLookAndFeelModifiable(lookAndFeels[index]))
                label.setIcon(transparentIcon);
            else
                label.setIcon(lockIcon);
            return label;
        }
    });
    // Populates the look and feel combo box.
    populateLookAndFeels();
    // Initialises buttons and event listening.
    importLookAndFeelButton = new JButton(Translator.get("prefs_dialog.import") + "...");
    deleteLookAndFeelButton = new JButton(Translator.get("delete"));
    importLookAndFeelButton.addActionListener(this);
    deleteLookAndFeelButton.addActionListener(this);
    resetLookAndFeelButtons();
    lookAndFeelComboBox.addActionListener(this);
    // Adds the look and feel list and the action buttons to the panel.
    JPanel flowPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    flowPanel.add(lookAndFeelComboBox);
    flowPanel.add(importLookAndFeelButton);
    flowPanel.add(deleteLookAndFeelButton);
    flowPanel.add(new JLabel(dial = new SpinningDial()));
    lnfPanel.add(flowPanel);
    return lnfPanel;
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) BasicComboBoxRenderer(javax.swing.plaf.basic.BasicComboBoxRenderer) YBoxPanel(com.mucommander.commons.util.ui.layout.YBoxPanel) PrefComboBox(com.mucommander.ui.dialog.pref.component.PrefComboBox) SpinningDial(com.mucommander.ui.icon.SpinningDial) Component(java.awt.Component) JList(javax.swing.JList)

Example 2 with PrefComboBox

use of com.mucommander.ui.dialog.pref.component.PrefComboBox in project mucommander by mucommander.

the class AppearancePanel method createThemesPanel.

/**
 * Creates the themes panel.
 *
 * @return the themes panel.
 */
private JPanel createThemesPanel() {
    JPanel gridPanel = new ProportionalGridPanel(4);
    // Creates the various panel's buttons.
    editThemeButton = new JButton(Translator.get("edit") + "...");
    importThemeButton = new JButton(Translator.get("prefs_dialog.import") + "...");
    exportThemeButton = new JButton(Translator.get("prefs_dialog.export") + "...");
    renameThemeButton = new JButton(Translator.get("rename"));
    deleteThemeButton = new JButton(Translator.get("delete"));
    duplicateThemeButton = new JButton(Translator.get("duplicate"));
    editThemeButton.addActionListener(this);
    importThemeButton.addActionListener(this);
    exportThemeButton.addActionListener(this);
    renameThemeButton.addActionListener(this);
    deleteThemeButton.addActionListener(this);
    duplicateThemeButton.addActionListener(this);
    // Creates the panel's 'type label'.
    typeLabel = new JLabel("");
    // Creates the theme combo box.
    themeComboBox = new PrefComboBox() {

        public boolean hasChanged() {
            return !ThemeManager.isCurrentTheme((Theme) getSelectedItem());
        }
    };
    themeComboBox.addActionListener(this);
    // Sets the combobox's renderer.
    lockIcon = IconManager.getIcon(IconManager.PREFERENCES_ICON_SET, "lock.png");
    transparentIcon = new ImageIcon(new BufferedImage(lockIcon.getIconWidth(), lockIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB));
    themeComboBox.setRenderer(new BasicComboBoxRenderer() {

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            JLabel label;
            Theme theme;
            label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            theme = (Theme) value;
            if (ThemeManager.isCurrentTheme(theme))
                label.setText(theme.getName() + " (" + Translator.get("theme.current") + ")");
            else
                label.setText(theme.getName());
            if (theme.getType() != Theme.CUSTOM_THEME)
                label.setIcon(lockIcon);
            else
                label.setIcon(transparentIcon);
            return label;
        }
    });
    // Initialises the content of the combo box.
    populateThemes(ThemeManager.getCurrentTheme());
    gridPanel.add(themeComboBox);
    gridPanel.add(editThemeButton);
    gridPanel.add(importThemeButton);
    gridPanel.add(exportThemeButton);
    gridPanel.add(typeLabel);
    gridPanel.add(renameThemeButton);
    gridPanel.add(deleteThemeButton);
    gridPanel.add(duplicateThemeButton);
    JPanel flowPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
    flowPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.themes")));
    flowPanel.add(gridPanel);
    return flowPanel;
}
Also used : JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) FlowLayout(java.awt.FlowLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) BufferedImage(java.awt.image.BufferedImage) BasicComboBoxRenderer(javax.swing.plaf.basic.BasicComboBoxRenderer) PrefComboBox(com.mucommander.ui.dialog.pref.component.PrefComboBox) Theme(com.mucommander.ui.theme.Theme) ProportionalGridPanel(com.mucommander.commons.util.ui.layout.ProportionalGridPanel) Component(java.awt.Component) JList(javax.swing.JList)

Aggregations

PrefComboBox (com.mucommander.ui.dialog.pref.component.PrefComboBox)2 Component (java.awt.Component)2 FlowLayout (java.awt.FlowLayout)2 JButton (javax.swing.JButton)2 JLabel (javax.swing.JLabel)2 JList (javax.swing.JList)2 JPanel (javax.swing.JPanel)2 BasicComboBoxRenderer (javax.swing.plaf.basic.BasicComboBoxRenderer)2 ProportionalGridPanel (com.mucommander.commons.util.ui.layout.ProportionalGridPanel)1 YBoxPanel (com.mucommander.commons.util.ui.layout.YBoxPanel)1 SpinningDial (com.mucommander.ui.icon.SpinningDial)1 Theme (com.mucommander.ui.theme.Theme)1 BufferedImage (java.awt.image.BufferedImage)1 ImageIcon (javax.swing.ImageIcon)1