Example usage for javax.swing SwingUtilities isEventDispatchThread

List of usage examples for javax.swing SwingUtilities isEventDispatchThread

Introduction

In this page you can find the example usage for javax.swing SwingUtilities isEventDispatchThread.

Prototype

public static boolean isEventDispatchThread() 

Source Link

Document

Returns true if the current thread is an AWT event dispatching thread.

Usage

From source file:javazoom.jlgui.player.amp.PlayerUI.java

public void loadSkin() {
    log.info("Load PlayerUI (EDT=" + SwingUtilities.isEventDispatchThread() + ")");
    removeAll();//w w  w  . j  ava 2  s  . c o  m
    // Load skin specified in args
    if (ui.getPath() != null) {
        log.info("Load default skin from " + ui.getPath());
        ui.loadSkin(ui.getPath());
        config.setDefaultSkin(ui.getPath());
    }
    // Load skin specified in jlgui.ini
    else if ((config.getDefaultSkin() != null) && (!config.getDefaultSkin().trim().equals(""))) {
        log.info("Load default skin from " + config.getDefaultSkin());
        ui.loadSkin(config.getDefaultSkin());
    }
    // Default included skin
    else {
        ClassLoader cl = getClass().getClassLoader();
        InputStream sis = cl.getResourceAsStream("javazoom/jlgui/player/amp/metrix.wsz");
        log.info("Load default skin for JAR");
        ui.loadSkin(sis);
    }
    // Background
    ImageBorder border = new ImageBorder();
    border.setImage(ui.getMainImage());
    setBorder(border);
    // Buttons        
    add(ui.getAcPrevious(), ui.getAcPrevious().getConstraints());
    ui.getAcPrevious().removeActionListener(this);
    ui.getAcPrevious().addActionListener(this);
    add(ui.getAcPlay(), ui.getAcPlay().getConstraints());
    ui.getAcPlay().removeActionListener(this);
    ui.getAcPlay().addActionListener(this);
    add(ui.getAcPause(), ui.getAcPause().getConstraints());
    ui.getAcPause().removeActionListener(this);
    ui.getAcPause().addActionListener(this);
    add(ui.getAcStop(), ui.getAcStop().getConstraints());
    ui.getAcStop().removeActionListener(this);
    ui.getAcStop().addActionListener(this);
    add(ui.getAcNext(), ui.getAcNext().getConstraints());
    ui.getAcNext().removeActionListener(this);
    ui.getAcNext().addActionListener(this);
    add(ui.getAcEject(), ui.getAcEject().getConstraints());
    ui.getAcEject().removeActionListener(this);
    ui.getAcEject().addActionListener(this);
    // EqualizerUI toggle
    add(ui.getAcEqualizer(), ui.getAcEqualizer().getConstraints());
    ui.getAcEqualizer().removeActionListener(this);
    ui.getAcEqualizer().addActionListener(this);
    // Playlist toggle
    add(ui.getAcPlaylist(), ui.getAcPlaylist().getConstraints());
    ui.getAcPlaylist().removeActionListener(this);
    ui.getAcPlaylist().addActionListener(this);
    // Shuffle toggle
    add(ui.getAcShuffle(), ui.getAcShuffle().getConstraints());
    ui.getAcShuffle().removeActionListener(this);
    ui.getAcShuffle().addActionListener(this);
    // Repeat toggle
    add(ui.getAcRepeat(), ui.getAcRepeat().getConstraints());
    ui.getAcRepeat().removeActionListener(this);
    ui.getAcRepeat().addActionListener(this);
    // Volume
    add(ui.getAcVolume(), ui.getAcVolume().getConstraints());
    ui.getAcVolume().removeChangeListener(this);
    ui.getAcVolume().addChangeListener(this);
    // Balance
    add(ui.getAcBalance(), ui.getAcBalance().getConstraints());
    ui.getAcBalance().removeChangeListener(this);
    ui.getAcBalance().addChangeListener(this);
    // Seek bar
    add(ui.getAcPosBar(), ui.getAcPosBar().getConstraints());
    ui.getAcPosBar().removeChangeListener(this);
    ui.getAcPosBar().addChangeListener(this);
    // Mono
    add(ui.getAcMonoIcon(), ui.getAcMonoIcon().getConstraints());
    // Stereo
    add(ui.getAcStereoIcon(), ui.getAcStereoIcon().getConstraints());
    // Title label
    add(ui.getAcTitleLabel(), ui.getAcTitleLabel().getConstraints());
    // Sample rate label
    add(ui.getAcSampleRateLabel(), ui.getAcSampleRateLabel().getConstraints());
    // Bit rate label
    add(ui.getAcBitRateLabel(), ui.getAcBitRateLabel().getConstraints());
    // Play icon
    add(ui.getAcPlayIcon(), ui.getAcPlayIcon().getConstraints());
    // Time icon
    add(ui.getAcTimeIcon(), ui.getAcTimeIcon().getConstraints());
    // MinuteH number
    add(ui.getAcMinuteH(), ui.getAcMinuteH().getConstraints());
    // MinuteL number
    add(ui.getAcMinuteL(), ui.getAcMinuteL().getConstraints());
    // SecondH number
    add(ui.getAcSecondH(), ui.getAcSecondH().getConstraints());
    // SecondL number
    add(ui.getAcSecondL(), ui.getAcSecondL().getConstraints());
    // TitleBar
    add(ui.getAcTitleBar(), ui.getAcTitleBar().getConstraints());
    add(ui.getAcMinimize(), ui.getAcMinimize().getConstraints());
    ui.getAcMinimize().removeActionListener(this);
    ui.getAcMinimize().addActionListener(this);
    add(ui.getAcExit(), ui.getAcExit().getConstraints());
    ui.getAcExit().removeActionListener(this);
    ui.getAcExit().addActionListener(this);
    // DSP
    if (ui.getAcAnalyzer() != null) {
        add(ui.getAcAnalyzer(), ui.getAcAnalyzer().getConstraints());
    }
    // Popup menu
    mainpopup = new JPopupMenu(ui.getResource("popup.title"));
    JMenuItem mi = new JMenuItem(Skin.TITLETEXT + "- JavaZOOM");
    //mi.removeActionListener(this);
    //mi.addActionListener(this);
    mainpopup.add(mi);
    mainpopup.addSeparator();
    JMenu playSubMenu = new JMenu(ui.getResource("popup.play"));
    miPlayFile = new JMenuItem(ui.getResource("popup.play.file"));
    miPlayFile.setActionCommand(PlayerActionEvent.MIPLAYFILE);
    miPlayFile.removeActionListener(this);
    miPlayFile.addActionListener(this);
    miPlayLocation = new JMenuItem(ui.getResource("popup.play.location"));
    miPlayLocation.setActionCommand(PlayerActionEvent.MIPLAYLOCATION);
    miPlayLocation.removeActionListener(this);
    miPlayLocation.addActionListener(this);
    playSubMenu.add(miPlayFile);
    playSubMenu.add(miPlayLocation);
    mainpopup.add(playSubMenu);
    mainpopup.addSeparator();
    miPlaylist = new JCheckBoxMenuItem(ui.getResource("popup.playlist"));
    miPlaylist.setActionCommand(PlayerActionEvent.MIPLAYLIST);
    if (config.isPlaylistEnabled())
        miPlaylist.setState(true);
    miPlaylist.removeActionListener(this);
    miPlaylist.addActionListener(this);
    mainpopup.add(miPlaylist);
    miEqualizer = new JCheckBoxMenuItem(ui.getResource("popup.equalizer"));
    miEqualizer.setActionCommand(PlayerActionEvent.MIEQUALIZER);
    if (config.isEqualizerEnabled())
        miEqualizer.setState(true);
    miEqualizer.removeActionListener(this);
    miEqualizer.addActionListener(this);
    mainpopup.add(miEqualizer);
    mainpopup.addSeparator();
    mi = new JMenuItem(ui.getResource("popup.preferences"));
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK, false));
    mi.setActionCommand(PlayerActionEvent.MIPREFERENCES);
    mi.removeActionListener(this);
    mi.addActionListener(this);
    mainpopup.add(mi);
    JMenu skinsSubMenu = new JMenu(ui.getResource("popup.skins"));
    mi = new JMenuItem(ui.getResource("popup.skins.browser"));
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.ALT_MASK, false));
    mi.setActionCommand(PlayerActionEvent.MISKINBROWSER);
    mi.removeActionListener(this);
    mi.addActionListener(this);
    skinsSubMenu.add(mi);
    mi = new JMenuItem(ui.getResource("popup.skins.load"));
    mi.setActionCommand(PlayerActionEvent.MILOADSKIN);
    mi.removeActionListener(this);
    mi.addActionListener(this);
    skinsSubMenu.add(mi);
    mainpopup.add(skinsSubMenu);
    JMenu playbackSubMenu = new JMenu(ui.getResource("popup.playback"));
    mi = new JMenuItem(ui.getResource("popup.playback.jump"));
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, 0, false));
    mi.setActionCommand(PlayerActionEvent.MIJUMPFILE);
    mi.removeActionListener(this);
    mi.addActionListener(this);
    playbackSubMenu.add(mi);
    mi = new JMenuItem(ui.getResource("popup.playback.stop"));
    mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, 0, false));
    mi.setActionCommand(PlayerActionEvent.MISTOP);
    mi.removeActionListener(this);
    mi.addActionListener(this);
    playbackSubMenu.add(mi);
    mainpopup.add(playbackSubMenu);
    mainpopup.addSeparator();
    mi = new JMenuItem(ui.getResource("popup.exit"));
    mi.setActionCommand(PlayerActionEvent.ACEXIT);
    mi.removeActionListener(this);
    mi.addActionListener(this);
    mainpopup.add(mi);
    // Popup menu on TitleBar
    ui.getAcTitleBar().removeMouseListener(popupAdapter);
    popupAdapter = new PopupAdapter(mainpopup);
    ui.getAcTitleBar().addMouseListener(popupAdapter);
    // Popup menu on Eject button
    ejectpopup = new JPopupMenu();
    mi = new JMenuItem(ui.getResource("popup.eject.openfile"));
    mi.setActionCommand(PlayerActionEvent.MIPLAYFILE);
    mi.removeActionListener(this);
    mi.addActionListener(this);
    ejectpopup.add(mi);
    mi = new JMenuItem(ui.getResource("popup.eject.openlocation"));
    mi.setActionCommand(PlayerActionEvent.MIPLAYLOCATION);
    mi.removeActionListener(this);
    mi.addActionListener(this);
    ejectpopup.add(mi);
    ui.getAcEject().removeMouseListener(ejectpopupAdapter);
    ejectpopupAdapter = new PopupAdapter(ejectpopup);
    ui.getAcEject().addMouseListener(ejectpopupAdapter);
    // EqualizerUI
    if (equalizerUI != null)
        equalizerUI.loadUI();
    if (playlistUI != null)
        playlistUI.loadUI();
    validate();
    loader.loaded();
}

