tuner-option: add tuner option
authorminkee.lee <minkee.lee@samsung.com>
Wed, 2 Dec 2015 12:34:56 +0000 (21:34 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 3 Dec 2015 06:52:54 +0000 (15:52 +0900)
Add tuner option.
- Move some common function to CategoryItem.

Change-Id: I8994b26fbdda6e4b49e1ecced5fcc251bd81212f
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
15 files changed:
resource/renewal/res/icon_title_tuner.png
resource/renewal/res/icon_title_tuner_01.png [new file with mode: 0644]
src/org/tizen/emulator/manager/renewal/resources/ImageResources.java
src/org/tizen/emulator/manager/ui/renewal/item/CommonItemListFactory.java
src/org/tizen/emulator/manager/ui/renewal/item/ItemName.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/common/ModifyDialogItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CameraItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/CategoryItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/NetworkItem.java
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TunerCountryItem.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TunerItem.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TunerSystemItem.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TunerTableItem.java [new file with mode: 0644]
src/org/tizen/emulator/manager/ui/renewal/widgets/TextBox.java
xsd/x86-standard-template-v2.xml

index b561c14..faea941 100644 (file)
Binary files a/resource/renewal/res/icon_title_tuner.png and b/resource/renewal/res/icon_title_tuner.png differ
diff --git a/resource/renewal/res/icon_title_tuner_01.png b/resource/renewal/res/icon_title_tuner_01.png
new file mode 100644 (file)
index 0000000..b561c14
Binary files /dev/null and b/resource/renewal/res/icon_title_tuner_01.png differ
index ca03805..17ce64b 100644 (file)
@@ -286,6 +286,7 @@ public enum ImageResources {
        ICON_TITLE_OCI_DEVICE2("icon_title_oci_device"),
        ICON_TITLE_SENSOR("icon_title_sensor"),
        ICON_TITLE_TUNER("icon_title_tuner"),
+       ICON_TITLE_TUNER_01("icon_title_tuner_01"),
        ICON_TITLE_VERSION("icon_title_version"),
        ICON_TITLE_PROCESSOR("icon_title_processor"),
        ICON_TITLE_TREE_EXPANDED("icon_title_tree_expanded"),
index 863d420..76dfb31 100644 (file)
@@ -66,6 +66,10 @@ import org.tizen.emulator.manager.ui.renewal.item.modify.vm.NetTapDeviceItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.NetTapDeviceItemForWin;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.NetworkItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.vm.OCIDeviceItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.TunerCountryItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.TunerItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.TunerSystemItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.vm.TunerTableItem;
 
 public class CommonItemListFactory implements IItemListFactory{
 
@@ -153,7 +157,19 @@ public class CommonItemListFactory implements IItemListFactory{
 
                } else if (name.equals(ItemName.CAMERA_IMAGE_REAR)) {
                        categoryItem.addSubItems(new CameraImageItem(name, title));
+
+               } else if (name.equals(ItemName.TUNER_SYSTEM)) {
+                       categoryItem.addSubItems(new TunerSystemItem(title,
+                                       VMTemplateUtil.getOptionList(item.getOptions())));
+
+               } else if (name.equals(ItemName.TUNER_COUNTRY)) {
+                       categoryItem.addSubItems(new TunerCountryItem(title,
+                                       VMTemplateUtil.getOptionList(item.getOptions())));
+
+               } else if (name.equals(ItemName.TUNER_TABLE)) {
+                       categoryItem.addSubItems(new TunerTableItem(title));
                }
+
        }
 
 
@@ -231,6 +247,11 @@ public class CommonItemListFactory implements IItemListFactory{
                } else if (name.equals(ItemName.OCI_DEVICE)) {
                        // TODO this may be moved to tv plugin.
                        itemList.add(new OCIDeviceItem(title));
+
+               } else if (name.equals(ItemName.TUNER)) {
+                       TunerItem tunerItem = new TunerItem(title);
+                       itemList.add(tunerItem);
+                       addSubItems(item.getSubItems(), tunerItem);
                }
 
        }
index 6d75940..6d6048e 100644 (file)
@@ -87,6 +87,7 @@ public class ItemName {
        public static final String TUNER_NUMBER="number"; //$NON-NLS-1$
        public static final String TUNER_SYSTEM="system"; //$NON-NLS-1$
        public static final String TUNER_COUNTRY="country"; //$NON-NLS-1$
+       public static final String TUNER_TABLE = "table";
        public static final String TUNER_FILE_PATH="tunerFilePath"; //$NON-NLS-1$
        public static final String TUNER_FILE_NAME="tunerFileName"; //$NON-NLS-1$
 
index e7b0cc0..089084f 100644 (file)
@@ -324,6 +324,9 @@ public abstract class ModifyDialogItem implements IModifyDialogItem {
 
 
        protected Canvas createDetailItem(String text) {
+               if (text == null) {
+                       text = "";
+               }
                item.setBodyLayoutForm();
                Canvas canvas = new Canvas(item.getBody(), SWT.NONE)    ;
                canvas.setLayoutData(getDetailItemFormData());
index 40138f2..ddbb64a 100644 (file)
@@ -97,14 +97,10 @@ public class CameraItem extends CategoryItem {
        }
 
 
-       private void createSubItems() {
-               for (ModifyDialogItem item : subItems) {
-                       item.setParentItem(this);
-                       item.setItemListComp(this.getItemListComp());
-                       item.setInitialValue(this.getItemListComp().getPropertyValue());
-                       item.create(this.item.getBody());
-                       item.setVisible();
-               }
+
+       @Override
+       protected void createSubItems() {
+               super.createSubItems();
 
                if (getItemListComp().isDetailMode()) {
                        return;
@@ -226,4 +222,5 @@ public class CameraItem extends CategoryItem {
                boolean useRear = value.getCheckBoxValue(ItemName.CAMERA, ItemName.CAMERA_REAR);
                setRearCameraCheck(useRear);
        }
+
 }
index a14b717..502c1c2 100644 (file)
@@ -69,10 +69,6 @@ public abstract class CategoryItem extends ModifyDialogItem {
                }
        }
 
-       @Override
-       public void setInitialValue(PropertyValue value) {
-               // override this if you want.
-       }
 
        protected ModifyDialogItem getSubItemByName(String itemName) {
                for (ModifyDialogItem subItem : subItems) {
@@ -83,5 +79,37 @@ public abstract class CategoryItem extends ModifyDialogItem {
                return null;
        }
 
+       protected void createSubItems() {
+               for (ModifyDialogItem item : subItems) {
+                       item.setParentItem(this);
+                       item.setItemListComp(this.getItemListComp());
+                       item.setInitialValue(this.getItemListComp().getPropertyValue());
+                       item.create(this.item.getBody());
+                       item.setVisible();
+               }
+       }
+
+
+       @Override
+       public void setInitialValue(PropertyValue value) {
+               // nothing to do
+       }
+
+
+
+       @Override
+       public boolean isValid() {
+               if (getItemListComp().isDetailMode()) {
+                       return true;
+               }
+               boolean isValid = true;
+               for (ModifyDialogItem item : subItems) {
+                       if(!item.isValid()) {
+                               isValid = false;
+                       }
+               }
+               return isValid;
+       }
+
 
 }
index f742077..dedeaad 100644 (file)
@@ -36,7 +36,6 @@ import org.tizen.emulator.manager.renewal.resources.ImageResources;
 import org.tizen.emulator.manager.ui.renewal.item.ItemName;
 import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
 import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
-import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
 
 public class NetworkItem extends CategoryItem {
 
@@ -74,49 +73,8 @@ public class NetworkItem extends CategoryItem {
                createSubItems();
        }
 
-       private void createSubItems() {
-               for (ModifyDialogItem item : subItems) {
-                       item.setItemListComp(this.getItemListComp());
-                       item.setInitialValue(this.getItemListComp().getPropertyValue());
-                       item.setParentItem(this);
-                       item.create(this.item.getBody());
-                       item.setVisible();
-               }
-       }
-
-       @Override
-       public void setInitialValue(PropertyValue value) {
-               for (ModifyDialogItem item : subItems) {
-                       item.setInitialValue(value);
-               }
-       }
-
-
-
-       @Override
-       public boolean isValid() {
-               if (getItemListComp().isDetailMode()) {
-                       return true;
-               }
-               boolean isValid = true;
-               for (ModifyDialogItem item : subItems) {
-                       if(!item.isValid()) {
-                               isValid = false;
-                       }
-               }
-               return isValid;
-       }
-
 
-       @Override
-       public ModifyDialogItem cloneItem() {
-               NetworkItem item = new NetworkItem();
-               for (ModifyDialogItem subItem : subItems) {
-                       item.addSubItems(subItem.cloneItem());
-               }
 
-               return item;
-       }
 
        public boolean isNATType() {
                String connectType = getItemListComp().getPropertyValue().
@@ -221,4 +179,14 @@ public class NetworkItem extends CategoryItem {
                        item.changeItem(srcDialogItem);
                }
        }
+
+       @Override
+       public ModifyDialogItem cloneItem() {
+               NetworkItem item = new NetworkItem();
+               for (ModifyDialogItem subItem : subItems) {
+                       item.addSubItems(subItem.cloneItem());
+               }
+
+               return item;
+       }
 }
diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TunerCountryItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TunerCountryItem.java
new file mode 100644 (file)
index 0000000..bdf28ae
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * 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.item.modify.vm;
+
+import java.util.List;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ComboItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubModifyItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
+
+public class TunerCountryItem extends ComboItem {
+
+       List<String> optionList;
+       private String tunerCountry = "";
+       public static String SYSTEM_ATSC = "ATSC"; //$NON-NLS-1$
+
+       public TunerCountryItem(String title, List<String> optionList) {
+               super(ItemName.TUNER_COUNTRY, title);
+               this.optionList = optionList;
+       }
+
+       @Override
+       public void create(Composite parent) {
+               item = new SubModifyItem(this);
+               item.setItemHeight(SubModifyItem.ITEM_HEIGHT);
+               item.init(parent);
+               item.setItemTitle(new SubItemTitle(item.getItemComp(), getTitle(),
+                               ColorResources.WHITE));
+               item.create();
+
+               makeBody();
+       }
+
+       private void createDetailItem() {
+               createDetailItem(tunerCountry);
+               String tunerSystem = getItemListComp().getPropertyValue().getSubOptionValue(
+                               ItemName.TUNER, ItemName.TUNER_SYSTEM);
+
+               setTitleEnable(SYSTEM_ATSC.equals(tunerSystem));
+       }
+
+
+       protected void makeBody() {
+               if (isDetailMode()) {
+                       createDetailItem();
+                       return;
+               }
+               // create combo
+               createCombo(item, SubModifyItem.BOX_WIDTH);
+
+               // init combo list
+               initComboList();
+               resetCombo(getItemListComp().getPropertyValue().getSubOptionValue(
+                               ItemName.TUNER, ItemName.TUNER_SYSTEM));
+       }
+
+
+       public void resetCombo(String tunerSystem) {
+               if (getItemListComp().isCreateMode()
+                               && tunerSystem == null || tunerSystem.isEmpty()) {
+                       tunerSystem = SYSTEM_ATSC;
+               }
+
+               if (SYSTEM_ATSC.equals(tunerSystem)) {
+                       // enable & init combo
+                       setItemEnable(true);
+
+                       // select item
+                       selectItem();
+
+               } else {
+                       // disable
+                       tunerCountry = "";
+                       comboBox.setText("");
+                       setItemEnable(false);
+               }
+       }
+
+
+       private void initComboList() {
+               for (String str : optionList) {
+                       addComboItem(str);
+               }
+
+               selectItem();
+       }
+
+       private void selectItem() {
+               if (comboBox == null || comboBox.isDisposed()) {
+                       return;
+               }
+
+               int index = -1;
+               for (int i=0 ; i < getComboItemList().size() ; i++) {
+                       if (getComboItemList().get(i).equals(tunerCountry)) {
+                               index = i;
+                               break;
+                       }
+               }
+
+               if (index == -1 || getItemListComp().isCreateMode()) {
+                       index = 0;
+                       tunerCountry = getComboItem(index);
+               }
+               selectComboItem(index, false);
+               comboSelected();
+       }
+
+       @Override
+       public void itemSelected(ComboBox comboBox) {
+               // This is called when combo item is selected
+               tunerCountry = comboBox.getSelectedItem();
+
+               comboSelected();
+       }
+
+       private void comboSelected() {
+               getItemListComp().checkValid();
+       }
+
+
+       @Override
+       public void setInitialValue(PropertyValue value) {
+               tunerCountry = value.getSubOptionValue(ItemName.TUNER, getName());
+       }
+
+       @Override
+       public void setValue(PropertyValue value) {
+               value.setSubOptionValue(ItemName.TUNER, getName(), tunerCountry);
+       }
+
+
+       @Override
+       public ModifyDialogItem cloneItem() {
+               return new TunerCountryItem(getTitle(), optionList);
+       }
+
+}
diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TunerItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TunerItem.java
new file mode 100644 (file)
index 0000000..3dacafc
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * 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.item.modify.vm;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ImageResources;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.ModifyItem;
+
+public class TunerItem extends CategoryItem {
+
+       public TunerItem(String title) {
+               super(ItemName.TUNER, title);
+               // TODO Auto-generated constructor stub
+       }
+
+       @Override
+       public void create(Composite parent) {
+               int itemHeight = 0;
+               if (subItems.size() == 0) {
+                       itemHeight = ModifyItem.ITEM_HEIGHT;
+
+               } else {
+                       subItems.get(subItems.size()-1).setDrawBottomLine(false);
+                       itemHeight = getItemHeight();
+               }
+
+               for (ModifyDialogItem subItem : subItems) {
+                       subItem.setDrawBottomLine(false);
+               }
+
+               item = new ModifyItem(this);
+//             item.setItemHeight(ModifyItem.ITEM_HEIGHT * subItems.size());
+               item.setItemHeight(itemHeight);
+               item.init(parent);
+               item.setItemTitle(createIconTitle(item, ImageResources.ICON_TITLE_TUNER));
+               item.create();
+
+               makeBody();
+       }
+
+
+       private void makeBody() {
+               item.setBodyLayoutGrid(1, 0);
+               createSubItems();
+       }
+
+       public void resetCountryItem(String tunerSystem) {
+               TunerCountryItem item = (TunerCountryItem)getSubItemByName(ItemName.TUNER_COUNTRY);
+               if (item == null) {
+                       return;
+               }
+               item.resetCombo(tunerSystem);
+       }
+
+
+       @Override
+       public ModifyDialogItem cloneItem() {
+               TunerItem item = new TunerItem(getTitle());
+               for (ModifyDialogItem subItem : subItems) {
+                       item.addSubItems(subItem.cloneItem());
+               }
+
+               return item;
+       }
+
+}
diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TunerSystemItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TunerSystemItem.java
new file mode 100644 (file)
index 0000000..8ce35bf
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Minkee Lee <minkee.lee@samsung.com>
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * 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.item.modify.vm;
+
+import java.util.List;
+
+import org.eclipse.swt.widgets.Composite;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ComboItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubModifyItem;
+import org.tizen.emulator.manager.ui.renewal.widgets.ComboBox;
+
+public class TunerSystemItem extends ComboItem {
+
+       private String tunerSystem = "";
+       List<String> optionList;
+
+       public TunerSystemItem(String title, List<String> optionList) {
+               super(ItemName.TUNER_SYSTEM, title);
+               this.optionList = optionList;
+       }
+
+       @Override
+       public void create(Composite parent) {
+               item = new SubModifyItem(this);
+               item.setItemHeight(SubModifyItem.ITEM_HEIGHT);
+               item.init(parent);
+               item.setItemTitle(new SubItemTitle(item.getItemComp(), getTitle(),
+                               ColorResources.WHITE));
+               item.create();
+
+               makeBody();
+       }
+
+
+       protected void makeBody() {
+               if (isDetailMode()) {
+                       createDetailItem(tunerSystem);
+                       return;
+               }
+               // create combo
+               createCombo(item, SubModifyItem.BOX_WIDTH);
+
+               // init combo list
+               initComboList();
+       }
+
+
+       private void initComboList() {
+               for (String str : optionList) {
+                       addComboItem(str);
+               }
+
+               selectItem();
+       }
+
+       private void selectItem() {
+               if (comboBox == null || comboBox.isDisposed()) {
+                       return;
+               }
+
+               int index = -1;
+               for (int i=0 ; i < getComboItemList().size() ; i++) {
+                       if (getComboItemList().get(i).equals(tunerSystem)) {
+                               index = i;
+                               break;
+                       }
+               }
+
+               if (index == -1 || getItemListComp().isCreateMode()) {
+                       index = 0;
+                       tunerSystem = getComboItem(index);
+               }
+               selectComboItem(index, false);
+               comboSelected();
+       }
+
+       @Override
+       public void itemSelected(ComboBox comboBox) {
+               // This is called when combo item is selected
+               tunerSystem = comboBox.getSelectedItem();
+               ((TunerItem)getParentItem()).resetCountryItem(tunerSystem);
+
+               comboSelected();
+       }
+
+       private void comboSelected() {
+               getItemListComp().checkValid();
+       }
+
+       @Override
+       public void setInitialValue(PropertyValue value) {
+               tunerSystem = value.getSubOptionValue(ItemName.TUNER, getName());
+       }
+
+       @Override
+       public void setValue(PropertyValue value) {
+               value.setSubOptionValue(ItemName.TUNER, getName(), tunerSystem);
+       }
+
+       @Override
+       public ModifyDialogItem cloneItem() {
+               return new TunerSystemItem(getTitle(), optionList);
+       }
+
+}
diff --git a/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TunerTableItem.java b/src/org/tizen/emulator/manager/ui/renewal/item/modify/vm/TunerTableItem.java
new file mode 100644 (file)
index 0000000..0919d0f
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * 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.item.modify.vm;
+
+import java.io.File;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.tizen.emulator.manager.renewal.resources.ColorResources;
+import org.tizen.emulator.manager.ui.renewal.MainDialog;
+import org.tizen.emulator.manager.ui.renewal.item.ItemName;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.FileDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.common.ModifyDialogItem;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.PropertyValue;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubItemTitle;
+import org.tizen.emulator.manager.ui.renewal.item.modify.comp.SubModifyItem;
+
+public class TunerTableItem extends FileDialogItem {
+
+       private String newTableFilePath = "";
+       private String newTableFileName = "";
+       private static final int BOX_WIDTH = 154;
+
+       private static FileDialog fd;
+
+       public static String TABLE_DEFAULT = "tuner_default.cfg"; //$NON-NLS-1$
+
+       public TunerTableItem(String title) {
+               super(ItemName.TUNER_TABLE, title);
+       }
+
+       @Override
+       public void create(Composite parent) {
+               item = new SubModifyItem(this);
+               item.setItemHeight(SubModifyItem.ITEM_HEIGHT);
+               item.init(parent);
+               item.setItemTitle(new SubItemTitle(item.getItemComp(), getTitle(),
+                               ColorResources.WHITE));
+               item.create();
+
+               makeBody(BOX_WIDTH);
+
+       }
+
+       @Override
+       protected void makeBody(int textBoxWidth) {
+               item.setBodyLayoutForm();
+               if (getItemListComp().isDetailMode()) {
+                       createDetailItem();
+
+               } else {
+                       createTextBox(textBoxWidth);
+                       createFileDialogButton();
+                       String text = newTableFilePath.isEmpty() ? newTableFileName
+                                       : newTableFilePath;
+                       setTextBox(text);
+               }
+       }
+
+       private void createDetailItem() {
+               item.setBodyLayoutForm();
+               Canvas canvas = new Canvas(item.getBody(), SWT.NONE)    ;
+               canvas.setLayoutData(getDetailItemFormData());
+
+               String text = newTableFilePath.isEmpty() ? newTableFileName
+                               : newTableFilePath;
+               settingDetailItemPath(text, canvas);
+
+       }
+
+       @Override
+       public void setInitialValue(PropertyValue value) {
+               newTableFileName = value.getSubOptionValue(ItemName.TUNER, ItemName.TUNER_FILE_NAME);
+               newTableFilePath = value.getSubOptionValue(ItemName.TUNER, ItemName.TUNER_FILE_PATH);
+
+               if (newTableFileName.isEmpty()) {
+                       newTableFileName = TABLE_DEFAULT;
+                       newTableFilePath = "";
+               }
+       }
+
+       @Override
+       public void setValue(PropertyValue value) {
+               value.setSubOptionValue(ItemName.TUNER, ItemName.TUNER_FILE_NAME, newTableFileName);
+               value.setSubOptionValue(ItemName.TUNER, ItemName.TUNER_FILE_PATH, newTableFilePath);
+
+       }
+
+       @Override
+       public ModifyDialogItem cloneItem() {
+               return new TunerTableItem(getTitle());
+       }
+
+       @Override
+       public void fileSelected() {
+               newTableFilePath = filePath;
+               newTableFileName = newTableFilePath.substring(newTableFilePath
+                               .lastIndexOf(File.separator) + 1, newTableFilePath.length());
+               getItemListComp().checkValid();
+       }
+
+
+       @Override
+       protected String clickFileDialogButon() {
+               if (fd == null) {
+                       fd = new FileDialog(MainDialog.getShell(), SWT.OPEN);
+                       fd.setText("Select tuner file");
+
+                       String[] filter = null;
+                       String[] filterName = null;
+                       filter = new String[] {"*.cfg", "*"};
+                       fd.setFilterExtensions(filter);
+
+                       filterName = new String[] {
+                                       "Tuner config file (*.cfg) ", "All Files"};
+                       fd.setFilterNames(filterName);
+               }
+
+
+               fd.setFilterPath(getLastDirectoryPath());
+               return fd.open();
+       }
+
+       @Override
+       public boolean isValid() {
+               boolean isValid = true;
+               String msg = "";
+               if (newTableFilePath != null && !newTableFilePath.isEmpty()) {
+                       if (!new File(newTableFilePath).exists()) {
+                               msg = "Tuner file is not exist";
+                               isValid = false;
+                       }
+               }
+
+               changeItemState(!isValid, BOX_WIDTH + 37 /* TODO: dialog button width*/, msg);
+               return isValid;
+       }
+}
index 3395b4d..547a4f9 100644 (file)
@@ -118,8 +118,9 @@ public class TextBox extends NinePatchBox {
                                gc.setForeground(ColorResources.DISABLED_TEXT.getColor());
                                gc.setFont(FontResources.CONTENT.getFont());
 
+                               String displayText = WidgetHelper.shortenText(gc, text, ((Composite)e.widget).getClientArea());
                                int itemHeight = ((Composite)e.widget).getBounds().height;
-                               Point textExt = gc.textExtent(text);
+                               Point textExt = gc.textExtent(displayText);
                                int posY = (itemHeight - textExt.y) / 2;
 
                                int posX = TEXT_INDENT;
@@ -127,7 +128,7 @@ public class TextBox extends NinePatchBox {
                                        int itemWidth = ((Composite)e.widget).getBounds().width;
                                        posX = (itemWidth - textExt.x)/ 2;
                                }
-                               gc.drawText(text, posX, posY);
+                               gc.drawText(displayText, posX, posY);
                        }
 
                });
index 2e8244e..d7a4944 100644 (file)
                        <option name="defaultOnCreate">Native</option>
                </item>
 <!--           <item name="ociDevice" title="OCI Device" type="combo" /> -->
+<!--           <item name="tuner" title="Tuner" type="label" > -->
+<!--                   <item name="system" title="System" type="combo" > -->
+<!--                           <option name="list">ATSC,DVB,ISDB</option> -->
+<!--                           <option name="defaultOnCreate">ATSC</option> -->
+<!--                   </item> -->
+<!--                   <item name="country" title="Country" type="combo" > -->
+<!--                           <option name="list">KOR,USA</option> -->
+<!--                           <option name="defaultOnCreate">KOR</option> -->
+<!--                   </item> -->
+<!--                   <item name="table" title="Table" type="file"> -->
+<!--                           <option name="filter">*.cfg</option> -->
+<!--                           <option name="defaultOnCreate">tuner_default.cfg</option> -->
+<!--                   </item> -->
+<!--           </item> -->
        </itemGroup>
 
 </ItemList>