[Title] applied CommonProjectDependentPackager#buildPackage()'s change
authorGun Kim <gune.kim@samsung.com>
Tue, 28 Aug 2012 08:08:48 +0000 (17:08 +0900)
committerGun Kim <gune.kim@samsung.com>
Tue, 28 Aug 2012 12:28:31 +0000 (21:28 +0900)
[Type]
[Module]
[Priority]
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I94575459bcdc6d02f75d2cfaf553daf8d751437b

org.tizen.nativeplatform/src/org/tizen/nativeplatform/build/BuildPackageObjectAction.java

index dfa5fa7..46ba5f9 100644 (file)
@@ -37,150 +37,156 @@ import org.tizen.nativecommon.build.exception.SBIException;
 import org.tizen.nativeplatform.Activator;
 
 public class BuildPackageObjectAction implements IWorkbenchWindowActionDelegate, IObjectActionDelegate {
-       protected IProject project;
-       protected IWorkbenchWindow window;
-       private IStatus status = null;
-       private final String PKGTYPE = "RPM";
-
-       public BuildPackageObjectAction() {
-       }
-
-       public BuildPackageObjectAction(IProject project) {
-               this.project = project;
-       }
-
-       @Override
-       public void run(IAction action) {
-               
-               CommonBuildPackageFile.setPackageType(project, PKGTYPE);
-               window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-               ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell());
-
-               try {
-                       dialog.run(true, true, new IRunnableWithProgress() {
-                               @Override
-                               public void run(IProgressMonitor monitor) throws InvocationTargetException,
-                                               InterruptedException {
-                                       status = null;
-                                       monitor.beginTask(CommonBuildMessages.PACKAGING_APPLICATION, -1);
-                                       
-                                       CommonProjectDependentPackager packager = ProjectTypeManager.getProjectPackagerInstance(project);
-                                       CheckCancelJob cancelJob = new CheckCancelJob(monitor, project, packager.getSbi(), true);
-                                       Thread checkCancelThread = new Thread(cancelJob);
-                                       checkCancelThread.start();                              
-
-                                       try {                                                                           
-                                               monitor.subTask("Building package...");
-                                               packager.buildPackage(PKGTYPE);
-                                       } catch (SBIException e) {
-                                               e.printStackTrace();
-                                               status = new Status(Status.ERROR, Activator.PLUGIN_ID, CommonBuildMessages.FAIL_TO_BUILD_PACKAGE);
-                                               cancelJob.setFinishFlag(true);
-                                               monitor.done();
-                                               return;
-                                       }
-                                       cancelJob.setFinishFlag(true);
-                                       monitor.done();                                 
-                               }
-                       });
-               } catch (Exception e) {
-                       e.printStackTrace();
-               }
-
-               if (status != null) {
-                       if (status.isOK()) {
-                               MessageDialog.openInformation(window.getShell(), CommonBuildMessages.BUILD_RESULT, status.getMessage());
-                       } else {
-                               MessageDialog.openError(window.getShell(), CommonBuildMessages.BUILD_RESULT, status.getMessage());
-                       }
-               }
-
-
-               // refresh the project explorer
-               try {
-                       project.refreshLocal(IResource.DEPTH_INFINITE, null );
-               } catch (CoreException e) {
-                       e.printStackTrace();
-               }
-       }
-
-       protected File findFirstFilebyExtension(File searchPath, String ext) {
-               File[] allFiles = searchPath.listFiles(new ExtFilter(ext));
-               if (allFiles == null || allFiles.length == 0)
-                       return null;
-               return allFiles[0];
-       }
-
-       protected class ExtFilter implements FilenameFilter {
-               protected String ext;
-
-               public ExtFilter(String ext) {
-                       this.ext = ext;
-               }
-
-               public boolean accept(File dir, String name) {
-                       return name.endsWith(ext);
-               }
-       }
-
-       @Override
-       public void selectionChanged(IAction action, ISelection selection) {
-               Object obj = null;
-
-               if (selection instanceof TreeSelection) {
-                       TreeSelection _selection = (TreeSelection)selection;
-
-                       if (_selection != null) {
-                               obj = _selection.getFirstElement();
-                       }
-               }
-
-               if (obj != null) {
-                       if (obj instanceof IProject) {
-                               project = (IProject) obj;
-                       }
-               }
-       }
-
-       @Override
-       public void setActivePart(IAction action, IWorkbenchPart targetPart) {
-               // do nothing
-       }
-
-       @Override
-       public void dispose() {
-               // do nothing
-       }
-
-       @Override
-       public void init(IWorkbenchWindow window) {
-               // do nothing
-       }
-
-       private class checkBuildPackageContinue implements Runnable {
-               private int result = -1;
-
-               public checkBuildPackageContinue() {
-               }
-
-               @Override
-               public void run() {
-                       synchronized(this) {
-                               // TODO Auto-generated method stub
-                               Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
-                               boolean bResult = MessageDialog.openQuestion(shell, "Question",
-                                               "Dependency checking has finished.\nDo you want to continue ?");
-                               if (bResult) {
-                                       result = 1;
-                               } else {
-                                       result = 0;
-                               }
-                       }
-               }
-
-               public int getResult() {
-                       return this.result;
-               }
-       };
+    protected IProject project;
+    protected IWorkbenchWindow window;
+    private IStatus status = null;
+    private final String PKGTYPE = "RPM";
+
+    public BuildPackageObjectAction() {
+    }
+
+    public BuildPackageObjectAction(IProject project) {
+        this.project = project;
+    }
+
+    @Override
+    public void run(IAction action) {
+
+        CommonBuildPackageFile.setPackageType(project, PKGTYPE);
+        window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+        ProgressMonitorDialog dialog = new ProgressMonitorDialog(window.getShell());
+
+        try {
+            dialog.run(true, true, new IRunnableWithProgress() {
+                @Override
+                public void run(IProgressMonitor monitor) throws InvocationTargetException,
+                InterruptedException {
+                    status = null;
+                    monitor.beginTask(CommonBuildMessages.PACKAGING_APPLICATION, -1);
+
+                    CommonProjectDependentPackager packager = ProjectTypeManager.getProjectPackagerInstance(project);
+                    CheckCancelJob cancelJob = new CheckCancelJob(monitor, project, packager.getSbi(), true);
+                    Thread checkCancelThread = new Thread(cancelJob);
+                    checkCancelThread.start();
+
+                    try {
+                        monitor.subTask("Building package...");
+                        packager.buildPackage(PKGTYPE);
+                    } catch (SBIException e) {
+                        e.printStackTrace();
+                        status = new Status(Status.ERROR, Activator.PLUGIN_ID, CommonBuildMessages.FAIL_TO_BUILD_PACKAGE);
+                        cancelJob.setFinishFlag(true);
+                        monitor.done();
+                        return;
+                    } catch (CoreException e) {
+                        status = new Status(Status.ERROR, Activator.PLUGIN_ID, e.getMessage());
+                        cancelJob.setFinishFlag(true);
+                        monitor.done();
+                        return;
+                    }
+
+                    cancelJob.setFinishFlag(true);
+                    monitor.done();
+                }
+            });
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        if (status != null) {
+            if (status.isOK()) {
+                MessageDialog.openInformation(window.getShell(), CommonBuildMessages.BUILD_RESULT, status.getMessage());
+            } else {
+                MessageDialog.openError(window.getShell(), CommonBuildMessages.BUILD_RESULT, status.getMessage());
+            }
+        }
+
+
+        // refresh the project explorer
+        try {
+            project.refreshLocal(IResource.DEPTH_INFINITE, null );
+        } catch (CoreException e) {
+            e.printStackTrace();
+        }
+    }
+
+    protected File findFirstFilebyExtension(File searchPath, String ext) {
+        File[] allFiles = searchPath.listFiles(new ExtFilter(ext));
+        if (allFiles == null || allFiles.length == 0)
+            return null;
+        return allFiles[0];
+    }
+
+    protected class ExtFilter implements FilenameFilter {
+        protected String ext;
+
+        public ExtFilter(String ext) {
+            this.ext = ext;
+        }
+
+        public boolean accept(File dir, String name) {
+            return name.endsWith(ext);
+        }
+    }
+
+    @Override
+    public void selectionChanged(IAction action, ISelection selection) {
+        Object obj = null;
+
+        if (selection instanceof TreeSelection) {
+            TreeSelection _selection = (TreeSelection)selection;
+
+            if (_selection != null) {
+                obj = _selection.getFirstElement();
+            }
+        }
+
+        if (obj != null) {
+            if (obj instanceof IProject) {
+                project = (IProject) obj;
+            }
+        }
+    }
+
+    @Override
+    public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+        // do nothing
+    }
+
+    @Override
+    public void dispose() {
+        // do nothing
+    }
+
+    @Override
+    public void init(IWorkbenchWindow window) {
+        // do nothing
+    }
+
+    private class checkBuildPackageContinue implements Runnable {
+        private int result = -1;
+
+        public checkBuildPackageContinue() {
+        }
+
+        @Override
+        public void run() {
+            synchronized(this) {
+                // TODO Auto-generated method stub
+                Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+                boolean bResult = MessageDialog.openQuestion(shell, "Question",
+                        "Dependency checking has finished.\nDo you want to continue ?");
+                if (bResult) {
+                    result = 1;
+                } else {
+                    result = 0;
+                }
+            }
+        }
+
+        public int getResult() {
+            return this.result;
+        }
+    };
 }