Changeset 73

Show
Ignore:
Timestamp:
05/26/07 02:37:54 (1 year ago)
Author:
chris
Message:

r7764@flan: chris | 2007-05-26 02:23:11 -0700
more minor UI cleanups
moved Log screen into a JDialog

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/org/lastpod/UI.java

    r71 r73  
    2424import org.lastpod.action.SubmitTracks; 
    2525import org.lastpod.action.UnselectAll; 
     26import org.lastpod.action.ViewLog; 
    2627 
    2728import org.lastpod.util.SwingUtils; 
     
    4849import javax.swing.JPanel; 
    4950import javax.swing.JProgressBar; 
    50 import javax.swing.JScrollPane; 
    5151import javax.swing.JTextArea; 
    5252import javax.swing.JToolBar; 
     
    6262public class UI implements ChunkProgress { 
    6363    private RecentPanel recentpanel; 
    64     private JTextArea logtextarea; 
     64 
     65    /** 
     66     * A status label for the submission. 
     67     */ 
     68    private JLabel submitStatus = null; 
    6569 
    6670    /** 
     
    9195 
    9296    /** 
     97     * The action that views the log. 
     98     */ 
     99    private final Action actionViewLog; 
     100 
     101    /** 
    93102     * The action that deletes the iPod's play counts file. 
    94103     */ 
     
    105114    public UI(Model model) { 
    106115        frame = new JFrame("LastPod"); 
     116 
     117        submitStatus = new JLabel(); 
    107118 
    108119        ImageIcon idleIcon = SwingUtils.createImageIcon(UI.class, "images/busyicons/idle-icon.png"); 
     
    123134        actionUnselectAll = new UnselectAll(frame, model, "Unselect All", iconUnselectAll, 
    124135                "Unselects All Tracks", KeyEvent.VK_A); 
    125         actionSubmitTracks = new SubmitTracks(this, model, statusAnimationLabel, "Submit Tracks", 
    126                 iconSubmitTracks, "Submits the selected tracks to Last.fm", KeyEvent.VK_S); 
     136        actionSubmitTracks = new SubmitTracks(this, model, "Submit Tracks", iconSubmitTracks, 
     137                "Submits the selected tracks to Last.fm", KeyEvent.VK_S); 
     138        actionViewLog = new ViewLog(this, "View Log", iconOpenPreferences, 
     139                "Opens Preferences Editor", KeyEvent.VK_L); 
    127140        actionDeletePlayCounts = new DeletePlayCounts(this, model, "Delete Play Counts", 
    128141                iconDeletePlayCounts, "Removes the play counts file from the iPod.", KeyEvent.VK_D); 
     
    207220        toolBar.addSeparator(); 
    208221 
     222        button = new JButton(actionViewLog); 
     223        layout.setConstraints(button, c); 
     224        toolBar.add(button); 
     225 
     226        toolBar.addSeparator(); 
     227 
    209228        button = new JButton(actionDeletePlayCounts); 
    210229        layout.setConstraints(button, c); 
     
    229248        frame.getContentPane().add(this.recentpanel); 
    230249 
    231         c.gridy = 2; 
    232         c.weighty = 0.5; 
    233         this.logtextarea = new JTextArea("=====LOG=====\n"); 
    234         this.logtextarea.setLineWrap(true); 
    235         this.logtextarea.setWrapStyleWord(true); 
    236         this.logtextarea.setEditable(false); 
    237  
    238         JScrollPane scrollpane = new JScrollPane(this.logtextarea); 
    239         layout.setConstraints(scrollpane, c); 
    240         frame.getContentPane().add(scrollpane); 
    241  
    242250        c.gridwidth = 1; 
    243251        c.weightx = 0.0; 
    244252        c.weighty = 0.0; 
    245  
    246253        c.fill = GridBagConstraints.NONE; 
     254        c.anchor = GridBagConstraints.WEST; 
     255        c.gridx = 0; 
     256        c.gridy = 2; 
     257        c.insets = new Insets(3, 10, 4, 5); 
     258        layout.setConstraints(submitStatus, c); 
     259        frame.getContentPane().add(submitStatus); 
     260 
    247261        c.gridx = 2; 
    248         c.gridy = 3; 
    249262        c.anchor = GridBagConstraints.LAST_LINE_END; 
    250263 
     
    258271        c.gridx = 0; 
    259272        c.gridy = 0; 
    260         c.insets = new Insets(3, 10, 4, 5); 
    261273        layout.setConstraints(progressBar, c); 
    262274        statusBar.add(progressBar); 
     
    279291 
    280292    public JTextArea getLogtextarea() { 
    281         return this.logtextarea; 
     293        return ((ViewLog) actionViewLog).getLogTextArea(); 
     294    } 
     295 
     296    public UnselectAll getUnselectAll() { 
     297        return (UnselectAll) actionUnselectAll; 
     298    } 
     299 
     300    public JLabel getStatusAnimationLabel() { 
     301        return statusAnimationLabel; 
     302    } 
     303 
     304    public JLabel getSubmitStatus() { 
     305        return submitStatus; 
    282306    } 
    283307 
  • trunk/src/main/org/lastpod/action/SubmitTracks.java

    r71 r73  
    3131import javax.swing.Icon; 
    3232import javax.swing.ImageIcon; 
    33 import javax.swing.JLabel; 
    3433import javax.swing.Timer; 
    3534 
     
    7675 
    7776    /** 
    78      * The label used to display the idle and busy icons. 
    79      */ 
    80     private JLabel statusAnimationLabel; 
    81  
    82     /** 
    8377     * This worker is used to perform the submission and is a nice threaded 
    8478     * implementation. 
     
    9589     * @param mnemonic  The action's mnemonic. 
    9690     */ 
    97     public SubmitTracks(UI userInterface, Model model, JLabel statusAnimationLabel, String text
    98         ImageIcon icon, String desc, int mnemonic) { 
     91    public SubmitTracks(UI userInterface, Model model, String text, ImageIcon icon, String desc
     92        int mnemonic) { 
    9993        super(text, icon); 
    10094        putValue(SHORT_DESCRIPTION, desc); 
     
    10296        this.userInterface = userInterface; 
    10397        this.model = model; 
    104         this.statusAnimationLabel = statusAnimationLabel; 
    10598 
    10699        idleIcon = SwingUtils.createImageIcon(UI.class, "images/busyicons/idle-icon.png"); 
     
    121114                    public void actionPerformed(ActionEvent e) { 
    122115                        busyIconIndex = (busyIconIndex + 1) % busyIcons.length; 
    123                         statusAnimationLabel.setIcon(busyIcons[busyIconIndex]); 
     116                        userInterface.getStatusAnimationLabel().setIcon(busyIcons[busyIconIndex]); 
    124117                    } 
    125118                }); 
     
    142135            new SwingWorker() { 
    143136                    public Object construct() { 
    144                         statusAnimationLabel.setIcon(busyIcons[0]); 
     137                        userInterface.getSubmitStatus().setText("Transferring Data..."); 
     138                        userInterface.getStatusAnimationLabel().setIcon(busyIcons[0]); 
    145139                        busyIconIndex = 0; 
    146140                        busyIconTimer.start(); 
     
    150144 
    151145                    public void finished() { 
     146                        userInterface.getSubmitStatus().setText("Done"); 
    152147                        busyIconTimer.stop(); 
    153                         statusAnimationLabel.setIcon(idleIcon); 
     148                        userInterface.getStatusAnimationLabel().setIcon(idleIcon); 
     149                        userInterface.getUnselectAll().reset(); 
    154150                        setEnabled(true); 
    155151                    } 
  • trunk/src/main/org/lastpod/action/UnselectAll.java

    r71 r73  
    7272 
    7373    /** 
     74     * Resets this button. 
     75     */ 
     76    public void reset() { 
     77        setSelectAllType(Boolean.FALSE); 
     78        putValue(NAME, "Unselect All"); 
     79        putValue(SHORT_DESCRIPTION, "Unselects All Tracks"); 
     80    } 
     81 
     82    /** 
    7483     * Gets the action's select all type. 
    7584     * @return  The action's select all type.