+++ /dev/null
-/*
- * Copyright (c) 2012 Intel Corporation. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.tizen.web.simulator;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.Properties;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-public class PreferenceInitializer extends AbstractPreferenceInitializer {
-
- private static final String ENV_USERPROFILE = "USERPROFILE";
- private static final String ENV_LOCALAPPDATA = "LOCALAPPDATA";
- private static final String WIN_VER_6 = "6";
- private static final String OS_VERSION = "os.version";
- private static final String CHROME_LINUX = "/opt/google/chrome/google-chrome";
- private static final String CHROME_WIN = "\\Google\\Chrome\\Application\\chrome.exe";
- private static final String CHROME_MACOS = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
-
- public PreferenceInitializer() {
- }
-
- @Override
- public void initializeDefaultPreferences() {
- reinitializeDefaultPreferences();
- }
-
- public static void reinitializeDefaultPreferences(){
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- //the process of finding Chrome is according to the start script of WebSimulatorAIO
- String os = Platform.getOS();
- String chrome;
- if (os.equals(Platform.OS_MACOSX)) {
- chrome = CHROME_MACOS;
- } else if (os.equals(Platform.OS_WIN32)) {
- String chromeDir;
- if (System.getProperty(OS_VERSION).startsWith(WIN_VER_6))
- chromeDir = System.getenv(ENV_LOCALAPPDATA);
- else
- // XP does not have LOCALAPPDATA environment variable
- chromeDir = System.getenv(ENV_USERPROFILE) + File.separator + "Local Settings" + File.separator + "Application Data";
- chrome = chromeDir + CHROME_WIN;
- } else {
- chrome = CHROME_LINUX;
- }
- StringBuffer simulatorPath = new StringBuffer();
- StringBuffer simulatorLoc = new StringBuffer();
- simulatorLoc.append(System.getProperty("user.home"));
- simulatorLoc.append("/.TizenSDK/tizensdkpath");
- Properties pro = new Properties();
- try {
- pro.load(new FileInputStream(simulatorLoc.toString()));
- simulatorPath.append(pro.getProperty("TIZEN_SDK_INSTALLED_PATH"));
- simulatorPath.append("/Simulator/web/index.html");
- } catch (Exception e) {
- System.out.println("cannot find the simulator exec path");
- }
- store.setDefault(Settings.CHROME_EXECUTABLE, chrome);
- store.setDefault(Settings.EXTRA_PARAM, "");
- store.setDefault(Settings.USE_INTERNAL_SIMULATOR, Settings.FALSE);
- store.setDefault(Settings.SIMULATOR_PATH, simulatorPath.toString());
- store.setDefault(Settings.APP_MODE, true);
- }
-}
+++ /dev/null
-/*
- * Copyright (c) 2012 Intel Corporation. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.tizen.web.simulator;
-
-import org.eclipse.jface.preference.*;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
-public class WorkbenchPreferencePage extends FieldEditorPreferencePage implements
- IWorkbenchPreferencePage {
-
- public WorkbenchPreferencePage () {
- super(FLAT);
- }
-
- @Override
- public void init(IWorkbench workbench) {
- this.setPreferenceStore(Activator.getDefault().getPreferenceStore());
- this.setDescription(Messages.msgPreferencePageDescription);
- }
-
- protected Control createContents(Composite parent) {
- Composite page = new Composite(parent, SWT.NONE);
- page.setLayout(new GridLayout());
-
- Group grpChrome = new Group(page, SWT.NONE);
- grpChrome.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- grpChrome.setLayout(new GridLayout());
- grpChrome.setText(Messages.Chrome_Settings);
- addField(new FileFieldEditor(Settings.CHROME_EXECUTABLE, Messages.Chrome_excutable, new FieldEditorComposite(grpChrome)){
- @Override
- //The executable may be in the path, so we don't check it's existence.
- protected boolean checkState() {
- clearErrorMessage();
- return true;
- }
- });
- addField(new StringFieldEditor(Settings.EXTRA_PARAM,Messages.Extra_parameters, new FieldEditorComposite(grpChrome)));
-
- Group grpSimulator = new Group(page, SWT.NONE);
- grpSimulator.setLayoutData( new GridData(GridData.FILL_HORIZONTAL));
- grpSimulator.setLayout(new GridLayout());
- grpSimulator.setText(Messages.Simulator_Settings);
- RadioGroupFieldEditor feUseInternal = new RadioGroupFieldEditor(Settings.USE_INTERNAL_SIMULATOR,Messages.Simulator_to_use, 1,
- new String[][]{ { Messages.Internal, Settings.TRUE },
- { Messages.User_specified, Settings.FALSE } }, new FieldEditorComposite(grpSimulator));
- addField(feUseInternal);
- final Composite cpSimulatorDir = new FieldEditorComposite(grpSimulator);
- final FieldEditor feSimulatorDir = new FileFieldEditor(Settings.SIMULATOR_PATH, Messages.EightSpacesIndent, cpSimulatorDir);
- addField(feSimulatorDir);
- addField(new BooleanFieldEditor(Settings.APP_MODE,Messages.Launch_in_app_mode, new FieldEditorComposite(grpSimulator)));
-
- initialize();
-
- feUseInternal.setPropertyChangeListener( new IPropertyChangeListener () {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- feSimulatorDir.setEnabled(Settings.FALSE.equals(event.getNewValue()), cpSimulatorDir);
- }});
- feSimulatorDir.setEnabled(Settings.FALSE.equals(getPreferenceStore().getString(Settings.USE_INTERNAL_SIMULATOR)), cpSimulatorDir);
-
- checkState();
- return page;
- }
-
- @Override
- protected void performDefaults () {
- PreferenceInitializer.reinitializeDefaultPreferences();
- super.performDefaults();
- }
-
- @Override
- protected void createFieldEditors() {
-
- }
-}
-
-class FieldEditorComposite extends Composite{
- FieldEditorComposite (Composite parent) {
- super(parent, SWT.NONE);
- this.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
-}
-