Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2013-10-11 11:14:50 +0000
committerTom Schindl2013-10-11 11:14:50 +0000
commitab07174d53d9ce1cee07df6dd58bfdefdc25a61e (patch)
tree56a84089fe7e310055ff948a5f62194df4f74429 /bundles/tooling
parent110bf9c4ec2c8670293022cdf0595e1a2ad19f3d (diff)
downloadorg.eclipse.efxclipse-ab07174d53d9ce1cee07df6dd58bfdefdc25a61e.tar.gz
org.eclipse.efxclipse-ab07174d53d9ce1cee07df6dd58bfdefdc25a61e.tar.xz
org.eclipse.efxclipse-ab07174d53d9ce1cee07df6dd58bfdefdc25a61e.zip
Bug 419042 - Add a small mobile framework
Diffstat (limited to 'bundles/tooling')
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/META-INF/MANIFEST.MF1
-rw-r--r--bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/src/org/eclipse/fx/ide/ui/mobile/sim/device/MobileDeviceSimulator.java96
2 files changed, 97 insertions, 0 deletions
diff --git a/bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/META-INF/MANIFEST.MF b/bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/META-INF/MANIFEST.MF
index ba745ef02..7f89bd645 100644
--- a/bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/META-INF/MANIFEST.MF
+++ b/bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/META-INF/MANIFEST.MF
@@ -41,3 +41,4 @@ Export-Package: org.eclipse.fx.ide.ui.mobile.sim.device,
org.eclipse.fx.ide.ui.mobile.sim.device.android.galaxyS3,
org.eclipse.fx.ide.ui.mobile.sim.device.ios.ipad,
org.eclipse.fx.ide.ui.mobile.sim.device.ios.iphone
+Require-Bundle: org.eclipse.fx.ui.mobile;bundle-version="0.9.0"
diff --git a/bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/src/org/eclipse/fx/ide/ui/mobile/sim/device/MobileDeviceSimulator.java b/bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/src/org/eclipse/fx/ide/ui/mobile/sim/device/MobileDeviceSimulator.java
new file mode 100644
index 000000000..220a6e7f0
--- /dev/null
+++ b/bundles/tooling/org.eclipse.fx.ide.ui.mobile.sim.device/src/org/eclipse/fx/ide/ui/mobile/sim/device/MobileDeviceSimulator.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2013 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.ide.ui.mobile.sim.device;
+
+import javafx.application.Application;
+import javafx.scene.Parent;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+
+import org.eclipse.fx.ide.ui.mobile.sim.device.android.galaxyNote2.AndroidTabletHorizontalDevice;
+import org.eclipse.fx.ide.ui.mobile.sim.device.android.galaxyNote2.AndroidTabletVerticalDevice;
+import org.eclipse.fx.ide.ui.mobile.sim.device.android.galaxyS3.AndroidPhoneHorizontalDevice;
+import org.eclipse.fx.ide.ui.mobile.sim.device.android.galaxyS3.AndroidPhoneVerticalDevice;
+import org.eclipse.fx.ide.ui.mobile.sim.device.ios.ipad.AppleIPadHorizontalDevice;
+import org.eclipse.fx.ide.ui.mobile.sim.device.ios.ipad.AppleIPadVerticalDevice;
+import org.eclipse.fx.ide.ui.mobile.sim.device.ios.iphone.AppleIPhone4HorizontalDevice;
+import org.eclipse.fx.ide.ui.mobile.sim.device.ios.iphone.AppleIPhone4VerticalDevice;
+import org.eclipse.fx.ui.mobile.MobileApp;
+
+public class MobileDeviceSimulator extends Application {
+ public static final String DEVICE_TYPE = "-deviceType";
+ public static final String DEVICE_ORIENTATION = "-deviceOrientation";
+ public static final String DISPLAYSIZE = "-displaySize";
+ public static final String APPLICATION_CLASS = "-applicationClass";
+
+ private static String[] ARGS;
+
+ public static void main(String[] args) {
+ ARGS = args;
+ launch(args);
+ }
+
+ @Override
+ public void start(Stage primaryStage) throws Exception {
+ BasicDevice dev = createDevice();
+ Parent root = (Parent) dev.getSimulatorNode();
+
+ String mainClass = findParam(APPLICATION_CLASS, null);
+ if( mainClass != null ) {
+ Class<MobileApp> clazz = (Class<MobileApp>) Class.class.forName(mainClass);
+ MobileApp app = clazz.newInstance();
+ dev.setContent(app.createUI());
+ }
+
+ primaryStage.setScene(new Scene(root));
+ primaryStage.show();
+ }
+
+ private BasicDevice createDevice() {
+ String type = findParam(DEVICE_TYPE,null);
+ String orientation = findParam(DEVICE_ORIENTATION,"vertical");
+ String displaySize = findParam(DEVICE_ORIENTATION,"1024x768");
+
+ int width = Integer.parseInt(displaySize.substring(0,displaySize.indexOf('x')));
+ int height = Integer.parseInt(displaySize.substring(displaySize.indexOf('x')+1));
+
+ if( orientation.equals("vertical") ) {
+ if( "android-phone".equals(type) ) {
+ return new AndroidPhoneVerticalDevice(width, height);
+ } else if( "android-tablet".equals(type) ) {
+ return new AndroidTabletVerticalDevice(width, height);
+ } else if( "ipad".equals(type) ) {
+ return new AppleIPadVerticalDevice(width, height);
+ } else {
+ return new AppleIPhone4VerticalDevice(width, height);
+ }
+ } else {
+ if( "android-phone".equals(type) ) {
+ return new AndroidPhoneHorizontalDevice(width, height);
+ } else if( "android-tablet".equals(type) ) {
+ return new AndroidTabletHorizontalDevice(width, height);
+ } else if( "ipad".equals(type) ) {
+ return new AppleIPadHorizontalDevice(width, height);
+ } else {
+ return new AppleIPhone4HorizontalDevice(width, height);
+ }
+ }
+ }
+
+ private static String findParam(String name, String defaultValue) {
+ for( int i = 0; i < ARGS.length; i++ ) {
+ if( name.equals(ARGS[i]) ) {
+ return ARGS[i+1];
+ }
+ }
+ return defaultValue;
+ }
+} \ No newline at end of file

Back to the top