Search in sources :

Example 1 with XAlignedComponentPanel

use of com.mucommander.commons.util.ui.layout.XAlignedComponentPanel in project mucommander by mucommander.

the class BatchRenameDialog method getPnlTop.

/**
 * Creates a panel with edit controls.
 */
private JPanel getPnlTop() {
    // file & extension mask
    edtFileNameMask = new JTextField("[N].[E]");
    edtFileNameMask.setColumns(20);
    edtFileNameMask.getDocument().addDocumentListener(this);
    edtFileNameMask.setToolTipText(getPatternHelp());
    // search & replace
    edtSearchFor = new JTextField();
    edtSearchFor.setColumns(20);
    edtSearchFor.getDocument().addDocumentListener(this);
    edtReplaceWith = new JTextField();
    edtReplaceWith.setColumns(20);
    edtReplaceWith.getDocument().addDocumentListener(this);
    // upper/lower case
    Vector<String> ulcase = new Vector<String>();
    ulcase.add(Translator.get("batch_rename_dialog.no_change"));
    ulcase.add(Translator.get("batch_rename_dialog.lower_case"));
    ulcase.add(Translator.get("batch_rename_dialog.upper_case"));
    ulcase.add(Translator.get("batch_rename_dialog.first_upper"));
    ulcase.add(Translator.get("batch_rename_dialog.word"));
    cbCase = new JComboBox<>(ulcase);
    cbCase.addActionListener(this);
    // counter
    edtCounterStart = new JTextField("1");
    edtCounterStart.getDocument().addDocumentListener(this);
    edtCounterStart.setColumns(2);
    edtCounterStep = new JTextField("1");
    edtCounterStep.getDocument().addDocumentListener(this);
    edtCounterStep.setColumns(2);
    Vector<String> digits = new Vector<String>();
    String zeros = "0000";
    for (int i = 1; i <= 5; i++) {
        digits.add(zeros.substring(0, i - 1) + "1");
    }
    cbCounterDigits = new JComboBox<>(digits);
    cbCounterDigits.addActionListener(this);
    // add controls
    XBoxPanel pnlTop = new XBoxPanel();
    YBoxPanel pnl1 = new YBoxPanel();
    pnl1.setBorder(BorderFactory.createTitledBorder(Translator.get("batch_rename_dialog.mask")));
    pnl1.add(edtFileNameMask);
    JPanel pnl1Btns = new JPanel(new GridLayout(3, 2));
    btnName = new JButton("[N] - " + Translator.get("name"));
    btnName.addActionListener(this);
    btnName.setHorizontalAlignment(SwingConstants.LEFT);
    pnl1Btns.add(btnName);
    btnExtension = new JButton("[E] - " + Translator.get("extension"));
    btnExtension.addActionListener(this);
    btnExtension.setHorizontalAlignment(SwingConstants.LEFT);
    pnl1Btns.add(btnExtension);
    btnNameRange = new JButton("[N#-#] - " + Translator.get("batch_rename_dialog.range"));
    btnNameRange.addActionListener(this);
    btnNameRange.setHorizontalAlignment(SwingConstants.LEFT);
    pnl1Btns.add(btnNameRange);
    btnCounter = new JButton("[C] - " + Translator.get("batch_rename_dialog.counter"));
    btnCounter.addActionListener(this);
    btnCounter.setHorizontalAlignment(SwingConstants.LEFT);
    pnl1Btns.add(btnCounter);
    pnl1.add(pnl1Btns);
    pnl1.add(new JPanel());
    pnlTop.add(pnl1);
    XAlignedComponentPanel pnl2 = new XAlignedComponentPanel(5);
    pnl2.setBorder(BorderFactory.createTitledBorder(Translator.get("batch_rename_dialog.search_replace")));
    pnl2.addRow(Translator.get("batch_rename_dialog.search_for"), edtSearchFor, 5);
    pnl2.addRow(Translator.get("batch_rename_dialog.replace_with"), edtReplaceWith, 5);
    pnl2.addRow(Translator.get("batch_rename_dialog.upper_lower_case"), cbCase, 5);
    pnlTop.add(pnl2);
    XAlignedComponentPanel pnl3 = new XAlignedComponentPanel(5);
    pnl3.setBorder(BorderFactory.createTitledBorder(Translator.get("batch_rename_dialog.counter") + " [C]"));
    pnl3.addRow(Translator.get("batch_rename_dialog.start_at"), edtCounterStart, 5);
    pnl3.addRow(Translator.get("batch_rename_dialog.step_by"), edtCounterStep, 5);
    pnl3.addRow(Translator.get("batch_rename_dialog.format"), cbCounterDigits, 5);
    pnlTop.add(pnl3);
    return pnlTop;
}
Also used : GridLayout(java.awt.GridLayout) XBoxPanel(com.mucommander.commons.util.ui.layout.XBoxPanel) XAlignedComponentPanel(com.mucommander.commons.util.ui.layout.XAlignedComponentPanel) YBoxPanel(com.mucommander.commons.util.ui.layout.YBoxPanel)

