Changeset 11612


Ignore:
Timestamp:
2006-04-06T17:08:29+12:00 (18 years ago)
Author:
mdewsnip
Message:

Moved the MappingPrompt out of GatherPane and into it's own class called CreateShortcutPrompt.

Location:
trunk/gli/src/org/greenstone/gatherer/gui
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/GatherPane.java

    r11608 r11612  
    111111    /** Ensures that expansion and selection events between collection trees based on the same model are synchronized. */
    112112    private TreeSynchronizer collection_tree_sync = null;
    113     /** The default size of a special mapping dialog. */
    114     static final Dimension DIALOG_SIZE = new Dimension(400, 120);
    115113    /** The minimum size a gui component can become. */
    116114    static private Dimension MIN_SIZE   = new Dimension( 90,  90);
     
    660658        // Create shortcut
    661659        if (source == create_shortcut) {
    662         MappingPrompt mp = new MappingPrompt(node.getFile());
    663         mp.destroy();
     660        CreateShortcutPrompt csp = new CreateShortcutPrompt(workspace_tree, node.getFile());
     661        csp.destroy();
    664662        }
    665663
     
    728726    }
    729727
    730 
    731     /** This provides a small prompt for gathering addition details about a special directory mapping such as its symbolic name.
    732      * Used when creating a new shortcut to a folder */
    733     private class MappingPrompt
    734     extends JDialog
    735     implements ActionListener, KeyListener {
    736     private boolean cancelled = false;
    737     private JButton cancel_button = null;
    738     private JButton ok_button = null;
    739     private JTextField name_field = null;
    740     public MappingPrompt(File file) {
    741         super(Gatherer.g_man);
    742         setModal(true);
    743         setSize(DIALOG_SIZE);
    744         Dictionary.setText(this, "MappingPrompt.Title");
    745 
    746         // Creation
    747         JPanel content_pane = (JPanel) getContentPane();
    748         JPanel center_pane = new JPanel();
    749         JPanel labels_pane = new JPanel();
    750         JPanel fields_pane = new JPanel();
    751 
    752         JLabel file_label = new JLabel();
    753         Dictionary.setText(file_label, "MappingPrompt.File");
    754         JLabel file_field = new JLabel(file.getAbsolutePath());
    755 
    756         JLabel name_label = new JLabel();
    757         Dictionary.setText(name_label, "MappingPrompt.Name");
    758         name_field = new JTextField(file.getName());
    759 
    760         JPanel button_pane = new JPanel();
    761         ok_button = new GLIButton();
    762         ok_button.setEnabled(name_field.getText().length() > 0);
    763         ok_button.setMnemonic(KeyEvent.VK_O);
    764         Dictionary.setBoth(ok_button, "General.OK", "General.OK_Tooltip");
    765         cancel_button = new GLIButton();
    766         cancel_button.setMnemonic(KeyEvent.VK_C);
    767         Dictionary.setBoth(cancel_button, "General.Cancel", "General.Cancel_Tooltip");
    768 
    769         // Connection
    770         cancel_button.addActionListener(this);
    771         ok_button.addActionListener(this);
    772         name_field.addKeyListener(this);
    773 
    774         // Layout
    775         labels_pane.setLayout(new GridLayout(2,1,5,0));
    776         labels_pane.add(file_label);
    777         labels_pane.add(name_label);
    778        
    779         fields_pane.setLayout(new GridLayout(2,1,5,0));
    780         fields_pane.add(file_field);
    781         fields_pane.add(name_field);
    782 
    783         center_pane.setBorder(BorderFactory.createEmptyBorder(0,0,5,0));
    784         center_pane.setLayout(new BorderLayout(5,0));
    785         center_pane.add(labels_pane, BorderLayout.WEST);
    786         center_pane.add(fields_pane, BorderLayout.CENTER);
    787 
    788         button_pane.setLayout(new GridLayout(1,2,5,5));
    789         button_pane.add(ok_button);
    790         button_pane.add(cancel_button);
    791 
    792         content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    793         content_pane.setLayout(new BorderLayout());
    794         content_pane.add(center_pane, BorderLayout.CENTER);
    795         content_pane.add(button_pane, BorderLayout.SOUTH);
    796         // Display
    797         Dimension screen_size = Configuration.screen_size;
    798         setLocation((screen_size.width - DIALOG_SIZE.width) / 2, (screen_size.height - DIALOG_SIZE.height) / 2);
    799         setVisible(true);
    800         // If not cancelled create mapping.
    801         if (!cancelled) {
    802         workspace_tree.addDirectoryMapping(name_field.getText(), file);
    803         }
    804     }
    805     public void actionPerformed(ActionEvent event) {
    806         if(event.getSource() == cancel_button) {
    807         cancelled = true;
    808         }
    809         dispose();
    810     }
    811     public void destroy() {
    812         cancel_button = null;
    813         ok_button = null;
    814         name_field = null;
    815     }
    816     public void keyPressed(KeyEvent event) {
    817     }
    818     public void keyReleased(KeyEvent event) {
    819         ok_button.setEnabled(name_field.getText().length() > 0);
    820 
    821     }
    822     public void keyTyped(KeyEvent event) {
    823     }
    824     }
    825728
    826729    /** This class listens for mouse clicks and responds right mouse button clicks (popup menu). */
Note: See TracChangeset for help on using the changeset viewer.