From source file:com.archivas.clienttools.arcmover.gui.panels.ProfilePanel.java

private void updateLockState() {
    if (!SwingUtilities.isEventDispatchThread()) {
        String errMsg = "updateLockState is not on the EDT but it should be";
        IllegalStateException ex = new IllegalStateException(errMsg);
        LOG.log(Level.SEVERE, errMsg, ex);
        throw ex;
    }/* w  ww .  j a v  a2s  .co m*/
    boolean locked = isLocked();

    if (locked) {
        setCursor(HCPDataMigrator.waitCursor);
    }
    subSetEnabled(!locked);
    if (!locked) {
        setCursor(null);
    }
}

From source file:com.aw.swing.mvp.action.Action.java

public void updateUIStatus() {
    if (needVisualComponent) {
        if (SwingUtilities.isEventDispatchThread()) {
            jComponent.setEnabled(isEnabled());
        } else {//from   w  w  w  .  j  a v  a2s.  co  m
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        jComponent.setEnabled(isEnabled());
                    }
                });
            } catch (Throwable e) {
                throw new AWSystemException("Problems updating UI:" + this, e);
            }
        }

    }
}

From source file:com.kenai.redminenb.issue.RedmineIssue.java

public synchronized boolean refresh() {
    assert !SwingUtilities.isEventDispatchThread() : "Accessing remote host. Do not call in awt"; // NOI18N

    try {/* ww  w .j  a  va  2s  .com*/
        if (issue != null && issue.getId() != null) {
            setIssue(getRepository().getIssueManager().getIssueById(issue.getId(), Include.journals,
                    Include.attachments, Include.watchers));
        }
        return true;
    } catch (RedmineException | RuntimeException ex) {
        ExceptionHandler.handleException(LOG, "Can't refresh Redmine issue", ex);
    }
    return false;
}

