Package com.mucommander.ui.layout

Examples of com.mucommander.ui.layout.YBoxPanel


    public GeneralPanel(PreferencesDialog parent) {
        super(parent, Translator.get("prefs_dialog.general_tab"));

        setLayout(new BorderLayout());
       
        YBoxPanel mainPanel = new YBoxPanel();
        JPanel tempPanel;

        // Language
        JPanel languagePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        languagePanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.language")));
        this.languages = Translator.getAvailableLanguages();
        String currentLang = MuConfigurations.getPreferences().getVariable(MuPreference.LANGUAGE);
        String lang;
        languageComboBox = new PrefComboBox() {
      public boolean hasChanged() {
        return !languages[getSelectedIndex()].equals(MuConfigurations.getPreferences().getVariable(MuPreference.LANGUAGE));
      }
        };

        // Use a custom combo box renderer to display language icons
        class LanguageComboBoxRenderer extends BasicComboBoxRenderer {

            @Override
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

                String language = (String)value;
                label.setText(Translator.get("language."+language));
                label.setIcon(IconManager.getIcon(IconManager.LANGUAGE_ICON_SET, language+".png"));

                return label;
            }
        }
        languageComboBox.setRenderer(new LanguageComboBoxRenderer());
   
        // Add combo items and select current language (defaults to EN if current language can't be found)
        int languageIndex = -1;
        for(int i=0; i<languages.length; i++) {
            lang = languages[i];
            languageComboBox.addItem(lang);

            if(lang.equalsIgnoreCase(currentLang))
                languageIndex = i;
            else if(languageIndex==-1 && lang.equalsIgnoreCase("en"))
                languageIndex = i;
        }
        languageComboBox.setSelectedIndex(languageIndex);

        languagePanel.add(languageComboBox);
        mainPanel.add(languagePanel);
        mainPanel.addSpace(10);
   
        // Date & time format panel
        YBoxPanel dateTimeFormatPanel = new YBoxPanel();
        dateTimeFormatPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.date_time")));

        JPanel gridPanel = new JPanel(new GridLayout(1, 2));

        YBoxPanel dateFormatPanel = new YBoxPanel();
        dateFormatPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.date")));

        // Date format combo
        dateFormatComboBox = new PrefComboBox() {
      public boolean hasChanged() {
        return !getDateFormatString().equals(MuConfigurations.getPreferences().getVariable(MuPreference.DATE_FORMAT));
      }
        };
        String dateFormat = MuConfigurations.getPreferences().getVariable(MuPreference.DATE_FORMAT);
        String separator = MuConfigurations.getPreferences().getVariable(MuPreference.DATE_SEPARATOR, MuPreferences.DEFAULT_DATE_SEPARATOR);
        int dateFormatIndex = 0;
        String buffer = dateFormat.replace(separator.charAt(0), '/');
        for(int i=0; i<DATE_FORMATS.length; i++) {
            dateFormatComboBox.addItem(DATE_FORMAT_LABELS[i]);
            if(buffer.equals(DATE_FORMATS[i]) || buffer.equals(DATE_FORMATS_WITH_CENTURY[i]))
                dateFormatIndex = i;
        }       
        dateFormatComboBox.setSelectedIndex(dateFormatIndex);
        dateFormatComboBox.addItemListener(this);

        tempPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        tempPanel.add(dateFormatComboBox);
        tempPanel.add(Box.createHorizontalGlue());
        dateFormatPanel.add(tempPanel);

        // Date separator field
        tempPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        tempPanel.add(new JLabel(Translator.get("prefs_dialog.date_separator")+": "));
        dateSeparatorField = new PrefTextField(1) {
      public boolean hasChanged() {
        return !getText().equals(MuConfigurations.getPreferences().getVariable(MuPreference.DATE_SEPARATOR));
      }
        };
        // Limit the number of characters in the text field to 1 and enforces only non-alphanumerical characters
        PlainDocument doc = new PlainDocument() {
                @Override
                public void insertString(int param, String str, javax.swing.text.AttributeSet attributeSet) throws javax.swing.text.BadLocationException {
                    // Limit field to 1 character max
                    if (str != null && this.getLength() + str.length() > 1)
                        return;
       
                    // Reject letters and digits, as they don't make much sense,
                    // plus letters would be misinterpreted by SimpleDateFormat
                    if (str != null) {
                        int len = str.length();
                        for(int i=0; i<len; i++)
                            if(Character.isLetterOrDigit(str.charAt(i)))
                                return;
                    }
         

                    super.insertString(param, str, attributeSet);
                }
            };
        dateSeparatorField.setDocument(doc);
        dateSeparatorField.setText(separator);
        doc.addDocumentListener(this);
        tempPanel.add(dateSeparatorField);
        tempPanel.add(Box.createHorizontalGlue());
        dateFormatPanel.add(tempPanel);

        showCenturyCheckBox = new PrefCheckBox(Translator.get("prefs_dialog.show_century")) {
      public boolean hasChanged() {
        return isSelected() != (MuConfigurations.getPreferences().getVariable(MuPreference.DATE_FORMAT).indexOf("yyyy")!=-1);
      }
        };
        showCenturyCheckBox.setSelected(dateFormat.indexOf("yyyy")!=-1);
        showCenturyCheckBox.addItemListener(this);
        dateFormatPanel.add(showCenturyCheckBox);
        dateFormatPanel.addSpace(10);
        gridPanel.add(dateFormatPanel);

        // Time format
        YBoxPanel timeFormatPanel = new YBoxPanel();
        timeFormatPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.time")));

        time12RadioButton = new PrefRadioButton(Translator.get("prefs_dialog.time_12_hour")) {
      public boolean hasChanged() {
        String timeFormat = MuConfigurations.getPreferences().getVariable(MuPreference.TIME_FORMAT);
            return isSelected() != (timeFormat.equals(HOUR_12_TIME_FORMAT) || timeFormat.equals(HOUR_12_TIME_FORMAT_WITH_SECONDS));
      }
        };
        time12RadioButton.addActionListener(this);
        PrefRadioButton time24RadioButton = new PrefRadioButton(Translator.get("prefs_dialog.time_24_hour")) {
      public boolean hasChanged() {
        String timeFormat = MuConfigurations.getPreferences().getVariable(MuPreference.TIME_FORMAT);
            return isSelected() != (timeFormat.equals(HOUR_24_TIME_FORMAT) || timeFormat.equals(HOUR_24_TIME_FORMAT_WITH_SECONDS));
      }
        };
        time24RadioButton.addActionListener(this);
       
        String timeFormat = MuConfigurations.getPreferences().getVariable(MuPreference.TIME_FORMAT);
        if(timeFormat.equals(HOUR_12_TIME_FORMAT) || timeFormat.equals(HOUR_12_TIME_FORMAT_WITH_SECONDS))
            time12RadioButton.setSelected(true);
        else
            time24RadioButton.setSelected(true);
           
        ButtonGroup buttonGroup = new ButtonGroup();
        buttonGroup.add(time12RadioButton);
        buttonGroup.add(time24RadioButton);

        timeFormatPanel.add(time12RadioButton);
        timeFormatPanel.add(time24RadioButton);
        timeFormatPanel.addSpace(10);

        showSecondsCheckBox = new PrefCheckBox(Translator.get("prefs_dialog.show_seconds")) {
      public boolean hasChanged() {
        return isSelected() != (MuConfigurations.getPreferences().getVariable(MuPreference.TIME_FORMAT).indexOf(":ss")!=-1);
      }
        };
        showSecondsCheckBox.setSelected(timeFormat.indexOf(":ss")!=-1);
        showSecondsCheckBox.addItemListener(this);
        timeFormatPanel.add(showSecondsCheckBox);
        timeFormatPanel.addSpace(10);
        gridPanel.add(timeFormatPanel);

        dateTimeFormatPanel.add(gridPanel);

        // Date/time preview
