[hg] main-silver: removed not used code

  • From: Tomas Stupka < >
  • To: ,
  • Subject: [hg] main-silver: removed not used code
  • Date: Fri, 03 May 2013 03:47:56 -0700

changeset 17bf53c20fa2 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/17bf53c20fa2
description:
        removed not used code

diffstat:

 
bugtracking.bridge/src/org/netbeans/modules/bugtracking/vcs/HgQueueHookImpl.java
                     |    4 +-
 
bugtracking/src/org/netbeans/modules/bugtracking/tasklist/TaskListProvider.java
                      |    2 +-
 bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueAction.java   
                        |    2 +-
 
bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingOwnerSupport.java
                   |  235 ++++-----
 bugtracking/src/org/netbeans/modules/bugtracking/util/OwnerUtils.java        
                        |    4 +-
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyBugtrackingOwnerSupport.java
 |   14 +-
 6 files changed, 110 insertions(+), 151 deletions(-)

diffs (407 lines):

diff --git 
a/bugtracking.bridge/src/org/netbeans/modules/bugtracking/vcs/HgQueueHookImpl.java
 
b/bugtracking.bridge/src/org/netbeans/modules/bugtracking/vcs/HgQueueHookImpl.java
--- 
a/bugtracking.bridge/src/org/netbeans/modules/bugtracking/vcs/HgQueueHookImpl.java
+++ 
b/bugtracking.bridge/src/org/netbeans/modules/bugtracking/vcs/HgQueueHookImpl.java
@@ -225,7 +225,7 @@
         File file = files[0];
         HookImpl.LOG.log(Level.FINE, "afterPatchFinish start for {0}", 
file);              // NOI18N
 
