[hg] main-silver: added can remove to queryprovider

  • From: Tomas Stupka < >
  • To:
  • Subject: [hg] main-silver: added can remove to queryprovider
  • Date: Thu, 10 Oct 2013 18:54:35 -0700

changeset ae4240789eca in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/ae4240789eca
description:
        added can remove to queryprovider

diffstat:

 bugtracking/src/org/netbeans/modules/bugtracking/QueryImpl.java              
        |   4 +
 bugtracking/src/org/netbeans/modules/bugtracking/spi/QueryProvider.java      
        |  26 ++++++++-
 bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestQuery.java    
        |   4 +
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestQueryProvider.java
    |   5 +
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
 |   5 +
 
bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestQuery.java
     |   4 +
 bugzilla/src/org/netbeans/modules/bugzilla/BugzillaQueryProvider.java        
        |   5 +
 bugzilla/src/org/netbeans/modules/bugzilla/kenai/KenaiQuery.java             
        |   4 +
 bugzilla/src/org/netbeans/modules/bugzilla/query/BugzillaQuery.java          
        |   4 +
 jira/src/org/netbeans/modules/jira/JiraQueryProvider.java                    
        |   5 +
 jira/src/org/netbeans/modules/jira/query/JiraQuery.java                      
        |  12 +++-
 odcs.tasks/src/org/netbeans/modules/odcs/tasks/ODCSQueryProvider.java        
        |   5 +
 odcs.tasks/src/org/netbeans/modules/odcs/tasks/query/ODCSQuery.java          
        |   4 +
 13 files changed, 80 insertions(+), 7 deletions(-)

diffs (248 lines):

diff --git a/bugtracking/src/org/netbeans/modules/bugtracking/QueryImpl.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/QueryImpl.java
--- a/bugtracking/src/org/netbeans/modules/bugtracking/QueryImpl.java
+++ b/bugtracking/src/org/netbeans/modules/bugtracking/QueryImpl.java
@@ -126,6 +126,10 @@
         return queryProvider.isSaved(data);
     }
 
+    public boolean canRemove() {
+        return queryProvider.canRemove(data);
+    }
+    
     public void remove() {
         queryProvider.remove(data);
     }
diff --git 
a/bugtracking/src/org/netbeans/modules/bugtracking/spi/QueryProvider.java 
b/bugtracking/src/org/netbeans/modules/bugtracking/spi/QueryProvider.java
--- a/bugtracking/src/org/netbeans/modules/bugtracking/spi/QueryProvider.java
+++ b/bugtracking/src/org/netbeans/modules/bugtracking/spi/QueryProvider.java
@@ -96,31 +96,47 @@
 
     /**
      * Returns the {@link QueryController} for this query
-     * @param q
+     * @param q the implementation specific query type
      * @return
      */
     public abstract QueryController getController(Q q);
 
     /**
      * Returns true if query is saved
-     * @param q
+     * @param q the implementation specific query type
      * @return
      */
     public abstract boolean isSaved(Q q);
 
+    /**
+     * Determines whether it is possible to remove the given Query.
+     * 
+     * @param q 
+     * @return  
+     */
+    public abstract boolean canRemove(Q q);
+    
+    /** 
+     * Removes the given query.
+     * 
+     * @param q 
+     */
     public abstract void remove(Q q);
     
     /**
-     * Determines if it is possible to rename the given query
+     * Determines whether it is possible to rename the given Query
+     * @param q
      * @return 
      */
     public abstract boolean canRename(Q q);
     
     /**
-     * Renames the given query
+     * Renames the given query.
+     * 
      * @param q 
+     * @param newName 
      */
-    public abstract void rename(Q q, String displayName);
+    public abstract void rename(Q q, String newName);
     
     public abstract Collection<I> getIssues(Q q);
 
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestQuery.java 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestQuery.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestQuery.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestQuery.java
@@ -95,4 +95,8 @@
         throw new UnsupportedOperationException("Not supported yet.");
     }
     
+    boolean canRemove() {
+        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/TestQueryProvider.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestQueryProvider.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestQueryProvider.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/TestQueryProvider.java
@@ -114,4 +114,9 @@
         q.rename(displayName);
     }
 
+    @Override
+    public boolean canRemove(TestQuery q) {
+        return q.canRemove();
 }
+
+}
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestConnector.java
@@ -195,6 +195,11 @@
             q.rename(displayName);
         }
 
+        @Override
+        public boolean canRemove(APITestQuery q) {
+            return q.canRemove();
+        }
+
     }
 
     public static class APITestRepositoryProvider extends 
RepositoryProvider<APITestRepository, APITestQuery, APITestIssue> {
diff --git 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestQuery.java
 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestQuery.java
--- 
a/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestQuery.java
+++ 
b/bugtracking/test/unit/src/org/netbeans/modules/bugtracking/api/APITestQuery.java
@@ -165,4 +165,8 @@
         this.name = name;
     }
     
+    boolean canRemove() {
+        return true;
 }
+    
+}
diff --git 
a/bugzilla/src/org/netbeans/modules/bugzilla/BugzillaQueryProvider.java 
b/bugzilla/src/org/netbeans/modules/bugzilla/BugzillaQueryProvider.java
--- a/bugzilla/src/org/netbeans/modules/bugzilla/BugzillaQueryProvider.java
+++ b/bugzilla/src/org/netbeans/modules/bugzilla/BugzillaQueryProvider.java
@@ -69,6 +69,11 @@
     }
 
     @Override