View Full Code Here


    scroll.getVerticalScrollBar().setFocusable( false );
        scroll.getHorizontalScrollBar().setFocusable( false );

        // Creates the panel.
        panel = new JPanel();       
        quickListPreviewPanel = new YBoxPanel();       
        quickListPreviewPanel.add(header);
        quickListPreviewPanel.add(scroll);
        quickListPreviewPanel.setBorder(new QuickList.PopupsBorder());
        panel.add(quickListPreviewPanel);
        panel.setBorder(BorderFactory.createTitledBorder(Translator.get("preview")));
View Full Code Here

  /**
     * Initializes the panel's UI.
     */
    private void initUI() {
        YBoxPanel   headerConfigurationPanel; // Contains all the configuration elements.
        YBoxPanel   itemConfigurationPanel; // Contains all the configuration elements.
        FontChooser fontChooser1;        // Used to select a font.
        FontChooser fontChooser2;        // Used to select a font.
        JPanel      mainPanel;          // Main panel.
        JTabbedPane tabbedPane;
       
        header.addComponentListener(new ComponentListener() {

      public void componentHidden(ComponentEvent e) {}

      public void componentMoved(ComponentEvent e) {}

      public void componentResized(ComponentEvent e) {
        quickListPreviewPanel.repaint();
      }

      public void componentShown(ComponentEvent e) {}
        });


        // Font chooser and preview initialization.
        fontChooser1 = createFontChooser(ThemeData.QUICK_LIST_HEADER_FONT);
        fontChooser2 = createFontChooser(ThemeData.QUICK_LIST_ITEM_FONT);
        addFontChooserListener(fontChooser1, header);
        addFontChooserListener(fontChooser2, list);

        // Header configuration panel initialization.
        headerConfigurationPanel = new YBoxPanel();
        headerConfigurationPanel.add(fontChooser1);
        headerConfigurationPanel.addSpace(10);
        headerConfigurationPanel.add(createHeaderColorsPanel(fontChooser1));

        // Item configuration panel initialization.
        itemConfigurationPanel = new YBoxPanel();
        itemConfigurationPanel.add(fontChooser2);
        itemConfigurationPanel.addSpace(10);
        itemConfigurationPanel.add(createItemColorsPanel(fontChooser1));
       
        // Create the tabbed pane.
        tabbedPane = new JTabbedPane();
        tabbedPane.add(Translator.get("theme_editor.header"), headerConfigurationPanel);
        tabbedPane.add(Translator.get("theme_editor.item"), itemConfigurationPanel);
View Full Code Here

        this.addToSelection = addToSelection;

        Container contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());

        YBoxPanel northPanel = new YBoxPanel(5);
        JLabel label = new JLabel(Translator.get(addToSelection?"file_selection_dialog.mark_description":"file_selection_dialog.unmark_description")+" :");
        northPanel.add(label);

        JPanel tempPanel = new JPanel();
        tempPanel.setLayout(new BoxLayout(tempPanel, BoxLayout.X_AXIS));
        comparisonComboBox = new JComboBox();
        comparisonComboBox.addItem(Translator.get("file_selection_dialog.contains"));
        comparisonComboBox.addItem(Translator.get("file_selection_dialog.starts_with"));
        comparisonComboBox.addItem(Translator.get("file_selection_dialog.ends_with"));
        comparisonComboBox.addItem(Translator.get("file_selection_dialog.is"));
        comparisonComboBox.addItem(Translator.get("file_selection_dialog.matches_regexp"));
        comparisonComboBox.setSelectedIndex(comparison);
        tempPanel.add(comparisonComboBox);
       
        // selectionField is initialized with last textfield's value (if any)
        selectionField = new JTextField(keywordString);
        selectionField.addActionListener(this);
        selectionField.setSelectionStart(0);
        selectionField.setSelectionEnd(keywordString.length());
        tempPanel.add(selectionField);
        northPanel.add(tempPanel);

        // Add some vertical space
        northPanel.addSpace(10);
   
        caseSensitiveCheckBox = new JCheckBox(Translator.get("file_selection_dialog.case_sensitive"), caseSensitive);
        northPanel.add(caseSensitiveCheckBox);

        includeFoldersCheckBox = new JCheckBox(Translator.get("file_selection_dialog.include_folders"), includeFolders);
        northPanel.add(includeFoldersCheckBox);
   
        northPanel.addSpace(10);
        northPanel.add(Box.createVerticalGlue());

        contentPane.add(northPanel, BorderLayout.NORTH);

        okButton = new JButton(Translator.get(addToSelection?"file_selection_dialog.mark":"file_selection_dialog.unmark"));
        contentPane.add(DialogToolkit.createOKCancelPanel(okButton, new JButton(Translator.get("cancel")), getRootPane(), this), BorderLayout.SOUTH);
