Author: yradtsevich
Date: 2011-11-10 12:35:00 -0500 (Thu, 10 Nov 2011)
New Revision: 36281
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Messages.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/NLS.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/messages.properties
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/config/
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/config/devices.cfg
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.eclipse/src/org/jboss/tools/browsersim/eclipse/util/BrowserSimLauncher.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/META-INF/MANIFEST.MF
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/DevicesManager.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/EditDeviceDialog.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
- externalized dialogs' messages
- added loading of devices list from config file
- added logging to console
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/META-INF/MANIFEST.MF
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/META-INF/MANIFEST.MF 2011-11-10
16:24:16 UTC (rev 36280)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/META-INF/MANIFEST.MF 2011-11-10
17:35:00 UTC (rev 36281)
@@ -5,6 +5,5 @@
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.swt;bundle-version="3.7.0",
- org.jboss.tools.browsersim.webkit;bundle-version="1.0.0",
- org.eclipse.core.runtime;bundle-version="3.7.0"
+ org.jboss.tools.browsersim.webkit;bundle-version="1.0.0"
Export-Package: org.jboss.tools.browsersim
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-10
16:24:16 UTC (rev 36280)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/BrowserSim.java 2011-11-10
17:35:00 UTC (rev 36281)
@@ -10,11 +10,12 @@
******************************************************************************/
package org.jboss.tools.browsersim;
+import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
-import java.util.List;
import java.util.Observable;
import java.util.Observer;
@@ -33,6 +34,7 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.internal.win32.DLLVERSIONINFO;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
@@ -53,7 +55,7 @@
* @author Yahor Radtsevich (yradtsevich)
*/
public class BrowserSim implements Runnable {
- private static final String DEFAULT_URL =
"http://www.w3schools.com/js/tryit_view.asp?filename=try_nav_useragent";
+ private static final String DEFAULT_URL =
"http://www.w3schools.com/js/tryit_view.asp?filename=try_nav_useragent";
//$NON-NLS-1$
private AbstractWebKitBrowser browser;
private Display display;
private Shell shell;
@@ -89,7 +91,7 @@
@Override
public void run() {
shell = new Shell(display);
- shell.setText("BrowserSim");
+ shell.setText(Messages.BrowserSim_BROWSER_SIM);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
shell.setLayout(gridLayout);
@@ -105,7 +107,7 @@
toolbar.setLayoutData(data);
Label labelAddress = new Label(shell, SWT.NONE);
- labelAddress.setText("Address");
+ labelAddress.setText(Messages.BrowserSim_ADDRESS);
locationText = new Text(shell, SWT.BORDER);
data = new GridData();
@@ -118,7 +120,7 @@
try {
browser = WebKitBrowserFactory.createWebKitBrowser(shell, SWT.NONE);
} catch (SWTError e) {
- System.out.println("Could not instantiate Browser: " + e.getMessage());
+ System.out.println(Messages.BrowserSim_COULD_NOT_INSTANTIATE_BROWSER +
e.getMessage());
display.dispose();
return;
}
@@ -228,11 +230,11 @@
}
});
- final Image imageBack = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_backward.gif"));
- final Image imageForward = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_forward.gif"));
- final Image imageStop = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_stop.gif"));
- final Image imageRefresh = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_refresh.gif"));
- final Image imageGo = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_go.gif"));
+ final Image imageBack = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_backward.gif"));
//$NON-NLS-1$
+ final Image imageForward = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_forward.gif"));
//$NON-NLS-1$
+ final Image imageStop = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_stop.gif"));
//$NON-NLS-1$
+ final Image imageRefresh = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_refresh.gif"));
//$NON-NLS-1$
+ final Image imageGo = new Image(display,
getResourceAsStream("/org/jboss/tools/browsersim/resources/icons/nav_go.gif"));
//$NON-NLS-1$
itemBack.setImage(imageBack);
itemForward.setImage(imageForward);
@@ -258,18 +260,22 @@
private InputStream getResourceAsStream(String name) {
return this.getClass().getResourceAsStream(name);
}
+
+ private File getResourceAsFile(String name) {
+ return new File(this.getClass().getResource(name).getFile());
+ }
public void fillMenuBar(Menu appMenuBar) {
- Menu file = createDropDownMenu(appMenuBar, "File");
+ Menu file = createDropDownMenu(appMenuBar, Messages.BrowserSim_FILE);
MenuItem exit = new MenuItem(file, SWT.PUSH);
- exit.setText("Exit");
+ exit.setText(Messages.BrowserSim_EXIT);
exit.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
display.dispose();
};
});
- devicesMenu = createDropDownMenu(appMenuBar, "Devices");
+ devicesMenu = createDropDownMenu(appMenuBar, Messages.BrowserSim_DEVICES);
devicesManager = DevicesManager.getInstance();
devicesManager.addObserver(new Observer() {
public void update(Observable o, Object arg) {
@@ -284,12 +290,20 @@
});
}
});
- devicesManager.setDevicesList(DevicesManager.getDefaultDevicesList());
+
+ DevicesList devicesList;
+ try {
+ devicesList = DevicesManager.loadDevicesList(getResourceAsFile(
+ "/org/jboss/tools/browsersim/resources/config/devices.cfg"));
+ } catch (IOException e) {
+ devicesList = new DevicesList(new ArrayList<Device>(), 0);
+ }
+ devicesManager.setDevicesList(devicesList);
devicesManager.notifyObservers();
new MenuItem(devicesMenu, SWT.BAR);
MenuItem manageDevicesMenuItem = new MenuItem(devicesMenu, SWT.PUSH);
- manageDevicesMenuItem.setText("Manage Devices...");
+ manageDevicesMenuItem.setText(Messages.BrowserSim_MORE);
manageDevicesMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DevicesList newDevicesList = new ManageDevicesDialog(shell, SWT.APPLICATION_MODAL |
SWT.SHELL_TRIM,
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-10
16:24:16 UTC (rev 36280)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/DevicesManager.java 2011-11-10
17:35:00 UTC (rev 36281)
@@ -52,15 +52,12 @@
}
}
- public static DevicesList getDefaultDevicesList() {
- 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"));
-
- return new DevicesList(devices, 0);
- }
+// 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"));
+
public static String encode(String string) {
return string.replace("\\", "\\\\").replace("\n",
"\\n").replace("\t", "\\t");
@@ -91,6 +88,8 @@
result.append(c0);
break;
}
+ } else {
+ result.append(c0);
}
i++;
}
@@ -130,7 +129,7 @@
if (nextLine != null) {
selectedDeviceIndex = Integer.parseInt(nextLine);
}
- Pattern devicePattern =
Pattern.compile("(.*)\\t([0-9]*)\\t([0-9]*)\\t(.*)");
+ Pattern devicePattern =
Pattern.compile("^(.*)\\t([0-9]*)\\t([0-9]*)\\t(.*)$");
List<Device> devices = new ArrayList<Device>();
while ((nextLine = reader.readLine()) != null) {
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/EditDeviceDialog.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/EditDeviceDialog.java 2011-11-10
16:24:16 UTC (rev 36280)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/EditDeviceDialog.java 2011-11-10
17:35:00 UTC (rev 36281)
@@ -34,7 +34,7 @@
*/
public EditDeviceDialog(Shell parent, int style, Device initialDevice) {
super(parent, style);
- setText("SWT Dialog");
+ setText(Messages.EditDeviceDialog_MANAGE_DEVICES);
this.initialDevice = initialDevice;
}
@@ -63,12 +63,12 @@
private void createContents() {
shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX);
shell.setSize(450, 300);
- shell.setText("Edit Device");
+ shell.setText(Messages.EditDeviceDialog_EDIT_DEVICE);
shell.setLayout(new GridLayout(2, false));
Label labelName = new Label(shell, SWT.NONE);
labelName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- labelName.setText("Name:");
+ labelName.setText(Messages.EditDeviceDialog_NAME);
textName = new Text(shell, SWT.BORDER);
textName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
@@ -77,7 +77,7 @@
Label labelWidth = new Label(shell, SWT.NONE);
labelWidth.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- labelWidth.setText("Width:");
+ labelWidth.setText(Messages.EditDeviceDialog_WIDTH);
textWidth = new Text(shell, SWT.BORDER);
textWidth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
@@ -89,7 +89,7 @@
Label labelHeight = new Label(shell, SWT.NONE);
labelHeight.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- labelHeight.setText("Height:");
+ labelHeight.setText(Messages.EditDeviceDialog_HEIGHT);
textHeight = new Text(shell, SWT.BORDER);
textHeight.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
@@ -101,7 +101,7 @@
Label labelUseragent = new Label(shell, SWT.NONE);
labelUseragent.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- labelUseragent.setText("User-Agent:");
+ labelUseragent.setText(Messages.EditDeviceDialog_USER_AGENT);
textUserAgent = new Text(shell, SWT.BORDER);
textUserAgent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
@@ -113,7 +113,7 @@
composite.setLayoutData(new GridData(SWT.RIGHT, SWT.BOTTOM, true, true, 2, 1));
Button buttonOk = new Button(composite, SWT.NONE);
- buttonOk.setText("OK");
+ buttonOk.setText(Messages.EditDeviceDialog_OK);
buttonOk.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
resultDevice = new Device(textName.getText(), Integer.valueOf(textWidth.getText()),
@@ -124,7 +124,7 @@
shell.setDefaultButton(buttonOk);
Button buttonCancel = new Button(composite, SWT.NONE);
- buttonCancel.setText("Cancel");
+ buttonCancel.setText(Messages.EditDeviceDialog_CANCEL);
buttonCancel.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
resultDevice = null;
@@ -149,7 +149,7 @@
public void focusLost(FocusEvent e) {
Text text = ((Text) e.widget);
if (text.getText().trim().isEmpty()) {
- text.setText("0");
+ text.setText("0"); //$NON-NLS-1$
}
}
}
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-10
16:24:16 UTC (rev 36280)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ManageDevicesDialog.java 2011-11-10
17:35:00 UTC (rev 36281)
@@ -47,7 +47,7 @@
*/
public ManageDevicesDialog(Shell parent, int style, DevicesList oldDevicesList) {
super(parent, style);
- setText("Devices");
+ setText(Messages.ManageDevicesDialog_DEVICES);
this.oldDevicesList = oldDevicesList;
this.devices = new ArrayList<Device>(oldDevicesList.getDevices());
this.selectedDeviceIndex = oldDevicesList.getSelectedDeviceIndex();
@@ -91,30 +91,30 @@
TableColumn tableColumnName = new TableColumn(table, SWT.NONE);
tableColumnName.setWidth(100);
- tableColumnName.setText("Name");
+ tableColumnName.setText(Messages.ManageDevicesDialog_NAME);
TableColumn tableColumnWidth = new TableColumn(table, SWT.NONE);
tableColumnWidth.setWidth(100);
- tableColumnWidth.setText("Width");
+ tableColumnWidth.setText(Messages.ManageDevicesDialog_WIDTH);
TableColumn tableColumnHeight = new TableColumn(table, SWT.NONE);
tableColumnHeight.setWidth(100);
- tableColumnHeight.setText("Height");
+ tableColumnHeight.setText(Messages.ManageDevicesDialog_HEIGHT);
TableColumn tableColumnUseragent = new TableColumn(table, SWT.NONE);
tableColumnUseragent.setWidth(100);
- tableColumnUseragent.setText("User-Agent");
+ tableColumnUseragent.setText(Messages.ManageDevicesDialog_USER_AGENT);
Composite compositeControls = new Composite(shell, SWT.NONE);
compositeControls.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1));
compositeControls.setLayout(new FillLayout(SWT.VERTICAL));
Button buttonAdd = new Button(compositeControls, SWT.NONE);
- buttonAdd.setText("Add");
+ buttonAdd.setText(Messages.ManageDevicesDialog_ADD);
buttonAdd.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Device newDevice = new EditDeviceDialog(shell, SWT.APPLICATION_MODAL |
SWT.SHELL_TRIM,
- new Device("Some Device", 480, 800, "Some User
Agent")).open();
+ new Device(Messages.ManageDevicesDialog_NEW_DEVICE, 480, 800,
Messages.ManageDevicesDialog_NEW_USER_AGENT)).open();
if (newDevice != null) {
devices.add(newDevice);
selectedDeviceIndex = devices.size() - 1;
@@ -124,7 +124,7 @@
});
Button buttonEdit = new Button(compositeControls, SWT.NONE);
- buttonEdit.setText("Edit");
+ buttonEdit.setText(Messages.ManageDevicesDialog_EDIT);
buttonEdit.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Device newDevice = new EditDeviceDialog(shell, SWT.APPLICATION_MODAL |
SWT.SHELL_TRIM,
@@ -138,7 +138,7 @@
});
Button buttonRemove = new Button(compositeControls, SWT.NONE);
- buttonRemove.setText("Remove");
+ buttonRemove.setText(Messages.ManageDevicesDialog_REMOVE);
buttonRemove.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
System.out.println(devices.size());
@@ -153,7 +153,7 @@
});
Button buttonReset = new Button(compositeControls, SWT.NONE);
- buttonReset.setText("Reset");
+ buttonReset.setText(Messages.ManageDevicesDialog_RESET);
buttonReset.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
devices = new ArrayList<Device>(oldDevicesList.getDevices());
@@ -167,7 +167,7 @@
compositeOkCancel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 2,
1));
Button buttonOk = new Button(compositeOkCancel, SWT.NONE);
- buttonOk.setText("OK");
+ buttonOk.setText(Messages.ManageDevicesDialog_OK);
shell.setDefaultButton(buttonOk);
buttonOk.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
@@ -177,7 +177,7 @@
});
Button buttonCancel = new Button(compositeOkCancel, SWT.NONE);
- buttonCancel.setText("Cancel");
+ buttonCancel.setText(Messages.ManageDevicesDialog_CANCEL);
buttonCancel.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
resultDevicesList = null;
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Messages.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Messages.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/Messages.java 2011-11-10
17:35:00 UTC (rev 36281)
@@ -0,0 +1,39 @@
+package org.jboss.tools.browsersim;
+
+public class Messages {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.browsersim.messages"; //$NON-NLS-1$
+ public static String BrowserSim_ADDRESS;
+ public static String BrowserSim_BROWSER_SIM;
+ public static String BrowserSim_COULD_NOT_INSTANTIATE_BROWSER;
+ public static String BrowserSim_DEVICES;
+ public static String BrowserSim_EXIT;
+ public static String BrowserSim_FILE;
+ public static String BrowserSim_MORE;
+ public static String EditDeviceDialog_CANCEL;
+ public static String EditDeviceDialog_EDIT_DEVICE;
+ public static String EditDeviceDialog_HEIGHT;
+ public static String EditDeviceDialog_MANAGE_DEVICES;
+ public static String EditDeviceDialog_NAME;
+ public static String EditDeviceDialog_OK;
+ public static String EditDeviceDialog_USER_AGENT;
+ public static String EditDeviceDialog_WIDTH;
+ public static String ManageDevicesDialog_ADD;
+ public static String ManageDevicesDialog_CANCEL;
+ public static String ManageDevicesDialog_DEVICES;
+ public static String ManageDevicesDialog_EDIT;
+ public static String ManageDevicesDialog_HEIGHT;
+ public static String ManageDevicesDialog_NAME;
+ public static String ManageDevicesDialog_NEW_DEVICE;
+ public static String ManageDevicesDialog_NEW_USER_AGENT;
+ public static String ManageDevicesDialog_OK;
+ public static String ManageDevicesDialog_REMOVE;
+ public static String ManageDevicesDialog_RESET;
+ public static String ManageDevicesDialog_USER_AGENT;
+ public static String ManageDevicesDialog_WIDTH;
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/NLS.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/NLS.java
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/NLS.java 2011-11-10
17:35:00 UTC (rev 36281)
@@ -0,0 +1,33 @@
+package org.jboss.tools.browsersim;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class NLS {
+ private static final int MOD_EXPECTED = Modifier.PUBLIC | Modifier.STATIC;
+
+ private NLS(){};
+
+ public static void initializeMessages(String bundleName, Class<?> clazz) {
+ ResourceBundle resourceBundle = ResourceBundle.getBundle(bundleName);
+
+ try {
+ for (Field field : clazz.getDeclaredFields()) {
+ // if it is a public static uninitialized String field
+ if ((field.getModifiers() & MOD_EXPECTED) == MOD_EXPECTED
+ && field.getType() == String.class
+ && field.get(null) == null) {
+ try {
+ field.set(null, resourceBundle.getString(field.getName()));
+ } catch (MissingResourceException e) {
+ field.set(null, '!' + field.getName() + '!');
+ }
+ }
+ }
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+}
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/messages.properties
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/messages.properties
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/messages.properties 2011-11-10
17:35:00 UTC (rev 36281)
@@ -0,0 +1,28 @@
+BrowserSim_ADDRESS=Address
+BrowserSim_BROWSER_SIM=BrowserSim
+BrowserSim_COULD_NOT_INSTANTIATE_BROWSER=Could not instantiate Browser:
+BrowserSim_DEVICES=Devices
+BrowserSim_EXIT=Exit
+BrowserSim_FILE=File
+BrowserSim_MORE=More...
+EditDeviceDialog_CANCEL=Cancel
+EditDeviceDialog_EDIT_DEVICE=Edit Device
+EditDeviceDialog_HEIGHT=Height:
+EditDeviceDialog_MANAGE_DEVICES=Manage Devices
+EditDeviceDialog_NAME=Name:
+EditDeviceDialog_OK=OK
+EditDeviceDialog_USER_AGENT=User-Agent:
+EditDeviceDialog_WIDTH=Width:
+ManageDevicesDialog_ADD=Add
+ManageDevicesDialog_CANCEL=Cancel
+ManageDevicesDialog_DEVICES=Devices
+ManageDevicesDialog_EDIT=Edit
+ManageDevicesDialog_HEIGHT=Height
+ManageDevicesDialog_NAME=Name
+ManageDevicesDialog_NEW_DEVICE=New Device
+ManageDevicesDialog_NEW_USER_AGENT=New User-Agent
+ManageDevicesDialog_OK=OK
+ManageDevicesDialog_REMOVE=Remove
+ManageDevicesDialog_RESET=Reset
+ManageDevicesDialog_USER_AGENT=User-Agent
+ManageDevicesDialog_WIDTH=Width
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/config/devices.cfg
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/config/devices.cfg
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/config/devices.cfg 2011-11-10
17:35:00 UTC (rev 36281)
@@ -0,0 +1,5 @@
+0
+Apple iPhone 3 320 480 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
+Apple iPhone 4 640 960 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
+RIM 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+
+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
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.eclipse/src/org/jboss/tools/browsersim/eclipse/util/BrowserSimLauncher.java
===================================================================
---
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.eclipse/src/org/jboss/tools/browsersim/eclipse/util/BrowserSimLauncher.java 2011-11-10
16:24:16 UTC (rev 36280)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim.eclipse/src/org/jboss/tools/browsersim/eclipse/util/BrowserSimLauncher.java 2011-11-10
17:35:00 UTC (rev 36281)
@@ -10,7 +10,10 @@
******************************************************************************/
package org.jboss.tools.browsersim.eclipse.util;
+import java.io.BufferedInputStream;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -51,7 +54,35 @@
}
try {
- Process child = Runtime.getRuntime().exec(commandElements.toArray(new String[0]));
+ ProcessBuilder processBuilder = new ProcessBuilder(commandElements);
+ Process browserSimProcess = processBuilder.start();
+ BufferedInputStream j;
+ final InputStream errorStream = browserSimProcess.getErrorStream();
+ final InputStream inputStream = browserSimProcess.getInputStream();
+ new Thread() {
+ public void run() {
+ int nextByte;
+ try {
+ while ((nextByte = inputStream.read()) >= 0) {
+ System.out.write(nextByte);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ };
+ }.start();
+ new Thread() {
+ public void run() {
+ int nextByte;
+ try {
+ while ((nextByte = errorStream.read()) >= 0) {
+ System.err.write(nextByte);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ };
+ }.start();
} catch (IOException e) {
e.printStackTrace();
}