From source file:javazoom.jlgui.player.amp.equalizer.ui.EqualizerUI.java

public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();
    log.debug("Action=" + cmd + " (EDT=" + SwingUtilities.isEventDispatchThread() + ")");
    // On/Off/*from  w w  w .ja v  a2  s  .c  om*/
    if (cmd.equals(PlayerActionEvent.ACEQONOFF)) {
        if (ui.getAcEqOnOff().isSelected()) {
            config.setEqualizerOn(true);
        } else {
            config.setEqualizerOn(false);
        }
        synchronizeEqualizer();
    }
    // Auto
    else if (cmd.equals(PlayerActionEvent.ACEQAUTO)) {
        if (ui.getAcEqAuto().isSelected()) {
            config.setEqualizerAuto(true);
        } else {
            config.setEqualizerAuto(false);
        }
    }
    // Presets
    else if (cmd.equals(PlayerActionEvent.ACEQPRESETS)) {
        if (e.getModifiers() == MouseEvent.BUTTON1_MASK) {
            mainpopup.show(this, ui.getAcEqPresets().getLocation().x, ui.getAcEqPresets().getLocation().y);
        }
    } else if (cmd.equals("Normal")) {
        updateSliders(PRESET_NORMAL);
        synchronizeEqualizer();
    } else if (cmd.equals("Classical")) {
        updateSliders(PRESET_CLASSICAL);
        synchronizeEqualizer();
    } else if (cmd.equals("Club")) {
        updateSliders(PRESET_CLUB);
        synchronizeEqualizer();
    } else if (cmd.equals("Dance")) {
        updateSliders(PRESET_DANCE);
        synchronizeEqualizer();
    } else if (cmd.equals("Full Bass")) {
        updateSliders(PRESET_FULLBASS);
        synchronizeEqualizer();
    } else if (cmd.equals("Full Bass & Treble")) {
        updateSliders(PRESET_FULLBASSTREBLE);
        synchronizeEqualizer();
    } else if (cmd.equals("Full Treble")) {
        updateSliders(PRESET_FULLTREBLE);
        synchronizeEqualizer();
    } else if (cmd.equals("Laptop")) {
        updateSliders(PRESET_LAPTOP);
        synchronizeEqualizer();
    } else if (cmd.equals("Live")) {
        updateSliders(PRESET_LIVE);
        synchronizeEqualizer();
    } else if (cmd.equals("Party")) {
        updateSliders(PRESET_PARTY);
        synchronizeEqualizer();
    } else if (cmd.equals("Pop")) {
        updateSliders(PRESET_POP);
        synchronizeEqualizer();
    } else if (cmd.equals("Reggae")) {
        updateSliders(PRESET_REGGAE);
        synchronizeEqualizer();
    } else if (cmd.equals("Rock")) {
        updateSliders(PRESET_ROCK);
        synchronizeEqualizer();
    } else if (cmd.equals("Techno")) {
        updateSliders(PRESET_TECHNO);
        synchronizeEqualizer();
    }
}

