[Title] Added AppTrayIcon Feature
authorchanghyun1.lee <changhyun1.lee@samsung.com>
Sat, 16 Mar 2013 07:47:12 +0000 (16:47 +0900)
committerchanghyun1.lee <changhyun1.lee@samsung.com>
Sat, 16 Mar 2013 08:01:53 +0000 (17:01 +0900)
[Desc.]
[Issue] Redmine-8752

Change-Id: I8fcc4c560288826bc757789118d4bc9a16d67544

org.tizen.common/src/org/tizen/common/ui/dialog/NewIconDialog.java
org.tizen.common/src/org/tizen/common/util/ImageUtil.java

index 981f9b4..50fbac6 100644 (file)
@@ -205,6 +205,8 @@ public class NewIconDialog extends SelectionStatusDialog {
     @Override
     protected void okPressed() {
         IFile destFile = fProject.getFile(ICON_FILE_NAME);
+        String destFilePath =  destFile.getLocation().toString();
+
         if (destFile.exists()) {
             MessageDialog dlg = new MessageDialog(getShell(),
                     "File Already Exists",
@@ -219,7 +221,9 @@ public class NewIconDialog extends SelectionStatusDialog {
                 return;
             } else {
                 try {
-                    destFile.delete(true, null);
+                    if (! fPath.equals(destFilePath)) {
+                        destFile.delete(true, null);
+                    }
                 } catch (CoreException e) {
                     Logger.log(e);
                 }
@@ -231,9 +235,11 @@ public class NewIconDialog extends SelectionStatusDialog {
                 Image image = fPreviewImage.getImage();
                 ImageLoader loader = new ImageLoader();
                 loader.data = new ImageData[] { image.getImageData() };
-                loader.save(destFile.getLocation().toString(), SWT.IMAGE_PNG);
+                loader.save(destFilePath, SWT.IMAGE_PNG);
             } else {
-                FileUtil.copyTo(fPath, destFile.getLocation().toString(), false);
+                if (! fPath.equals(destFilePath)) {
+                    FileUtil.copyTo(fPath, destFilePath, false);
+                }
             }
 
             destFile.getParent().refreshLocal(1, null);
index acec67e..e066370 100644 (file)
@@ -30,7 +30,6 @@ import java.awt.image.DirectColorModel;
 import java.awt.image.IndexColorModel;
 import java.awt.image.WritableRaster;
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 
@@ -176,13 +175,7 @@ public class ImageUtil {
         } catch (Exception e) {
             Logger.log(e);
         } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (IOException e) {
-                    Logger.log(e);
-                }
-            }
+            IOUtil.tryClose(is);
         }
 
         if (image == null) {
@@ -201,13 +194,7 @@ public class ImageUtil {
         } catch (RuntimeException ex) {
             Logger.log(ex);
         } finally {
-            try {
-                if (is != null) {
-                    is.close();
-                }
-            } catch (IOException e) {
-                Logger.log(e);
-            }
+            IOUtil.tryClose(is);
         }
 
         if (image == null) {