[hg] main-silver: node lookup wouldn't work with jdev so changed...

  • From: Tomas Stupka < >
  • To: ,
  • Subject: [hg] main-silver: node lookup wouldn't work with jdev so changed...
  • Date: Tue, 02 Jul 2013 14:28:34 -0700

changeset ff8971517da7 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/ff8971517da7
description:
        node lookup wouldn't work with jdev so changed the ProjectsServices 
spi accordingly

diffstat:

 bugtracking.bridge/manifest.mf                                               
                        |    2 +-
 bugtracking.bridge/nbproject/project.xml                                     
                        |    2 +-
 
bugtracking.bridge/src/org/netbeans/modules/bugtracking/bridge/ideservices/ProjectServicesImpl.java
  |   28 ++
 bugtracking/manifest.mf                                                      
                        |    2 +-
 bugtracking/nbproject/project.xml                                            
                        |    2 +-
 bugtracking/src/org/netbeans/modules/bugtracking/ui/issue/IssueAction.java   
                        |   10 +-
 bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryAction.java   
                        |   18 +-
 
bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingOwnerSupport.java
                   |   61 +---
 bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingUtil.java   
                        |   39 +-
 
bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupport.java
                    |   16 +-
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyBugtrackingOwnerSupport.java
 |   13 +-
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyNode.java
                    |   37 ++-
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyProjectServices.java
         |  129 ++++++++++
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupportTest.java
      |   36 ++-
 team.ui.util/manifest.mf                                                     
                        |    2 +-
 team.ui.util/src/org/netbeans/modules/team/ide/spi/ProjectServices.java      
                        |   13 +-
 16 files changed, 271 insertions(+), 139 deletions(-)

diffs (782 lines):

diff --git a/bugtracking.bridge/manifest.mf b/bugtracking.bridge/manifest.mf
--- a/bugtracking.bridge/manifest.mf
+++ b/bugtracking.bridge/manifest.mf
@@ -3,4 +3,4 @@
 OpenIDE-Module: org.netbeans.modules.bugtracking.bridge
 OpenIDE-Module-Layer: org/netbeans/modules/bugtracking/bridge/layer.xml
 OpenIDE-Module-Localizing-Bundle: 
org/netbeans/modules/bugtracking/bridge/Bundle.properties
-OpenIDE-Module-Specification-Version: 1.29
+OpenIDE-Module-Specification-Version: 1.30
diff --git a/bugtracking.bridge/nbproject/project.xml 
b/bugtracking.bridge/nbproject/project.xml
--- a/bugtracking.bridge/nbproject/project.xml
+++ b/bugtracking.bridge/nbproject/project.xml
@@ -133,7 +133,7 @@
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>1.11</specification-version>
+                        <specification-version>1.12</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
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
@@ -65,6 +65,7 @@
 import org.netbeans.api.project.ProjectManager;
 import org.netbeans.api.project.ProjectUtils;
 import org.netbeans.api.project.ui.OpenProjects;
+import org.netbeans.modules.bugtracking.util.BugtrackingUtil;
 import org.netbeans.modules.team.ide.spi.IDEProject;
 import org.netbeans.modules.team.ide.spi.ProjectServices;
 import org.netbeans.spi.project.ui.support.ProjectChooser;
@@ -73,6 +74,7 @@
 import org.openide.filesystems.FileEvent;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
+import org.openide.loaders.DataObject;
 import org.openide.nodes.Node;
 import org.openide.util.Exceptions;
 import org.openide.util.Lookup;
@@ -120,6 +122,32 @@
     }
 
     @Override