From source file:com.nbt.TileCanvas.java

public void doRepaint() {
    Runnable runnable = new Runnable() {
        @Override//from w w w.j  a v a2 s .  c o m
        public void run() {
            repaint();
        }
    };
    if (SwingUtilities.isEventDispatchThread())
        runnable.run();
    else
        SwingUtilities.invokeLater(runnable);
}

From source file:hermes.browser.HermesBrowser.java

private static void setStatusMessage(final String statusMessage) {
    if (ui != null && ui.progressStatus != null && statusMessage != null) {
        if (SwingUtilities.isEventDispatchThread()) {
            ui.progressStatus.setStatus(statusMessage);
        } else {/*from   w  w  w. j  a va 2s.  com*/
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    ui.progressStatus.setStatus(statusMessage);
                }
            });
        }
    }
}

From source file:dk.dma.epd.common.prototype.gui.notification.ChatServicePanel.java

/**
 * Updates the chat message panel in the Swing event thread
 *//*from   ww  w  .ja v  a 2 s .  c o  m*/
public void updateChatMessagePanel() {
    // Ensure that we operate in the Swing event thread
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                updateChatMessagePanel();
            }
        });
        return;
    }

    // Set the title header
    titleHeader.setText(chatData != null ? NameUtils.getName(chatData.getId(), NameFormat.MEDIUM) : " ");
    titleHeader.setVisible(chatData != null);

    // Only enable send-function when there is chat data, and hence a target
    sendBtn.setEnabled(chatData != null);
    messageText.setEditable(chatData != null);

    // Remove all components from the messages panel
    messagesPanel.removeAll();

    Insets insets = new Insets(0, 2, 2, 2);
    Insets insets2 = new Insets(6, 2, 0, 2);

    if (chatData != null && chatData.getMessageCount() > 0) {

        // First, add a filler component
        int y = 0;
        messagesPanel.add(new JLabel(""),
                new GridBagConstraints(0, y++, 1, 1, 0.0, 1.0, NORTH, VERTICAL, insets, 0, 0));

        // Add the messages
        long lastMessageTime = 0;
        for (EPDChatMessage message : chatData.getMessages()) {

            // Check if we need to add a time label
            if (message.getSendDate().getTime() - lastMessageTime > PRINT_DATE_INTERVAL) {
                JLabel dateLabel = new JLabel(
                        String.format(message.isOwnMessage() ? "Sent to %s" : "Received %s",
                                Formatter.formatShortDateTimeNoTz(new Date(message.getSendDate().getTime()))));
                dateLabel.setFont(dateLabel.getFont().deriveFont(9.0f).deriveFont(Font.PLAIN));
                dateLabel.setHorizontalAlignment(SwingConstants.CENTER);
                dateLabel.setForeground(Color.LIGHT_GRAY);
                messagesPanel.add(dateLabel,
                        new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets2, 0, 0));
            }

            // Add a chat message field
            JPanel msg = new JPanel();
            msg.setBorder(new ChatMessageBorder(message));
            JLabel msgLabel = new ChatMessageLabel(message.getMsg(), message.isOwnMessage());
            msg.add(msgLabel);
            messagesPanel.add(msg,
                    new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets, 0, 0));

            lastMessageTime = message.getSendDate().getTime();
        }

        // Scroll to the bottom
        validate();
        scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum());
        messagesPanel.repaint();

    } else if (chatData == null && noDataComponent != null) {
        // The noDataComponent may e.g. be a message
        messagesPanel.add(noDataComponent,
                new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0));
    }
}