View Full Code Here

        initUI();
    }

    private JPanel createConfigurationPanel() {
        FontChooser           fontChooser;
        YBoxPanel             mainPanel;
        JPanel                flowPanel;
        ProportionalGridPanel colorsPanel;
        PreviewLabel          label;

        fontChooser = createFontChooser(ThemeData.LOCATION_BAR_FONT);
        addFontChooserListener(fontChooser, normalPreview);
        addFontChooserListener(fontChooser, progressPreview);

        addLabelRow(colorsPanel = new ProportionalGridPanel(3), false);

        label = new PreviewLabel();
        addColorButtons(colorsPanel, fontChooser, "theme_editor.normal",
                          ThemeData.LOCATION_BAR_FOREGROUND_COLOR, ThemeData.LOCATION_BAR_BACKGROUND_COLOR, label).addPropertyChangeListener(this);
        addColorButtons(colorsPanel, fontChooser, "theme_editor.selected",
                          ThemeData.LOCATION_BAR_SELECTED_FOREGROUND_COLOR, ThemeData.LOCATION_BAR_SELECTED_BACKGROUND_COLOR).addPropertyChangeListener(this);

        label.setTextPainted(true);
        addFontChooserListener(fontChooser, label);
        colorsPanel.add(createCaptionLabel("theme_editor.progress"));
        colorsPanel.add(new JLabel());
        colorsPanel.add(new ColorButton(parent, themeData, ThemeData.LOCATION_BAR_PROGRESS_COLOR, PreviewLabel.OVERLAY_COLOR_PROPERTY_NAME, label));
        label.addPropertyChangeListener(this);

        flowPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        flowPanel.add(colorsPanel);
        flowPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("theme_editor.colors")));

        mainPanel = new YBoxPanel();
        mainPanel.add(fontChooser);
        mainPanel.addSpace(10);
        mainPanel.add(flowPanel);

        /*
        normalPreview.setPreferredSize(new Dimension((normalPreview.getPreferredSize().width * 3) / 2, normalPreview.getPreferredSize().height));
        progressPreview.setPreferredSize(new Dimension((progressPreview.getPreferredSize().width * 3) / 2, progressPreview.getPreferredSize().height));
        */
 
