[hg] main-silver: minor refactorings and TODOs

  • From: Tomas Stupka < >
  • To: ,
  • Subject: [hg] main-silver: minor refactorings and TODOs
  • Date: Fri, 03 May 2013 03:47:57 -0700

changeset 0a0c651d9e74 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/0a0c651d9e74
description:
        minor refactorings and TODOs

diffstat:

 
bugtracking.bridge/src/org/netbeans/modules/bugtracking/bridge/ideservices/IDEServicesImpl.java
     |  34 +++--
 
bugtracking.bridge/src/org/netbeans/modules/bugtracking/bridge/ideservices/ProjectServicesImpl.java
 |   4 +-
 bugtracking/src/org/netbeans/modules/bugtracking/ide/spi/IDEServices.java    
                       |  58 +++++++--
 
bugtracking/src/org/netbeans/modules/bugtracking/ide/spi/ProjectServices.java 
                      |   9 +-
 bugtracking/src/org/netbeans/modules/bugtracking/jira/JiraUpdater.java       
                       |   2 +-
 
bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/DashboardViewer.java
               |   2 +-
 bugtracking/src/org/netbeans/modules/bugtracking/util/AutoupdateSupport.java 
                       |   2 +-
 bugtracking/src/org/netbeans/modules/bugtracking/util/FindTypesSupport.java  
                       |   4 +-
 bugtracking/src/org/netbeans/modules/bugtracking/util/StackTraceSupport.java 
                       |  28 +---
 9 files changed, 84 insertions(+), 59 deletions(-)

diffs (326 lines):

diff --git 
a/bugtracking.bridge/src/org/netbeans/modules/bugtracking/bridge/ideservices/IDEServicesImpl.java
 
b/bugtracking.bridge/src/org/netbeans/modules/bugtracking/bridge/ideservices/IDEServicesImpl.java
--- 
a/bugtracking.bridge/src/org/netbeans/modules/bugtracking/bridge/ideservices/IDEServicesImpl.java
+++ 
b/bugtracking.bridge/src/org/netbeans/modules/bugtracking/bridge/ideservices/IDEServicesImpl.java
@@ -69,6 +69,7 @@
 import org.openide.DialogDisplayer;
 import org.openide.NotifyDescriptor;
 import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
 import org.openide.loaders.DataObject;
 import org.openide.loaders.DataObjectNotFoundException;
 import org.openide.text.Line;
@@ -116,23 +117,13 @@
     }
 
     @Override
-    public boolean providesFindFile() {
-        return true;
-    }
-    
-    @Override
-    public FileObject findFile(String resourcePath) {
-        return GlobalPathRegistry.getDefault().findResource(resourcePath);
-    }    
-    
-    @Override
     public boolean providesJumpTo() {
         return true;
     }
 
     @Override
