Package org.jampa.gui.actions.playlist

Source Code of org.jampa.gui.actions.playlist.NewPlaylistAction

/*
* 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.actions.playlist;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.swt.widgets.Shell;
import org.jampa.controllers.Controller;
import org.jampa.gui.handlers.playlists.NewPlaylistHandler;
import org.jampa.gui.translations.Messages;
import org.jampa.logging.Log;
import org.jampa.model.validators.PlaylistNameValidator;


public class NewPlaylistAction extends Action {
 
  private Shell _shell;
  private String _newPlaylist;
 
  public NewPlaylistAction(Shell shell) {
    _newPlaylist = Messages.getString("NewPlaylistAction.DefaultName"); //$NON-NLS-1$
    _shell = shell;
  }
 
  public NewPlaylistAction(Shell shell, String proposedName) {
    if (proposedName != null)
      _newPlaylist = proposedName;
    else
      _newPlaylist = Messages.getString("NewPlaylistAction.DefaultName"); //$NON-NLS-1$
    _shell = shell;
  }
 
  public void run() {
    InputDialog dialog = new InputDialog(_shell,
        Messages.getString("NewPlaylistAction.Title"), Messages.getString("NewPlaylistAction.Question"), _newPlaylist, new PlaylistNameValidator()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    int result = dialog.open();

    if (result == InputDialog.OK) {
      _newPlaylist = dialog.getValue();
      Controller.getInstance().getPlaylistController().addEmptyPlaylist(_newPlaylist);
      Log.getInstance(NewPlaylistHandler.class).debug("New playlist added : " + _newPlaylist); //$NON-NLS-1$
    } else {
      _newPlaylist = null;
    }
  }
 
  public String getPlaylistName() {
    return _newPlaylist;
  }

}
TOP

Related Classes of org.jampa.gui.actions.playlist.NewPlaylistAction

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.