-        Repository repository = OwnerUtils.getRepository(file, 
op.getIssueID(), true);
+        Repository repository = OwnerUtils.getRepository(file, true);
         if (repository == null) {
             HookImpl.LOG.log(Level.FINE, " no issue repository for {0}:{1}", 
new Object[] { op.getIssueID(), file }); //NOI18N
             return;
@@ -301,7 +301,7 @@
                             Issue issue = null;
                             Repository repository = null;
                             try {
-                                repository = 
OwnerUtils.getRepository(referenceFile, issueId, false);
+                                repository = 
OwnerUtils.getRepository(referenceFile, false);
                                 if (repository == null) {
                                     issue = null;
                                 } else {
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasklist/TaskListProvider.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasklist/TaskListProvider.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasklist/TaskListProvider.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasklist/TaskListProvider.java
@@ -454,7 +454,7 @@
                     startTime = System.currentTimeMillis();
                 }
                 // lookup a repository registered with current projects
-                RepositoryImpl repository = 
BugtrackingOwnerSupport.getInstance().getRepository(fo, false);
+                RepositoryImpl repository = 
BugtrackingOwnerSupport.getInstance().getRepository(fo);
                 if (LOG.isLoggable(Level.FINER)) {
                     LOG.log(Level.FINER, "getRepositoriesFor: repository: 
{0} for {1} after {2}", new Object[] {repository, fo, 
(System.currentTimeMillis() - startTime)});
                 }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueAction.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueAction.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueAction.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueAction.java
@@ -192,7 +192,7 @@
 
                                 RepositoryImpl repository;
                                 if(repositoryParam == null) {
-                                    repository = 
BugtrackingOwnerSupport.getInstance().getRepository(file, issueId, true);
+                                    repository = 
BugtrackingOwnerSupport.getInstance().getRepository(file, true);
                                     if(repository == null) {
                                         // if no repository was known user 
was supposed to choose or create one
                                         // in scope of the previous 
getRepository() call. So null shoud stand
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingOwnerSupport.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingOwnerSupport.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingOwnerSupport.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingOwnerSupport.java
@@ -72,7 +72,9 @@
  * @author Tomas Stupka
  * @author Marian Petras
  */
-public abstract class BugtrackingOwnerSupport {
+public class BugtrackingOwnerSupport {
+
+    private static final Logger LOG = 
Logger.getLogger("org.netbeans.modules.bugtracking.bridge.BugtrackingOwnerSupport");
   // NOI18N
 
     private static BugtrackingOwnerSupport instance;
 
@@ -82,7 +84,7 @@
         if(instance == null) {
             instance = 
Lookup.getDefault().lookup(BugtrackingOwnerSupport.class);
             if (instance == null) {
-                instance = new DefaultImpl();
+                instance = new BugtrackingOwnerSupport();
             }
         }
         return instance;
@@ -93,8 +95,6 @@
         SELECTED_FILE_AND_ALL_PROJECTS,
     }
 
-    
//--------------------------------------------------------------------------
-
     public RepositoryImpl getRepository(Node... nodes) {
         if (nodes == null) {
             return null;
@@ -102,13 +102,11 @@
         if (nodes.length == 0) {
             return null;
         }
-        if (nodes.length == 1) {
-            return getRepository(nodes[0]);
-        }
 
         RepositoryImpl chosenRepo = null;
         for (Node node : nodes) {
             RepositoryImpl repo = getRepository(node);
+            
             if (repo == null) {
                 continue;
             }
@@ -126,7 +124,7 @@
         
         FileObject[] fos = BugtrackingUtil.getProjectDirectories(nodeLookup);
         if (fos != null && fos.length > 0) {
-            return getRepository(fos[0], false);
+            return getRepository(fos[0]);
         }
 
         DataObject dataObj = nodeLookup.lookup(DataObject.class);
@@ -137,19 +135,83 @@
         return null;
     }
 
-    protected abstract RepositoryImpl getRepository(DataObject dataObj);
+    private RepositoryImpl getRepository(DataObject dataObj) {
+        FileObject fileObj = dataObj.getPrimaryFile();
+        if (fileObj == null) {
+            return null;
+        }
 
-    public abstract RepositoryImpl getRepository(FileObject fileObject, 
boolean askIfUnknown);
+        FileObject ownerDirectory = 
BugtrackingUtil.getFileOwnerDirectory(fileObj);
+        if (ownerDirectory != null) {
+            return getRepository(ownerDirectory);
+        }
+
+        RepositoryImpl repo;
+
+        try {
+            repo = getRepositoryIntern(fileObj);
+        } catch (IOException ex) {
+            Exceptions.printStackTrace(ex);
+            repo = null;
+        }
+
+        return repo;
+    }
+
+    public RepositoryImpl getRepository(FileObject fileObject) {
+        RepositoryImpl repo;
+
+        try {
+            repo = getRepositoryIntern(fileObject);
+            if (repo != null) {
+                return repo;
+            }
+        } catch (IOException ex) {
+            return null;
+        }
+
+        File context = getLargerContext(fileObject);
+        if (context != null) {
+            return getRepositoryForContext(context, false);
+        } else {
+            return askUserToSpecifyRepository(null);
+        }
+    }
 
     public RepositoryImpl getRepository(File file, boolean askIfUnknown) {
-        return getRepository(file, null, askIfUnknown);
+        if(file == null) {
+            if(askIfUnknown) {
+                return askUserToSpecifyRepository(null);
+            } else {
+                return null;
+            }
+        }
+        //TODO - synchronization/threading
+        FileObject fileObject = FileUtil.toFileObject(file);
+        if (fileObject == null) {
+            LOG.log(Level.WARNING, " did not find a FileObject for file 
{0}", new Object[] {file}); //NOI18N
+        } else {
+            try {
+                RepositoryImpl repo = getRepositoryIntern(fileObject);
+                if (repo != null) {
+                    return repo;
+                }
+            } catch (IOException ex) {
+                LOG.log(Level.INFO,
+                      " communication with Kenai failed while loading " 
//NOI18N
+                          + "information about bugtracking repository", 
//NOI18N
+                      ex);
+                return null;
+            }
     }
 
-    public abstract RepositoryImpl getRepository(File file, String issueId, 
boolean askIfUnknown);
+        File context = getLargerContext(file, fileObject);
+        if (context == null) {
+            context = file;
+        }
 
-    protected abstract RepositoryImpl getRepositoryForContext(File context,
-                                                          String issueId,
-                                                          boolean 
askIfUnknown);
+        return getRepositoryForContext(context, askIfUnknown);
+    }
 
     public void setFirmAssociations(File[] files, RepositoryImpl repository) 
{
         if (files == null) {
@@ -203,6 +265,30 @@
         return 
FileToRepoMappingStorage.getInstance().getAllFirmlyAssociatedUrls();
     }
 
+    protected RepositoryImpl getRepositoryForContext(File context, boolean 
askIfUnknown) {
+        RepositoryImpl repo = FileToRepoMappingStorage.getInstance()
+                          .getFirmlyAssociatedRepository(context);
+        if (repo != null) {
+            LOG.log(Level.FINER, 
+                    " found stored repository [{0}] for directory {1}",     
//NOI18N
+                    new Object[]{repo, context});
+            return repo;
+        }
+
+        RepositoryImpl suggestedRepository = 
FileToRepoMappingStorage.getInstance()
+                                         
.getLooselyAssociatedRepository(context);
+        if (!askIfUnknown) {
+            return suggestedRepository;
+        }
+
+        repo = askUserToSpecifyRepository(suggestedRepository);
+        if (repo != null) {
+            return repo;
+        }
+
+        return null;
+    }
+    
     private static File getLargerContext() {
         FileObject openFile = getOpenFileObj();
         if (openFile != null) {
@@ -315,129 +401,13 @@
         return dataObj.getPrimaryFile();
     }
 
-    
//--------------------------------------------------------------------------
-
-    private static class DefaultImpl extends BugtrackingOwnerSupport {
-
-        private static final Logger LOG = 
Logger.getLogger("org.netbeans.modules.bugtracking.bridge.BugtrackingOwnerSupport");
   // NOI18N
-
-        @Override
-        protected RepositoryImpl getRepository(DataObject dataObj) {
-            FileObject fileObj = dataObj.getPrimaryFile();
-            if (fileObj == null) {
-                return null;
-            }
-            
-            FileObject ownerDirectory = 
BugtrackingUtil.getFileOwnerDirectory(fileObj);
-            if (ownerDirectory != null) {
-                return getRepository(ownerDirectory, false);
-            }
-
-            RepositoryImpl repo;
-
-            try {
-                repo = getKenaiBugtrackingRepository(fileObj);
-            } catch (IOException ex) {
-                Exceptions.printStackTrace(ex);
-                repo = null;
-            }
-
-            return repo;
-        }
-
-        @Override
-        public RepositoryImpl getRepository(FileObject fileObject, boolean 
askIfUnknown) {
-            RepositoryImpl repo;
-
-            try {
-                repo = getKenaiBugtrackingRepository(fileObject);
-                if (repo != null) {
-                    return repo;
-                }
-            } catch (IOException ex) {
-                return null;
-            }
-
-            File context = getLargerContext(fileObject);
-            if (context != null) {
-                return getRepositoryForContext(context, null, askIfUnknown);
-            } else {
-                return askUserToSpecifyRepository(null);
-            }
-        }
-
-        @Override
-        public RepositoryImpl getRepository(File file, String issueId, 
boolean askIfUnknown) {
-            if(file == null) {
-                if(askIfUnknown) {
-                    return askUserToSpecifyRepository(null);
-                } else {
-                    return null;
-                }
-            }
-            //TODO - synchronization/threading
-            FileObject fileObject = FileUtil.toFileObject(file);
-            if (fileObject == null) {
-                LOG.log(Level.WARNING, " did not find a FileObject for file 
{0}", new Object[] {file}); //NOI18N
-            } else {
-                try {
-                    RepositoryImpl repo = 
getKenaiBugtrackingRepository(fileObject);
-                    if (repo != null) {
-                        return repo;
-                    }
-                } catch (IOException ex) {
-                    LOG.log(Level.INFO,
-                          " communication with Kenai failed while loading " 
//NOI18N
-                              + "information about bugtracking repository", 
//NOI18N
-                          ex);
-                    return null;
-                }
-            }
-
-            File context = getLargerContext(file, fileObject);
-            if (context == null) {
-                context = file;
-            }
-
-            return getRepositoryForContext(context, issueId, askIfUnknown);
-        }
-
-        protected RepositoryImpl getRepositoryForContext(File context, 
String issueId,
-                                                     boolean askIfUnknown) {
-            RepositoryImpl repo = FileToRepoMappingStorage.getInstance()
-                              .getFirmlyAssociatedRepository(context);
-            if (repo != null) {
-                LOG.log(Level.FINER, 
-                        " found stored repository [{0}] for directory {1}",  
   //NOI18N
-                        new Object[]{repo, context});
-                return repo;
-            }
-
-            RepositoryImpl suggestedRepository = 
FileToRepoMappingStorage.getInstance()
-                                             
.getLooselyAssociatedRepository(context);
-            if (!askIfUnknown) {
-                return suggestedRepository;
-            }
-
-            repo = askUserToSpecifyRepository(suggestedRepository);
-            if (repo != null) {
-                return repo;
-            }
-
-            return null;
-        }
-
-        private static RepositoryImpl 
getKenaiBugtrackingRepository(FileObject fileObject) throws IOException {
-            return getRepository(fileObject);
-        }
-
         /**
          *
          * @param fileObject
          * @return
          * @throws IOException
          */
-        private static RepositoryImpl getRepository(FileObject fileObject) 
throws IOException {
+    private static RepositoryImpl getRepositoryIntern(FileObject fileObject) 
throws IOException {
             Object attValue = fileObject.getAttribute(
                                            
"ProvidedExtensions.RemoteLocation");//NOI18N
             if (attValue instanceof String) {
@@ -516,7 +486,6 @@
         private String getMessage(String msgKey) {
             return NbBundle.getMessage(BugtrackingOwnerSupport.class, 
msgKey);
         }
-    }
 
     private static FileObject getMainProjectDirectory() {
         ProjectServices projectServices = 
BugtrackingManager.getInstance().getProjectServices();
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/OwnerUtils.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/OwnerUtils.java
--- a/bugtracking/src/org/netbeans/modules/bugtracking/util/OwnerUtils.java
+++ b/bugtracking/src/org/netbeans/modules/bugtracking/util/OwnerUtils.java
@@ -57,8 +57,8 @@
     }
 
     // XXX don't need this, rely on repositoryquery, issueid isn't evaluated 
anyway
-    public static Repository getRepository(File file, String issueID, 
boolean askIfUnknown) {
-        RepositoryImpl impl = 
BugtrackingOwnerSupport.getInstance().getRepository(file, issueID, 
askIfUnknown);
+    public static Repository getRepository(File file, boolean askIfUnknown) {
+        RepositoryImpl impl = 
BugtrackingOwnerSupport.getInstance().getRepository(file, askIfUnknown);
         return impl != null ? impl.getRepository() : null;
     }
 
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyBugtrackingOwnerSupport.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyBugtrackingOwnerSupport.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyBugtrackingOwnerSupport.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyBugtrackingOwnerSupport.java
@@ -119,17 +119,7 @@
     }
 
     @Override
-    protected RepositoryImpl getRepository(DataObject dataObj) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public RepositoryImpl getRepository(FileObject fileObject, boolean 
askIfUnknown) {
-        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
-    }
-    
-    @Override
-    public RepositoryImpl getRepository(File file, String issueId, boolean 
askIfUnknown) {
+    public RepositoryImpl getRepository(File file, boolean askIfUnknown) {
         if (file == null) {
             throw new IllegalArgumentException("file is <null>");
         }
@@ -146,7 +136,7 @@
     }
 
     @Override
-    protected RepositoryImpl getRepositoryForContext(File context, String 
issueId, boolean askIfUnknown) {
+    protected RepositoryImpl getRepositoryForContext(File context, boolean 
askIfUnknown) {
         throw new UnsupportedOperationException("Not supported yet.");
     }
 

[hg] main-silver: removed not used code

Tomas Stupka 05/03/2013

Project Features

About this Project

ConnectedDeveloper was started in November 2009, is owned by tpavek, and has 64 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close