tmf: Switch tmf.ui to Java 7 + fix warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / wizards / importtrace / BatchImportTraceWizard.java
index b1074d65c004748c6fb5c741564bf7eea7361f4e..e814d8acf5f81af59a9003b7577a021acf7326c6 100644 (file)
@@ -91,19 +91,19 @@ public class BatchImportTraceWizard extends Wizard implements IImportWizard {
     private IWizardPage fSelectTypePage;
     private IWizardPage fOptions;
 
-    private final List<String> fTraceTypesToScan = new ArrayList<String>();
-    private final Set<String> fParentFilesToScan = new HashSet<String>();
+    private final List<String> fTraceTypesToScan = new ArrayList<>();
+    private final Set<String> fParentFilesToScan = new HashSet<>();
 
     private ImportTraceContentProvider fScannedTraces = new ImportTraceContentProvider(fTraceTypesToScan, fParentFilesToScan);
 
-    private final Map<TraceValidationHelper, Boolean> fResults = new HashMap<TraceValidationHelper, Boolean>();
+    private final Map<TraceValidationHelper, Boolean> fResults = new HashMap<>();
     private boolean fOverwrite = true;
     private boolean fLinked = true;
 
     private BlockingQueue<TraceValidationHelper> fTracesToScan;
-    private final Set<FileAndName> fTraces = new TreeSet<FileAndName>();
+    private final Set<FileAndName> fTraces = new TreeSet<>();
 
-    private Map<String, Set<String>> fParentFiles = new HashMap<String, Set<String>>();
+    private Map<String, Set<String>> fParentFiles = new HashMap<>();
 
     // Target import directory ('Traces' folder)
     private IFolder fTargetFolder;
@@ -261,7 +261,7 @@ public class BatchImportTraceWizard extends Wizard implements IImportWizard {
                     }
                 }
                 else {
-                    List<File> subList = new ArrayList<File>();
+                    List<File> subList = new ArrayList<>();
                     IPath path = fTargetFolder.getFullPath();
                     File parentFile = traceToImport.getFile();
                     final boolean isFile = parentFile.isFile();
@@ -270,12 +270,12 @@ public class BatchImportTraceWizard extends Wizard implements IImportWizard {
                         if (fOverwrite || !resource.exists()) {
                             subList.add(parentFile);
                             parentFile = parentFile.getParentFile();
-                            final FileInputStream source = new FileInputStream(traceToImport.getFile());
-                            if (resource.exists()) {
-                                resource.delete(IResource.FORCE, new NullProgressMonitor());
+                            try (final FileInputStream source = new FileInputStream(traceToImport.getFile());) {
+                                if (resource.exists()) {
+                                    resource.delete(IResource.FORCE, new NullProgressMonitor());
+                                }
+                                resource.create(source, true, new NullProgressMonitor());
                             }
-                            resource.create(source, true, new NullProgressMonitor());
-                            source.close();
                             setTraceType(traceToImport);
                             success = true;
                         }
@@ -408,7 +408,7 @@ public class BatchImportTraceWizard extends Wizard implements IImportWizard {
     public void setTraceTypesToScan(List<String> tracesToScan) {
         // intersection to know if there's a diff.
         // if there's a diff, we need to re-enque everything
-        List<String> added = new ArrayList<String>();
+        List<String> added = new ArrayList<>();
         for (String traceLoc : tracesToScan) {
             if (!fTraceTypesToScan.contains(traceLoc)) {
                 added.add(traceLoc);
@@ -580,7 +580,7 @@ public class BatchImportTraceWizard extends Wizard implements IImportWizard {
     private void updateTracesToScan(final List<String> added) {
         // Treeset is used instead of a hashset since the traces should be read
         // in the order they were added.
-        final Set<String> filesToScan = new TreeSet<String>();
+        final Set<String> filesToScan = new TreeSet<>();
         for (String name : fParentFiles.keySet()) {
             filesToScan.addAll(fParentFiles.get(name));
         }
@@ -596,7 +596,7 @@ public class BatchImportTraceWizard extends Wizard implements IImportWizard {
      * I am a job. Make me work
      */
     private synchronized IStatus updateFiles(IProgressMonitor monitor, String traceToScanAbsPath) {
-        final Set<String> filesToScan = new TreeSet<String>();
+        final Set<String> filesToScan = new TreeSet<>();
 
         int workToDo = 1;
         for (String name : fParentFiles.keySet()) {
This page took 0.027007 seconds and 5 git commands to generate.