/* * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package org.eclipse.visualvm.launcher.preferences; import java.io.File; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.visualvm.launcher.Activator; /** * Class used to initialize default preference values. */ public class PreferenceInitializer extends AbstractPreferenceInitializer { /* * (non-Javadoc) * * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() */ public void initializeDefaultPreferences() { IPreferenceStore store = Activator.getDefault().getPreferenceStore(); String JAVA_HOME = System.getProperty("java.home"); if (JAVA_HOME.endsWith(File.separator + "jre")) { JAVA_HOME = JAVA_HOME.substring(0, JAVA_HOME.length() - 4); } File visualvm = new File(JAVA_HOME + File.separator + "bin" + File.separator + "jvisualvm"); if (visualvm.exists()) { store.setDefault(PreferenceConstants.P_PATH, visualvm.getAbsolutePath()); } else { store.setDefault(PreferenceConstants.P_PATH, ""); } store.setDefault(PreferenceConstants.P_JAVAHOME, JAVA_HOME); // store.setDefault(PreferenceConstants.P_BOOLEAN, true); // store.setDefault(PreferenceConstants.P_CHOICE, "choice2"); // store.setDefault(PreferenceConstants.P_STRING, // "Default value"); } }