Example 2 with XAlignedComponentPanel

use of com.mucommander.commons.util.ui.layout.XAlignedComponentPanel in project mucommander by mucommander.

the class SplitFileDialog method initialize.

/**
 * Initializes the dialog.
 */
protected void initialize() {
    Container content = getContentPane();
    content.setLayout(new BorderLayout(0, 5));
    XAlignedComponentPanel pnlMain = new XAlignedComponentPanel(10);
    pnlMain.addRow(Translator.get("split_file_dialog.file_to_split") + ":", new JLabel(file.getName()), 0);
    String size = SizeFormat.format(file.getSize(), SizeFormat.DIGITS_FULL | SizeFormat.UNIT_LONG | SizeFormat.INCLUDE_SPACE);
    pnlMain.addRow(Translator.get("size") + ":", new JLabel(size), 10);
    edtTargetDirectory = new FilePathField(destFolder.getAbsolutePath(), 40);
    pnlMain.addRow(Translator.get("split_file_dialog.target_directory") + ":", edtTargetDirectory, 5);
    XBoxPanel pnlSize = new XBoxPanel();
    String[] sizes = new String[] { MSG_AUTO, "10 " + Translator.get("unit.mb"), "100 " + Translator.get("unit.mb"), "250 " + Translator.get("unit.mb"), "650 " + Translator.get("unit.mb"), "700 " + Translator.get("unit.mb") };
    edtSize = new JTextField();
    EditableComboBox cbSize = new EditableComboBox(edtSize, sizes);
    cbSize.setComboSelectionUpdatesTextField(true);
    cbSize.setSelectedIndex(1);
    edtSize.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            updatePartsNumber();
        }
    });
    cbSize.addComboBoxListener(new ComboBoxListener() {

        public void comboBoxSelectionChanged(SaneComboBox source) {
            updatePartsNumber();
        }
    });
    pnlSize.add(cbSize);
    pnlSize.addSpace(10);
    pnlSize.add(new JLabel(Translator.get("split_file_dialog.parts") + ":"));
    pnlSize.addSpace(5);
    spnParts = new JSpinner(new SpinnerNumberModel(1, 1, file.getSize(), 1));
    spnParts.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            if (!edtChange) {
                long parts = ((Number) spnParts.getValue()).longValue();
                long newsize = file.getSize() / parts;
                if (file.getSize() % parts != 0) {
                    newsize++;
                }
                if (getBytes() != newsize) {
                    edtSize.setText(Long.toString(newsize));
                }
            }
        }
    });
    pnlSize.add(spnParts);
    pnlMain.addRow(Translator.get("split_file_dialog.part_size") + ":", pnlSize, 0);
    cbGenerateCRC = new JCheckBox(Translator.get("split_file_dialog.generate_CRC"));
    cbGenerateCRC.setSelected(true);
    pnlMain.addRow("", cbGenerateCRC, 0);
    content.add(pnlMain, BorderLayout.CENTER);
    content.add(getPnlButtons(), BorderLayout.SOUTH);
    getRootPane().setDefaultButton(btnSplit);
    updatePartsNumber();
}
Also used : KeyAdapter(java.awt.event.KeyAdapter) JLabel(javax.swing.JLabel) FilePathField(com.mucommander.ui.text.FilePathField) SaneComboBox(com.mucommander.commons.util.ui.combobox.SaneComboBox) JTextField(javax.swing.JTextField) EditableComboBox(com.mucommander.commons.util.ui.combobox.EditableComboBox) KeyEvent(java.awt.event.KeyEvent) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JCheckBox(javax.swing.JCheckBox) Container(java.awt.Container) XAlignedComponentPanel(com.mucommander.commons.util.ui.layout.XAlignedComponentPanel) XBoxPanel(com.mucommander.commons.util.ui.layout.XBoxPanel) BorderLayout(java.awt.BorderLayout) ChangeEvent(javax.swing.event.ChangeEvent) ComboBoxListener(com.mucommander.commons.util.ui.combobox.ComboBoxListener) JSpinner(javax.swing.JSpinner) ChangeListener(javax.swing.event.ChangeListener)

