1 package fr.ifremer.quadrige3.ui.swing.desktop; 2 3 /* 4 * #%L 5 * Reef DB :: UI 6 * $Id:$ 7 * $HeadURL:$ 8 * %% 9 * Copyright (C) 2014 - 2015 Ifremer 10 * %% 11 * This program is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Affero General Public License as published by 13 * the Free Software Foundation, either version 3 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU Affero General Public License 22 * along with this program. If not, see <http://www.gnu.org/licenses/>. 23 * #L% 24 */ 25 26 import fr.ifremer.quadrige3.ui.swing.desktop.os.win.WindowsPower; 27 import org.apache.commons.lang3.SystemUtils; 28 import org.apache.commons.logging.Log; 29 import org.apache.commons.logging.LogFactory; 30 31 /** 32 * <p>Abstract Desktop class.</p> 33 * 34 */ 35 public abstract class Desktop { 36 37 private static final Log LOG = LogFactory.getLog(Desktop.class); 38 39 private static DesktopPower desktopPower = null; 40 41 /** 42 * <p>Getter for the field <code>desktopPower</code>.</p> 43 * 44 * @return a {@link DesktopPower} object. 45 */ 46 public static DesktopPower getDesktopPower() { 47 if (desktopPower == null) { 48 49 50 if (SystemUtils.IS_OS_WINDOWS) { 51 // All Windows version are handled with WindowsPower class 52 try { 53 desktopPower = new WindowsPower(); 54 } catch (Exception e) { 55 LOG.error(e.getLocalizedMessage(), e); 56 } 57 58 59 } else if (SystemUtils.IS_OS_LINUX) { 60 61 // TODO create a Linux/UnixPower because (for example) Kubuntu sends KILL signal when it shutdown, it should sent TERM !! 62 } 63 64 65 } 66 67 return desktopPower; 68 } 69 70 }