From source file:com.moss.greenshell.wizard.ProcessPanel.java

private void transitionStatic(final JPanel oldView, final JPanel newView, final Runnable followupAction) {
    try {/*from  w ww.j  a v  a  2s.  c o  m*/
        Runnable action = new Runnable() {
            public void run() {
                synchronized (view.getActionArea()) {
                    view.getActionArea().removeAll();
                    view.getActionArea().add(newView);
                    view.getActionArea().invalidate();
                    view.validate();
                    if (followupAction != null)
                        followupAction.run();
                }
            }
        };

        if (SwingUtilities.isEventDispatchThread()) {
            action.run();
        } else {
            SwingUtilities.invokeAndWait(action);
        }
    } catch (Exception e) {
        failCatastrophically(e);
    }
}

From source file:javazoom.jlgui.player.amp.playlist.ui.PlaylistUI.java

/**
 * Process action event./*from w w  w. java2 s  .  com*/
 * @param e
 */
public void processActionEvent(ActionEvent e) {
    String cmd = e.getActionCommand();
    log.debug("Action=" + cmd + " (EDT=" + SwingUtilities.isEventDispatchThread() + ")");
    int n = playlist.getPlaylistSize();
    if (cmd.equals(PlayerActionEvent.ACPLUP)) {
        topIndex--;
        if (topIndex < 0)
            topIndex = 0;
        resetScrollBar();
        paintList();
    } else if (cmd.equals(PlayerActionEvent.ACPLDOWN)) {
        topIndex++;
        if (topIndex > n - 1)
            topIndex = n - 1;
        resetScrollBar();
        paintList();
    } else if (cmd.equals(PlayerActionEvent.ACPLADDPOPUP)) {
        ui.getAcPlAdd().setVisible(false);
        ui.getAcPlAddPopup().setVisible(true);
    } else if (cmd.equals(PlayerActionEvent.ACPLREMOVEPOPUP)) {
        ui.getAcPlRemove().setVisible(false);
        ui.getAcPlRemovePopup().setVisible(true);
    } else if (cmd.equals(PlayerActionEvent.ACPLSELPOPUP)) {
        ui.getAcPlSelect().setVisible(false);
        ui.getAcPlSelectPopup().setVisible(true);
    } else if (cmd.equals(PlayerActionEvent.ACPLMISCPOPUP)) {
        ui.getAcPlMisc().setVisible(false);
        ui.getAcPlMiscPopup().setVisible(true);
    } else if (cmd.equals(PlayerActionEvent.ACPLLISTPOPUP)) {
        ui.getAcPlList().setVisible(false);
        ui.getAcPlListPopup().setVisible(true);
    } else if (cmd.equals(PlayerActionEvent.ACPLINFO)) {
        popupFileInfo();
    } else if (cmd.equals(PlayerActionEvent.ACPLPLAY)) {
        int n0 = playlist.getPlaylistSize();
        PlaylistItem pli = null;
        for (int i = n0 - 1; i >= 0; i--) {
            pli = playlist.getItemAt(i);
            if (pli.isSelected())
                break;
        }
        // Play.
        if ((pli != null) && (pli.getTagInfo() != null)) {
            player.pressStop();
            player.setCurrentSong(pli);
            playlist.setCursor(playlist.getIndex(pli));
            player.pressStart();
        }
    } else if (cmd.equals(PlayerActionEvent.ACPLREMOVE)) {
        delSelectedItems();
    } else if (cmd.equals(PlayerActionEvent.ACPLADDFILE)) {
        ui.getAcPlAddPopup().setVisible(false);
        ui.getAcPlAdd().setVisible(true);
        File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.OPEN, true,
                config.getExtensions(), ui.getResource("playlist.popup.add.file"),
                new File(config.getLastDir()));
        if (FileSelector.getInstance().getDirectory() != null)
            config.setLastDir(FileSelector.getInstance().getDirectory().getPath());
        addFiles(file);
    } else if (cmd.equals(PlayerActionEvent.ACPLADDURL)) {
        ui.getAcPlAddPopup().setVisible(false);
        ui.getAcPlAdd().setVisible(true);
        UrlDialog UD = new UrlDialog(config.getTopParent(), ui.getResource("playlist.popup.add.url"),
                player.getLoader().getLocation().x, player.getLoader().getLocation().y + player.getHeight(),
                null);
        UD.show();
        if (UD.getFile() != null) {
            PlaylistItem pli = new PlaylistItem(UD.getFile(), UD.getURL(), -1, false);
            playlist.appendItem(pli);
            resetScrollBar();
            repaint();
        }
    } else if (cmd.equals(PlayerActionEvent.ACPLADDDIR)) {
        ui.getAcPlAddPopup().setVisible(false);
        ui.getAcPlAdd().setVisible(true);
        File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.DIRECTORY, false, "",
                ui.getResource("playlist.popup.add.dir"), new File(config.getLastDir()));
        if (FileSelector.getInstance().getDirectory() != null)
            config.setLastDir(FileSelector.getInstance().getDirectory().getPath());
        if (file == null || !file[0].isDirectory())
            return;
        // TODO - add message box for wrong filename
        addDir(file[0]);
    } else if (cmd.equals(PlayerActionEvent.ACPLREMOVEALL)) {
        ui.getAcPlRemovePopup().setVisible(false);
        ui.getAcPlRemove().setVisible(true);
        delAllItems();
    } else if (cmd.equals(PlayerActionEvent.ACPLREMOVESEL)) {
        ui.getAcPlRemovePopup().setVisible(false);
        ui.getAcPlRemove().setVisible(true);
        delSelectedItems();
    } else if (cmd.equals(PlayerActionEvent.ACPLREMOVEMISC)) {
        ui.getAcPlRemovePopup().setVisible(false);
        ui.getAcPlRemove().setVisible(true);
        // TODO
    } else if (cmd.equals(PlayerActionEvent.ACPLREMOVECROP)) {
        ui.getAcPlRemovePopup().setVisible(false);
        ui.getAcPlRemove().setVisible(true);
        // TODO
    } else if (cmd.equals(PlayerActionEvent.ACPLSELALL)) {
        ui.getAcPlSelectPopup().setVisible(false);
        ui.getAcPlSelect().setVisible(true);
        selFunctions(1);
    } else if (cmd.equals(PlayerActionEvent.ACPLSELINV)) {
        ui.getAcPlSelectPopup().setVisible(false);
        ui.getAcPlSelect().setVisible(true);
        selFunctions(-1);
    } else if (cmd.equals(PlayerActionEvent.ACPLSELZERO)) {
        ui.getAcPlSelectPopup().setVisible(false);
        ui.getAcPlSelect().setVisible(true);
        selFunctions(0);
    } else if (cmd.equals(PlayerActionEvent.ACPLMISCOPTS)) {
        ui.getAcPlMiscPopup().setVisible(false);
        ui.getAcPlMisc().setVisible(true);
        // TODO
    } else if (cmd.equals(PlayerActionEvent.ACPLMISCFILE)) {
        ui.getAcPlMiscPopup().setVisible(false);
        ui.getAcPlMisc().setVisible(true);
        popupFileInfo();
    } else if (cmd.equals(PlayerActionEvent.ACPLMISCSORT)) {
        ui.getAcPlMiscPopup().setVisible(false);
        ui.getAcPlMisc().setVisible(true);
        // TODO
    } else if (cmd.equals(PlayerActionEvent.ACPLLISTLOAD)) {
        ui.getAcPlListPopup().setVisible(false);
        ui.getAcPlList().setVisible(true);
        File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.OPEN, true,
                config.getExtensions(), ui.getResource("playlist.popup.list.load"),
                new File(config.getLastDir()));
        if (FileSelector.getInstance().getDirectory() != null)
            config.setLastDir(FileSelector.getInstance().getDirectory().getPath());
        if ((file != null) && (file[0] != null)) {
            String fsFile = file[0].getName();
            if ((fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.m3u")))
                    || (fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.pls")))) {
                if (player.loadPlaylist(config.getLastDir() + fsFile)) {
                    config.setPlaylistFilename(config.getLastDir() + fsFile);
                    playlist.begin();
                    playlist.setCursor(-1);
                    // TODO
                    topIndex = 0;
                }
                resetScrollBar();
                repaint();
            }
        }
    } else if (cmd.equals(PlayerActionEvent.ACPLLISTSAVE)) {
        ui.getAcPlListPopup().setVisible(false);
        ui.getAcPlList().setVisible(true);
        // TODO
    } else if (cmd.equals(PlayerActionEvent.ACPLLISTNEW)) {
        ui.getAcPlListPopup().setVisible(false);
        ui.getAcPlList().setVisible(true);
        // TODO
    }
}