Property: Fix file sharing option.
authorminkee.lee <minkee.lee@samsung.com>
Wed, 15 Oct 2014 14:04:22 +0000 (23:04 +0900)
committerminkee.lee <minkee.lee@samsung.com>
Thu, 16 Oct 2014 05:29:22 +0000 (14:29 +0900)
- Check if sharing directory exists.(when create/modify VM, launch VM)

Change-Id: I892374651797596b67bbd6329f5511ac8ec2c5d9
Signed-off-by: minkee.lee <minkee.lee@samsung.com>
common-project/src/org/tizen/emulator/manager/ui/detail/item/property/FileShareDialogSubViewItem.java
common-project/src/org/tizen/emulator/manager/ui/detail/item/template/FileSubViewItem.java
common-project/src/org/tizen/emulator/manager/vms/Creator.java
common-project/src/org/tizen/emulator/manager/vms/VMWorkerCommon.java

index 8055a8a..a43fa05 100644 (file)
@@ -39,9 +39,6 @@ import org.tizen.emulator.manager.vms.xml.template.Item;
 
 public class FileShareDialogSubViewItem extends FileSubViewItem {
 
-       private String oldPathName;
-       private String newPathName;
-
        public FileShareDialogSubViewItem(LabelViewItem parentItem, Composite comp,
                        Item template) {
                super(parentItem, comp, template);
@@ -65,15 +62,15 @@ public class FileShareDialogSubViewItem extends FileSubViewItem {
 
        @Override
        public boolean settingModifyItem(VMPropertyValue value) {
-               newValue        = value.fileSharePath;
+               newValue = oldValue = value.fileSharePath;
                newPathName = oldPathName = value.fileSharePathName;
 
                if (value.isFileShareSupport) {
-                       filePathLabel.setText(oldPathName);
+                       filePathLabel.setText(newPathName);
                        filePathLabel.setToolTipText(newValue);
                        selectFileButton.setEnabled(true);
                } else {
-                       filePathLabel.setText(oldPathName);
+                       filePathLabel.setText(newPathName);
                        selectFileButton.setEnabled(false);
                }
 
@@ -81,12 +78,18 @@ public class FileShareDialogSubViewItem extends FileSubViewItem {
        }
 
        public void setFileShareOn() {
+               newValue = oldValue;
+               newPathName = oldPathName;
                selectFileButton.setEnabled(true);
                filePathLabel.setText(newPathName);
+               filePathLabel.setToolTipText(newValue);
        }
 
        public void setFileShareOff() {
+               newValue = "";
+               newPathName = "";
                selectFileButton.setEnabled(false);
-               filePathLabel.setText("");
+               filePathLabel.setText(newPathName);
+               filePathLabel.setToolTipText(newValue);
        }
 }
index 3aecfbf..175f4a6 100644 (file)
@@ -59,6 +59,9 @@ public class FileSubViewItem extends SubViewItem {
        protected String oldValue;
        protected String newValue;
 
+       protected String oldPathName;
+       protected String newPathName;
+
        // for modify view
        protected ImageLabel filePathLabel;
        protected ImageButton selectFileButton;
@@ -147,10 +150,10 @@ public class FileSubViewItem extends SubViewItem {
 
                                        String path = fd.open();
                                        if (path != null) {
-                                               newValue = path;
-                                               String fileName = newValue.substring(newValue
+                                               oldValue = newValue = path;
+                                               oldPathName = newPathName = newValue.substring(newValue
                                                                                        .lastIndexOf(File.separator) + 1, newValue.length());
-                                               filePathLabel.setText(fileName);
+                                               filePathLabel.setText(newPathName);
                                                filePathLabel.setToolTipText(newValue);
 
                                        }
@@ -164,10 +167,10 @@ public class FileSubViewItem extends SubViewItem {
                                        EMLogger.getLogger().fine("Open Directory Dialog");
                                        String path = dd.open();
                                        if (path != null) {
-                                               newValue = path;
-                                               String dirName = path.substring(path
+                                               oldValue = newValue = path;
+                                               oldPathName = newPathName = path.substring(path
                                                                                        .lastIndexOf(File.separator) + 1, path.length());
-                                               filePathLabel.setText(dirName);
+                                               filePathLabel.setText(newPathName);
                                                filePathLabel.setToolTipText(newValue);
                                        }
                                }
index 73c8547..20cc9b9 100644 (file)
@@ -232,6 +232,10 @@ public class Creator {
                        if (newVM.fileSharePath == null || newVM.fileSharePath.isEmpty()) {
                                throw new VMCreatorException("Select sharing file path");
                        }
+                       File file = new File(newVM.fileSharePath);
+                       if (!file.exists()) {
+                               throw new VMCreatorException("Sharing file path is invalid.");
+                       }
                }
        }
 
index 1de2db5..2e98a9b 100644 (file)
@@ -113,6 +113,15 @@ public abstract class VMWorkerCommon {
                                                }
                                        }
 
+                                       // Check File sharing
+                                       String fileshare = property.getConfiguration().getUsability().getFileSharing().getPath();
+                                       if (fileshare != null) {
+                                               File f = new File(fileshare);
+                                               if (!f.exists()) {
+                                                       throw new VMWorkerException("File sharing path is invalid or not exist.");
+                                               }
+                                       }
+
                                        isRunningNow();
 
                                        if (!launcher.launch(property, wait)) {