+    public FileObject[] getCurrentSelection() {
+        Node[] nodes = TopComponent.getRegistry().getCurrentNodes();
+        if(nodes == null) {
+            return null;
+        }        
+        List<FileObject> ret = new ArrayList<FileObject>();
+        for(Node node : nodes) {
+            Lookup nodeLookup = node.getLookup();
+            Collection<? extends Project> projects = 
nodeLookup.lookupAll(Project.class);
+            if(projects != null && !projects.isEmpty()) {
+                for (Project project : projects) {
+                    ret.add(project.getProjectDirectory());
+                }
+            } else {
+                DataObject dataObj = nodeLookup.lookup(DataObject.class);
+                if (dataObj != null) {
+                    FileObject fileObj = dataObj.getPrimaryFile();
+                    if (fileObj != null) {
+                        ret.add(fileObj);
+                    }
+                }
+            }
+        }
+        return ret.toArray(new FileObject[ret.size()]);
+    }
+
     public FileObject[] getProjectDirectories(Lookup lookup) {
         Collection<? extends Project> projects = 
lookup.lookupAll(Project.class);
         if(projects == null) {
diff --git a/bugtracking/manifest.mf b/bugtracking/manifest.mf
--- a/bugtracking/manifest.mf
+++ b/bugtracking/manifest.mf
@@ -3,5 +3,5 @@
 OpenIDE-Module: org.netbeans.modules.bugtracking
 OpenIDE-Module-Layer: org/netbeans/modules/bugtracking/layer.xml
 OpenIDE-Module-Localizing-Bundle: 
org/netbeans/modules/bugtracking/Bundle.properties
-OpenIDE-Module-Specification-Version: 1.59
+OpenIDE-Module-Specification-Version: 1.60
 
diff --git a/bugtracking/nbproject/project.xml 
b/bugtracking/nbproject/project.xml
--- a/bugtracking/nbproject/project.xml
+++ b/bugtracking/nbproject/project.xml
@@ -54,7 +54,7 @@
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>1.11</specification-version>
+                        <specification-version>1.12</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
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
@@ -58,10 +58,8 @@
 import org.netbeans.modules.bugtracking.util.BugtrackingOwnerSupport;
 import org.netbeans.modules.bugtracking.util.BugtrackingUtil;
 import org.netbeans.modules.bugtracking.util.UIUtils;
-import org.openide.nodes.Node;
 import org.openide.util.NbBundle;
 import org.openide.util.RequestProcessor;
-import org.openide.windows.WindowManager;
 
 /**
  * 
@@ -120,18 +118,14 @@
     }
 
     private static void createIssue() {
-        createIssue(null, 
WindowManager.getDefault().getRegistry().getActivatedNodes());
+        createIssue(null);
     }
 
     public static void createIssue(final RepositoryImpl repository) {
-        createIssue(repository, 
WindowManager.getDefault().getRegistry().getActivatedNodes());
-    }
-
-    private static void createIssue(final RepositoryImpl repository, final 
Node[] context) {
         BugtrackingManager.getInstance().getRequestProcessor().post(new 
Runnable() {
             @Override
             public void run() {
-                final File file = BugtrackingUtil.getFile(context);
+                final File file = BugtrackingUtil.getLargerSelection();
                 final boolean repositoryGiven = repository != null;
                 SwingUtilities.invokeLater(new Runnable() {
                     @Override
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryAction.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryAction.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryAction.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/ui/query/QueryAction.java
@@ -55,6 +55,8 @@
 import org.netbeans.modules.bugtracking.RepositoryImpl;
 import org.netbeans.modules.bugtracking.util.BugtrackingUtil;
 import org.netbeans.modules.bugtracking.util.UIUtils;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
 import org.openide.nodes.Node;
 import org.openide.util.NbBundle;
 import org.openide.windows.TopComponent;
@@ -83,30 +85,22 @@
 
     @Override
     public void actionPerformed(ActionEvent ev) {
-        openQuery(null, 
WindowManager.getDefault().getRegistry().getActivatedNodes());
+        openQuery(null);
     }
 
-    private static void openQuery(QueryImpl query, Node[] context) {
-        openQuery(query, null, context);
+    private static void openQuery(QueryImpl query) {
+        openQuery(query, null);
     }
 
     public static void openQuery(final QueryImpl query, final RepositoryImpl 
repositoryToSelect) {
-        openQuery(query, repositoryToSelect, null);
-    }
-
-    private static void openQuery(final QueryImpl query, final 
RepositoryImpl repositoryToSelect, Node[] context) {
         openQuery(query, repositoryToSelect, false);
     }
 
     public static void openQuery(final QueryImpl query, final RepositoryImpl 
repository, final boolean suggestedSelectionOnly) {
-        openQuery(query, repository, 
WindowManager.getDefault().getRegistry().getActivatedNodes(), 
suggestedSelectionOnly);
-    }
-
-    private static void openQuery(final QueryImpl query, final 
RepositoryImpl repository, final Node[] context, final boolean 
suggestedSelectionOnly) {
         BugtrackingManager.getInstance().getRequestProcessor().post(new 
Runnable() {
             @Override
             public void run() {
-                final File file = BugtrackingUtil.getFile(context);
+                final File file = BugtrackingUtil.getLargerSelection();
                 SwingUtilities.invokeLater(new Runnable() {
                     @Override
                     public void run() {
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
@@ -48,6 +48,7 @@
 import java.util.Collection;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.netbeans.api.queries.VersioningQuery;
 import org.netbeans.modules.bugtracking.APIAccessor;
 import org.netbeans.modules.bugtracking.BugtrackingManager;
 import org.netbeans.modules.bugtracking.DelegatingConnector;
@@ -62,8 +63,6 @@
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
 import org.openide.loaders.DataObject;
-import org.openide.nodes.Node;
-import org.openide.util.Exceptions;
 import org.openide.util.Lookup;
 import org.openide.util.NbBundle;
 import org.openide.windows.TopComponent;
@@ -96,17 +95,17 @@
         SELECTED_FILE_AND_ALL_PROJECTS,
     }
 
-    public RepositoryImpl getRepository(Node... nodes) {
-        if (nodes == null) {
+    public RepositoryImpl getRepository(FileObject... files) {
+        if (files == null) {
             return null;
         }
-        if (nodes.length == 0) {
+        if (files.length == 0) {
             return null;
         }
 
         RepositoryImpl chosenRepo = null;
-        for (Node node : nodes) {
-            RepositoryImpl repo = getRepository(node);
+        for (FileObject fo : files) {
+            RepositoryImpl repo = getRepository(fo);
             
             if (repo == null) {
                 continue;
@@ -120,45 +119,6 @@
         return chosenRepo;
     }
 
-    protected RepositoryImpl getRepository(Node node) {
-        final Lookup nodeLookup = node.getLookup();
-        
-        FileObject[] fos = BugtrackingUtil.getProjectDirectories(nodeLookup);
-        if (fos != null && fos.length > 0) {
-            return getRepository(fos[0]);
-        }
-
-        DataObject dataObj = nodeLookup.lookup(DataObject.class);
-        if (dataObj != null) {
-            return getRepository(dataObj);
-        }
-
-        return null;
-    }
-        
-    private RepositoryImpl getRepository(DataObject dataObj) {
-        FileObject fileObj = dataObj.getPrimaryFile();
-        if (fileObj == null) {
-            return null;
-        }
-
-        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;
 
@@ -409,11 +369,10 @@
      * @throws IOException
      */
     private static RepositoryImpl getRepositoryIntern(FileObject fileObject) 
throws IOException {
-        Object attValue = fileObject.getAttribute(
-                                       
"ProvidedExtensions.RemoteLocation");//NOI18N
-        if (attValue instanceof String) {
+        String url = VersioningQuery.getRemoteLocation(fileObject.toURI());
+        
+        if (url != null) {
             RepositoryImpl repository = null;
-            String url = (String) attValue;
             if(NBBugzillaUtils.isNbRepository(url)) {
                 File file = FileUtil.toFile(fileObject);
                 if(file != null) {
@@ -440,7 +399,7 @@
                     BugtrackingManager.LOG.log(
                             Level.INFO,
                             "Team project corresponding to URL {0} does not 
exist.",  // NOI18N
-                            attValue);
+                            url);
                 } else {
                     BugtrackingManager.LOG.throwing(
                             BugtrackingOwnerSupport.class.getName(),    
//class name
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingUtil.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingUtil.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingUtil.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/BugtrackingUtil.java
@@ -80,8 +80,7 @@
 import org.openide.NotifyDescriptor;
 import org.openide.awt.Mnemonics;
 import org.openide.filesystems.FileObject;
-import org.openide.loaders.DataObject;
-import org.openide.nodes.Node;
+import org.openide.filesystems.FileUtil;
 import org.openide.util.*;
 import org.openide.windows.TopComponent;
 import org.openide.windows.WindowManager;
@@ -409,18 +408,20 @@
         return "******"; // NOI18N
     }
 
-    public static File getFile(Node[] nodes) {
-        if(nodes == null || nodes.length == 0) {
+    public static File getLargerSelection() {
+        FileObject[] fos = BugtrackingUtil.getCurrentSelection();
+        if(fos == null) {
             return null;
         }
-        Lookup nodeLookup = nodes[0].getLookup();
-        FileObject[] fos = getProjectDirectories(nodeLookup);
-        if(fos != null && fos.length > 0) {
-            return org.openide.filesystems.FileUtil.toFile(fos[0]);
+        for (FileObject fo : fos) {
+            FileObject ownerDirectory = 
BugtrackingUtil.getFileOwnerDirectory(fo);
+            if (ownerDirectory != null) {
+                fo = ownerDirectory;
         }
-        DataObject dataObj = nodeLookup.lookup(DataObject.class);
-        if (dataObj != null) {
-            return getFile(dataObj);
+            File file = FileUtil.toFile(fo);
+            if(file != null) {
+                return file;
+        }
         }
         return null;
     }
@@ -440,26 +441,14 @@
         });
     }
     
-    private static File getFile(DataObject dataObj) {
-        FileObject fileObj = dataObj.getPrimaryFile();
-        if (fileObj == null) {
-            return null;
-        }
-        FileObject ownerDirectory = getFileOwnerDirectory(fileObj);
-        if (ownerDirectory != null) {
-            return org.openide.filesystems.FileUtil.toFile(ownerDirectory);
-        }
-        return org.openide.filesystems.FileUtil.toFile(fileObj);
-    }  
-
     public static FileObject getFileOwnerDirectory(FileObject fileObject) {
         ProjectServices projectServices = 
BugtrackingManager.getInstance().getProjectServices();
         return projectServices != null ? 
projectServices.getFileOwnerDirectory(fileObject): null;
     }
     
-    public static FileObject[] getProjectDirectories(Lookup lookup) {
+    public static FileObject[] getCurrentSelection() {
         ProjectServices projectServices = 
BugtrackingManager.getInstance().getProjectServices();
-        return projectServices != null ? 
projectServices.getProjectDirectories(lookup) : null;
+        return projectServices != null ? 
projectServices.getCurrentSelection() : null;
     }
     
 }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupport.java
 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupport.java
--- 
a/bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupport.java
+++ 
b/bugtracking/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupport.java
@@ -105,7 +105,7 @@
     private boolean shutdown;
     private boolean repositoriesDisplayed = false;
     private boolean defaultRepoSelected = false;
-    private volatile Node[] selectedNodes;
+    private volatile FileObject[] selectedFiles;
     private volatile Repository[] repositories;
     private volatile boolean defaultRepoComputationPending;
     private volatile Repository defaultRepo;
@@ -234,11 +234,11 @@
 
         /* This is the right time to get information about selected nodes: */
         if ((defaultRepo == null) && (refFile == null)) {
-            Node[] currNodes = TopComponent.getRegistry().getCurrentNodes();
-            if (currNodes == null) {
-                currNodes = new Node[0];
+            FileObject[] currFiles = BugtrackingUtil.getCurrentSelection();
+            if (currFiles == null) {
+                currFiles = new FileObject[0];
             }
-            this.selectedNodes = currNodes;
+            this.selectedFiles = currFiles;
         }
 
         /*
@@ -640,14 +640,14 @@
 
         startTimeMillis = System.currentTimeMillis();
 
-        assert (refFile == null) ^ (selectedNodes == null);
+        assert (refFile == null) ^ (selectedFiles == null);
 
         if (refFile != null) {
             result = 
BugtrackingOwnerSupport.getInstance().getRepository(refFile,
                                                                          
false);
         } else {
-            assert (selectedNodes != null);
-            result = 
BugtrackingOwnerSupport.getInstance().getRepository(selectedNodes);
+            assert (selectedFiles != null);
+            result = 
BugtrackingOwnerSupport.getInstance().getRepository(selectedFiles);
         }
 
         endTimeMillis = System.currentTimeMillis();
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
@@ -48,8 +48,9 @@
 import java.util.List;
 import org.netbeans.modules.bugtracking.APIAccessor;
 import org.netbeans.modules.bugtracking.RepositoryImpl;
+import org.netbeans.modules.bugtracking.api.Repository;
 import org.netbeans.modules.bugtracking.util.BugtrackingOwnerSupport;
-import org.openide.nodes.Node;
+import org.openide.filesystems.FileObject;
 
 /**
  *
@@ -110,10 +111,12 @@
     }
 
     @Override
-    synchronized protected RepositoryImpl getRepository(Node node) {
-        return (node instanceof DummyNode)
-               ? APIAccessor.IMPL.getImpl(((DummyNode) 
node).getAssociatedRepository())
-               : null;
+    synchronized public RepositoryImpl getRepository(FileObject fo) {
+        Object obj = fo.getAttribute(DummyNode.TEST_REPO);
+        if(obj instanceof Repository) {
+            return APIAccessor.IMPL.getImpl((Repository)obj);
+        }
+        return null;
     }
 
     @Override
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyNode.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyNode.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyNode.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyNode.java
@@ -42,39 +42,54 @@
 
 package org.netbeans.modules.bugtracking.dummies;
 
+import java.io.IOException;
 import org.netbeans.modules.bugtracking.api.Repository;
+import org.openide.filesystems.FileObject;
+import org.openide.loaders.DataFolder;
+import org.openide.loaders.DataLoader;
+import org.openide.loaders.DataObject;
+import org.openide.loaders.DataObjectExistsException;
 import org.openide.nodes.AbstractNode;
 import org.openide.nodes.Children;
+import org.openide.util.Exceptions;
+import org.openide.util.HelpCtx;
+import org.openide.util.lookup.Lookups;
 
 /**
  *
  * @author Marian Petras
  */
 public class DummyNode extends AbstractNode {
+    final static String TEST_REPO = "testrepo";
 
     private final String name;
     private final Repository repository;
+    private FileObject fo;
 
-    public DummyNode() {
-        this((String) null);
+    public DummyNode(String name) {
+        this(name, null, null);
     }
 
-    public DummyNode(String name) {
-        this(name, null);
-    }
-
-    public DummyNode(Repository repository) {
-        this(null, repository);
-    }
-
-    public DummyNode(String name, Repository repository) {
+    public DummyNode(String name, Repository repository, FileObject fo) {
         super(Children.LEAF);
         this.name = name;
         this.repository = repository;
+        this.fo = fo;
+        if(fo != null) {
+            try {
+                fo.setAttribute(TEST_REPO, repository);
+            } catch (IOException ex) {
+                Exceptions.printStackTrace(ex);
+            }
+        }
     }
 
     Repository getAssociatedRepository() {
         return repository;
     }
 
+    FileObject getAssociatedFileObject() {
+        return fo;
 }
+
+}
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyProjectServices.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyProjectServices.java
new file mode 100644
--- /dev/null
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/dummies/DummyProjectServices.java
@@ -0,0 +1,129 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.bugtracking.dummies;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import org.netbeans.modules.team.ide.spi.IDEProject;
+import org.netbeans.modules.team.ide.spi.ProjectServices;
+import org.openide.filesystems.FileObject;
+import org.openide.nodes.Node;
+import org.openide.windows.WindowManager;
+
+/**
+ *
+ * @author tomas
+ */
+public class DummyProjectServices implements ProjectServices {
+
+    @Override
+    public <T> T runAfterProjectOpenFinished(Callable<T> operation) throws 
Exception {
+        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public FileObject[] getOpenProjectsDirectories() {
+        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public FileObject getMainProjectDirectory() {
+        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public FileObject getFileOwnerDirectory(FileObject fileObject) {
+        return fileObject;
+    }
+
+    @Override
+    public FileObject[] getCurrentSelection() {
+        Node[] nodes = 
WindowManager.getDefault().getRegistry().getCurrentNodes();
+        if(nodes == null) {
+            return null;
+        }
+        List<FileObject> ret = new ArrayList<FileObject>(nodes.length);
+        for (Node node : nodes) {
+            if(node instanceof DummyNode) {
+                FileObject fo = ((DummyNode) node).getAssociatedFileObject();
+                if(fo != null) {
+                    ret.add(fo);
+                }
+            }
+        }
+        return ret.toArray(new FileObject[ret.size()]);
+    }
+    
+    @Override
+    public boolean openProject(URL url) {
+        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public void openOtherProject(File workingDir) {
+        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public IDEProject getIDEProject(URL url) {
+        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public IDEProject[] getOpenProjects() {
+        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public void addProjectOpenListener(IDEProject.OpenListener listener) {
+        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public void removeProjectOpenListener(IDEProject.OpenListener listener) {
+        throw new UnsupportedOperationException("Not supported yet."); //To 
change body of generated methods, choose Tools | Templates.
+    }
+    
+}
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupportTest.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupportTest.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupportTest.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/util/RepositoryComboSupportTest.java
@@ -44,6 +44,7 @@
 
 import java.awt.EventQueue;
 import java.io.File;
+import java.io.IOException;
 import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import javax.swing.JComboBox;
@@ -70,10 +71,14 @@
 import org.netbeans.modules.bugtracking.BugtrackingManager;
 import org.netbeans.modules.bugtracking.DelegatingConnector;
 import org.netbeans.modules.bugtracking.api.Repository;
+import org.netbeans.modules.bugtracking.dummies.DummyProjectServices;
 import static 
org.netbeans.modules.bugtracking.util.RepositoryComboSupport.LOADING_REPOSITORIES;
 import static 
org.netbeans.modules.bugtracking.util.RepositoryComboSupport.SELECT_REPOSITORY;
 import static 
org.netbeans.modules.bugtracking.util.RepositoryComboSupportTest.ThreadType.AWT;
 import static 
org.netbeans.modules.bugtracking.util.RepositoryComboSupportTest.ThreadType.NON_AWT;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
 import org.openide.util.Lookup;
 import org.openide.util.test.MockLookup;
 
@@ -91,6 +96,7 @@
             new DummyKenaiRepositories(), 
             new DummyWindowManager(), 
             new DummyBugtrackingOwnerSupport(),
+            new DummyProjectServices(),
             new DelegatingConnector(
                 new DummyBugtrackingConnector(),
                 DummyBugtrackingConnector.ID,
@@ -125,9 +131,9 @@
 
         protected DummyBugtrackingConnector connector = 
DummyBugtrackingConnector.instance;
 
-        protected Node node1 = new DummyNode("node1");
-        protected Node node2 = new DummyNode("node2");
-        protected Node node3 = new DummyNode("node3");
+        protected Node node1;
+        protected Node node2;
+        protected Node node3;
         protected Node repoNode1;
         protected Node repoNode2;
         protected Node repoNode3;
@@ -136,6 +142,11 @@
         protected Repository repository3;
 
         public AbstractRepositoryComboTezt() {
+            node1 = new DummyNode("node1");
+            node2 = new DummyNode("node2");
+            node3 = new DummyNode("node3");
+            
+        
             DelegatingConnector[] conns = 
BugtrackingManager.getInstance().getConnectors();
             for (DelegatingConnector dc : conns) {
                 if(dc.getDelegate() instanceof DummyBugtrackingConnector) {
@@ -147,17 +158,17 @@
         
         protected void createRepository1() {
             repository1 = connector.createRepository("alpha");
-            repoNode1 = new DummyNode("node1", repository1);
+            repoNode1 = createDummyNode("node1", repository1);
         }
 
         protected void createRepository2() {
             repository2 = connector.createRepository("beta");
-            repoNode2 = new DummyNode("node2", repository2);
+            repoNode2 = createDummyNode("node2", repository2);
         }
 
         protected void createRepository3() {
             repository3 = connector.createRepository("gamma");
-            repoNode3 = new DummyNode("node3", repository3);
+            repoNode3 = createDummyNode("node3", repository3);
         }
 
         protected void createRepositories() {
@@ -182,7 +193,18 @@
             
progressTester.scheduleSuspendingTest(Progress.SCHEDULED_DISPLAY_OF_REPOS, 
NON_AWT);
             progressTester.scheduleTest          
(Progress.WILL_DISPLAY_REPOS, AWT);
         }
+    }    
 
+    private Node createDummyNode(String node, Repository repo) {
+        try {
+            File f = File.createTempFile("repotest-" + node, "");
+            FileObject fo = FileUtil.toFileObject(f);
+            return new DummyNode(node, repo, fo);
+        } catch (IOException ex) {
+            Exceptions.printStackTrace(ex);
+            fail();
+        }
+        return null;
     }
 
     abstract class SingleRepoComboTezt extends AbstractRepositoryComboTezt {
@@ -477,7 +499,7 @@
             @Override
             protected void createRepositories() {
                 super.createRepositories();
-                repoNode2_2 = new DummyNode("beta 2", repository2);
+                repoNode2_2 = createDummyNode("beta 2", repository2);
             }
             @Override
             protected void setUpEnvironment() {
diff --git a/team.ui.util/manifest.mf b/team.ui.util/manifest.mf
--- a/team.ui.util/manifest.mf
+++ b/team.ui.util/manifest.mf
@@ -2,4 +2,4 @@
 AutoUpdate-Show-In-Client: false
 OpenIDE-Module: org.netbeans.modules.team.ui.util
 OpenIDE-Module-Localizing-Bundle: 
org/netbeans/modules/team/ui/util/Bundle.properties
-OpenIDE-Module-Specification-Version: 1.11
+OpenIDE-Module-Specification-Version: 1.12
diff --git 
a/team.ui.util/src/org/netbeans/modules/team/ide/spi/ProjectServices.java 
b/team.ui.util/src/org/netbeans/modules/team/ide/spi/ProjectServices.java
--- a/team.ui.util/src/org/netbeans/modules/team/ide/spi/ProjectServices.java
+++ b/team.ui.util/src/org/netbeans/modules/team/ide/spi/ProjectServices.java
@@ -84,13 +84,12 @@
      */
     public FileObject getFileOwnerDirectory(FileObject fileObject);
     
-    // 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();  
+    /**
+     * Determines the FileObject-s representing the current selection in the 
IDE.
+     * 
+     * @return 
+     */
+    public FileObject[] getCurrentSelection();
 
     /**
      * Opens project of given URL in the IDE.

[hg] main-silver: node lookup wouldn't work with jdev so changed...

Tomas Stupka 07/02/2013

Project Features

About this Project

DB was started in November 2009, is owned by Antonin Nebuzelsky, and has 113 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