Example 3 with XAlignedComponentPanel

use of com.mucommander.commons.util.ui.layout.XAlignedComponentPanel in project mucommander by mucommander.

the class ShortcutsDialog method addTopic.

private void addTopic(JTabbedPane tabbedPane, String titleKey, Iterator<String> descriptionsIterator) {
    XAlignedComponentPanel compPanel;
    JPanel northPanel;
    JScrollPane scrollPane;
    compPanel = new XAlignedComponentPanel(15);
    // Add all shortcuts and their description
    addShortcutList(compPanel, descriptionsIterator);
    // Panel needs to be vertically aligned to the top
    northPanel = new JPanel(new BorderLayout());
    northPanel.add(compPanel, BorderLayout.NORTH);
    // Horizontal/vertical scroll bars will be displayed if needed
    scrollPane = new JScrollPane(northPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setBorder(null);
    tabbedPane.addTab(titleKey, scrollPane);
}
Also used : XAlignedComponentPanel(com.mucommander.commons.util.ui.layout.XAlignedComponentPanel)

Example 4 with XAlignedComponentPanel

use of com.mucommander.commons.util.ui.layout.XAlignedComponentPanel in project mucommander by mucommander.

the class ShortcutsDialog method addTopic.

private void addTopic(JTabbedPane tabbedPane, String titleKey, Map<String, String> actionsToShortcutsMap) {
    XAlignedComponentPanel compPanel;
    JPanel northPanel;
    JScrollPane scrollPane;
    compPanel = new XAlignedComponentPanel(15);
    // Add all shortcuts and their description
    addShortcutList(compPanel, actionsToShortcutsMap);
    // Panel needs to be vertically aligned to the top
    northPanel = new JPanel(new BorderLayout());
    northPanel.add(compPanel, BorderLayout.NORTH);
    // Horizontal/vertical scroll bars will be displayed if needed
    scrollPane = new JScrollPane(northPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setBorder(null);
    tabbedPane.addTab(titleKey, scrollPane);
}
Also used : XAlignedComponentPanel(com.mucommander.commons.util.ui.layout.XAlignedComponentPanel)

Example 5 with XAlignedComponentPanel

use of com.mucommander.commons.util.ui.layout.XAlignedComponentPanel in project mucommander by mucommander.

the class FileCollisionDialog method init.

private void init(int collisionType, AbstractFile sourceFile, AbstractFile destFile, boolean multipleFilesMode, boolean allowRename) {
    // Init choices
    List<DialogAction> actionChoices = new ArrayList<>();
    actionChoices.add(FileCollisionAction.CANCEL);
    if (multipleFilesMode) {
        actionChoices.add(FileCollisionAction.SKIP);
    }
    // Add 'overwrite' / 'overwrite if older' / 'resume' actions only for 'destination file already exists' collision type
    if (collisionType == FileCollisionChecker.DESTINATION_FILE_ALREADY_EXISTS && !destFile.isDirectory()) {
        actionChoices.add(FileCollisionAction.OVERWRITE);
        if (sourceFile != null) {
            actionChoices.add(FileCollisionAction.OVERWRITE_IF_OLDER);
            actionChoices.add(FileCollisionAction.OVERWRITE_IF_SIZE_DIFFERS);
            // Give resume option only if destination file is smaller than source file
            long destSize = destFile.getSize();
            long sourceSize = sourceFile.getSize();
            if (destSize != -1 && (sourceSize == -1 || destSize < sourceSize)) {
                actionChoices.add(FileCollisionAction.RESUME);
            }
            if (allowRename) {
                actionChoices.add(FileCollisionAction.RENAME);
            }
        }
    }
    // Init UI
    String desc = null;
    switch(collisionType) {
        case FileCollisionChecker.DESTINATION_FILE_ALREADY_EXISTS:
            desc = Translator.get("file_exists_in_destination");
            break;
        case FileCollisionChecker.SAME_SOURCE_AND_DESTINATION:
            desc = Translator.get("same_source_destination");
            break;
        case FileCollisionChecker.SOURCE_PARENT_OF_DESTINATION:
            desc = Translator.get("source_parent_of_destination");
            break;
    }
    YBoxPanel yPanel = new YBoxPanel();
    if (desc != null) {
        yPanel.add(new InformationPane(desc, null, Font.PLAIN, InformationPane.QUESTION_ICON));
        yPanel.addSpace(10);
    }
    // Add a separator before file details
    yPanel.add(new JSeparator());
    XAlignedComponentPanel tfPanel = new XAlignedComponentPanel(10);
    // If collision type is 'same source and destination' no need to show both source and destination
    if (collisionType == FileCollisionChecker.SAME_SOURCE_AND_DESTINATION) {
        addFileDetails(tfPanel, sourceFile, Translator.get("name"));
    } else {
        if (sourceFile != null) {
            addFileDetails(tfPanel, sourceFile, Translator.get("source"));
        }
        addFileDetails(tfPanel, destFile, Translator.get("destination"));
    }
    yPanel.add(tfPanel);
    // Add a separator after file details
    yPanel.add(new JSeparator());
    init(yPanel, actionChoices, 3);
    // TODO below there's workaround to accommodate texts within buttons - any idea to how to make it better?
    // override to avoid FocusDialog#pack making the dialog box too small for some buttons
    // so they won't display full texts (observe when Spanish lang pack is chosen - a lot of them have ellipsis)
    setMinimumSize(null);
    setMaximumSize(null);
    // 'Apply to all' is available only for 'destination file already exists' collision type
    if (multipleFilesMode && collisionType == FileCollisionChecker.DESTINATION_FILE_ALREADY_EXISTS) {
        applyToAllCheckBox = new JCheckBox(Translator.get("apply_to_all"));
        addComponent(applyToAllCheckBox);
    }
    // Send a system notification if a notifier is available and enabled
    if (NotifierProvider.isAvailable() && NotifierProvider.getNotifier().isEnabled()) {
        NotifierProvider.displayBackgroundNotification(NotificationType.JOB_ERROR, getTitle(), desc);
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) XAlignedComponentPanel(com.mucommander.commons.util.ui.layout.XAlignedComponentPanel) YBoxPanel(com.mucommander.commons.util.ui.layout.YBoxPanel) DialogAction(com.mucommander.ui.dialog.DialogAction) ArrayList(java.util.ArrayList) InformationPane(com.mucommander.ui.layout.InformationPane) JSeparator(javax.swing.JSeparator)

Aggregations

XAlignedComponentPanel (com.mucommander.commons.util.ui.layout.XAlignedComponentPanel)6 XBoxPanel (com.mucommander.commons.util.ui.layout.XBoxPanel)2 YBoxPanel (com.mucommander.commons.util.ui.layout.YBoxPanel)2 JCheckBox (javax.swing.JCheckBox)2 JTextField (javax.swing.JTextField)2 ComboBoxListener (com.mucommander.commons.util.ui.combobox.ComboBoxListener)1 EditableComboBox (com.mucommander.commons.util.ui.combobox.EditableComboBox)1 SaneComboBox (com.mucommander.commons.util.ui.combobox.SaneComboBox)1 DialogAction (com.mucommander.ui.dialog.DialogAction)1 InformationPane (com.mucommander.ui.layout.InformationPane)1 FilePathField (com.mucommander.ui.text.FilePathField)1 BorderLayout (java.awt.BorderLayout)1 Container (java.awt.Container)1 GridLayout (java.awt.GridLayout)1 KeyAdapter (java.awt.event.KeyAdapter)1 KeyEvent (java.awt.event.KeyEvent)1 ArrayList (java.util.ArrayList)1 JLabel (javax.swing.JLabel)1 JSeparator (javax.swing.JSeparator)1 JSpinner (javax.swing.JSpinner)1