/*
* 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.utils;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.jampa.controllers.Controller;
import org.jampa.engine.PlaybackEngine;
import org.jampa.logging.Log;
public class ApplicationUtils {
public static void closeViewByID(String id) {
IViewReference view = null;
IWorkbenchPage _page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewReference[] tabView = _page.getViewReferences();
for (int i = 0; i < tabView.length; i++) {
if ((tabView[i].getId() != null) &&
(tabView[i].getId().equals(id))) {
view = tabView[i];
break;
}
}
if (view != null) {
_page.hideView(view);
}
}
public static void closeViewByID(String primaryId, String secondaryId) {
IViewReference view = null;
IWorkbenchPage _page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewReference[] tabView = _page.getViewReferences();
for (int i = 0; i < tabView.length; i++) {
if ((tabView[i].getId() != null) &&
(tabView[i].getSecondaryId() != null) &&
(tabView[i].getId().equals(primaryId))&&
(tabView[i].getSecondaryId().equals(secondaryId))) {
view = tabView[i];
break;
}
}
if (view != null) {
_page.hideView(view);
}
}
public static void showViewByID(String id) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
page.showView(id);
} catch (PartInitException e) {
Log.getInstance(ApplicationUtils.class).warn("Unable to open view: " + id); //$NON-NLS-1$
}
}
public static void showViewByID(String id, String secondaryId) {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
page.showView(id, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
} catch (PartInitException e) {
Log.getInstance(ApplicationUtils.class).warn("Unable to open view: " + id); //$NON-NLS-1$
}
}
public static boolean doesEngineSupportPodcasts() {
return (Controller.getInstance().getEngine().getEngineType() != PlaybackEngine.JLAYER);
}
public static boolean doesEngineSupportRadio() {
return (Controller.getInstance().getEngine().getEngineType() != PlaybackEngine.JLAYER);
}
public static boolean doesEngineSupportEqualizer() {
return (Controller.getInstance().getEngine().getEngineType() != PlaybackEngine.JLAYER);
}
}