Index: org/jboss/tools/vpe/browsersim/ui/BrowserSim.java =================================================================== --- org/jboss/tools/vpe/browsersim/ui/BrowserSim.java (revision 41070) +++ org/jboss/tools/vpe/browsersim/ui/BrowserSim.java (working copy) @@ -67,6 +67,7 @@ public class BrowserSim { private static final String DEFAULT_URL = "about:blank"; //"http://www.w3schools.com/js/tryit_view.asp?filename=try_nav_useragent"; //$NON-NLS-1$ private static final String[] BROWSERSIM_ICONS = {"icons/browsersim_16px.png", "icons/browsersim_32px.png", "icons/browsersim_64px.png", "icons/browsersim_128px.png", "icons/browsersim_256px.png", }; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$ + private static int BROWSERSIM_ICON_32PX_INDEX = 2; private static final String BROWSERSIM_CLASS_NAME = "org.jboss.tools.vpe.browsersim.ui.BrowserSim"; //$NON-NLS-1$ /** @see org.jboss.tools.vpe.browsersim.eclipse.callbacks.OpenFileCallback */ private static final String OPEN_FILE_COMMAND = BROWSERSIM_CLASS_NAME + ".command.openFile:"; //$NON-NLS-1$ @@ -309,6 +310,8 @@ addTurnMenuItems(contextMenu); new MenuItem(contextMenu, SWT.BAR); addFileMenuItems(contextMenu); + new MenuItem(contextMenu, SWT.BAR); + addAbooutItem(contextMenu); } }); } @@ -329,6 +332,8 @@ addTurnMenuItems(devicesMenu); } }); + Menu help = createDropDownMenu(appMenuBar, Messages.BrowserSim_HELP); + addAbooutItem(help); } private void addDevicesMenuItems(final Menu devicesMenu) { @@ -431,7 +436,28 @@ } }); } + + + public void addAbooutItem(Menu menu) { + MenuItem about = new MenuItem(menu, SWT.PUSH); + about.setText(Messages.BrowserSim_ABOUT); + about.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + new MessageBoxWithLinks( + e.display.getActiveShell(), + Messages.BrowserSim_COPYRIGHT, + icons[BROWSERSIM_ICON_32PX_INDEX], + Messages.BrowserSim_ABOUT).open(); + + } + }); + } + + + + + private void addDevicesListForMenu(final DevicesList devicesList, Menu devicesMenu) { List devices = devicesList.getDevices(); for (int i = 0; i < devices.size(); i++) { Index: org/jboss/tools/vpe/browsersim/ui/CustomMessageBox.java =================================================================== --- org/jboss/tools/vpe/browsersim/ui/CustomMessageBox.java (revision 41070) +++ org/jboss/tools/vpe/browsersim/ui/CustomMessageBox.java (working copy) @@ -48,7 +48,7 @@ } protected void createWidgets() { - shell = new Shell(getParent(), SWT.DIALOG_TRIM); + shell = new Shell(getParent(), SWT.APPLICATION_MODAL|SWT.DIALOG_TRIM); GridLayout shellLayout = new GridLayout(1, true); shellLayout.marginHeight = 0; shellLayout.marginWidth = 0; Index: org/jboss/tools/vpe/browsersim/ui/EditDeviceDialog.java =================================================================== --- org/jboss/tools/vpe/browsersim/ui/EditDeviceDialog.java (revision 41070) +++ org/jboss/tools/vpe/browsersim/ui/EditDeviceDialog.java (working copy) @@ -87,7 +87,7 @@ * Create contents of the dialog. */ private void createContents() { - shell = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.MIN | SWT.MAX); + shell = new Shell(getParent(), getStyle()); shell.setSize(450, 300); shell.setText(Messages.EditDeviceDialog_EDIT_DEVICE); shell.setLayout(new GridLayout(2, false)); Index: org/jboss/tools/vpe/browsersim/ui/ExceptionNotifier.java =================================================================== --- org/jboss/tools/vpe/browsersim/ui/ExceptionNotifier.java (revision 41070) +++ org/jboss/tools/vpe/browsersim/ui/ExceptionNotifier.java (working copy) @@ -14,14 +14,6 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.SWTError; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.program.Program; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Link; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.jboss.tools.vpe.browsersim.browser.PlatformUtil; @@ -63,57 +55,7 @@ public static void showErrorMessageWithLinks(Shell shell, String message) { System.err.println(message); - ErrorMessageBoxWithLinks messageBox = new ErrorMessageBoxWithLinks(shell); - messageBox.setText(Messages.BrowserSim_ERROR); - messageBox.setMessage(message); + MessageBoxWithLinks messageBox = new MessageBoxWithLinks(shell, message, shell.getDisplay().getSystemImage(SWT.ICON_ERROR), Messages.BrowserSim_ERROR); messageBox.open(); } } - - -/** - * Behaves like MessageBox with styles SWT.OK and SWT.ICON_ERROR, but allows HTML links is messages. - * @author Yahor Radtsevich (yradtsevich) - * - */ -class ErrorMessageBoxWithLinks extends CustomMessageBox { - - private String message; - - public ErrorMessageBoxWithLinks(Shell parent) { - super(parent, parent.getDisplay().getSystemImage(SWT.ICON_ERROR)); - message = ""; //$NON-NLS-1$ - } - - @Override - protected void createWidgets() { - super.createWidgets(); - - Link link = new Link(getMessageComposite(), SWT.WRAP); - link.setText(message); - link.setBackground(getMessageCompositeBackground()); - link.addListener (SWT.Selection, new Listener () { - public void handleEvent(Event event) { - Program.launch(event.text); - } - }); - - Button ok = new Button(getButtonsComposite(), SWT.PUSH); - ok.setText(Messages.ExceptionNotifier_OK); - ok.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - getShell().close(); - } - }); - GridData okLayoutData = new GridData(SWT.END, SWT.CENTER, true, true); - okLayoutData.widthHint = 88; - ok.setLayoutData(okLayoutData); - getShell().setDefaultButton(ok); - getShell().pack(); - } - - public void setMessage(String message) { - this.message = message; - } -} Index: org/jboss/tools/vpe/browsersim/ui/MessageBoxWithLinks.java =================================================================== --- org/jboss/tools/vpe/browsersim/ui/MessageBoxWithLinks.java (revision 0) +++ org/jboss/tools/vpe/browsersim/ui/MessageBoxWithLinks.java (working copy) @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2007-2012 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.vpe.browsersim.ui; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.program.Program; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Link; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; + +/** + * Behaves like MessageBox with styles SWT.OK and SWT.ICON_ERROR, but allows + * HTML links is messages. + * + * @author Yahor Radtsevich (yradtsevich) + * + */ +public class MessageBoxWithLinks extends CustomMessageBox { + + private String message; + private String header; + + public MessageBoxWithLinks(Shell parent, String message, Image icon, String header) { + super(parent, icon); + this.message = message; //$NON-NLS-1$ + this.header = header; + } + + @Override + protected void createWidgets() { + super.createWidgets(); + + Link link = new Link(getMessageComposite(), SWT.WRAP); + link.setText(message); + link.setBackground(getMessageCompositeBackground()); + link.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event event) { + Program.launch(event.text); + } + }); + + Button ok = new Button(getButtonsComposite(), SWT.PUSH); + ok.setText(Messages.ExceptionNotifier_OK); + ok.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + getShell().close(); + } + }); + GridData okLayoutData = new GridData(SWT.END, SWT.CENTER, true, true); + okLayoutData.widthHint = 88; + ok.setLayoutData(okLayoutData); + getShell().setText(header); + getShell().setDefaultButton(ok); + getShell().pack(); + } + + public void setMessage(String message) { + this.message = message; + } + + public void setHeader(String header) { + this.header = header; + } + +} \ No newline at end of file Index: org/jboss/tools/vpe/browsersim/ui/Messages.java =================================================================== --- org/jboss/tools/vpe/browsersim/ui/Messages.java (revision 41070) +++ org/jboss/tools/vpe/browsersim/ui/Messages.java (working copy) @@ -23,6 +23,8 @@ public static String BrowserSim_COULD_NOT_OPEN_DEFAULT_BROWSER; public static String BrowserSim_DEVICES; public static String BrowserSim_ERROR; + public static String BrowserSim_HELP; + public static String BrowserSim_ABOUT; public static String BrowserSim_EXIT; public static String BrowserSim_FILE; public static String BrowserSim_OPEN_IN_DEFAULT_BROWSER; @@ -31,6 +33,7 @@ public static String BrowserSim_TURN_RIGHT; public static String BrowserSim_USE_SKINS; public static String BrowserSim_VIEW_PAGE_SOURCE; + public static String BrowserSim_COPYRIGHT; public static String EditDeviceDialog_CANCEL; public static String EditDeviceDialog_EDIT_DEVICE; public static String EditDeviceDialog_HEIGHT; @@ -76,7 +79,7 @@ public static String SizeWarningDialog_DEVICE_SIZE_WILL_BE_TRUNCATED; public static String SizeWarningDialog_OK; public static String SizeWarningDialog_REMEMBER_MY_DECISION; - + static { NLS.initializeMessages(BUNDLE_NAME, Messages.class); } Index: org/jboss/tools/vpe/browsersim/ui/messages.properties =================================================================== --- org/jboss/tools/vpe/browsersim/ui/messages.properties (revision 41070) +++ org/jboss/tools/vpe/browsersim/ui/messages.properties (working copy) @@ -3,7 +3,9 @@ BrowserSim_COULD_NOT_OPEN_DEFAULT_BROWSER=Could not open default browser: BrowserSim_DEVICES=Devices BrowserSim_ERROR=Error +BrowserSim_ABOUT=About BrowserSim_EXIT=Exit +BrowserSim_HELP=Help BrowserSim_FILE=File BrowserSim_PREFERENCES=Preferences... BrowserSim_OPEN_IN_DEFAULT_BROWSER=Open in default browser @@ -11,6 +13,7 @@ BrowserSim_TURN_RIGHT=Turn Right BrowserSim_USE_SKINS=Use Skins BrowserSim_VIEW_PAGE_SOURCE=View page source +BrowserSim_COPYRIGHT=Copyright (c) 2007-2012 Red Hat, Inc. EditDeviceDialog_CANCEL=Cancel EditDeviceDialog_EDIT_DEVICE=Edit Device EditDeviceDialog_HEIGHT=Height: