@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",
return;
} else {
try {
- destFile.delete(true, null);
+ if (! fPath.equals(destFilePath)) {
+ destFile.delete(true, null);
+ }
} catch (CoreException e) {
Logger.log(e);
}
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);
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;
} 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) {
} 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) {