Package com.mucommander.ui.layout

Examples of com.mucommander.ui.layout.YBoxPanel


    public DeleteDialog(MainFrame mainFrame, FileSet files, boolean deletePermanently) {
        super(mainFrame, ActionProperties.getActionLabel(DeleteAction.Descriptor.ACTION_ID), files);

        this.mainFrame = mainFrame;

        YBoxPanel mainPanel = new YBoxPanel();

        // Allow 'Move to trash' option only if:
        // - the current platform has a trash
        // - the base folder is not an archive
        // - the base folder of the to-be-deleted files is not a trash folder or one of its children
        // - the base folder can be moved to the trash (the eligibility conditions should be the same as the files to-be-deleted)
        AbstractTrash trash = DesktopManager.getTrash();
        AbstractFile baseFolder = files.getBaseFolder();
        if(trash!=null && !baseFolder.isArchive() && !trash.isTrashFile(baseFolder) && trash.canMoveToTrash(baseFolder)) {
            moveToTrash = !deletePermanently;

            moveToTrashCheckBox = new JCheckBox(Translator.get("delete_dialog.move_to_trash.option"), moveToTrash);
            moveToTrashCheckBox.addItemListener(this);
        }

        informationPane = new InformationPane();
        mainPanel.add(informationPane);
        mainPanel.addSpace(10);

        JPanel fileDetailsPanel = createFileDetailsPanel();

        // Create file details button and OK/cancel buttons and lay them out a single row
        deleteButton = new JButton(Translator.get("delete"));
        JButton cancelButton = new JButton(Translator.get("cancel"));

        mainPanel.add(createButtonsPanel(createFileDetailsButton(fileDetailsPanel),
                DialogToolkit.createOKCancelPanel(deleteButton, cancelButton, getRootPane(), this)));

        mainPanel.add(fileDetailsPanel);

        if(moveToTrashCheckBox!=null)
            mainPanel.add(moveToTrashCheckBox);

        getContentPane().add(mainPanel);

        // Give initial keyboard focus to the 'Delete' button
        setInitialFocusComponent(deleteButton);
View Full Code Here



    public ChangePermissionsDialog(MainFrame mainFrame, FileSet files) {
        super(mainFrame, ActionProperties.getActionLabel(ChangePermissionsAction.Descriptor.ACTION_ID), files);

        YBoxPanel mainPanel = new YBoxPanel();

        mainPanel.add(new JLabel(ActionProperties.getActionLabel(ChangePermissionsAction.Descriptor.ACTION_ID)+" :"));
        mainPanel.addSpace(10);

        JPanel gridPanel = new JPanel(new GridLayout(4, 4));
        permCheckBoxes = new JCheckBox[5][5];
        JCheckBox permCheckBox;

        AbstractFile firstFile = files.elementAt(0);
        int permSetMask = firstFile.getChangeablePermissions().getIntValue();
        boolean canSetPermission = permSetMask!=0;
        int defaultPerms = firstFile.getPermissions().getIntValue();

        gridPanel.add(new JLabel());
        gridPanel.add(new JLabel(Translator.get("permissions.read")));
        gridPanel.add(new JLabel(Translator.get("permissions.write")));
        gridPanel.add(new JLabel(Translator.get("permissions.executable")));

        for(int a=USER_ACCESS; a>=OTHER_ACCESS; a--) {
            gridPanel.add(new JLabel(Translator.get(a==USER_ACCESS ?"permissions.user":a==GROUP_ACCESS?"permissions.group":"permissions.other")));

            for(int p=READ_PERMISSION; p>=EXECUTE_PERMISSION; p=p>>1) {
                permCheckBox = new JCheckBox();
                permCheckBox.setSelected((defaultPerms & (p<<a*3))!=0);

                // Enable the checkbox only if the permission can be set in the destination
                if((permSetMask & (p<<a*3))==0)
                    permCheckBox.setEnabled(false);
                else
                    permCheckBox.addItemListener(this);

                gridPanel.add(permCheckBox);
                permCheckBoxes[a][p] = permCheckBox;
            }
        }

        mainPanel.add(gridPanel);

        octalPermTextField = new JTextField(3);
        // Constrains text field to 3 digits, from 0 to 7 (octal base)
        Document doc = new SizeConstrainedDocument(3) {
            @Override
            public void insertString(int offset, String str, AttributeSet attributeSet) throws BadLocationException {
                int strLen = str.length();
                char c;
                for(int i=0; i<strLen; i++) {
                    c = str.charAt(i);
                    if(c<'0' || c>'7')
                        return;
                }

                super.insertString(offset, str, attributeSet);
            }
        };
        octalPermTextField.setDocument(doc);
        // Initializes the field's value
        updateOctalPermTextField();

        if(canSetPermission) {
            doc.addDocumentListener(this);
        }
        // Disable text field if no permission bit can be set
        else {
            octalPermTextField.setEnabled(false);
        }

        mainPanel.addSpace(10);
        JPanel tempPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        tempPanel.add(new JLabel(Translator.get("permissions.octal_notation")));
        tempPanel.add(octalPermTextField);
        mainPanel.add(tempPanel);

        mainPanel.addSpace(15);

        recurseDirCheckBox = new JCheckBox(Translator.get("recurse_directories"));
        // Disable check box if no permission bit can be set
        recurseDirCheckBox.setEnabled(canSetPermission && (files.size()>1 || files.elementAt(0).isDirectory()));
        mainPanel.add(recurseDirCheckBox);

        // Create file details button and OK/cancel buttons and lay them out a single row
        JPanel fileDetailsPanel = createFileDetailsPanel();

        okButton = new JButton(Translator.get("change"));
        cancelButton = new JButton(Translator.get("cancel"));

        mainPanel.add(createButtonsPanel(createFileDetailsButton(fileDetailsPanel),
                DialogToolkit.createOKCancelPanel(okButton, cancelButton, getRootPane(), this)));
        mainPanel.add(fileDetailsPanel);

        getContentPane().add(mainPanel, BorderLayout.NORTH);

        if(!canSetPermission) {
            // Disable OK button if no permission bit can be set
View Full Code Here

        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")));
View Full Code Here

        else if(collisionType==FileCollisionChecker.SOURCE_PARENT_OF_DESTINATION)
            desc = Translator.get("source_parent_of_destination");
        else
            desc = null;

        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,
             choicesText,
             choicesActions,
             3);
View Full Code Here

    public FileCollisionRenameDialog(MainFrame mainFrame, AbstractFile file) {
        super(mainFrame, Translator.get("rename"), mainFrame);

        Container contentPane = getContentPane();

        YBoxPanel mainPanel = new YBoxPanel();
        mainPanel.add(new JLabel(Translator.get("rename_dialog.new_name") + ":"));
        edtNewName = new JTextField();
        edtNewName.addActionListener(this);

        // Sets the initial selection.
        AbstractCopyDialog.selectDestinationFilename(file, file.getName(), 0).feedToPathField(edtNewName);
        mainPanel.add(edtNewName);
  
        mainPanel.addSpace(10);
        contentPane.add(mainPanel, BorderLayout.NORTH);
       
        okButton = new JButton(Translator.get("rename"));
        JButton cancelButton = new JButton(Translator.get("cancel"));
        contentPane.add(DialogToolkit.createOKCancelPanel(okButton, cancelButton, getRootPane(), this), BorderLayout.SOUTH);
View Full Code Here


    public CalculateChecksumDialog(MainFrame mainFrame, FileSet files) {
        super(mainFrame, ActionProperties.getActionLabel(CalculateChecksumAction.Descriptor.ACTION_ID), files);

        YBoxPanel mainPanel = new YBoxPanel();

        // Retrieve all MessageDigest instances and sort them by alphabetical order of their algorithm

        // Create a TreeSet with a custom Comparator
        SortedSet<MessageDigest> algorithmSortedSet = new TreeSet<MessageDigest>(new Comparator<MessageDigest>() {
                    public int compare(MessageDigest md1, MessageDigest md2) {
                        return md1.getAlgorithm().compareTo(md2.getAlgorithm());
                    }
                });

        // Add all MessageDigest to the TreeSet
        for(String algo : Security.getAlgorithms("MessageDigest")) {
            try {
                algorithmSortedSet.add(MessageDigest.getInstance(algo));
            }
            catch(NoSuchAlgorithmException e) {
                // Should never happen and if it ever does, the digest will simply be discarded
            }
        }

        // Convert the sorted set into an array
        messageDigests = new MessageDigest[algorithmSortedSet.size()];
        algorithmSortedSet.toArray(messageDigests);

        // Add the sorted list of algorithms to a combo box to let the user choose one
        algorithmComboBox = new JComboBox();
        for (MessageDigest messageDigest : messageDigests)
            algorithmComboBox.addItem(messageDigest.getAlgorithm());

        // Select the last used algorithm (if any), or the default algorithm
        algorithmComboBox.setSelectedItem(lastUsedAlgorithm);
        algorithmComboBox.addItemListener(this);

        FlowLayout flowLayout = new FlowLayout(FlowLayout.LEADING, 0, 0);
        JPanel tempPanel = new JPanel(flowLayout);
        tempPanel.add(new JLabel(Translator.get("calculate_checksum_dialog.checksum_algorithm")+" : "));
        tempPanel.add(algorithmComboBox);

        mainPanel.add(tempPanel);
        mainPanel.addSpace(10);

        // Create the components that allow to choose where the checksum file should be created

        mainPanel.add(new JLabel(Translator.get("destination")+" :"));
        mainPanel.addSpace(5);

        JRadioButton tempLocationRadioButton = new JRadioButton(Translator.get("calculate_checksum_dialog.temporary_file"), true);
        mainPanel.add(tempLocationRadioButton);

        specificLocationRadioButton = new JRadioButton("", false);
        tempPanel = new JPanel(new BorderLayout());
        tempPanel.add(specificLocationRadioButton, BorderLayout.WEST);
        specificLocationRadioButton.addItemListener(this);
       
        // Create a path field with auto-completion capabilities
        specificLocationTextField = new FilePathField(getChecksumFilename(lastUsedAlgorithm));
        specificLocationTextField.setEnabled(false);
        tempPanel.add(specificLocationTextField, BorderLayout.CENTER);

        JPanel tempPanel2 = new JPanel(new BorderLayout());
        tempPanel2.add(tempPanel, BorderLayout.NORTH);
        mainPanel.add(tempPanel2);

        ButtonGroup buttonGroup = new ButtonGroup();
        buttonGroup.add(tempLocationRadioButton);
        buttonGroup.add(specificLocationRadioButton);

        // Create file details button and OK/cancel buttons and lay them out a single row

        JPanel fileDetailsPanel = createFileDetailsPanel();

        okButton = new JButton(Translator.get("ok"));
        JButton cancelButton = new JButton(Translator.get("cancel"));

        mainPanel.add(createButtonsPanel(createFileDetailsButton(fileDetailsPanel),
                DialogToolkit.createOKCancelPanel(okButton, cancelButton, getRootPane(), this)));

        mainPanel.add(fileDetailsPanel);

//        mainPanel.add(new HelpButtonPanel(new HelpButton(mainFrame, "CalculateChecksum")));
       
        getContentPane().add(mainPanel);
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.