View Full Code Here

        return mainPanel;
    }

    private JPanel createPreviewPanel() {
        YBoxPanel panel;
        JPanel    borderPanel;

        panel = new YBoxPanel();

        //        panel.add(new JLabel(Translator.get("theme_editor.normal")));
        panel.add(createCaptionLabel("theme_editor.normal"));
        normalPreview = new ProgressTextField(0, themeData.getColor(ThemeData.LOCATION_BAR_PROGRESS_COLOR));
        panel.add(normalPreview);
        normalPreview.setText(System.getProperty("user.home"));

        panel.addSpace(10);
        panel.add(createCaptionLabel("theme_editor.progress"));
        progressPreview = new ProgressTextField(50, themeData.getColor(ThemeData.LOCATION_BAR_PROGRESS_COLOR));
        panel.add(progressPreview);
        progressPreview.setText(System.getProperty("user.home"));
        progressPreview.setEnabled(false);

        borderPanel = new JPanel(new BorderLayout());
        borderPanel.add(panel, BorderLayout.NORTH);
View Full Code Here

        formatsComboBox.setSelectedIndex(lastFormatIndex);
   
        formatsComboBox.addItemListener(this);
        tempPanel.add(formatsComboBox);

        YBoxPanel mainPanel = getMainPanel();
        mainPanel.add(tempPanel);   
        mainPanel.addSpace(10);
   
        // Comment area, enabled only if selected archive format has comment support
   
        mainPanel.add(new JLabel(Translator.get("comment")));
        commentArea = new JTextArea();
        commentArea.setRows(4);
        mainPanel.add(commentArea);
    }
