+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2011 Samsung Electronics Co.
- * For conditions of distribution and use, see http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-package com.samsung.linuxplatform.sensor.motion.page;
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-
-import com.samsung.ide.connection.device.DeviceChecker;
-import com.samsung.ide.connection.device.IDeviceListener;
-import com.samsung.linuxplatform.injector.protocol.sensor.TestSensorMessage;
-import com.samsung.linuxplatform.injector.provider.AbstractInjectorItem;
-import com.samsung.linuxplatform.injector.provider.AbstractInjectorPage;
-
-public class MotionPage extends AbstractInjectorPage implements IDeviceListener {
- private final String sensorNumber = "6\n";
-
- public MotionPage(AbstractInjectorItem item, String name) {
- super(item, name);
- }
-
- @Override
- protected void createContents() {
- Composite mainComposite = formUtil.createComposite(parent, 3);
-
- Button button_doubleTap = formUtil.createButton(mainComposite, "Double Tap", SWT.PUSH);
- Button button_shakeStart = formUtil.createButton(mainComposite, "Shake Start", SWT.PUSH);
- Button button_shakeEnd = formUtil.createButton(mainComposite, "Shake End", SWT.PUSH);
- Button button_snapXp = formUtil.createButton(mainComposite, "Snap X+", SWT.PUSH);
- Button button_snapYp = formUtil.createButton(mainComposite, "Snap Y+", SWT.PUSH);
- Button button_snapZp = formUtil.createButton(mainComposite, "Snap Z+", SWT.PUSH);
- Button button_snapXm = formUtil.createButton(mainComposite, "Snap X-", SWT.PUSH);
- Button button_snapYm = formUtil.createButton(mainComposite, "Snap Y-", SWT.PUSH);
- Button button_snapZm = formUtil.createButton(mainComposite, "Snap Z-", SWT.PUSH);
-
- GridData gd = new GridData(GridData.FILL, GridData.FILL, true, false);
-
- button_doubleTap.setLayoutData(gd);
- button_shakeStart.setLayoutData(gd);
- button_shakeEnd.setLayoutData(gd);
- button_snapXp.setLayoutData(gd);
- button_snapXm.setLayoutData(gd);
- button_snapYp.setLayoutData(gd);
- button_snapYm.setLayoutData(gd);
- button_snapZp.setLayoutData(gd);
- button_snapZm.setLayoutData(gd);
-
- button_doubleTap.addSelectionListener(new SelectionListener(){
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- @Override
- public void widgetSelected(SelectionEvent e) {
- sendMessage(1);
- }
- });
- button_shakeStart.addSelectionListener(new SelectionListener(){
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- @Override
- public void widgetSelected(SelectionEvent e) {
- sendMessage(2);
- }
- });
- button_shakeEnd.addSelectionListener(new SelectionListener(){
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- @Override
- public void widgetSelected(SelectionEvent e) {
- sendMessage(3);
- }
- });
- button_snapXp.addSelectionListener(new SelectionListener(){
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- @Override
- public void widgetSelected(SelectionEvent e) {
- sendMessage(4);
- }
- });
- button_snapXm.addSelectionListener(new SelectionListener(){
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- @Override
- public void widgetSelected(SelectionEvent e) {
- sendMessage(5);
- }
- });
- button_snapYp.addSelectionListener(new SelectionListener(){
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- @Override
- public void widgetSelected(SelectionEvent e) {
- sendMessage(6);
- }
- });
- button_snapYm.addSelectionListener(new SelectionListener(){
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- @Override
- public void widgetSelected(SelectionEvent e) {
- sendMessage(7);
- }
- });
- button_snapZp.addSelectionListener(new SelectionListener(){
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- @Override
- public void widgetSelected(SelectionEvent e) {
- sendMessage(8);
- }
- });
- button_snapZm.addSelectionListener(new SelectionListener(){
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- @Override
- public void widgetSelected(SelectionEvent e) {
- sendMessage(9);
- }
- });
- }
-
- @Override
- protected void registerReceivers() {
- // TODO Auto-generated method stub
-
- }
- public void sendMessage(int level) {
- TestSensorMessage msg = new TestSensorMessage(level);
- try {
- sensorSocket.send(sensorNumber + msg.getMessage());
- } catch (Exception e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
-// DeviceLauncherManager.removeDeviceListener(this);
-// TargetConnectionControl.removeTargetConnectionListener(this);
- super.finalize();
- }
-
- @Override
- public void ConnectionChanged() {
- if (DeviceChecker.hasActiveVirtualDevice( null)) {
-// connect();
- }
- else {
-// disconnect();
- }
- }
-
- @Override
- public void SelectionChanged() {
- // TODO Auto-generated method stub
-
- }
-
-}