final Policy policy = context.getPolicy( Policy.NONEXIST_IN_PROJECT );
final MessagePolicy messagePolicy = policy.adapt( MessagePolicy.class );
- messagePolicy.print( context.getPrompter(), "{0} doesn't exist", this.path );
+ if ( messagePolicy != null ) {
+ messagePolicy.print( context.getPrompter(), "{0} doesn't exist", this.path );
+ }
+
return ;
}
if ( !handler.is( baseDir, Attribute.EXISTS ) )
{
final Policy policy = context.getPolicy( NONEXIST_IN_DIRECTORY );
-
+ if ( policy == null ) {
+ throw new IllegalStateException( "Could not find a policy : " + NONEXIST_IN_DIRECTORY );
+ }
+
final MessagePolicy messagePolicy = policy.adapt( MessagePolicy.class );
-
- messagePolicy.print( context.getPrompter(), "{0} doesn't exist.", baseDir );
+ if ( messagePolicy != null ) {
+ messagePolicy.print( context.getPrompter(), "{0} doesn't exist.", baseDir );
+ }
+
return ;
}
if ( handler.is( path, Attribute.EXISTS ) )
{
final Policy policy = context.getPolicy( EXIST_OUT_WGT );
-
+ if ( policy == null ) {
+ throw new IllegalStateException( "Could not find a policy : " + EXIST_OUT_WGT );
+ }
+
final MessagePolicy messagePolicy = policy.adapt( MessagePolicy.class );
- messagePolicy.print( context.getPrompter(), "Widget already exist." );
-
+ if ( messagePolicy != null ) {
+ messagePolicy.print( context.getPrompter(), "Widget already exist." );
+ }
final FilePolicy filePolicy = policy.adapt( FilePolicy.class );
-
+
if ( FilePolicy.OVERWRITE.equals( filePolicy ) )
{
logger.debug( "No operation" );
{ // It is default to stop process
return ;
}
-
}
final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
int x = 1;\r
int y = 1;\r
int clientAreaWidth = getClientArea().width;\r
- int textWidth = gc.stringExtent(text).x;\r
int imageWidth = image.getBounds().width;\r
int imageHeght = image.getBounds().height;\r
int maxWidth = Math.max(Math.max(imageWidth, imageWidth), clientAreaWidth);\r
\r
if ((image != null) & (text != null)) {\r
+ int textWidth = gc.stringExtent(text).x;\r
x = 1 + (maxWidth - imageWidth) / 2;\r
gc.drawImage(image, x, y);\r
y = y + imageHeght + 5;\r
x = 1 + (maxWidth - imageWidth) / 2;\r
gc.drawImage(image, x, 1);\r
} else if (text != null) {\r
+ int textWidth = gc.stringExtent(text).x;\r
x = 1 + (maxWidth - textWidth) / 2;\r
gc.drawText(text, x, 1);\r
}\r
*/
public static String getEncryptedString(String s)
throws InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
- return new String(Base64.encode(encryptByDES(s)));
+ String encoded = Base64.encode( encryptByDES( s ) );
+ if ( encoded == null ) {
+ return s;
+ }
+
+ return encoded;
}
}
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils;
import org.eclipse.ui.internal.ide.dialogs.IFileStoreFilter;
import org.tizen.common.Surrogate;
Assert.notNull(source);
Assert.notNull(destination);
+
+ IWorkbenchWindow window = ViewUtil.getWorkbenchWindow();
+ if ( window == null ) {
+ throw new OperationCanceledException( "Could not find a window" );
+ }
+
previousChoice = isExistResourceWithDialog(
- ViewUtil.getWorkbenchWindow().getShell(), Messages.FileExistDialogTitle,
+ window.getShell(), Messages.FileExistDialogTitle,
Messages.bind( Messages.FileExistMsg, destination.getName() ),
previousChoice, destination);
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
*/
public static void generateDocument(Map<String, Object> root, Configuration cfg, String templateFile, File destinationFile)
throws IOException, TemplateException {
- generateDocument(root, cfg, templateFile, new FileOutputStream( destinationFile ));
+ OutputStream out = null;
+ try {
+ out = new FileOutputStream( destinationFile );
+ generateDocument(root, cfg, templateFile, out );
+ } finally {
+ IOUtil.tryClose( out );
+ }
}
/**
*/
public static void generateDocument(Map<String, Object> root, Configuration cfg, String templateFile, OutputStream outputStream)
throws IOException, TemplateException {
- generateDocument(root, cfg, templateFile, new BufferedWriter( new OutputStreamWriter( outputStream ) ));
+
+ Writer writer = null;
+ try {
+ writer = new OutputStreamWriter( outputStream );
+ writer = new BufferedWriter( writer );
+ generateDocument( root, cfg, templateFile, writer );
+ } finally {
+ IOUtil.tryClose( writer );
+ }
}
/**
Template template = cfg.getTemplate(templateFile);
// generate document
- try {
- template.process(root, writer);
- IOUtil.tryFlush(writer);
- } finally {
- IOUtil.tryClose(writer);
- }
+ template.process(root, writer);
+ IOUtil.tryFlush(writer);
}
}
}
ZipFile zipfile = new ZipFile( fullpath );
- ZipEntry entry = zipfile.getEntry( name );
- if ( entry == null ) {
- return null;
+ try {
+ ZipEntry entry = zipfile.getEntry( name );
+ if ( entry == null ) {
+ return null;
+ }
+
+ InputStream in = zipfile.getInputStream( entry );
+ return IOUtil.getString( in, true );
+ } finally {
+ if ( zipfile != null ) {
+ zipfile.close();
+ }
}
-
- InputStream in = zipfile.getInputStream( entry );
- return IOUtil.getString( in, true );
}
}