View Full Code Here

    public MailPanel(PreferencesDialog parent) {
        super(parent, Translator.get("prefs_dialog.mail_tab"));

        setLayout(new BorderLayout());

        YBoxPanel mainPanel = new YBoxPanel(5);
        mainPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.mail_settings")));

        // Text fields panel
        XAlignedComponentPanel compPanel = new XAlignedComponentPanel();

        // Name field
        nameField = new PrefTextField(MuConfigurations.getPreferences().getVariable(MuPreference.MAIL_SENDER_NAME, "")) {
      public boolean hasChanged() {
        return !nameField.getText().equals(MuConfigurations.getPreferences().getVariable(MuPreference.MAIL_SENDER_NAME, ""));
      }
        };
        compPanel.addRow(Translator.get("prefs_dialog.mail_name"), nameField, 10);
   
        // Email field
        emailField = new PrefTextField(MuConfigurations.getPreferences().getVariable(MuPreference.MAIL_SENDER_ADDRESS, "")) {
      public boolean hasChanged() {
        return !emailField.getText().equals(MuConfigurations.getPreferences().getVariable(MuPreference.MAIL_SENDER_ADDRESS, ""));
      }
        };
        compPanel.addRow(Translator.get("prefs_dialog.mail_address"), emailField, 10);

        // SMTP field
        smtpField = new PrefTextField(MuConfigurations.getPreferences().getVariable(MuPreference.SMTP_SERVER, "")) {
      public boolean hasChanged() {
        return !smtpField.getText().equals(MuConfigurations.getPreferences().getVariable(MuPreference.SMTP_SERVER, ""));
      }
        };
        compPanel.addRow(Translator.get("prefs_dialog.mail_server"), smtpField, 10);

        // SMTP port field
        portField = new PrefTextField(""+MuConfigurations.getPreferences().getVariable(MuPreference.SMTP_PORT, MuPreferences.DEFAULT_SMTP_PORT)) {
      public boolean hasChanged() {
        return !portField.getText().equals(String.valueOf(MuConfigurations.getPreferences().getVariable(MuPreference.SMTP_PORT, MuPreferences.DEFAULT_SMTP_PORT)));
      }
        };
        compPanel.addRow(Translator.get("server_connect_dialog.port"), portField, 10);

        mainPanel.add(compPanel, BorderLayout.NORTH);
        add(mainPanel, BorderLayout.NORTH);
       
        nameField.addDialogListener(parent);
      emailField.addDialogListener(parent);
      smtpField.addDialogListener(parent);
View Full Code Here

    /**
     * Creates the 'general' theme.
     */
    private JPanel createGeneralPanel(FontChooser chooser) {
        YBoxPanel             mainPanel;
        JPanel                quickSearchPanel;
        ProportionalGridPanel panel;
        JPanel                wrapper;

        // Initialises the quicksearch panel.
        panel = new ProportionalGridPanel(4);
        addLabelRow(panel);
        panel.add(addColorButtons(panel, chooser, "theme_editor.quick_search.unmatched_file", ThemeData.FILE_TABLE_UNMATCHED_FOREGROUND_COLOR,
                                  ThemeData.FILE_TABLE_UNMATCHED_BACKGROUND_COLOR));
        quickSearchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        quickSearchPanel.add(panel);
        quickSearchPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("theme_editor.quick_search")));

        // Initialises the panel.
        mainPanel = new YBoxPanel();
        mainPanel.add(chooser);
        mainPanel.addSpace(10);
        mainPanel.add(quickSearchPanel);

        // Wraps everything in a border layout.
        wrapper = new JPanel(new BorderLayout());
        wrapper.add(mainPanel, BorderLayout.NORTH);
        return wrapper;
View Full Code Here

        // Split pane will be given any extra space
        insetsPane.add(splitPane, BorderLayout.CENTER);

        // Add a 2-pixel gap between the file table and status bar
        YBoxPanel southPanel = new YBoxPanel();
        southPanel.addSpace(2);

        // Add status bar
        this.statusBar = new StatusBar(this);
        southPanel.add(statusBar);
   
        // Show command bar only if it hasn't been disabled in the preferences
        this.commandBar = new CommandBar(this);
        // Note: CommandBar.setVisible() has to be called no matter if CommandBar is visible or not, in order for it to be properly initialized
        this.commandBar.setVisible(MuConfigurations.getPreferences().getVariable(MuPreference.COMMAND_BAR_VISIBLE, MuPreferences.DEFAULT_COMMAND_BAR_VISIBLE));
        southPanel.add(commandBar);
        insetsPane.add(southPanel, BorderLayout.SOUTH);

        // Perform CloseAction when the user asked the window to close
        setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        addWindowListener(new WindowAdapter() {
View Full Code Here

TOP

Related Classes of com.mucommander.ui.layout.YBoxPanel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.