From 616cbe259a99feadea419802cda234fba4240bea Mon Sep 17 00:00:00 2001 From: "minkee.lee" Date: Wed, 6 Jan 2016 21:05:32 +0900 Subject: [PATCH] tap-dialog: change tap device dialog Apply new UI to tap device dialog. Change-Id: I7e918e3bfc84956fc68671556ba7123049c3303b Signed-off-by: minkee.lee --- resource/strings/uimessages.properties | 6 + .../emulator/manager/ui/renewal/dialog/Dialog.java | 18 + .../ui/renewal/dialog/network/ProxyDialog.java | 34 +- .../dialog/network/TapDeviceDialogForWin.java | 540 +++++++++++++++++++++ .../renewal/item/modify/vm/NetTapDeviceItem.java | 3 + .../item/modify/vm/NetTapDeviceItemForWin.java | 5 +- .../manager/ui/renewal/widgets/WidgetHelper.java | 4 + 7 files changed, 581 insertions(+), 29 deletions(-) create mode 100644 src/org/tizen/emulator/manager/ui/renewal/dialog/network/TapDeviceDialogForWin.java diff --git a/resource/strings/uimessages.properties b/resource/strings/uimessages.properties index cbc93e2..5e46940 100644 --- a/resource/strings/uimessages.properties +++ b/resource/strings/uimessages.properties @@ -78,6 +78,7 @@ ProxyDialog.Title=Proxy Setting ProxyDialog.HTTPCheckBoxTitle=Use this proxy for all protocols SkinSubViewItem.SkinToolTip.0=check skin directory: . SuspendSupportViewItem.SuspendWarning.0=This is incomplete feature. It may not work properly. +TapDeviceDialog.Title=Creating tap device TapGuideDialogForWin.CreateBridgeDialog.0=Create a network bridge TapGuideDialogForWin.CreateBridgeDialog.1=1. Open Network Connections by clicking the Start button, and then TapGuideDialogForWin.CreateBridgeDialog.2=\nclicking Control Panel. In the search box, type adapter, and then, @@ -103,6 +104,11 @@ TapGuideDialogForWin.TCPSetting.9=\nDefault gateway. And set DNS server. TapGuideDialogForWin.UseBridgeDialog.0=Using bridge network TapGuideDialogForWin.UseBridgeDialog.1=To use bridge network in Tizen emulator, bridge connection should be TapGuideDialogForWin.UseBridgeDialog.2=\ncreated with proper TCP/IP setting. +TapUtil.CreatedTapDevice.0=Tap device created : +TapUtil.CreatedTapDevice.1=Do you want to see the guide for bridge network? +TapUtil.CreateTapDevice.0=Creating tap device. +TapUtil.CreateTapDevice.1=This will take minutes.. +TapUtil.FailedCreateTapDevice.0=Failed to create tap device. VMButton.FailedToLoad.0=failed VMButton.FailedToLoad.1=to load VMButton.FailedToLoad.2=plug in diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/Dialog.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/Dialog.java index 688dd33..ad2a969 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialog/Dialog.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialog/Dialog.java @@ -61,6 +61,8 @@ public class Dialog { private int returnValue = SWT.CANCEL; private NinePatchButton okButton; + public static int CONTENT_MARGIN_WIDTH = 7; + public static int CONTENT_MARGIN_HEIGHT = 7; protected static final int BORDER_WIDTH = 1; @@ -194,5 +196,21 @@ public class Dialog { bodyComp.setLayoutData(gridData); } + protected void setBodyLayoutGrid(int numColumn, int marginWidth, int marginHeight) { + GridLayout layout = new GridLayout(); + layout.numColumns = numColumn; + layout.verticalSpacing = 0; + layout.marginHeight = marginHeight; + layout.marginWidth = marginWidth; + getBodyComposite().setLayout(layout); + getBodyComposite().setBackground(ColorResources.WHITE.getColor()); + } + + + protected GridData makeLayoutData(int rowNum) { + GridData data = new GridData(GridData.FILL, SWT.NONE, true, false); + data.heightHint = (getBodyHeight() - CONTENT_MARGIN_HEIGHT * 2) / rowNum; + return data; + } } diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/network/ProxyDialog.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/network/ProxyDialog.java index 1a4fd32..bae6edd 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/dialog/network/ProxyDialog.java +++ b/src/org/tizen/emulator/manager/ui/renewal/dialog/network/ProxyDialog.java @@ -33,11 +33,8 @@ package org.tizen.emulator.manager.ui.renewal.dialog.network; import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; -import org.tizen.emulator.manager.renewal.resources.ColorResources; import org.tizen.emulator.manager.ui.Messages; import org.tizen.emulator.manager.ui.renewal.dialog.Dialog; @@ -48,10 +45,9 @@ public class ProxyDialog extends Dialog { private static String TITLE = Messages.getString("ProxyDialog.Title"); public static int WIDTH = 400; public static int HEIGHT = 250; - public static int CONTENT_MARGIN_WIDTH = 7; - public static int CONTENT_MARGIN_HEIGHT = 7; public static int CONTENT_WIDTH = WIDTH - (CONTENT_MARGIN_WIDTH * 2) - (BORDER_WIDTH * 2); + private static int ROW_NUM = 5; private final String value; @@ -76,7 +72,6 @@ public class ProxyDialog extends Dialog { returnValue = dialog.getReturnValue(); } - System.out.println(returnValue); return returnValue; } @@ -140,33 +135,18 @@ public class ProxyDialog extends Dialog { } private void addItems() { - setBodyLayout(); + setBodyLayoutGrid(1, CONTENT_MARGIN_WIDTH, CONTENT_MARGIN_HEIGHT); Composite body = getBodyComposite(); - httpItem = new AddressPortItem(this, body, makeLayoutData(), "HTTP"); - httpCheckItem = new HTTPCheckBoxItem(this, body, makeLayoutData()); - httpsItem = new AddressPortItem(this, body, makeLayoutData(), "HTTPS"); - ftpItem = new AddressPortItem(this, body, makeLayoutData(), "FTP"); - socksItem = new AddressPortItem(this, body, makeLayoutData(), "SOCKS"); + httpItem = new AddressPortItem(this, body, makeLayoutData(ROW_NUM), "HTTP"); + httpCheckItem = new HTTPCheckBoxItem(this, body, makeLayoutData(ROW_NUM)); + httpsItem = new AddressPortItem(this, body, makeLayoutData(ROW_NUM), "HTTPS"); + ftpItem = new AddressPortItem(this, body, makeLayoutData(ROW_NUM), "FTP"); + socksItem = new AddressPortItem(this, body, makeLayoutData(ROW_NUM), "SOCKS"); settingItemValue(); } - private void setBodyLayout() { - GridLayout layout = new GridLayout(); - layout.numColumns = 1; - layout.verticalSpacing = 0; - layout.marginHeight = CONTENT_MARGIN_HEIGHT; - layout.marginWidth = CONTENT_MARGIN_WIDTH; - getBodyComposite().setLayout(layout); - getBodyComposite().setBackground(ColorResources.WHITE.getColor()); - } - - public GridData makeLayoutData() { - GridData data = new GridData(GridData.FILL, SWT.NONE, true, false); - data.heightHint = (getBodyHeight() - CONTENT_MARGIN_HEIGHT * 2) / 5; - return data; - } public void setApplyAllProtocol(boolean isApplyAll) { httpsItem.setEnabled(!isApplyAll); diff --git a/src/org/tizen/emulator/manager/ui/renewal/dialog/network/TapDeviceDialogForWin.java b/src/org/tizen/emulator/manager/ui/renewal/dialog/network/TapDeviceDialogForWin.java new file mode 100644 index 0000000..45626b3 --- /dev/null +++ b/src/org/tizen/emulator/manager/ui/renewal/dialog/network/TapDeviceDialogForWin.java @@ -0,0 +1,540 @@ +/* + * Emulator Manager + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Minkee Lee + * JiHye Kim + * SeokYeon Hwang + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + + +package org.tizen.emulator.manager.ui.renewal.dialog.network; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.tizen.emulator.manager.EmulatorManager; +import org.tizen.emulator.manager.logging.EMLogger; +import org.tizen.emulator.manager.renewal.resources.ColorResources; +import org.tizen.emulator.manager.resources.FilePathResources; +import org.tizen.emulator.manager.resources.StringResources; +import org.tizen.emulator.manager.tool.TapUtil; +import org.tizen.emulator.manager.ui.Messages; +import org.tizen.emulator.manager.ui.dialog.TapGuideDialogForWin; +import org.tizen.emulator.manager.ui.renewal.dialog.Dialog; +import org.tizen.emulator.manager.ui.renewal.dialog.MessageDialog; +import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem; +import org.tizen.emulator.manager.ui.renewal.item.modify.vm.NetTapDeviceItemForWin; +import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox; +import org.tizen.emulator.manager.ui.renewal.widgets.TextInputBox; +import org.tizen.emulator.manager.ui.renewal.widgets.WidgetHelper; +import org.tizen.emulator.manager.vms.helper.HelperClass; +import org.tizen.emulator.manager.vms.helper.ProcessResult; +import org.tizen.emulator.manager.vms.helper.VMWorkerException; + +public class TapDeviceDialogForWin extends Dialog { + + + private static int WIDTH = 380; + private static int HEIGHT = 155; + private static String TITLE = Messages.getString("TapDeviceDialog.Title"); + + private String tapName; + private String ifName; + + private final NetTapDeviceItemForWin viewItem; + private final String platformVersion; + + private final int ROW_NUM = 2; + + private TextInputBox nameTextInput; + private ComboBox comboBox; + + static int TEXT_WIDGET_MARGIN_WIDTH = 5; + + public static Integer[] rate = {2,5}; + private static int rateTotal; + + static { + int total = 0; + for (int i : rate) { + total += i; + } + rateTotal = total; + } + + public String getTapName() { + return tapName; + } + + public String getInterfaceName() { + return ifName; + } + + public TapDeviceDialogForWin(Shell parent, + NetTapDeviceItemForWin viewItem, String platformVersion) { + super(parent, TITLE, WIDTH, HEIGHT, SWT.OK | SWT.CANCEL); + this.viewItem = viewItem; + this.platformVersion = platformVersion; + // TODO Auto-generated constructor stub + } + + public static int CONTENT_WIDTH = WIDTH - (CONTENT_MARGIN_WIDTH * 2) - (BORDER_WIDTH * 2); + + + public static void open(Shell parent, NetTapDeviceItemForWin viewItem, String platformVersion) { + TapDeviceDialogForWin dialog = new TapDeviceDialogForWin(parent, viewItem, platformVersion); + dialog.create(); + dialog.makeBody(); + + int res = dialog.open(); + if (res == SWT.OK){ + createTapDevice(dialog.getTapName(), dialog.getInterfaceName(), + viewItem, platformVersion); + } + } + + public void makeBody() { + + setBodyLayoutGrid(1, CONTENT_MARGIN_WIDTH, CONTENT_MARGIN_HEIGHT); + addTapNameItem(); + + if (!EmulatorManager.isWin8AndAbove()) { + addHostNetworkItem(); + } + } + + private void addTapNameItem() { + // item comp + Composite comp = createItemComp(); + addTitle(comp, "Tap Name"); + nameTextInput = addTextBox(comp); + + nameTextInput.setEnabled(false); + nameTextInput.setText(TapUtil.getAvailableTapName()); + tapName = nameTextInput.getValue(); + } + + private void addHostNetworkItem() { + Composite comp = createItemComp(); + addTitle(comp, "Host Network"); + comboBox = addComboBox(comp); + + for (String str : getInterfaceList()) { + comboBox.addItem(str); + } + comboBox.select(0); + ifName = comboBox.getSelectedItem(); + + addListener(); + } + + private void addListener() { + Listener listener = new Listener() { + @Override + public void handleEvent(Event event) { + switch(event.type) { + case SWT.Selection: + ifName = comboBox.getSelectedItem(); + + default: + break; + } + + } + }; + comboBox.addListener(SWT.Selection, listener); + } + + private Composite createItemComp() { + Composite comp = new Composite(getBodyComposite(), SWT.NONE); + comp.setLayoutData(makeLayoutData(ROW_NUM)); + comp.setBackground(ColorResources.WHITE.getColor()); + + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.marginWidth = 0; + layout.marginHeight = 0; + layout.horizontalSpacing = 0; + comp.setLayout(layout); + return comp; + } + + private ComboBox addComboBox(Composite parent) { + Composite comp = createWidgetComp(parent, 1); + comp.setBackground(ColorResources.WHITE.getColor()); + ComboBox combo = new ComboBox(getShell(), comp, SWT.NONE); + combo.setLayoutData(getWidgetLayoutData( + ((GridData)parent.getLayoutData()).heightHint)); + return combo; + } + + private TextInputBox addTextBox(Composite parent) { + Composite comp = createWidgetComp(parent, 1); + comp.setBackground(ColorResources.WHITE.getColor()); + TextInputBox textBox = new TextInputBox(comp, SWT.NONE); + textBox.setLayoutData(getWidgetLayoutData( + ((GridData)parent.getLayoutData()).heightHint)); + return textBox; + } + + private FormData getWidgetLayoutData(int height) { + FormData data = new FormData(); + data.top = new FormAttachment(0, (height - ModifyItem.WIDGET_HEIGHT) / 2); + data.height = ModifyItem.WIDGET_HEIGHT; + data.left = new FormAttachment(0, TEXT_WIDGET_MARGIN_WIDTH); + data.right = new FormAttachment(100, -TEXT_WIDGET_MARGIN_WIDTH); + return data; + } + + private void addTitle(Composite parent, String title) { + Composite comp = createWidgetComp(parent, 0); + Canvas canvas = new Canvas(comp, SWT.NONE); + canvas.setBackground(ColorResources.WHITE.getColor()); + canvas.setLayoutData(getTitleLayout()); + WidgetHelper.drawText(canvas, title, SWT.NONE); + } + + + private static FormData getTitleLayout() { + FormData data = new FormData(); + data.top = new FormAttachment(0, 0); + data.left = new FormAttachment(0, 5); + data.right = new FormAttachment(100, -10); + data.bottom = new FormAttachment(100, 0); + return data; + } + + private Composite createWidgetComp(Composite parent, int index) { + Composite widgetComp = new Composite(parent, SWT.NONE); + widgetComp.setBackground(ColorResources.WHITE.getColor()); + widgetComp.setLayoutData(getWidgetLayout(index)); + widgetComp.setLayout(new FormLayout()); + return widgetComp; + } + + private static GridData getWidgetLayout(int index) { + GridData data = new GridData(); + data.grabExcessVerticalSpace = true; + data.verticalAlignment = SWT.FILL; + data.widthHint = getWidth(index); + return data; + } + + public static int getWidth(int index) { + if (index >= rate.length) { + return 0; + } + return CONTENT_WIDTH * rate[index] / rateTotal; + } + + + + + public ArrayList getInterfaceList() { + // Get intereface list + ProcessResult res; + ArrayList ifList = new ArrayList(); + List cmd = Arrays.asList(FilePathResources.getPlatformEmulatorBinPath(platformVersion) + + File.separator + "devcon.exe", "find", "=net", "@pci*"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + res = HelperClass.runProcess(cmd); + boolean isCommandSuccess = false; + if (res.isSuccess()) { + for (String str : res.getStdOutMsg()) { + if (str.contains(": ")) { //$NON-NLS-1$ + isCommandSuccess = true; + String pciNet = str.split(": ")[1].trim(); //$NON-NLS-1$ + EMLogger.getLogger().info( + "PCI network interface: " + pciNet); //$NON-NLS-1$ + ifList.add(pciNet); + } + } + + } else if (!res.isSuccess() || !isCommandSuccess) { + EMLogger.getLogger().warning(res.getResultMessage()); + } + + return ifList; + } + + + + public static void createTapDevice(String tapName, String ifName, + NetTapDeviceItemForWin viewItem, String platformVersion) { + if (EmulatorManager.isWin()) { + MessageDialog msgDialog = new MessageDialog(); + msgDialog + .openNoButtonInfoDialog(Messages.getString("TapUtil.CreateTapDevice.0")); //$NON-NLS-1$ + TapCreateWorker worker = new TapCreateWorker(tapName, ifName, + msgDialog, viewItem, platformVersion); + worker.start(); + } + + } + + static class TapCreateWorker extends Thread { + + final MessageDialog dialog; + final String tapName; + final String ifName; + final NetTapDeviceItemForWin viewItem; // for refresh combo-list + final String platformVersion; + + public TapCreateWorker(String tapName, String ifName, + MessageDialog dialog, NetTapDeviceItemForWin viewItem, String platformVersion) { + this.dialog = dialog; + this.tapName = tapName; + this.ifName = ifName; + this.viewItem = viewItem; + this.platformVersion = platformVersion; + } + + @Override + public void run() { + // Create tap device + // - Create tap device and rename(user input name) because + // windows OS generate device name automatically. + // - For rename, inquire tap list before and after create and + // compare both to find what is new one. + List cmd; + ProcessResult res; + try { + if (!EmulatorManager.isWin8AndAbove()) { + EMLogger.getLogger().info( + "get CompatibleIDs from pci network device"); //$NON-NLS-1$ + cmd = Arrays.asList(TapUtil.getDevconPath(platformVersion), "find", "=net", //$NON-NLS-1$ //$NON-NLS-2$ + "@pci*"); //$NON-NLS-1$ + res = HelperClass.runProcess(cmd); + boolean isCommandSuccess = false; + String CompatibleIDs = null; + if (res.isSuccess()) { + for (String str : res.getStdOutMsg()) { + if (str.endsWith(ifName)) { + isCommandSuccess = true; + CompatibleIDs = str.split(":")[0].trim(); //$NON-NLS-1$ + EMLogger.getLogger().info( + "CompatibleIDs: " + CompatibleIDs); //$NON-NLS-1$ + break; + } + } + } else if (!res.isSuccess() || !isCommandSuccess) { + EMLogger.getLogger().warning(res.getResultMessage()); + } + + if (TapUtil.isWinBridgeExist() == false) { + // Create Bridge device and set IP + EMLogger.getLogger().info("create bridge"); //$NON-NLS-1$ + cmd = Arrays + .asList(TapUtil.getDevconPath(platformVersion), + "install", //$NON-NLS-1$ + "c:\\windows\\inf\\netbrdgm.inf", //$NON-NLS-1$ + "ms_bridgemp"); //$NON-NLS-1$ + res = HelperClass.runProcess(cmd); + if (!res.isSuccess()) { + throw new VMWorkerException(res.getResultMessage()); + } + + EMLogger.getLogger().info("bind interface to bridge"); //$NON-NLS-1$ + cmd = Arrays.asList(FilePathResources.getPlatformEmulatorBinPath(platformVersion) + + File.separator + "bindbridge.exe", //$NON-NLS-1$ + "ms_bridge", CompatibleIDs, "bind"); //$NON-NLS-1$ //$NON-NLS-2$ + res = HelperClass.runProcess(cmd); + if (!res.isSuccess()) { + throw new VMWorkerException(res.getResultMessage()); + } + EMLogger.getLogger().info("set bridge's IP"); //$NON-NLS-1$ + TapUtil.setWinbridgeNetwork(TapUtil.getClassIDFromPnpInstanceID(CompatibleIDs)); + } + } + + // Get tap list before create new tap. + EMLogger.getLogger() + .info("Get tap list before create new tap."); //$NON-NLS-1$ + List before = TapUtil.getTapList(); + + // Create new tap + EMLogger.getLogger().info("Create new tap."); //$NON-NLS-1$ + cmd = Arrays.asList(TapUtil.getDevconPath(platformVersion), "install", //$NON-NLS-1$ + FilePathResources.getPlatformEmulatorBinPath(platformVersion) + File.separator + + "OemWin2k.inf", "Tap0901"); //$NON-NLS-1$ //$NON-NLS-2$ + res = HelperClass.runProcess(cmd); + + if (!res.isSuccess()) { + throw new VMWorkerException(res.getResultMessage()); + } + + // Get tap list and find new one. + EMLogger.getLogger().info("Get tap list and find new one."); //$NON-NLS-1$ + List after = TapUtil.getTapList(); + String newOne = null; + for (String str : after) { + if (!before.contains(str)) { + newOne = str; + break; + } + } + + if (newOne == null) { + throw new VMWorkerException( + "Tap create fail. Cannot find new tap device."); //$NON-NLS-1$ + } + + // Rename new tap to tapX + EMLogger.getLogger().info("Rename new tap to tapX."); //$NON-NLS-1$ + cmd = Arrays.asList("netsh", "interface", "set", "interface", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + "name=" + newOne, "newname=" + tapName); //$NON-NLS-1$ //$NON-NLS-2$ + res = HelperClass.runProcess(cmd); + if (!res.isSuccess()) { + throw new VMWorkerException(res.getResultMessage()); + } + + // Check tap create in success. + EMLogger.getLogger().info("Check tap create in success."); //$NON-NLS-1$ + boolean isTapExist = false; + for (String str : TapUtil.getTapList()) { + if (str.equals(tapName)) { + isTapExist = true; + } + } + + if (!EmulatorManager.isWin8AndAbove()) { + EMLogger.getLogger().info("bind host network to bridge"); //$NON-NLS-1$ + String tapPnpInstanceID = TapUtil.getPnpInstanceIDFromName(tapName); + + cmd = Arrays.asList(FilePathResources.getPlatformEmulatorBinPath(platformVersion) + + File.separator + "bindbridge.exe", "ms_bridge", //$NON-NLS-1$ //$NON-NLS-2$ + tapPnpInstanceID, "bind"); //$NON-NLS-1$ + res = HelperClass.runProcess(cmd); + if (!res.isSuccess()) { + throw new VMWorkerException(res.getResultMessage()); + } + + EMLogger.getLogger().info( + "wait while finishing bridged network setting"); //$NON-NLS-1$ + String proxyCommand = "check-net.exe"; //$NON-NLS-1$ + cmd = Arrays.asList(FilePathResources.getEmulatorCheckToolPath() + + File.separator + proxyCommand, "--bridge"); //$NON-NLS-1$ + res = HelperClass.runProcess(cmd); + while (!res.getStdOutMsg().isEmpty()) { + boolean isCommandSuccess = false; + String ipAddr = null; + if (res.isSuccess()) { + for (String str : res.getStdOutMsg()) { + if (str.startsWith("IP Address:")) { //$NON-NLS-1$ + isCommandSuccess = true; + ipAddr = str.split("IP Address: ")[1] //$NON-NLS-1$ + .trim(); + EMLogger.getLogger().info( + "bridge IP address: " + ipAddr); //$NON-NLS-1$ + break; + } + } + } else if (!res.isSuccess() || !isCommandSuccess) { + EMLogger.getLogger() + .warning(res.getResultMessage()); + } + if (ipAddr != null) { + break; + } + res = HelperClass.runProcess(cmd); + } + + // shows success message + final MessageDialog messageDialog = new MessageDialog(); + if (isTapExist) { + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + messageDialog + .openInfoDialog(Messages.getString("TapUtil.CreatedTapDevice.0") //$NON-NLS-1$ + + tapName); + } + }); + } + } else { + final MessageDialog resultDialog = new MessageDialog(); + if (isTapExist) { + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + int res = resultDialog + .openSelectionDialog(Messages.getString("TapUtil.CreatedTapDevice.0") //$NON-NLS-1$ + + StringResources.NEW_LINE + + Messages.getString("TapUtil.CreatedTapDevice.1") //$NON-NLS-1$ + + tapName + StringResources.NEW_LINE + + Messages.getString("TapUtil.CreatedTapDevice.1")); //$NON-NLS-1$ + if (res == SWT.OK) { + // Show bridge guide dialog + TapGuideDialogForWin.open(); + } + } + }); + + } else { + throw new VMWorkerException("Tap is not exist : " //$NON-NLS-1$ + + tapName); + } + } + } catch (VMWorkerException e) { + EMLogger.getLogger().warning("Failed to create tap device."); //$NON-NLS-1$ + EMLogger.getLogger().warning(e.getMessage()); + final String msg = e.getMessage(); + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + new MessageDialog() + .openWarningDialog(StringResources.NEW_LINE + + Messages.getString("TapUtil.FailedCreateTapDevice.0") //$NON-NLS-1$ + + StringResources.NEW_LINE + StringResources.NEW_LINE + + msg); + } + }); + + } finally { + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + dialog.close(); + viewItem.resetCombo(true); + } + }); + } + } + } + +} diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/NetTapDeviceItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/NetTapDeviceItem.java index f5bfc61..320db5d 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/NetTapDeviceItem.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/NetTapDeviceItem.java @@ -97,6 +97,9 @@ public class NetTapDeviceItem extends ComboItem{ // reset combo according to connect type (NAT / Bridge) public void resetCombo(boolean isResetAddress) { + if (comboBox.isDisposed()) { + return; + } comboBox.clear(); if (((NetworkItem)getParentItem()).isNATType()) { diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/NetTapDeviceItemForWin.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/NetTapDeviceItemForWin.java index 88429cf..6ee322e 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/NetTapDeviceItemForWin.java +++ b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/NetTapDeviceItemForWin.java @@ -38,7 +38,7 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.tizen.emulator.manager.renewal.resources.ImageResources; import org.tizen.emulator.manager.tool.TapUtil; -import org.tizen.emulator.manager.ui.renewal.dialog.TapDeviceDialogForWin; +import org.tizen.emulator.manager.ui.renewal.dialog.network.TapDeviceDialogForWin; import org.tizen.emulator.manager.ui.renewal.item.ItemName; import org.tizen.emulator.manager.ui.renewal.item.ItemState; import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem; @@ -86,7 +86,8 @@ public class NetTapDeviceItemForWin extends NetTapDeviceItem { @Override public void handleEvent(Event event) { if (event.type == SWT.Selection) { - TapDeviceDialogForWin.open(thisItem, platformVersion); + TapDeviceDialogForWin.open(getItemListComp().getShell(), + thisItem, platformVersion); // resetCombo(NetConnectTypeViewItem.VALUE_BRIDGE); getItemListComp().checkValid(); } diff --git a/src/org/tizen/emulator/manager/ui/renewal/widgets/WidgetHelper.java b/src/org/tizen/emulator/manager/ui/renewal/widgets/WidgetHelper.java index 5627182..110d59b 100644 --- a/src/org/tizen/emulator/manager/ui/renewal/widgets/WidgetHelper.java +++ b/src/org/tizen/emulator/manager/ui/renewal/widgets/WidgetHelper.java @@ -85,6 +85,10 @@ public class WidgetHelper { if (horizentalAlign == SWT.CENTER) { int itemWidth = ((Composite)e.widget).getBounds().width; posX = (itemWidth - textExt.x)/ 2; + + } else if (horizentalAlign == SWT.RIGHT){ + int itemWidth = ((Composite)e.widget).getBounds().width; + posX = (itemWidth - textExt.x); } String displayText = shortenText(gc, text, ((Composite)e.widget).getClientArea()); -- 2.7.4