Package org.jampa.gui.handlers.playlists

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

/*
* 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 java.util.Iterator;

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.gui.actions.playlist.OpenPlaylistAction;
import org.jampa.logging.Log;
import org.jampa.model.playlists.Playlist;

public class MenuOpenPlaylistHandler extends AbstractHandler implements IHandler {

  @SuppressWarnings("unchecked")
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    ISelection selection = window.getActivePage().getSelection();

    Playlist item;
    Iterator iter = ((IStructuredSelection)selection).iterator();
   
    while (iter.hasNext()) {
      item = (Playlist) iter.next();
      Log.getInstance(MenuOpenPlaylistHandler.class).debug("Openning playlist: " + item.getName()); //$NON-NLS-1$
      new OpenPlaylistAction(item.getName()).run();
    }
    return null;
  }

}
TOP

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

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.