+    public boolean canRemove(BugzillaQuery q) {
+        return q.canRemove();
+    }
+    
+    @Override
     public void remove(BugzillaQuery q) {
         q.remove();
     }
diff --git a/bugzilla/src/org/netbeans/modules/bugzilla/kenai/KenaiQuery.java 
b/bugzilla/src/org/netbeans/modules/bugzilla/kenai/KenaiQuery.java
--- a/bugzilla/src/org/netbeans/modules/bugzilla/kenai/KenaiQuery.java
+++ b/bugzilla/src/org/netbeans/modules/bugzilla/kenai/KenaiQuery.java
@@ -89,4 +89,8 @@
         return super.getStoredQueryName() + "-" + product;
     }
 
+    @Override
+    public boolean canRemove() {
+        return predefinedQuery ? false : super.canRemove();
 }
+}
diff --git 
a/bugzilla/src/org/netbeans/modules/bugzilla/query/BugzillaQuery.java 
b/bugzilla/src/org/netbeans/modules/bugzilla/query/BugzillaQuery.java
--- a/bugzilla/src/org/netbeans/modules/bugzilla/query/BugzillaQuery.java
+++ b/bugzilla/src/org/netbeans/modules/bugzilla/query/BugzillaQuery.java
@@ -362,6 +362,10 @@
         return lastRefresh;
     }
 
+    public boolean canRemove() {
+        return true;
+    }
+
     private class QueryProgressListener implements 
SynchronizeQueryCommand.CommandProgressListener {
         
         private final Set<String> addedIds = new HashSet<String>();
diff --git a/jira/src/org/netbeans/modules/jira/JiraQueryProvider.java 
b/jira/src/org/netbeans/modules/jira/JiraQueryProvider.java
--- a/jira/src/org/netbeans/modules/jira/JiraQueryProvider.java
+++ b/jira/src/org/netbeans/modules/jira/JiraQueryProvider.java
@@ -76,6 +76,11 @@
     }
 
     @Override
+    public boolean canRemove(JiraQuery q) {
+        return q.canRemove();
+    }
+    
+    @Override
     public void remove(JiraQuery q) {
         q.remove();
     }
diff --git a/jira/src/org/netbeans/modules/jira/query/JiraQuery.java 
b/jira/src/org/netbeans/modules/jira/query/JiraQuery.java
--- a/jira/src/org/netbeans/modules/jira/query/JiraQuery.java
+++ b/jira/src/org/netbeans/modules/jira/query/JiraQuery.java
@@ -145,7 +145,7 @@
     }
 
     public boolean canRename() {
-        return jiraFilter != null && !(jiraFilter instanceof NamedFilter);
+        return jiraFilter != null && !(isModifiable(jiraFilter));
     }
     
     public String getTooltip() {
@@ -166,12 +166,16 @@
     protected QueryController createControler(JiraRepository r, JiraQuery q, 
JiraFilter jiraFilter) {
         if(jiraFilter == null || jiraFilter instanceof FilterDefinition) {
             return new QueryController(r, q, (FilterDefinition) jiraFilter);
-        } else if(jiraFilter instanceof NamedFilter) {
+        } else if(isModifiable(jiraFilter)) {
             return new QueryController(r, q, jiraFilter, false);
         }
         throw new IllegalStateException("wrong filter type : " + 
jiraFilter.getClass().getName());
     }
 
+    private static boolean isModifiable(JiraFilter jiraFilter) {
+        return jiraFilter instanceof NamedFilter;
+    }
+
     public ColumnDescriptor[] getColumnDescriptors() {
         return NbJiraIssue.getColumnDescriptors(repository);
     }
@@ -292,6 +296,10 @@
         refreshIntern(autoReresh);
     }
 
+    public boolean canRemove() {
+        return isModifiable(jiraFilter);
+    }
+        
     public void remove() {
         if(QueryController.isNamedFilter(jiraFilter)) {
             // Serverside filter. Can't remove.
diff --git 
a/odcs.tasks/src/org/netbeans/modules/odcs/tasks/ODCSQueryProvider.java 
b/odcs.tasks/src/org/netbeans/modules/odcs/tasks/ODCSQueryProvider.java
--- a/odcs.tasks/src/org/netbeans/modules/odcs/tasks/ODCSQueryProvider.java
+++ b/odcs.tasks/src/org/netbeans/modules/odcs/tasks/ODCSQueryProvider.java
@@ -78,6 +78,11 @@
     }
 
     @Override
+    public boolean canRemove(ODCSQuery q) {
+        return q.canRemove();
+    }
+    
+    @Override
     public void remove(ODCSQuery q) {
         q.remove();
     }
diff --git 
a/odcs.tasks/src/org/netbeans/modules/odcs/tasks/query/ODCSQuery.java 
b/odcs.tasks/src/org/netbeans/modules/odcs/tasks/query/ODCSQuery.java
--- a/odcs.tasks/src/org/netbeans/modules/odcs/tasks/query/ODCSQuery.java
+++ b/odcs.tasks/src/org/netbeans/modules/odcs/tasks/query/ODCSQuery.java
@@ -367,6 +367,10 @@
         }
     }
 
+    public boolean canRemove() {
+        return isModifiable();
+    }
+
     private class QueryProgressListener implements 
SynchronizeQueryCommand.CommandProgressListener {
         
         private final Set<String> addedIds = new HashSet<String>();

[hg] main-silver: added can remove to queryprovider

Tomas Stupka 10/11/2013

Project Features

About this Project

ConnectedDeveloper was started in November 2009, is owned by tpavek, and has 66 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