Author: yradtsevich
Date: 2011-11-02 15:14:44 -0400 (Wed, 02 Nov 2011)
New Revision: 36136
Added:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ManageDevicesDialog.java
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/BrowserSim.java
Log:
https://issues.jboss.org/browse/JBIDE-9539 : Browsersim app for testing mobile/desktop web
apps
- created the ManageDevicesDialog for adding/removing devices
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-02
17:59:07 UTC (rev 36135)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/BrowserSim.java 2011-11-02
19:14:44 UTC (rev 36136)
@@ -14,7 +14,6 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.eclipse.swt.SWT;
@@ -288,6 +287,15 @@
}
});
}
+
+ new MenuItem(devicesMenu, SWT.BAR);
+ MenuItem manageDevicesMenuItem = new MenuItem(devicesMenu, SWT.PUSH);
+ manageDevicesMenuItem.setText("Manage Devices...");
+ manageDevicesMenuItem.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ new ManageDevicesDialog(shell, SWT.APPLICATION_MODAL | SWT.SHELL_TRIM).open();
+ }
+ });
}
private Menu createDropDownMenu(Menu menuBar, String name) {
Added:
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
(rev 0)
+++
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ManageDevicesDialog.java 2011-11-02
19:14:44 UTC (rev 36136)
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * 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 org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Dialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+/**
+ * @author Yahor Radtsevich (yradtsevich)
+ */
+public class ManageDevicesDialog extends Dialog {
+
+ protected Object result;
+ protected Shell shell;
+
+
+ private Table table;
+
+ /**
+ * Create the dialog.
+ * @param parent
+ * @param style
+ */
+ public ManageDevicesDialog(Shell parent, int style) {
+ super(parent, style);
+ setText("Devices");
+ }
+
+ /**
+ * Open the dialog.
+ * @return the result
+ */
+ public Object open() {
+ createContents();
+ shell.open();
+ shell.layout();
+ Display display = getParent().getDisplay();
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Create contents of the dialog.
+ */
+ private void createContents() {
+ shell = new Shell(getParent(), getStyle());
+ shell.setSize(450, 300);
+ shell.setText(getText());
+ shell.setLayout(new GridLayout(2, false));
+
+ table = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION);
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ TableColumn tableColumnName = new TableColumn(table, SWT.NONE);
+ tableColumnName.setWidth(100);
+ tableColumnName.setText("Name");
+
+ TableColumn tableColumnWidth = new TableColumn(table, SWT.NONE);
+ tableColumnWidth.setWidth(100);
+ tableColumnWidth.setText("Width");
+
+ TableColumn tableColumnHeight = new TableColumn(table, SWT.NONE);
+ tableColumnHeight.setWidth(100);
+ tableColumnHeight.setText("Height");
+
+ TableColumn tableColumnUseragent = new TableColumn(table, SWT.NONE);
+ tableColumnUseragent.setWidth(100);
+ tableColumnUseragent.setText("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");
+
+ Button buttonEdit = new Button(compositeControls, SWT.NONE);
+ buttonEdit.setText("Edit");
+
+ Button buttonRemove = new Button(compositeControls, SWT.NONE);
+ buttonRemove.setText("Remove");
+
+ Button buttonReset = new Button(compositeControls, SWT.NONE);
+ buttonReset.setText("Reset");
+
+ Composite compositeOkCancel = new Composite(shell, SWT.NONE);
+ compositeOkCancel.setLayout(new FillLayout(SWT.HORIZONTAL));
+ compositeOkCancel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 2,
1));
+
+ Button buttonOk = new Button(compositeOkCancel, SWT.NONE);
+ buttonOk.setText("OK");
+
+ Button buttonCancel = new Button(compositeOkCancel, SWT.NONE);
+ buttonCancel.setText("Cancel");
+ }
+
+}