return "Fail delete file.";
case RESULT_FAIL_CREATE_FILE:
return "Fail create file.";
+ default :
+ break;
}
throw new RuntimeException();
short_size = (int)size % 1000;
- String unit = null;
+ String unit = "GB";
switch(index)
{
case 2:
unit = "MB";
break;
- case 3:
- unit = "GB";
+ default:
return String.format("%.2f %s", size_for_GB, unit);
}
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;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWTException;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.PaletteData;
} else {
image = ImageIO.read(new File(path));
}
- } catch (Exception e) {
+ } catch (IOException e) {
Logger.log(e);
} finally {
IOUtil.tryClose(is);
}
public static Image getSWTImage(Display display, String relativePath) {
- Image image = null;
+ if ( StringUtil.isEmpty(relativePath) ) {
+ return new Image( display, 1, 1 );
+ }
+
InputStream is = ImageUtil.class.getResourceAsStream(relativePath);
try {
- image = new Image(Display.getDefault(), is);
- } catch (RuntimeException ex) {
- Logger.log(ex);
+ Image image = new Image(Display.getDefault(), is);
+ if ( image == null ) {
+ image = new Image(display, 1, 1);
+ }
+ return image;
} finally {
IOUtil.tryClose(is);
}
-
- if (image == null) {
- image = new Image(display, 1, 1);
- }
- return image;
}
public static Image convertImageToSWT(Display display, BufferedImage bImage) {
*/
public class LocalPortChecker
{
-
+ protected static String LOCAL_ADDRESS_IP = "127.0.0.1";
+
public static boolean isPortInRange( final int port )
{
return ( 0 <= port ) && ( port < 65536 );
ServerSocket socket = null;
try
{
- InetAddress localhost = InetAddress.getByName( "127.0.0.1" );
+ InetAddress localhost = InetAddress.getByName( LOCAL_ADDRESS_IP );
socket = new ServerSocket( port, 50, localhost );
return true;
}