Package org.jampa.gui.handlers.playlists

Source Code of org.jampa.gui.handlers.playlists.MenuPlayPlaylistHandler

/*
* Jampa
* Copyright (C) 2008-2009 J. Devauchelle and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 3 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*/

package org.jampa.gui.handlers.playlists;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jampa.controllers.Controller;
import org.jampa.model.IAudioItem;
import org.jampa.model.playlists.Playlist;

public class MenuPlayPlaylistHandler extends AbstractHandler implements
    IHandler {

  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
   
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    ISelection selection = window.getActivePage().getSelection();
   
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    if (obj != null) {
      IAudioItem firstAudioItem = ((Playlist) obj).getAudioItemByIndex(0);
      Controller.getInstance().getPlaylistController().playFile((Playlist) obj, firstAudioItem);
    }

    return null;
  }

}
TOP

Related Classes of org.jampa.gui.handlers.playlists.MenuPlayPlaylistHandler

TOP
Copyright © 2018 www.massapi.com. 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.