-    public void jumpTo(String label, String resource) {
-        TypeDescriptor td = TypeBrowser.browse(label, resource, null);
+    public void jumpTo(String resourcePath, String title) {
+        TypeDescriptor td = TypeBrowser.browse(title, resourcePath, null);
         if(td != null) {
             td.open();
         }
@@ -162,7 +153,7 @@
                                 return updateElement.getDescription();
                             }
                             @Override
-                            public boolean openInstallWizard() {
+                            public boolean installOrUpdate() {
                                 OperationContainer<InstallSupport> oc = 
isInstalled ? 
                                         OperationContainer.createForUpdate() 

                                         
OperationContainer.createForInstall();
@@ -228,12 +219,18 @@
     }
 
     @Override
-    public boolean providesSearchHistory(File file) {
-        return SearchHistorySupport.getInstance(file) != null;
+    public boolean providesOpenHistory() {
+        return true;
     }
 
     @Override
-    public boolean searchHistory(File file , int line) {
+    public boolean openHistory(String resourcePath, int line) {
+        FileObject fo = findFile(resourcePath);
+        File file = fo != null ? FileUtil.toFile(fo) : null;
+        if(file == null) {
+            LOG.log(Level.INFO, "No file available for path {0}", 
resourcePath);
+            return false;
+        }
         try {
             SearchHistorySupport support = 
SearchHistorySupport.getInstance(file);
             if(support != null) {
@@ -244,4 +241,9 @@
         }
         return false;
     }
+    
+    private  FileObject findFile(String resourcePath) {
+        return GlobalPathRegistry.getDefault().findResource(resourcePath);
 }
+
+}
diff --git 
a/bugtracking.bridge/src/org/netbeans/modules/bugtracking/bridge/ideservices/ProjectServicesImpl.java
 
b/bugtracking.bridge/src/org/netbeans/modules/bugtracking/bridge/ideservices/ProjectServicesImpl.java
--- 
a/bugtracking.bridge/src/org/netbeans/modules/bugtracking/bridge/ideservices/ProjectServicesImpl.java
+++ 
b/bugtracking.bridge/src/org/netbeans/modules/bugtracking/bridge/ideservices/ProjectServicesImpl.java
@@ -102,8 +102,8 @@
     }
 
     @Override
-    public <T> T runWhenNotBlocked(Callable<T> operation) throws Exception {
-        // w8 with loading to preject ot be opened
+    public <T> T runAfterProjectOpenFinished(Callable<T> operation) throws 
Exception {
+        // wait until projects are opened
         OpenProjects.getDefault().getOpenProjects();
         return operation.call();
     }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/ide/spi/IDEServices.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/ide/spi/IDEServices.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/ide/spi/IDEServices.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/ide/spi/IDEServices.java
@@ -55,17 +55,29 @@
     public boolean providesOpenDocument();
     public void openDocument(String resourcePath, int offset);
     
-    public boolean providesFindFile();
-    // XXX to be clarified if FileObject or if URL would be eventually 
better.
-    // used when opening search history for a file given by a stacktrace.
-    // Note, that io.File wouldn't work for VCS on remote filesystems 
-    public FileObject findFile(String resourcePath);
+    public boolean providesJumpTo();
         
-    public boolean providesJumpTo();
-    public void jumpTo(String label, String resource);
+    /**
+     * 
+     * @param resourcePath
+     * @param title 
+     */
+    public void jumpTo(String resourcePath, String title);
 
+    /**
+     * Determines whether the functionality to download a plugin is available
+     * @return 
+     */
     public boolean providesPluginUpdate();
     
+    /**
+     * Returns a Plugin with the given code name base in case there is none 
installed, 
+     * or that the currently installed version is lesser than the installed.
+     * 
+     * @param cnb - the plugins code name base
+     * @param pluginName the plugins name - e.g. Bugzilla or Jira
+     * @return plugin or null if not available
+     */
     public Plugin getPluginUpdates(String cnb, String pluginName);
 
     public boolean providesPatchUtils();
@@ -96,28 +108,46 @@
      * 
      * @return 
      */
+    // XXX move to impl
     public File selectFileContext();
 
-    public boolean providesSearchHistory(File file);
+    /**
+     * Determines whether the functionality to open the Hisotry for a 
resource (file)
+     * is available.
+     * 
+     * @return <code>true</code> if available, otherwise <code>false</code>
+     */
+    public boolean providesOpenHistory();
     
     /**
      * Meant to open a VCS history view where:
-     * - it is possible to traverse the given files history entries 
+     * - it is possible to traverse the given resource history entries 
      * - a diff view is provided, showing the selected revision compared 
against 
      * it's parent and positioned on the given line.
      *
-     * @param file Must be a versioned file (not a folder), otherwise false 
is returned 
-     * and the panel won't be opened
+     * @param resource resourcePath representing a versioned file (not a 
folder). 
+     * <b>Note</b> that the given path musn't necessarily be the full path 
+     * - e.g. org/netbeans/modules/bugzilla/Bugzilla.jav
      * @param lineNumber requested line number to lock on
-     * @return true if parameters are valid and the search history panel is 
opened, otherwise false
+     * @return true if parameters are valid, the file is versioned and the 
history view was opened, 
+     * otherwise false.
      */
-    public boolean searchHistory(File file, int line);
+    public boolean openHistory(String resourcePath, int line);
     
     /**
      * Provides access to a downloadable plugin - e.g. from the NetBeans UC
      */
     public interface Plugin {
+        /**
+         * Returns the plugins description
+         * @return 
+         */
         String getDescription();
-        boolean openInstallWizard();
+        
+        /**
+         * Install or Update the plugin. 
+         * @return 
+         */
+        boolean installOrUpdate();
     }
 }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/ide/spi/ProjectServices.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/ide/spi/ProjectServices.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/ide/spi/ProjectServices.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/ide/spi/ProjectServices.java
@@ -50,6 +50,7 @@
  *
  * @author Tomas Stupka
  */
+// XXX try to use URL instead of FileObject
 public interface ProjectServices {
     
     /**
@@ -60,7 +61,7 @@
      * @return
      * @throws Exception 
      */
-    public <T> T runWhenNotBlocked(final Callable<T> operation) throws 
Exception;
+    public <T> T runAfterProjectOpenFinished(final Callable<T> operation) 
throws Exception;
     
     /**
      * Return the currently open projects
@@ -84,4 +85,10 @@
     // XXX to be clarified if lookup (given by a node) is enough 
     // to get the project(s)
     public FileObject[] getProjectDirectories(Lookup lookup);
+    
+    // XXX 
+    // BOS.getOpenFileObject();
+    // FileObject getFileForCurrentSelection();  
+    
+    
 }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/jira/JiraUpdater.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/jira/JiraUpdater.java
--- a/bugtracking/src/org/netbeans/modules/bugtracking/jira/JiraUpdater.java
+++ b/bugtracking/src/org/netbeans/modules/bugtracking/jira/JiraUpdater.java
@@ -128,7 +128,7 @@
         if(ideServices != null) {
             IDEServices.Plugin plugin = 
ideServices.getPluginUpdates(JIRA_CNB, Bundle.MSG_JiraPluginName());
             if(plugin != null) {
-                plugin.openInstallWizard();
+                plugin.installOrUpdate();
             }
         }
     }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/DashboardViewer.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/DashboardViewer.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/DashboardViewer.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/tasks/dashboard/DashboardViewer.java
@@ -808,7 +808,7 @@
                 ProjectServices projectServices = 
BugtrackingManager.getInstance().getProjectServices();
                 try {
                     if(projectServices != null) {
-                        projectServices.runWhenNotBlocked(c);
+                        projectServices.runAfterProjectOpenFinished(c);
                     } else {
                         c.call();
                     }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/AutoupdateSupport.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/AutoupdateSupport.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/AutoupdateSupport.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/AutoupdateSupport.java
@@ -139,7 +139,7 @@
                             Bundle.CTL_AutoupdateTitle(pluginName),
                             Bundle.CTL_Yes()))
                     {
-                        plugin.openInstallWizard();
+                        plugin.installOrUpdate();
                     }
                 }
             }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/FindTypesSupport.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/FindTypesSupport.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/FindTypesSupport.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/FindTypesSupport.java
@@ -152,7 +152,7 @@
     
     public void register(final JTextPane pane) {
         IDEServices ideServices = 
BugtrackingManager.getInstance().getIDEServices();
-        if(ideServices == null || !ideServices.providesFindFile() || 
!ideServices.providesJumpTo()) {
+        if(ideServices == null || !ideServices.providesJumpTo()) {
             return;
         }
         long t = System.currentTimeMillis();
@@ -322,7 +322,7 @@
         public void jumpTo(String resource) {
             IDEServices ideServices = 
BugtrackingManager.getInstance().getIDEServices();
             if(ideServices != null) {
-                
ideServices.jumpTo(NbBundle.getMessage(FindTypesSupport.class, 
"LBL_FindType"), resource);  // NOI18N
+                ideServices.jumpTo(resource, 
NbBundle.getMessage(FindTypesSupport.class, "LBL_FindType"));  // NOI18N
             }
         }
     }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/StackTraceSupport.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/StackTraceSupport.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/StackTraceSupport.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/StackTraceSupport.java
@@ -306,41 +306,27 @@
 
     static boolean isAvailable() {
         IDEServices ideServices = 
BugtrackingManager.getInstance().getIDEServices();
-        return ideServices != null && ideServices.providesOpenDocument() && 
ideServices.providesFindFile();
+        return ideServices != null && ideServices.providesOpenDocument();
     }
     
     @NbBundle.Messages({"CTL_ShowHistoryTitle=Show History",
-                        "# {0} - path to be opened",  "MSG_NoHistory=History 
View not available for file with path\n {0}.",
-                        "# {0} - path to be opened",  "MSG_NoFile=No file 
found for path\n {0}."})
+                        "# {0} - path to be opened",  "MSG_NoHistory=History 
View not available for file with path\n {0}."})
     private static void openSearchHistory(final String path, final int line) 
{
-        final File file = findFile(path);
-        if ( file != null ) {
+        if(path == null) {
+            return;
+        }
             final IDEServices ideServices = 
BugtrackingManager.getInstance().getIDEServices();
-            if(ideServices == null || 
!ideServices.providesSearchHistory(file)) {
+        if(ideServices == null || !ideServices.providesOpenHistory()) {
                 return;
             }
             BugtrackingManager.getInstance().getRequestProcessor().post(new 
Runnable() {
                 @Override
                 public void run() {
-                    if(!ideServices.searchHistory(file, line)) {
+                if(!ideServices.openHistory(path, line)) {
                         
BugtrackingUtil.notifyError(Bundle.CTL_ShowHistoryTitle(), 
Bundle.MSG_NoHistory(path));
                     }
                 }
             });
-        } else {
-            BugtrackingUtil.notifyError(Bundle.CTL_ShowHistoryTitle(), 
Bundle.MSG_NoFile(path));            
-        }
-    }
-
-    private static File findFile(String path) {
-        IDEServices ideServices = 
BugtrackingManager.getInstance().getIDEServices();
-        if(ideServices != null) {
-            FileObject fo = ideServices.findFile(path);
-            if(fo != null) {
-                return FileUtil.toFile(fo);
-            }
-        }
-        return null;
     }
 
     public static void register(final JTextPane textPane) {

[hg] main-silver: minor refactorings and TODOs

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