Author: yradtsevich
Date: 2011-11-04 13:01:13 -0400 (Fri, 04 Nov 2011)
New Revision: 36176
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/DevicesList.java
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/BrowserSim.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Device.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/DevicesManager.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ManageDevicesDialog.java
Log:
https://issues.jboss.org/browse/JBIDE-9539 : Browsersim app for testing mobile/desktop web
apps
- creating model for storing devices is in progress
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/BrowserSim.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/BrowserSim.java 2011-11-04
15:56:49 UTC (rev 36175)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/BrowserSim.java 2011-11-04
17:01:13 UTC (rev 36176)
@@ -170,8 +170,8 @@
}
});
- if (!DevicesManager.getInstance().getDevices().isEmpty()) {
- setDevice(DevicesManager.getInstance().getDevices().get(0));
+ if (!DevicesManager.getInstance().getDevicesList().getDevices().isEmpty()) {
+ setDevice(DevicesManager.getInstance().getDevicesList().getDevices().get(0));
}
shell.open();
browser.setUrl(initialUrl);
@@ -267,7 +267,7 @@
});
Menu devicesMenu = createDropDownMenu(appMenuBar, "Devices");
- for (Device device : DevicesManager.getInstance().getDevices()) {
+ for (Device device : DevicesManager.getInstance().getDevicesList().getDevices()) {
MenuItem deviceMenuItem = new MenuItem(devicesMenu, SWT.RADIO);
deviceMenuItem.setText(device.getName());
deviceMenuItem.setData(device);
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Device.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Device.java 2011-11-04
15:56:49 UTC (rev 36175)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Device.java 2011-11-04
17:01:13 UTC (rev 36176)
@@ -32,31 +32,15 @@
return width;
}
- public void setWidth(int width) {
- this.width = width;
- }
-
public int getHeight() {
return height;
}
- public void setHeight(int height) {
- this.height = height;
- }
-
public String getUserAgent() {
return userAgent;
}
- public void setUserAgent(String userAgent) {
- this.userAgent = userAgent;
- }
-
public String getName() {
return name;
}
-
- public void setName(String name) {
- this.name = name;
- }
}
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/DevicesList.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/DevicesList.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/DevicesList.java 2011-11-04
17:01:13 UTC (rev 36176)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.browsersim;
+
+import java.util.List;
+import java.util.Observable;
+
+/**
+ * An unmodifiable list of {@link Device}s, with modifiable {@link #currentDeviceIndex}.
+ *
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class DevicesList extends Observable {
+ private List<Device> devices;
+ private int currentDeviceIndex;
+
+ public DevicesList(List<Device> devices, int currentDeviceIndex) {
+ this.devices = devices;
+ this.currentDeviceIndex = currentDeviceIndex;
+ }
+
+ public List<Device> getDevices() {
+ return devices;
+ }
+
+ public int getCurrentDeviceIndex() {
+ return currentDeviceIndex;
+ }
+
+ public void setCurrentDeviceIndex(int currentDeviceIndex) {
+ if (this.currentDeviceIndex != currentDeviceIndex) {
+ this.currentDeviceIndex = currentDeviceIndex;
+ setChanged();
+ }
+ }
+}
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/DevicesManager.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/DevicesManager.java 2011-11-04
15:56:49 UTC (rev 36175)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/DevicesManager.java 2011-11-04
17:01:13 UTC (rev 36176)
@@ -12,22 +12,18 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Observable;
/**
* @author Yahor Radtsevich (yradtsevich)
*/
-public class DevicesManager {
+public class DevicesManager extends Observable {
private static DevicesManager instance;
- private List<Device> devices;
+ private DevicesList devicesList;
public static final String IPHONE_OS_4_0_USER_AGENT = "Mozilla/5.0 (iPhone; U; CPU
iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5
Mobile/8A293 Safari/6531.22.7";
- protected DevicesManager() {
- devices = new ArrayList<Device>();
- devices.add(new Device("iPhone 3", 320, 480, IPHONE_OS_4_0_USER_AGENT));
- devices.add(new Device("iPhone 4", 640, 960, IPHONE_OS_4_0_USER_AGENT));
- devices.add(new Device("BlackBerry Bold Touch 9900", 640, 480,
"Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.1+ (KHTML, like
Gecko) Version/6.0.0.246 Mobile Safari/534.1+"));
- devices.add(new Device("Samsung GT-I9100 (Galaxy S II)", 640, 800,
"Mozilla/5.0 (Linux; U; Android 2.3; en-us; GT-I9100 Build/GRH78) AppleWebKit/533.1
(KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"));
+ protected DevicesManager() {
}
public static DevicesManager getInstance() {
@@ -36,8 +32,25 @@
}
return instance;
}
+
+ public DevicesList getDevicesList() {
+ if (devicesList == null) {
+ List<Device> devices = new ArrayList<Device>();
+ devices.add(new Device("Apple iPhone 3", 320, 480,
IPHONE_OS_4_0_USER_AGENT));
+ devices.add(new Device("Apple iPhone 4", 640, 960,
IPHONE_OS_4_0_USER_AGENT));
+ devices.add(new Device("BlackBerry Bold Touch 9900", 640, 480,
"Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.1+ (KHTML, like
Gecko) Version/6.0.0.246 Mobile Safari/534.1+"));
+ devices.add(new Device("Samsung Galaxy S II", 640, 800, "Mozilla/5.0
(Linux; U; Android 2.3; en-us; GT-I9100 Build/GRH78) AppleWebKit/533.1 (KHTML, like Gecko)
Version/4.0 Mobile Safari/533.1"));
+
+ devicesList = new DevicesList(devices, 0);
+ }
+
+ return devicesList;
+ }
- public List<Device> getDevices() {
- return devices;
+ public void setDevicesList(DevicesList devicesList) {
+ if (this.devicesList != devicesList) {
+ this.devicesList = devicesList;
+ setChanged();
+ }
}
}
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ManageDevicesDialog.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ManageDevicesDialog.java 2011-11-04
15:56:49 UTC (rev 36175)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ManageDevicesDialog.java 2011-11-04
17:01:13 UTC (rev 36176)
@@ -102,7 +102,7 @@
public void widgetSelected(SelectionEvent e) {
Device newDevice = (Device) new EditDevicesDialog(shell, SWT.APPLICATION_MODAL |
SWT.SHELL_TRIM).open();
if (newDevice != null) {
- DevicesManager.getInstance().getDevices().add(newDevice);
+ DevicesManager.getInstance().getDevicesList().getDevices().add(newDevice);
updateDevices();
}
}
@@ -139,7 +139,7 @@
public void updateDevices() {
table.removeAll();
- for (Device device : DevicesManager.getInstance().getDevices()) {
+ for (Device device : DevicesManager.getInstance().getDevicesList().getDevices()) {
TableItem tableItem = new TableItem(table, SWT.NONE);
tableItem.setText(new String[] {device.getName(), String.valueOf(device.getWidth()),
String.valueOf(device.getHeight()), device.getUserAgent()});
}