From: minkee.lee Date: Wed, 21 Jan 2015 08:21:48 +0000 (+0900) Subject: Tun/tap: Set DHCP default if bridge-network is selected. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0354030136420a39a5947d823fd6a77c2c52a3a5;p=sdk%2Femulator%2Femulator-manager.git Tun/tap: Set DHCP default if bridge-network is selected. Change-Id: I228de489eeefe7cefa4b1a8ec4dd76485c435b4a Signed-off-by: minkee.lee --- diff --git a/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetConnectTypeViewItem.java b/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetConnectTypeViewItem.java index 5d7b9c7..20aec44 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetConnectTypeViewItem.java +++ b/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetConnectTypeViewItem.java @@ -58,6 +58,12 @@ public class NetConnectTypeViewItem extends ComboViewItem { public void widgetSelected(SelectionEvent e) { newValue = combo.getText(); + item = lineLabelViewItem + .getItem(CommonItemListFactory.ITEM_NET_TAP_DEVICE); + if (item != null && item instanceof NetTapDeviceViewItem) { + ((NetTapDeviceViewItem) item).resetCombo(newValue); + } + // Disable / enable following item - bridge name, ip info, dns AdvancedViewItem item = lineLabelViewItem .getItem(CommonItemListFactory.ITEM_NET_IP_INFO); @@ -65,11 +71,6 @@ public class NetConnectTypeViewItem extends ComboViewItem { ((NetIPInfoViewItem) item).resetSubItems(newValue); } - item = lineLabelViewItem - .getItem(CommonItemListFactory.ITEM_NET_TAP_DEVICE); - if (item != null && item instanceof NetTapDeviceViewItem) { - ((NetTapDeviceViewItem) item).resetCombo(newValue); - } item = lineLabelViewItem.getItem(CommonItemListFactory.ITEM_NET_DNS); if (item != null && item instanceof NetDnsViewItem) { diff --git a/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetDnsViewItem.java b/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetDnsViewItem.java index 1aa79dd..daac3d3 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetDnsViewItem.java +++ b/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetDnsViewItem.java @@ -60,17 +60,31 @@ public class NetDnsViewItem extends TextViewItem { return newValue; } + private boolean useDHCP() { + AdvancedViewItem item = lineLabelViewItem + .getItem(CommonItemListFactory.ITEM_NET_IP_INFO); + if (item != null && item instanceof NetIPInfoViewItem) { + if (((NetIPInfoViewItem) item).useDHCP()) { + return true; + } + } + return false; + } + public void resetText(String connectType) { - if (connectType.equals(NetConnectTypeViewItem.VALUE_NAT)) { + boolean enabled = false; + if (connectType.equals(NetConnectTypeViewItem.VALUE_BRIDGE) && !useDHCP()) { + enabled = true; + } + + if (enabled) { + text.setEnabled(true); + newValue = oldValue; // restore + } else { // disable text input text.setEnabled(false); oldValue = newValue; // save newValue = ""; - - } else if (connectType.equals(NetConnectTypeViewItem.VALUE_BRIDGE)) { - // enable text input - text.setEnabled(true); - newValue = oldValue; // restore } text.setText(newValue); @@ -93,13 +107,6 @@ public class NetDnsViewItem extends TextViewItem { resetText(connectType); } - // If use DHCP, set disabled. - item = lineLabelViewItem.getItem(CommonItemListFactory.ITEM_NET_IP_INFO); - if (item != null && item instanceof NetIPInfoViewItem) { - if (((NetIPInfoViewItem)item).useDHCP()) { - setEnabled(false); - } - } return false; } diff --git a/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetIPInfoDHCPSubViewItem.java b/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetIPInfoDHCPSubViewItem.java index d395b87..454e5b4 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetIPInfoDHCPSubViewItem.java +++ b/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetIPInfoDHCPSubViewItem.java @@ -59,6 +59,8 @@ public class NetIPInfoDHCPSubViewItem extends CheckSubViewItem { } else if (connectType.equals(NetConnectTypeViewItem.VALUE_BRIDGE)) { // setCheckBox(newValue ? true : false); setEnabled(true); + setCheckBox(true); // If Bridge network selected, set DHCP default. + setIPInfoEnabled(false); } } } diff --git a/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetIPInfoTextSubViewItem.java b/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetIPInfoTextSubViewItem.java index dea4727..31dd270 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetIPInfoTextSubViewItem.java +++ b/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetIPInfoTextSubViewItem.java @@ -66,12 +66,23 @@ public class NetIPInfoTextSubViewItem extends TextSubViewItem { } public void resetText(String connectType) { - if (connectType.equals(NetConnectTypeViewItem.VALUE_NAT)) { + if (connectType.equals(NetConnectTypeViewItem.VALUE_BRIDGE) + && !useDHCP()) { + resetText(true); + + } else { resetText(false); + } + } - } else if (connectType.equals(NetConnectTypeViewItem.VALUE_BRIDGE)) { - resetText(true); + private boolean useDHCP() { + if (parentItem instanceof NetIPInfoViewItem) { + NetIPInfoViewItem netItem = (NetIPInfoViewItem)parentItem; + if (netItem.useDHCP()) { + return true; + } } + return false; } @Override @@ -94,14 +105,6 @@ public class NetIPInfoTextSubViewItem extends TextSubViewItem { resetText(connectType); } - // If use DHCP, set disabled. - if (parentItem instanceof NetIPInfoViewItem) { - NetIPInfoViewItem netItem = (NetIPInfoViewItem)parentItem; - if (netItem.useDHCP()) { - setEnabled(false); - } - } - return false; } diff --git a/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetTapDeviceViewItem.java b/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetTapDeviceViewItem.java index ee2f9a4..ea8b4e1 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetTapDeviceViewItem.java +++ b/common-project/src/org/tizen/emulator/manager/ui/detail/item/property/NetTapDeviceViewItem.java @@ -169,7 +169,6 @@ public class NetTapDeviceViewItem extends ComboViewItem { @Override public boolean settingModifyItem(VMPropertyValue value) { - oldValue = newValue = value.getAdvancedOptionValue(name); // text.setText(newValue); diff --git a/common-project/src/org/tizen/emulator/manager/ui/detail/item/template/TextSubViewItem.java b/common-project/src/org/tizen/emulator/manager/ui/detail/item/template/TextSubViewItem.java index 46e98f5..c2f58df 100644 --- a/common-project/src/org/tizen/emulator/manager/ui/detail/item/template/TextSubViewItem.java +++ b/common-project/src/org/tizen/emulator/manager/ui/detail/item/template/TextSubViewItem.java @@ -163,12 +163,10 @@ public class TextSubViewItem extends SubViewItem { if (enabled) { // enable text input - setEnabled(true); newValue = oldValue; // restore } else { // disable text input - setEnabled(false); oldValue = newValue; // save newValue = ""; } @@ -176,6 +174,7 @@ public class TextSubViewItem extends SubViewItem { if (newValue != null) { text.setText(newValue); } + setEnabled(enabled); } }